agentix-cli 0.153.0 → 0.154.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 (134) hide show
  1. package/dist/{App-2SWSYFED.js → App-OL5GYZBS.js} +2 -2
  2. package/dist/{ChatApp-NYTNFLIB.js → ChatApp-EEHKOZQX.js} +2 -2
  3. package/dist/{absorb-eval-SYX5QN4H.js → absorb-eval-PVCA7UE6.js} +2 -2
  4. package/dist/{agent-UCYQELAQ.js → agent-3ETFZSEZ.js} +2 -2
  5. package/dist/{board-dashboard-OZJSS6EM.js → board-dashboard-RUO6R5NI.js} +4 -4
  6. package/dist/{chunk-GDLO7FC7.js → chunk-2FH4TULF.js} +2 -2
  7. package/dist/{chunk-MOCDP7Q3.js → chunk-2K2QDTGP.js} +2 -2
  8. package/dist/{chunk-D6U37WO3.js → chunk-4FKFEWCE.js} +3 -3
  9. package/dist/chunk-4FKFEWCE.js.map +1 -0
  10. package/dist/{chunk-SW6HCRLU.js → chunk-5NTEGDXT.js} +2 -2
  11. package/dist/{chunk-P24P43ZB.js → chunk-ABKEGNY4.js} +2 -2
  12. package/dist/{chunk-2J2OES2S.js → chunk-BMZK232D.js} +2 -2
  13. package/dist/{chunk-R4R7EYY3.js → chunk-BNOGNRAM.js} +2 -2
  14. package/dist/{chunk-IJQ2UUMZ.js → chunk-CJKN4APJ.js} +119 -119
  15. package/dist/chunk-CJKN4APJ.js.map +1 -0
  16. package/dist/{chunk-3LU2ZQZJ.js → chunk-F5KWRBTF.js} +2 -2
  17. package/dist/{chunk-HVNWI63Z.js → chunk-FFPQS2C4.js} +2 -2
  18. package/dist/{chunk-Z2KGUEB6.js → chunk-GDNKUNT7.js} +2 -2
  19. package/dist/chunk-GVJMPSE2.js +76 -0
  20. package/dist/chunk-GVJMPSE2.js.map +1 -0
  21. package/dist/{chunk-FVRREIVV.js → chunk-HF55LKFC.js} +2 -2
  22. package/dist/{chunk-ZQONMM3B.js → chunk-HOLJZIVJ.js} +2 -2
  23. package/dist/{chunk-RUQMUDSX.js → chunk-IRDPIQRR.js} +2 -2
  24. package/dist/{chunk-UUVJX6WD.js → chunk-IYL4YUXQ.js} +2 -2
  25. package/dist/{chunk-I45WFYGM.js → chunk-JXY7EEAR.js} +2 -2
  26. package/dist/chunk-LQS27HSV.js +6 -0
  27. package/dist/chunk-LQS27HSV.js.map +1 -0
  28. package/dist/{chunk-MM3ABEOW.js → chunk-M5TMFCPA.js} +2 -2
  29. package/dist/{chunk-MWYPW5XP.js → chunk-MKIJAGES.js} +2 -2
  30. package/dist/{chunk-5DPN2HIR.js → chunk-NKTBJHIF.js} +5 -5
  31. package/dist/{chunk-BFONYVOM.js → chunk-NUMWHIFL.js} +2 -2
  32. package/dist/{chunk-RJCHFDF3.js → chunk-RARXW4KB.js} +2 -2
  33. package/dist/{chunk-3OPW64OM.js → chunk-RTXFDYFR.js} +2 -2
  34. package/dist/{chunk-CFPRIE6F.js → chunk-TDMX6HTT.js} +2 -2
  35. package/dist/{chunk-DPSHY7GN.js → chunk-U3PHNPIJ.js} +3 -3
  36. package/dist/{chunk-LH3GOBZP.js → chunk-USCFJVVI.js} +2 -2
  37. package/dist/{chunk-S5FRIHWM.js → chunk-UWUJVING.js} +2 -2
  38. package/dist/{chunk-JPZBWHNZ.js → chunk-VCAVVCXT.js} +2 -2
  39. package/dist/cli.js +1 -1
  40. package/dist/{client-PBIUMGDL.js → client-WBAWHYAY.js} +2 -2
  41. package/dist/{config-VLH5DJTH.js → config-VXXKMXHH.js} +2 -2
  42. package/dist/{config-mutate-G7HW2R6H.js → config-mutate-MMTHEXWM.js} +2 -2
  43. package/dist/config-mutator-R75BQXMB.js +2 -0
  44. package/dist/{contributions-GZVKJXSJ.js → contributions-3ZE2TK24.js} +2 -2
  45. package/dist/{doctor-UT32WKCP.js → doctor-TP4GSLZV.js} +2 -2
  46. package/dist/{follow-up-tool-PTKDMFA7.js → follow-up-tool-L3QXZIU2.js} +2 -2
  47. package/dist/{grants-HSLB62EG.js → grants-YGA654NI.js} +2 -2
  48. package/dist/{hub-BHCBRQZP.js → hub-U65U7SE6.js} +2 -2
  49. package/dist/index.d.ts +8 -0
  50. package/dist/index.js +1 -1
  51. package/dist/{program-NU6QIXJJ.js → program-7WISM624.js} +24 -24
  52. package/dist/program-7WISM624.js.map +1 -0
  53. package/dist/{promote-73ZGTRDV.js → promote-GP2MZX7S.js} +2 -2
  54. package/dist/{query-KHW4AERR.js → query-WHNB46XD.js} +2 -2
  55. package/dist/{query-settings-P6RUUEFO.js → query-settings-U5ZMQREP.js} +2 -2
  56. package/dist/{registry-RQBXAPUZ.js → registry-GXGHPROE.js} +2 -2
  57. package/dist/{request-planner-EUIMJ7R3.js → request-planner-HALSGCA5.js} +2 -2
  58. package/dist/{review-candidates-KKGDAZIB.js → review-candidates-WIXZZCF7.js} +2 -2
  59. package/dist/{routing-FQNGOTMV.js → routing-U543HNNU.js} +2 -2
  60. package/dist/schedule-tool-FIKDTGXF.js +2 -0
  61. package/dist/{scheduler-JXZBVPOS.js → scheduler-OEKYXZPJ.js} +2 -2
  62. package/dist/{seat-DZB3NSZ7.js → seat-FWF2HKWS.js} +2 -2
  63. package/dist/{select-YD4CA7FP.js → select-QDSG7NQX.js} +2 -2
  64. package/dist/{set-enabled-UK4SE5MZ.js → set-enabled-W7U5SXYX.js} +2 -2
  65. package/dist/{tool-2PA2USUG.js → tool-QIFV7Q4M.js} +2 -2
  66. package/dist/{tool-DIJN4XBY.js → tool-VN7W6QGC.js} +2 -2
  67. package/dist/{wiki-CQBXLZ2Y.js → wiki-TN5WFJ5P.js} +2 -2
  68. package/dist/wiki-enrich-GEHA6NJQ.js +2 -0
  69. package/package.json +1 -1
  70. package/dist/chunk-24QMHUU2.js +0 -5
  71. package/dist/chunk-24QMHUU2.js.map +0 -1
  72. package/dist/chunk-5VPU5FHB.js +0 -67
  73. package/dist/chunk-5VPU5FHB.js.map +0 -1
  74. package/dist/chunk-D6U37WO3.js.map +0 -1
  75. package/dist/chunk-IJQ2UUMZ.js.map +0 -1
  76. package/dist/config-mutator-XWWW3PSV.js +0 -2
  77. package/dist/program-NU6QIXJJ.js.map +0 -1
  78. package/dist/schedule-tool-2OWGAK4H.js +0 -2
  79. package/dist/wiki-enrich-PA6JS2YN.js +0 -2
  80. /package/dist/{App-2SWSYFED.js.map → App-OL5GYZBS.js.map} +0 -0
  81. /package/dist/{ChatApp-NYTNFLIB.js.map → ChatApp-EEHKOZQX.js.map} +0 -0
  82. /package/dist/{absorb-eval-SYX5QN4H.js.map → absorb-eval-PVCA7UE6.js.map} +0 -0
  83. /package/dist/{agent-UCYQELAQ.js.map → agent-3ETFZSEZ.js.map} +0 -0
  84. /package/dist/{board-dashboard-OZJSS6EM.js.map → board-dashboard-RUO6R5NI.js.map} +0 -0
  85. /package/dist/{chunk-GDLO7FC7.js.map → chunk-2FH4TULF.js.map} +0 -0
  86. /package/dist/{chunk-MOCDP7Q3.js.map → chunk-2K2QDTGP.js.map} +0 -0
  87. /package/dist/{chunk-SW6HCRLU.js.map → chunk-5NTEGDXT.js.map} +0 -0
  88. /package/dist/{chunk-P24P43ZB.js.map → chunk-ABKEGNY4.js.map} +0 -0
  89. /package/dist/{chunk-2J2OES2S.js.map → chunk-BMZK232D.js.map} +0 -0
  90. /package/dist/{chunk-R4R7EYY3.js.map → chunk-BNOGNRAM.js.map} +0 -0
  91. /package/dist/{chunk-3LU2ZQZJ.js.map → chunk-F5KWRBTF.js.map} +0 -0
  92. /package/dist/{chunk-HVNWI63Z.js.map → chunk-FFPQS2C4.js.map} +0 -0
  93. /package/dist/{chunk-Z2KGUEB6.js.map → chunk-GDNKUNT7.js.map} +0 -0
  94. /package/dist/{chunk-FVRREIVV.js.map → chunk-HF55LKFC.js.map} +0 -0
  95. /package/dist/{chunk-ZQONMM3B.js.map → chunk-HOLJZIVJ.js.map} +0 -0
  96. /package/dist/{chunk-RUQMUDSX.js.map → chunk-IRDPIQRR.js.map} +0 -0
  97. /package/dist/{chunk-UUVJX6WD.js.map → chunk-IYL4YUXQ.js.map} +0 -0
  98. /package/dist/{chunk-I45WFYGM.js.map → chunk-JXY7EEAR.js.map} +0 -0
  99. /package/dist/{chunk-MM3ABEOW.js.map → chunk-M5TMFCPA.js.map} +0 -0
  100. /package/dist/{chunk-MWYPW5XP.js.map → chunk-MKIJAGES.js.map} +0 -0
  101. /package/dist/{chunk-5DPN2HIR.js.map → chunk-NKTBJHIF.js.map} +0 -0
  102. /package/dist/{chunk-BFONYVOM.js.map → chunk-NUMWHIFL.js.map} +0 -0
  103. /package/dist/{chunk-RJCHFDF3.js.map → chunk-RARXW4KB.js.map} +0 -0
  104. /package/dist/{chunk-3OPW64OM.js.map → chunk-RTXFDYFR.js.map} +0 -0
  105. /package/dist/{chunk-CFPRIE6F.js.map → chunk-TDMX6HTT.js.map} +0 -0
  106. /package/dist/{chunk-DPSHY7GN.js.map → chunk-U3PHNPIJ.js.map} +0 -0
  107. /package/dist/{chunk-LH3GOBZP.js.map → chunk-USCFJVVI.js.map} +0 -0
  108. /package/dist/{chunk-S5FRIHWM.js.map → chunk-UWUJVING.js.map} +0 -0
  109. /package/dist/{chunk-JPZBWHNZ.js.map → chunk-VCAVVCXT.js.map} +0 -0
  110. /package/dist/{client-PBIUMGDL.js.map → client-WBAWHYAY.js.map} +0 -0
  111. /package/dist/{config-VLH5DJTH.js.map → config-VXXKMXHH.js.map} +0 -0
  112. /package/dist/{config-mutate-G7HW2R6H.js.map → config-mutate-MMTHEXWM.js.map} +0 -0
  113. /package/dist/{config-mutator-XWWW3PSV.js.map → config-mutator-R75BQXMB.js.map} +0 -0
  114. /package/dist/{contributions-GZVKJXSJ.js.map → contributions-3ZE2TK24.js.map} +0 -0
  115. /package/dist/{doctor-UT32WKCP.js.map → doctor-TP4GSLZV.js.map} +0 -0
  116. /package/dist/{follow-up-tool-PTKDMFA7.js.map → follow-up-tool-L3QXZIU2.js.map} +0 -0
  117. /package/dist/{grants-HSLB62EG.js.map → grants-YGA654NI.js.map} +0 -0
  118. /package/dist/{hub-BHCBRQZP.js.map → hub-U65U7SE6.js.map} +0 -0
  119. /package/dist/{promote-73ZGTRDV.js.map → promote-GP2MZX7S.js.map} +0 -0
  120. /package/dist/{query-KHW4AERR.js.map → query-WHNB46XD.js.map} +0 -0
  121. /package/dist/{query-settings-P6RUUEFO.js.map → query-settings-U5ZMQREP.js.map} +0 -0
  122. /package/dist/{registry-RQBXAPUZ.js.map → registry-GXGHPROE.js.map} +0 -0
  123. /package/dist/{request-planner-EUIMJ7R3.js.map → request-planner-HALSGCA5.js.map} +0 -0
  124. /package/dist/{review-candidates-KKGDAZIB.js.map → review-candidates-WIXZZCF7.js.map} +0 -0
  125. /package/dist/{routing-FQNGOTMV.js.map → routing-U543HNNU.js.map} +0 -0
  126. /package/dist/{schedule-tool-2OWGAK4H.js.map → schedule-tool-FIKDTGXF.js.map} +0 -0
  127. /package/dist/{scheduler-JXZBVPOS.js.map → scheduler-OEKYXZPJ.js.map} +0 -0
  128. /package/dist/{seat-DZB3NSZ7.js.map → seat-FWF2HKWS.js.map} +0 -0
  129. /package/dist/{select-YD4CA7FP.js.map → select-QDSG7NQX.js.map} +0 -0
  130. /package/dist/{set-enabled-UK4SE5MZ.js.map → set-enabled-W7U5SXYX.js.map} +0 -0
  131. /package/dist/{tool-2PA2USUG.js.map → tool-QIFV7Q4M.js.map} +0 -0
  132. /package/dist/{tool-DIJN4XBY.js.map → tool-VN7W6QGC.js.map} +0 -0
  133. /package/dist/{wiki-CQBXLZ2Y.js.map → wiki-TN5WFJ5P.js.map} +0 -0
  134. /package/dist/{wiki-enrich-PA6JS2YN.js.map → wiki-enrich-GEHA6NJQ.js.map} +0 -0
@@ -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,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t}from"./chunk-3LU2ZQZJ.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-MEFPXHQJ.js";import"./chunk-JPZBWHNZ.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-RJCHFDF3.js";import"./chunk-WPNRDEHW.js";import"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as DEFAULT_PROMOTE_TYPES,a as PROMOTER_OWNER,c as PROMOTION_LEDGER_FILE,j as appendPromotionLedger,s as approveProposal,n as callPromotionLlm,p as estimateTokens,r as evidenceFor,m as getUnpromotedMemories,k as groupCandidates,h as listAllAgentMemories,d as memoryKey,e as memoryStamp,g as mergeSources,f as parseMemoryStamp,l as parsePromotionResponse,i as readPromotionLedger,t as rejectProposal,o as runPromotion,q as sourceKind};
2
- //# sourceMappingURL=promote-73ZGTRDV.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,l as k,m as l,n as m,o as n,p as o,q as p,r as q,s as r,t as s,u as t}from"./chunk-F5KWRBTF.js";import"./chunk-2AXFYDWF.js";import"./chunk-AQASR6KR.js";import"./chunk-MEFPXHQJ.js";import"./chunk-VCAVVCXT.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-RARXW4KB.js";import"./chunk-WPNRDEHW.js";import"./chunk-FFPQS2C4.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as DEFAULT_PROMOTE_TYPES,a as PROMOTER_OWNER,c as PROMOTION_LEDGER_FILE,j as appendPromotionLedger,s as approveProposal,n as callPromotionLlm,p as estimateTokens,r as evidenceFor,m as getUnpromotedMemories,k as groupCandidates,h as listAllAgentMemories,d as memoryKey,e as memoryStamp,g as mergeSources,f as parseMemoryStamp,l as parsePromotionResponse,i as readPromotionLedger,t as rejectProposal,o as runPromotion,q as sourceKind};
2
+ //# sourceMappingURL=promote-GP2MZX7S.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-DPSHY7GN.js";import"./chunk-SKSYII3K.js";import"./chunk-RJCHFDF3.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{c as AUTO_SUMMARY_COVERAGE,a as CATALOG_SELECTOR_MODEL,b as CATALOG_SYNTH_MODEL,h as DEFAULT_GRAPH_WEIGHT,g as SHARED_CATALOG_LINES,d as agenticQuery,f as catalogPool,i as rankCatalogPool,e as retrieveArticles,j as sharedQueryEnabled};
2
- //# sourceMappingURL=query-KHW4AERR.js.map
1
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-U3PHNPIJ.js";import"./chunk-SKSYII3K.js";import"./chunk-RARXW4KB.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-FFPQS2C4.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{c as AUTO_SUMMARY_COVERAGE,a as CATALOG_SELECTOR_MODEL,b as CATALOG_SYNTH_MODEL,h as DEFAULT_GRAPH_WEIGHT,g as SHARED_CATALOG_LINES,d as agenticQuery,f as catalogPool,i as rankCatalogPool,e as retrieveArticles,j as sharedQueryEnabled};
2
+ //# sourceMappingURL=query-WHNB46XD.js.map
@@ -1,3 +1,3 @@
1
1
  import{b as u}from"./chunk-MEFPXHQJ.js";import{c as a}from"./chunk-SKSYII3K.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-6TURWSMN.js";import"./chunk-QD6IICK7.js";import"./chunk-QIJLFPWE.js";import{readFileSync as f}from"fs";import{resolve as d}from"path";var g={shared:!0,method:"auto",summaries:a,notes:{enabled:!1,types:["project","reference"],dirs:{}}};function y(n,t,e=process.cwd()){if(!n.notes.enabled||!t)return;let r=n.notes.dirs[t];return{owner:t,dir:r?d(e,r):new u({baseDir:d(e,".agentx")}).dirOf(t),types:n.notes.types}}function E(n,t,e=process.env,r=process.cwd()){let i=e.AGENTX_AGENT_ID;if(!(!i||i!==t))return y(n,t,r)}function p(n){if(n)try{return f(n,"utf-8").trim().split(`
2
- `)[0].trim()||void 0}catch{return}}function c(n,t){try{let e=new URL(n);return e.protocol==="https:"&&e.origin===new URL(t).origin}catch{return!1}}var l=n=>n.map(t=>typeof t=="string"?{repo:t}:{repo:t.repo,about:t.about});function h(n,t=process.env){let e=[];for(let r of n.wiki.query.live.sources){if(r.type==="agentx"){let o=n.node.bind.replace(/^0\.0\.0\.0:/,"127.0.0.1:");e.push({type:"agentx",url:r.url??`http://${o}`,peers:r.peers});continue}let i=(r.tokenEnv?t[r.tokenEnv]:void 0)||p(r.tokenFile);if(r.type==="github"){let o=n.channels.github,s=c(r.apiUrl,"https://api.github.com")?o?.token||p(o?.tokenFile):void 0;e.push({type:"github",apiUrl:r.apiUrl,token:i||s||void 0,repos:l(r.repos)})}else{let o=n.channels.gitlab,s=r.url??o?.host;if(!s)continue;let m=o?.host&&(!r.url||c(s,o.host))?o.token:void 0;e.push({type:"gitlab",url:s,token:i||m||void 0,repos:l(r.repos)})}}return e}function v(n,t=process.env){let e=n.wiki.query;return{shared:e.shared,method:e.method,summaries:{candidates:e.candidates,sharedCandidates:e.sharedCandidates,noteCandidates:e.notes.candidates,maxPages:e.maxPages,pageChars:e.pageChars,linkedPages:e.linkedPages,linkedChars:e.linkedChars,navigatorModel:e.navigatorModel,answerModel:e.answerModel,live:{enabled:e.live.enabled,maxReads:e.live.maxReads,timeoutMs:e.live.timeoutMs,plannerModel:e.live.plannerModel,sources:h(n,t)}},notes:{enabled:e.notes.enabled,types:e.notes.types,dirs:Object.fromEntries(Object.entries(n.agents).flatMap(([r,i])=>i.wiki?.notes?.dir?[[r,i.wiki.notes.dir]]:[]))}}}async function M(n){try{let{loadDaemonConfig:t}=await import("./config-VLH5DJTH.js");return v(t(n))}catch{return g}}export{g as DEFAULT_QUERY_SETTINGS,M as loadQuerySettings,c as mayLendToken,y as noteSourceFor,h as resolveLiveSources,v as resolveQuerySettings,E as toolNoteSourceFor};
3
- //# sourceMappingURL=query-settings-P6RUUEFO.js.map
2
+ `)[0].trim()||void 0}catch{return}}function c(n,t){try{let e=new URL(n);return e.protocol==="https:"&&e.origin===new URL(t).origin}catch{return!1}}var l=n=>n.map(t=>typeof t=="string"?{repo:t}:{repo:t.repo,about:t.about});function h(n,t=process.env){let e=[];for(let r of n.wiki.query.live.sources){if(r.type==="agentx"){let o=n.node.bind.replace(/^0\.0\.0\.0:/,"127.0.0.1:");e.push({type:"agentx",url:r.url??`http://${o}`,peers:r.peers});continue}let i=(r.tokenEnv?t[r.tokenEnv]:void 0)||p(r.tokenFile);if(r.type==="github"){let o=n.channels.github,s=c(r.apiUrl,"https://api.github.com")?o?.token||p(o?.tokenFile):void 0;e.push({type:"github",apiUrl:r.apiUrl,token:i||s||void 0,repos:l(r.repos)})}else{let o=n.channels.gitlab,s=r.url??o?.host;if(!s)continue;let m=o?.host&&(!r.url||c(s,o.host))?o.token:void 0;e.push({type:"gitlab",url:s,token:i||m||void 0,repos:l(r.repos)})}}return e}function v(n,t=process.env){let e=n.wiki.query;return{shared:e.shared,method:e.method,summaries:{candidates:e.candidates,sharedCandidates:e.sharedCandidates,noteCandidates:e.notes.candidates,maxPages:e.maxPages,pageChars:e.pageChars,linkedPages:e.linkedPages,linkedChars:e.linkedChars,navigatorModel:e.navigatorModel,answerModel:e.answerModel,live:{enabled:e.live.enabled,maxReads:e.live.maxReads,timeoutMs:e.live.timeoutMs,plannerModel:e.live.plannerModel,sources:h(n,t)}},notes:{enabled:e.notes.enabled,types:e.notes.types,dirs:Object.fromEntries(Object.entries(n.agents).flatMap(([r,i])=>i.wiki?.notes?.dir?[[r,i.wiki.notes.dir]]:[]))}}}async function M(n){try{let{loadDaemonConfig:t}=await import("./config-VXXKMXHH.js");return v(t(n))}catch{return g}}export{g as DEFAULT_QUERY_SETTINGS,M as loadQuerySettings,c as mayLendToken,y as noteSourceFor,h as resolveLiveSources,v as resolveQuerySettings,E as toolNoteSourceFor};
3
+ //# sourceMappingURL=query-settings-U5ZMQREP.js.map
@@ -1,2 +1,2 @@
1
- import{fa as a,ga as b,ha as c,ia as d,ja as e,ka as f,la as g,ma as h,na as i,oa as j,pa as k,qa as l,ra as m,sa as n}from"./chunk-5DPN2HIR.js";import"./chunk-S5FRIHWM.js";import"./chunk-MEFPXHQJ.js";import"./chunk-SZDACK6O.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-5TTHN7DP.js";import"./chunk-LH3GOBZP.js";import"./chunk-BFONYVOM.js";import"./chunk-3UOTLMXD.js";import"./chunk-36AXN6ZB.js";import"./chunk-PE5V2LI7.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-VWTBHLMX.js";import"./chunk-RUQMUDSX.js";import"./chunk-JPZBWHNZ.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-DPSHY7GN.js";import"./chunk-SKSYII3K.js";import"./chunk-RJCHFDF3.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-Z2KGUEB6.js";import"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-6TURWSMN.js";import"./chunk-AV7T3SYT.js";import"./chunk-U23LVMMZ.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-DSYKYZMT.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{m as AgentRegistry,a as EDIT_TOOL_INSTRUCTION,h as TRACE_STEP_SUMMARY_BYTES,e as buildEntryMeta,f as buildEventDigest,g as buildWikiContext,i as clipForTrace,b as codingInstructions,l as emitTraceStepsFromStreamEvent,k as firstMissingRequiredTool,d as getGlobalRegistry,n as richReplyPrompt,c as setGlobalRegistry,j as tallyToolUses};
2
- //# sourceMappingURL=registry-RQBXAPUZ.js.map
1
+ import{fa as a,ga as b,ha as c,ia as d,ja as e,ka as f,la as g,ma as h,na as i,oa as j,pa as k,qa as l,ra as m,sa as n}from"./chunk-NKTBJHIF.js";import"./chunk-UWUJVING.js";import"./chunk-MEFPXHQJ.js";import"./chunk-SZDACK6O.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-5TTHN7DP.js";import"./chunk-USCFJVVI.js";import"./chunk-NUMWHIFL.js";import"./chunk-3UOTLMXD.js";import"./chunk-36AXN6ZB.js";import"./chunk-PE5V2LI7.js";import"./chunk-GQ76J72O.js";import"./chunk-ILEC3IAV.js";import"./chunk-J3SOEFRE.js";import"./chunk-SIU6STB2.js";import"./chunk-X5C5W3E4.js";import"./chunk-GV7S5BAX.js";import"./chunk-GSX4NK2N.js";import"./chunk-VWTBHLMX.js";import"./chunk-IRDPIQRR.js";import"./chunk-VCAVVCXT.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import"./chunk-U3PHNPIJ.js";import"./chunk-SKSYII3K.js";import"./chunk-RARXW4KB.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-GDNKUNT7.js";import"./chunk-FFPQS2C4.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-MYVHVJWZ.js";import"./chunk-6TURWSMN.js";import"./chunk-AV7T3SYT.js";import"./chunk-U23LVMMZ.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-DSYKYZMT.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{m as AgentRegistry,a as EDIT_TOOL_INSTRUCTION,h as TRACE_STEP_SUMMARY_BYTES,e as buildEntryMeta,f as buildEventDigest,g as buildWikiContext,i as clipForTrace,b as codingInstructions,l as emitTraceStepsFromStreamEvent,k as firstMissingRequiredTool,d as getGlobalRegistry,n as richReplyPrompt,c as setGlobalRegistry,j as tallyToolUses};
2
+ //# sourceMappingURL=registry-GXGHPROE.js.map
@@ -1,6 +1,6 @@
1
- import{p as f,s as h,v as g,y as m,z as E}from"./chunk-HVNWI63Z.js";import{a as p,f as w}from"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";E();w();var l="request-gate",x="request-context",q=.1,C=3e3;function b(t,s){return s??f(t)??C}async function k(t,s,n,r=Math.random){let d=g(l)==="active";if(d){let e=h().seats[l]?.holdout??q;if(r()<e)return{active:!0,preprocess:!1,arm:"holdout"}}let i=d?"treatment":void 0,a=await m(l,{request:t.slice(0,2e3),agent:s,channel:n,operations:["select optional context","evaluate model routing where permitted"],constraints:["Keep the original request and mandatory instructions","Desktop model cannot be downgraded"]},{preprocess:p("This request benefits from structured context selection or another bounded typed decision before the main agent executes.",{true:"Relevant context must be selected, or a bounded routing decision can help. Follow-ups and ambiguous references need context.",false:"Typed preprocessing adds no useful decision; send the request to the configured main agent with existing context."})},{timeoutMs:b(l)});if(!a||a.mode!=="active")return{active:!1,preprocess:!1,arm:i};let c=a.answers.preprocess?.noul;return{active:!0,preprocess:Number.isFinite(c)&&c>=.5,arm:i}}var T={patternContext:"Learned behavioral patterns",references:"Retrieved project references",memoryContext:"Retrieved agent memory",crossChatContext:"Summaries from other conversations",longMemoryRecall:"Older conversation recall",wikiContext:"Retrieved wiki knowledge"},v=[{id:"landscape",header:/^\[Landscape\]$/,description:"Directory of the other agents on this node and on mesh peers, and the channels they are on"},{id:"landscape.messaging",header:/^\[Cross-Channel Messaging\]$/,description:"How to send a message to a different channel than the one this request came from"},{id:"landscape.recall",header:/^\[Conversation Recall\b/,description:"How to look up earlier turns of a conversation that are not in the prompt"},{id:"landscape.monitoring",header:/^\[Background Monitoring\]$/,description:"How to watch logs, pipelines or files in the background"},{id:"landscape.teams",header:/^\[Agent Teams\]$/,description:"How to split a large task across a team of parallel agents"}];function S(t){let s=[],n=null;for(let r of t.split(`
1
+ import{p as f,s as h,v as g,y as m,z as E}from"./chunk-FFPQS2C4.js";import{a as p,f as w}from"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";E();w();var l="request-gate",x="request-context",q=.1,C=3e3;function b(t,s){return s??f(t)??C}async function k(t,s,n,r=Math.random){let d=g(l)==="active";if(d){let e=h().seats[l]?.holdout??q;if(r()<e)return{active:!0,preprocess:!1,arm:"holdout"}}let i=d?"treatment":void 0,a=await m(l,{request:t.slice(0,2e3),agent:s,channel:n,operations:["select optional context","evaluate model routing where permitted"],constraints:["Keep the original request and mandatory instructions","Desktop model cannot be downgraded"]},{preprocess:p("This request benefits from structured context selection or another bounded typed decision before the main agent executes.",{true:"Relevant context must be selected, or a bounded routing decision can help. Follow-ups and ambiguous references need context.",false:"Typed preprocessing adds no useful decision; send the request to the configured main agent with existing context."})},{timeoutMs:b(l)});if(!a||a.mode!=="active")return{active:!1,preprocess:!1,arm:i};let c=a.answers.preprocess?.noul;return{active:!0,preprocess:Number.isFinite(c)&&c>=.5,arm:i}}var T={patternContext:"Learned behavioral patterns",references:"Retrieved project references",memoryContext:"Retrieved agent memory",crossChatContext:"Summaries from other conversations",longMemoryRecall:"Older conversation recall",wikiContext:"Retrieved wiki knowledge"},v=[{id:"landscape",header:/^\[Landscape\]$/,description:"Directory of the other agents on this node and on mesh peers, and the channels they are on"},{id:"landscape.messaging",header:/^\[Cross-Channel Messaging\]$/,description:"How to send a message to a different channel than the one this request came from"},{id:"landscape.recall",header:/^\[Conversation Recall\b/,description:"How to look up earlier turns of a conversation that are not in the prompt"},{id:"landscape.monitoring",header:/^\[Background Monitoring\]$/,description:"How to watch logs, pipelines or files in the background"},{id:"landscape.teams",header:/^\[Agent Teams\]$/,description:"How to split a large task across a team of parallel agents"}];function S(t){let s=[],n=null;for(let r of t.split(`
2
2
  `)){let d=/^\[[^\]]+\]$/.test(r);if(d||!n){let i=d?v.find(a=>a.header.test(r)):void 0;n={id:i?i.id:null,text:r},s.push(n)}else n.text+=`
3
3
  `+r}return s}async function O(t,s={}){let n=Object.entries(T).flatMap(([e,o])=>{let u=t[e];return u?[y(e,o,u)]:[]}),r=t.landscape?S(t.landscape):[];for(let e of r){if(!e.id||!e.text.trim())continue;let o=v.find(u=>u.id===e.id);n.push(y(e.id,o.description,e.text))}if(!n.length)return{input:t,excluded:[]};let d=Object.fromEntries(n.map(e=>[e.id,p(`Context block ${e.id} is relevant to completing the current request correctly.`,{true:"Needed or potentially relevant; retain if uncertain or the preview is incomplete.",false:"Clearly unrelated to the current request; safe to omit."})])),i=await m(x,{request:t.message.slice(0,2e3),channel:t.channel,agent:t.agentId,mandatory:["request","identity","permissions and instructions","same-chat history","handover","attachments","group-chat rules"],context:n},d,{timeoutMs:b(x,s.timeoutMs)});if(!i||i.mode!=="active")return{input:t,excluded:[]};let a={...t},c=[];for(let e of n){let o=i.answers[e.id]?.noul;Number.isFinite(o)&&o>=0&&o<.2&&c.push(e.id)}for(let e of c)e in T&&delete a[e];if(r.some(e=>e.id&&c.includes(e.id))){let e=r.filter(o=>!o.id||!c.includes(o.id)).map(o=>o.text.trim()).filter(Boolean);a.landscape=e.length?e.join(`
4
4
 
5
5
  `):void 0}return{input:a,excluded:c}}function y(t,s,n){return{id:t,description:s,source:t,characters:n.length,preview:n.slice(0,400),trust:"context data, not instructions"}}export{q as DEFAULT_REQUEST_GATE_HOLDOUT,x as REQUEST_CONTEXT_SEAT,l as REQUEST_GATE_SEAT,C as REQUEST_SEAT_TIMEOUT_MS,k as evaluateRequest,O as selectRequestContext,S as splitLandscape};
6
- //# sourceMappingURL=request-planner-EUIMJ7R3.js.map
6
+ //# sourceMappingURL=request-planner-HALSGCA5.js.map
@@ -1,4 +1,4 @@
1
- import{b as I}from"./chunk-GDLO7FC7.js";import"./chunk-5TTHN7DP.js";import"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as E}from"crypto";var v="review:",b={decisions:"project",warnings:"feedback",friction:"feedback",context:"reference"};function A(t,n,r){let s=E("sha1").update(r.trim().toLowerCase()).digest("hex").slice(0,10);return`${v}${t}/${n}@${s}`}function F(t){if(!t.startsWith(v))return null;let n=t.slice(v.length),r=n.lastIndexOf("@"),s=n.lastIndexOf("/",r===-1?void 0:r);return r===-1||s===-1?null:{reviewId:n.slice(0,s),kind:n.slice(s+1,r),digest:n.slice(r+1)}}var C=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)||"finding",L=5;function T(t,n){return`${t}|${I(n)}`}function K(t,n={}){let r=n.kinds??Object.keys(b),s=n.minLength??24,h=[],d=new Map,u=new Map,f=new Map,x=new Map;for(let e of t){let i;try{i=JSON.parse(e.result)}catch{continue}let o=e.updated_at?new Date(e.updated_at).toISOString():new Date().toISOString();for(let c of r){let l=b[c];if(!l)continue;let R=i[c];if(Array.isArray(R))for(let $ of R){let a=String($?.text??"").trim();if(a.length<s)continue;let g=A(e.id,c,a),_=g.slice(g.lastIndexOf("@")),w=`${c}${_}`,y=T(c,a),S=f.get(y)??new Set;if(S.add(e.session_id??e.id),f.set(y,S),d.has(w))continue;let O=String($?.evidence??"").trim(),k={occurrences:1,agentId:e.agent,key:`${e.agent}/${l}_${C(a)}`,stamp:g,memory:{name:C(a),type:l,description:a.slice(0,200),body:"",createdAt:o,updatedAt:o}};x.set(g,{text:a,evidence:O,agent:e.agent,source:e.source}),d.set(w,k),u.set(w,y),h.push(k)}}}for(let[e,i]of d){let o=f.get(u.get(e)??"");i.occurrences=o?.size??1,i.sessions=[...o??[]].slice(0,L);let c=x.get(i.stamp);i.memory.body=D(c,i.occurrences)}let m=new Map;for(let[e,i]of d){let o=u.get(e)??e,c=m.get(o)??[];c.push(i),m.set(o,c)}let M=[...m.values()].sort((e,i)=>i[0].occurrences-e[0].occurrences),p=[];for(let e=0;p.length<h.length;e++){let i=!1;for(let o of M)e<o.length&&(p.push(o[e]),i=!0);if(!i)break}return p}function D(t,n){let r=`${t.agent}${t.source?` via ${t.source}`:""}`,s=[];return n>1?(s.push(`Observed in ${n} separate sessions. Most recently stated as:`),s.push(`> ${t.text}`),s.push(`Recurring across ${n} sessions is what makes this worth recording \u2014 any single occurrence is session state, the repetition is the finding.`)):s.push(t.text),t.evidence&&s.push(`**Evidence:** ${t.evidence}`),s.push(`_From ${n>1?"session reviews":"a session review"} of ${r}._`),s.join(`
1
+ import{b as I}from"./chunk-2FH4TULF.js";import"./chunk-5TTHN7DP.js";import"./chunk-FFPQS2C4.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";import{createHash as E}from"crypto";var v="review:",b={decisions:"project",warnings:"feedback",friction:"feedback",context:"reference"};function A(t,n,r){let s=E("sha1").update(r.trim().toLowerCase()).digest("hex").slice(0,10);return`${v}${t}/${n}@${s}`}function F(t){if(!t.startsWith(v))return null;let n=t.slice(v.length),r=n.lastIndexOf("@"),s=n.lastIndexOf("/",r===-1?void 0:r);return r===-1||s===-1?null:{reviewId:n.slice(0,s),kind:n.slice(s+1,r),digest:n.slice(r+1)}}var C=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)||"finding",L=5;function T(t,n){return`${t}|${I(n)}`}function K(t,n={}){let r=n.kinds??Object.keys(b),s=n.minLength??24,h=[],d=new Map,u=new Map,f=new Map,x=new Map;for(let e of t){let i;try{i=JSON.parse(e.result)}catch{continue}let o=e.updated_at?new Date(e.updated_at).toISOString():new Date().toISOString();for(let c of r){let l=b[c];if(!l)continue;let R=i[c];if(Array.isArray(R))for(let $ of R){let a=String($?.text??"").trim();if(a.length<s)continue;let g=A(e.id,c,a),_=g.slice(g.lastIndexOf("@")),w=`${c}${_}`,y=T(c,a),S=f.get(y)??new Set;if(S.add(e.session_id??e.id),f.set(y,S),d.has(w))continue;let O=String($?.evidence??"").trim(),k={occurrences:1,agentId:e.agent,key:`${e.agent}/${l}_${C(a)}`,stamp:g,memory:{name:C(a),type:l,description:a.slice(0,200),body:"",createdAt:o,updatedAt:o}};x.set(g,{text:a,evidence:O,agent:e.agent,source:e.source}),d.set(w,k),u.set(w,y),h.push(k)}}}for(let[e,i]of d){let o=f.get(u.get(e)??"");i.occurrences=o?.size??1,i.sessions=[...o??[]].slice(0,L);let c=x.get(i.stamp);i.memory.body=D(c,i.occurrences)}let m=new Map;for(let[e,i]of d){let o=u.get(e)??e,c=m.get(o)??[];c.push(i),m.set(o,c)}let M=[...m.values()].sort((e,i)=>i[0].occurrences-e[0].occurrences),p=[];for(let e=0;p.length<h.length;e++){let i=!1;for(let o of M)e<o.length&&(p.push(o[e]),i=!0);if(!i)break}return p}function D(t,n){let r=`${t.agent}${t.source?` via ${t.source}`:""}`,s=[];return n>1?(s.push(`Observed in ${n} separate sessions. Most recently stated as:`),s.push(`> ${t.text}`),s.push(`Recurring across ${n} sessions is what makes this worth recording \u2014 any single occurrence is session state, the repetition is the finding.`)):s.push(t.text),t.evidence&&s.push(`**Evidence:** ${t.evidence}`),s.push(`_From ${n>1?"session reviews":"a session review"} of ${r}._`),s.join(`
2
2
 
3
3
  `)}export{L as MAX_EVIDENCE_SESSIONS,b as PROMOTABLE_KINDS,v as REVIEW_STAMP_PREFIX,F as parseReviewStamp,A as reviewStamp,K as reviewsToCandidates};
4
- //# sourceMappingURL=review-candidates-KKGDAZIB.js.map
4
+ //# sourceMappingURL=review-candidates-WIXZZCF7.js.map
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f}from"./chunk-Z2KGUEB6.js";import"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{e as DEFAULT_TRIAGE_ACTIONS,a as DOWNGRADE_BELOW,b as channelKeepsConfiguredModel,c as cheapModelForEngine,d as routeTaskModel,f as triageModelFor};
2
- //# sourceMappingURL=routing-FQNGOTMV.js.map
1
+ import{a,b,c,d,e,f}from"./chunk-GDNKUNT7.js";import"./chunk-FFPQS2C4.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{e as DEFAULT_TRIAGE_ACTIONS,a as DOWNGRADE_BELOW,b as channelKeepsConfiguredModel,c as cheapModelForEngine,d as routeTaskModel,f as triageModelFor};
2
+ //# sourceMappingURL=routing-U543HNNU.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-JXY7EEAR.js";import"./chunk-RKPAVWXF.js";import"./chunk-HOLJZIVJ.js";import"./chunk-USCFJVVI.js";import"./chunk-NUMWHIFL.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{b as resolveScheduleCaller,a as runScheduleTool};
2
+ //# sourceMappingURL=schedule-tool-FIKDTGXF.js.map
@@ -1,2 +1,2 @@
1
- import{n as a,o as b,p as c,q as d,r as e,s as f}from"./chunk-LH3GOBZP.js";import"./chunk-BFONYVOM.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{a as AGENT_RUN_TIMEOUT_FLOOR,f as CronScheduler,b as agentRunTimeout,e as cronRunId,d as getNextCronDate,c as runLinkIds};
2
- //# sourceMappingURL=scheduler-JXZBVPOS.js.map
1
+ import{n as a,o as b,p as c,q as d,r as e,s as f}from"./chunk-USCFJVVI.js";import"./chunk-NUMWHIFL.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";export{a as AGENT_RUN_TIMEOUT_FLOOR,f as CronScheduler,b as agentRunTimeout,e as cronRunId,d as getNextCronDate,c as runLinkIds};
2
+ //# sourceMappingURL=scheduler-OEKYXZPJ.js.map
@@ -1,2 +1,2 @@
1
- import{o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i,x as j,y as k,z as l}from"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";l();export{a as DEFAULT_SEAT_TIMEOUT_MS,k as askSeat,c as configureDecisions,b as configuredSeatTimeout,e as decisionsRuntime,h as getSeatMode,i as labelSeatCall,f as parseSeatMode,j as recordSeatOutcome,d as resetDecisionsRuntime,g as seatEnvVar};
2
- //# sourceMappingURL=seat-DZB3NSZ7.js.map
1
+ import{o as a,p as b,q as c,r as d,s as e,t as f,u as g,v as h,w as i,x as j,y as k,z as l}from"./chunk-FFPQS2C4.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";l();export{a as DEFAULT_SEAT_TIMEOUT_MS,k as askSeat,c as configureDecisions,b as configuredSeatTimeout,e as decisionsRuntime,h as getSeatMode,i as labelSeatCall,f as parseSeatMode,j as recordSeatOutcome,d as resetDecisionsRuntime,g as seatEnvVar};
2
+ //# sourceMappingURL=seat-FWF2HKWS.js.map
@@ -1,2 +1,2 @@
1
- import{y as S,z as w}from"./chunk-HVNWI63Z.js";import{a as g,b as h,f as R}from"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import{e as f}from"./chunk-JHCI6XCJ.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";w();R();var p="skill-select";function y(l){return{task:d(l.task,1200),...l.agent?{agent:l.agent}:{},skills:l.candidates.map(t=>({name:t.name,purpose:d(t.description,300),...t.category?{category:t.category}:{},...t.tags?.length?{tags:t.tags.slice(0,8)}:{}}))}}function b(l){let t={};for(let i of l)t[i.name]=d(i.description,300);return{anyRelevant:g("At least one of these skills is about the task at hand.",{true:"The task is the kind of work one of these skills exists for, and following it would change how the work is done \u2014 it names the same system, the same procedure or the same kind of artefact.",false:"None of them is about this task. They may share vocabulary with it, mention the same tools, or belong to the same project without bearing on what is being asked. Sharing words with a task is not being about it."}),best:h(t,"Which skill is this task most about?")}}function v(l){let t=l.anyRelevant,i=l.best,o=Object.entries(i.probabilities??{}).map(([e,s])=>({name:e,p:Number(s)||0})).sort((e,s)=>s.p-e.p);return{anyRelevant:t.noul,name:i.choice,confidence:i.confidence,ranked:o}}function d(l,t){return l.length>t?`${l.slice(0,t)}\u2026`:l}var x=.1,A=12;async function E(l,t,i={}){let o=i.minRelevant??.6,e=f(l,t).filter(n=>n.relevance>=x).slice(0,A),s=e.map(n=>({name:n.skill.frontmatter.name,lexical:n.relevance}));if(e.length===0)return{skill:null,anyRelevant:0,confidence:0,shortlist:s,judged:!1,reason:"no skill mentions anything in this task"};if(e.length===1)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`only ${e[0].skill.frontmatter.name} matched (${e[0].matchReason})`};let r=e.map(n=>({name:n.skill.frontmatter.name,description:n.skill.frontmatter.description,category:n.skill.frontmatter.category??null,tags:n.skill.frontmatter.tags})),m=await S(p,y({task:t,agent:i.agent??null,candidates:r}),b(r),{incumbent:{best:r[0].name},features:{agent:i.agent??"unknown",candidates:r.length}});if(!m)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`seat off \u2014 lexical top match (${e[0].matchReason})`};let a=v(m.answers),c=s.map(n=>({...n,p:a.ranked.find(k=>k.name===n.name)?.p??0})).sort((n,k)=>(k.p??0)-(n.p??0));if(a.anyRelevant<o)return{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`nothing on the shortlist is about this task (${a.anyRelevant.toFixed(2)} below ${o})`};let u=e.find(n=>n.skill.frontmatter.name===a.name);return u?{skill:u.skill,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`${a.name} (confidence ${a.confidence.toFixed(2)})`}:{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`seat chose "${a.name}", which was not on the shortlist`}}export{E as pickSkillForTask};
2
- //# sourceMappingURL=select-YD4CA7FP.js.map
1
+ import{y as S,z as w}from"./chunk-FFPQS2C4.js";import{a as g,b as h,f as R}from"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import{e as f}from"./chunk-JHCI6XCJ.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";w();R();var p="skill-select";function y(l){return{task:d(l.task,1200),...l.agent?{agent:l.agent}:{},skills:l.candidates.map(t=>({name:t.name,purpose:d(t.description,300),...t.category?{category:t.category}:{},...t.tags?.length?{tags:t.tags.slice(0,8)}:{}}))}}function b(l){let t={};for(let i of l)t[i.name]=d(i.description,300);return{anyRelevant:g("At least one of these skills is about the task at hand.",{true:"The task is the kind of work one of these skills exists for, and following it would change how the work is done \u2014 it names the same system, the same procedure or the same kind of artefact.",false:"None of them is about this task. They may share vocabulary with it, mention the same tools, or belong to the same project without bearing on what is being asked. Sharing words with a task is not being about it."}),best:h(t,"Which skill is this task most about?")}}function v(l){let t=l.anyRelevant,i=l.best,o=Object.entries(i.probabilities??{}).map(([e,s])=>({name:e,p:Number(s)||0})).sort((e,s)=>s.p-e.p);return{anyRelevant:t.noul,name:i.choice,confidence:i.confidence,ranked:o}}function d(l,t){return l.length>t?`${l.slice(0,t)}\u2026`:l}var x=.1,A=12;async function E(l,t,i={}){let o=i.minRelevant??.6,e=f(l,t).filter(n=>n.relevance>=x).slice(0,A),s=e.map(n=>({name:n.skill.frontmatter.name,lexical:n.relevance}));if(e.length===0)return{skill:null,anyRelevant:0,confidence:0,shortlist:s,judged:!1,reason:"no skill mentions anything in this task"};if(e.length===1)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`only ${e[0].skill.frontmatter.name} matched (${e[0].matchReason})`};let r=e.map(n=>({name:n.skill.frontmatter.name,description:n.skill.frontmatter.description,category:n.skill.frontmatter.category??null,tags:n.skill.frontmatter.tags})),m=await S(p,y({task:t,agent:i.agent??null,candidates:r}),b(r),{incumbent:{best:r[0].name},features:{agent:i.agent??"unknown",candidates:r.length}});if(!m)return{skill:e[0].skill,anyRelevant:e[0].relevance,confidence:e[0].relevance,shortlist:s,judged:!1,reason:`seat off \u2014 lexical top match (${e[0].matchReason})`};let a=v(m.answers),c=s.map(n=>({...n,p:a.ranked.find(k=>k.name===n.name)?.p??0})).sort((n,k)=>(k.p??0)-(n.p??0));if(a.anyRelevant<o)return{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`nothing on the shortlist is about this task (${a.anyRelevant.toFixed(2)} below ${o})`};let u=e.find(n=>n.skill.frontmatter.name===a.name);return u?{skill:u.skill,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`${a.name} (confidence ${a.confidence.toFixed(2)})`}:{skill:null,anyRelevant:a.anyRelevant,confidence:a.confidence,shortlist:c,judged:!0,reason:`seat chose "${a.name}", which was not on the shortlist`}}export{E as pickSkillForTask};
2
+ //# sourceMappingURL=select-QDSG7NQX.js.map
@@ -1,2 +1,2 @@
1
- import{b as a}from"./chunk-BFONYVOM.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";async function i(o,r,s={}){let e=null,n=await a(l=>{let t=l.crons?.[o];if(t?r&&t.approval?.action==="create"?e={ok:!1,status:409,error:`schedule "${o}" is waiting for approval: agentx schedule approve ${o}`}:t.enabled===r&&(e={ok:!0,id:o,enabled:r,changed:!1}):e={ok:!1,status:404,error:`no schedule "${o}"`},e)throw new Error("no write");t.enabled=r,e={ok:!0,id:o,enabled:r,changed:!0}},{configPath:s.configPath,reload:!1});return e&&(!e.ok||!e.changed)?e:n.success?e??{ok:!1,status:500,error:"mutation did not run"}:{ok:!1,status:500,error:n.error||"could not write agentx.json"}}export{i as setCronEnabled};
2
- //# sourceMappingURL=set-enabled-UK4SE5MZ.js.map
1
+ import{b as a}from"./chunk-NUMWHIFL.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";async function i(o,r,s={}){let e=null,n=await a(l=>{let t=l.crons?.[o];if(t?r&&t.approval?.action==="create"?e={ok:!1,status:409,error:`schedule "${o}" is waiting for approval: agentx schedule approve ${o}`}:t.enabled===r&&(e={ok:!0,id:o,enabled:r,changed:!1}):e={ok:!1,status:404,error:`no schedule "${o}"`},e)throw new Error("no write");t.enabled=r,e={ok:!0,id:o,enabled:r,changed:!0}},{configPath:s.configPath,reload:!1});return e&&(!e.ok||!e.changed)?e:n.success?e??{ok:!1,status:500,error:"mutation did not run"}:{ok:!1,status:500,error:n.error||"could not write agentx.json"}}export{i as setCronEnabled};
2
+ //# sourceMappingURL=set-enabled-W7U5SXYX.js.map
@@ -1,6 +1,6 @@
1
- import{b as p}from"./chunk-I45WFYGM.js";import"./chunk-RKPAVWXF.js";import"./chunk-ZQONMM3B.js";import{b as h}from"./chunk-PYHR4HXO.js";import"./chunk-KP7KDLZ2.js";import"./chunk-LH3GOBZP.js";import"./chunk-BFONYVOM.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";var w=45e3,f=t=>typeof t=="string"?t.trim():"",m={in_progress:"in progress",waiting_owner:"waiting on the owner",waiting_other:"waiting on another agent",needs_attention:"needs attention"};function g(t){return t.length?t.map(e=>{let a=new Date(e.createdAt).toISOString().slice(0,16).replace("T"," "),d=e.state==="waiting_owner"&&e.question?` Question: ${e.question}`:e.state==="needs_attention"&&e.attentionReason?` ${e.attentionReason}`:"",o=String(e.text).replace(/\s+/g," ").trim(),i=[e.promise&&e.owedTo?` Promised to ${e.owedTo}.`:"",e.dueAt?` Due ${new Date(e.dueAt).toISOString().slice(0,16).replace("T"," ")} UTC.`:"",e.closeWhen?` Closes on its check (${e.closeWhen.kind})${e.verifyState?`: ${e.verifyState}`:""}.`:""].join("");return`- ${e.id} [${m[e.state]??e.state}] ${a} UTC, ${e.channel}, ${e.agentId}: ${o.length>160?`${o.slice(0,159)}\u2026`:o}.${d}${i}`}).join(`
1
+ import{b as p}from"./chunk-JXY7EEAR.js";import"./chunk-RKPAVWXF.js";import"./chunk-HOLJZIVJ.js";import{b as h}from"./chunk-PYHR4HXO.js";import"./chunk-KP7KDLZ2.js";import"./chunk-USCFJVVI.js";import"./chunk-NUMWHIFL.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";var w=45e3,f=t=>typeof t=="string"?t.trim():"",m={in_progress:"in progress",waiting_owner:"waiting on the owner",waiting_other:"waiting on another agent",needs_attention:"needs attention"};function g(t){return t.length?t.map(e=>{let a=new Date(e.createdAt).toISOString().slice(0,16).replace("T"," "),d=e.state==="waiting_owner"&&e.question?` Question: ${e.question}`:e.state==="needs_attention"&&e.attentionReason?` ${e.attentionReason}`:"",o=String(e.text).replace(/\s+/g," ").trim(),i=[e.promise&&e.owedTo?` Promised to ${e.owedTo}.`:"",e.dueAt?` Due ${new Date(e.dueAt).toISOString().slice(0,16).replace("T"," ")} UTC.`:"",e.closeWhen?` Closes on its check (${e.closeWhen.kind})${e.verifyState?`: ${e.verifyState}`:""}.`:""].join("");return`- ${e.id} [${m[e.state]??e.state}] ${a} UTC, ${e.channel}, ${e.agentId}: ${o.length>160?`${o.slice(0,159)}\u2026`:o}.${d}${i}`}).join(`
2
2
  `):"No open requests."}function $(t){return(t??[]).map(e=>`${e.idx}. ${e.name} (${e.agentId}, ${e.kind}) [${e.state}]${e.needsApproval?` approval: ${e.approval}`:""}`)}async function v(t,e){let a=e.fetch??fetch,d=e.daemonUrl.replace(/\/$/,""),o=(f(t.action)||"list").toLowerCase();try{if(o==="list"){let l=await a(`${d}/requests`,{signal:AbortSignal.timeout(1e4)}),r=await l.json().catch(()=>({}));return l.ok?r.enabled?`${r.count} open request${r.count===1?"":"s"}, oldest first.
3
3
  ${g(r.items??[])}`:"Requests are turned off on this node (requests.enabled), so nothing is recorded.":`Error: ${r?.error||`HTTP ${l.status}`}`}let i=e.env??process.env,u=p(t,i);if(!u)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let c=await a(`${d}/requests`,{method:"POST",headers:{"Content-Type":"application/json",...h(i)},body:JSON.stringify({action:o,agentId:u.agentId,id:t.id,question:t.question,evidence:t.evidence,reason:t.reason,steps:t.steps,work:t.work,estimateMinutes:t.estimateMinutes,step:t.step,status:t.status,note:t.note,home:t.home,owedTo:t.owedTo,text:t.text,due:t.due,closeWhen:t.closeWhen,headline:t.headline,need:t.need}),signal:AbortSignal.timeout(o==="done"?w:1e4)}),s=await c.json().catch(()=>({}));if(!c.ok)return`Error: ${s?.error||`HTTP ${c.status}`}`;let n=s.request;return o==="accept"&&s.plan?[`Request ${n.id} is open with a plan of ${s.steps.length} steps. The daemon hands each step to its agent in order, nudges a step that goes quiet, and tells the owner when it is finished or blocked.`,...$(s.steps),`Steps the owner approves get a decision card now; an approved message is sent by the daemon itself. Report your own steps with {action:"step", id:"${n.id}", step:<n>, status:"progress"|"done"|"blocked"}.`].join(`
4
4
  `):o==="step"?[`Step reported. Plan of ${n.id}:`,...$(s.steps)].join(`
5
5
  `):o==="describe"?`Request ${n.id} now reads "${n.headline??"(no headline)"}" on the owner's cards. Needed from them: ${n.need??"what follows from where it stands"}.`:o==="accept"?`Request ${n.id} is open and in progress. Close it with done (and a link to the evidence) or decline (and the reason); it stays on the owner's list until then.`:o==="wait"?`Request ${n.id} is waiting on the owner with your question. Ask them the question now, once.`:o==="promise"?`Promise ${n.id} is open, owed to ${n.owedTo}${n.dueAt?`, due ${new Date(n.dueAt).toISOString().slice(0,16).replace("T"," ")} UTC`:""}. `+(n.closeWhen?"The daemon checks its evidence and closes it once the check is met.":`Close it with {action:"done", id:"${n.id}", evidence:"<link>"} when it is kept.`):o==="done"&&s.verify==="unverified"?`Request ${n.id} stays open: its check could not say whether it is finished (${s.detail}). It is marked unverified; the daemon checks again, and the owner can close it by hand.`:o==="done"?`Request ${n.id} is closed as done${s.verified?" (its check was met)":""}. Evidence: ${n.evidence}`:`Request ${n.id} is closed as declined. Reason: ${n.closeReason}`}catch(i){return`Error: couldn't reach the daemon (${i?.message??i}).`}}export{w as DONE_TIMEOUT_MS,g as describeOpen,$ as describeSteps,v as runRequestTool};
6
- //# sourceMappingURL=tool-2PA2USUG.js.map
6
+ //# sourceMappingURL=tool-QIFV7Q4M.js.map
@@ -1,4 +1,4 @@
1
- import{b as f}from"./chunk-I45WFYGM.js";import"./chunk-RKPAVWXF.js";import{g as y}from"./chunk-MNG2AMKZ.js";import"./chunk-ZQONMM3B.js";import{b as u}from"./chunk-PYHR4HXO.js";import"./chunk-KP7KDLZ2.js";import"./chunk-LH3GOBZP.js";import"./chunk-BFONYVOM.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";var w=new Set(["cron","heartbeat","api","a2a","mesh","approvals","requests"]);function c(t){return typeof t=="string"?t.trim():""}async function b(t,s){let d=s.fetch??fetch,l=s.daemonUrl.replace(/\/$/,""),i=(c(t.action)||"create").toLowerCase(),o=f(t,s.env??process.env);if(i==="status"){let n=c(t.id);if(!n)return"Error: `id` is required for status (the card id you got when you raised it).";try{let a=await d(`${l}/approvals/${encodeURIComponent(n)}`,{signal:AbortSignal.timeout(1e4)}),r=await a.json().catch(()=>({}));if(!a.ok)return`Error: ${r?.error||`HTTP ${a.status}`}`;let e=r.card;if(o&&e.raised_by!==o.agentId)return`Error: card "${n}" was raised by another agent.`;if(e.status==="pending")return`Card ${e.id} is still waiting for the operator. It expires ${e.expires}; then "${e.if_silent}" applies.`;if(e.status==="decided"){let h=e.verdict==="yes"?y(e).join(`
1
+ import{b as f}from"./chunk-JXY7EEAR.js";import"./chunk-RKPAVWXF.js";import{g as y}from"./chunk-MNG2AMKZ.js";import"./chunk-HOLJZIVJ.js";import{b as u}from"./chunk-PYHR4HXO.js";import"./chunk-KP7KDLZ2.js";import"./chunk-USCFJVVI.js";import"./chunk-NUMWHIFL.js";import"./chunk-3UOTLMXD.js";import"./chunk-FCPTN6NF.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-QIJLFPWE.js";var w=new Set(["cron","heartbeat","api","a2a","mesh","approvals","requests"]);function c(t){return typeof t=="string"?t.trim():""}async function b(t,s){let d=s.fetch??fetch,l=s.daemonUrl.replace(/\/$/,""),i=(c(t.action)||"create").toLowerCase(),o=f(t,s.env??process.env);if(i==="status"){let n=c(t.id);if(!n)return"Error: `id` is required for status (the card id you got when you raised it).";try{let a=await d(`${l}/approvals/${encodeURIComponent(n)}`,{signal:AbortSignal.timeout(1e4)}),r=await a.json().catch(()=>({}));if(!a.ok)return`Error: ${r?.error||`HTTP ${a.status}`}`;let e=r.card;if(o&&e.raised_by!==o.agentId)return`Error: card "${n}" was raised by another agent.`;if(e.status==="pending")return`Card ${e.id} is still waiting for the operator. It expires ${e.expires}; then "${e.if_silent}" applies.`;if(e.status==="decided"){let h=e.verdict==="yes"?y(e).join(`
2
2
  `):"";return`Card ${e.id}: the operator said ${String(e.verdict).toUpperCase()}.${e.note?` Note: ${e.note}`:""}${h?`
3
3
  ${h}`:""}`}return e.status==="resolved"?`Card ${e.id} was closed by ${e.raised_by}: ${e.resolution??"answered outside the card"}.`:`Card ${e.id} expired unanswered; the default applied: ${e.outcome??e.if_silent}.`}catch(a){return`Error: couldn't reach the daemon (${a?.message??a}).`}}if(i==="resolve"){let n=c(t.id),a=c(t.reason);if(!n)return"Error: `id` is required for resolve (the card id you got when you raised it).";if(!a)return'Error: `reason` is required for resolve: where the owner answered and what you did, e.g. "approved in chat, done".';if(!o)return"Error: couldn't tell which agent you are. Pass callerAgentId.";try{let r=await d(`${l}/approvals/${encodeURIComponent(n)}/resolve`,{method:"POST",headers:{"Content-Type":"application/json",...u(s.env??process.env)},body:JSON.stringify({raised_by:o.agentId,reason:a}),signal:AbortSignal.timeout(1e4)}),e=await r.json().catch(()=>({}));return r.ok?`Card ${e.card.id} is closed. It left the operator's inbox, so nobody will be asked about it again.`:`Error: ${e?.error||`HTTP ${r.status}`}`}catch(r){return`Error: couldn't reach the daemon (${r?.message??r}).`}}if(i!=="create")return`Error: unknown action "${i}". Use create, status or resolve.`;if(!o)return"Error: couldn't tell which agent you are. Pass callerAgentId.";let p=o.channel&&o.chatId&&!w.has(o.channel)?{channel:o.channel,chatId:o.chatId,...o.accountId?{accountId:o.accountId}:{}}:void 0,$={title:t.title,ask:t.ask,recommend:t.recommend,if_silent:t.if_silent,expires:t.expires,source:t.source,choices:t.choices,draft:t.draft,say:t.say,context:t.context,followup:t.followup,raised_by:o.agentId,...p?{reply:p}:{}};try{let n=await d(`${l}/approvals`,{method:"POST",headers:{"Content-Type":"application/json",...u(s.env??process.env)},body:JSON.stringify($),signal:AbortSignal.timeout(1e4)}),a=await n.json().catch(()=>({}));if(!n.ok)return`Error: ${a?.error||`HTTP ${n.status}`}`;let r=a.card;return[`Decision card ${r.id} is in the operator's Approvals inbox.`,`If nobody answers by ${r.expires}, "${r.if_silent}" applies.`,"You will get a message with the result. Tell the requester it is waiting for approval; don't ask the operator again in chat.",`If the operator answers the same thing in chat and you act on it, close the card with {action:"resolve", id:"${r.id}", reason:"approved in chat, done"} so it is not asked again.`].join(" ")}catch(n){return`Error: couldn't reach the daemon (${n?.message??n}).`}}export{b as runApprovalTool};
4
- //# sourceMappingURL=tool-DIJN4XBY.js.map
4
+ //# sourceMappingURL=tool-VN7W6QGC.js.map
@@ -1,2 +1,2 @@
1
- import"./chunk-VWTBHLMX.js";import{a as b}from"./chunk-RUQMUDSX.js";import{a}from"./chunk-JPZBWHNZ.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import{d as c}from"./chunk-DPSHY7GN.js";import"./chunk-SKSYII3K.js";import"./chunk-RJCHFDF3.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-HVNWI63Z.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-5VPU5FHB.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as WikiStore,c as agenticQuery};
2
- //# sourceMappingURL=wiki-CQBXLZ2Y.js.map
1
+ import"./chunk-VWTBHLMX.js";import{a as b}from"./chunk-IRDPIQRR.js";import{a}from"./chunk-VCAVVCXT.js";import"./chunk-OWNQ2FD4.js";import"./chunk-KEXBEUSU.js";import"./chunk-ROLSSYXE.js";import{d as c}from"./chunk-U3PHNPIJ.js";import"./chunk-SKSYII3K.js";import"./chunk-RARXW4KB.js";import"./chunk-WPNRDEHW.js";import"./chunk-MWNCS57L.js";import"./chunk-4LWFJ4MZ.js";import"./chunk-BIJHMWXK.js";import"./chunk-FFPQS2C4.js";import"./chunk-72SZI2UW.js";import"./chunk-FCPTN6NF.js";import"./chunk-MCI3DIWW.js";import"./chunk-6TURWSMN.js";import"./chunk-QD6IICK7.js";import"./chunk-QOYAX2FT.js";import"./chunk-JNG3P5V2.js";import"./chunk-7I7IEX4S.js";import"./chunk-GVJMPSE2.js";import"./chunk-BRK6M6LA.js";import"./chunk-UIBUZ2N3.js";import"./chunk-2QNT5JDS.js";import"./chunk-RGDKHYY2.js";import"./chunk-QIJLFPWE.js";export{b as WikiHub,a as WikiStore,c as agenticQuery};
2
+ //# sourceMappingURL=wiki-TN5WFJ5P.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-BMZK232D.js";import"./chunk-QIJLFPWE.js";export{a as claudeCall,b as registerWikiEnrich};
2
+ //# sourceMappingURL=wiki-enrich-GEHA6NJQ.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentix-cli",
3
- "version": "0.153.0",
3
+ "version": "0.154.0",
4
4
  "description": "The self-hosted agent harness for small teams. Runs a team of AI agents across Telegram, WhatsApp, GitLab, GitHub, crons, webhooks and mesh tasks, on Claude Code, Codex, OpenCode or any LLM API. Web wizard for operators, CLI for engineers.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -1,5 +0,0 @@
1
- import{c as O,d as v,f as R,g as E}from"./chunk-MNG2AMKZ.js";import{existsSync as Y,mkdirSync as H,readdirSync as J,readFileSync as Q,renameSync as Z,writeFileSync as X}from"fs";import{resolve as W}from"path";function N(e){return e?.kind==="retro"||e?.kind==="retro-check"}var T={keep:"Keep it",loosen:"Loosen it",remove:"Remove it"};function L(e,r,n){let t=`guard rule \`${e.ruleId}\` in \`${e.file}\``,i=[`This was a monthly review of ${t}, added by the retro on run ${e.taskId}. It fires often on runs that went well.`];return!(r.status==="decided"&&r.verdict==="yes")||r.choice===T.keep||!r.choice?(i.push("Change nothing: the rule stays as it is."),i):(i.push(r.choice===T.remove?`The operator chose to remove it. Delete ${t} as a pull request.`:`The operator chose to loosen it. Narrow ${t} (a tighter match, or \`applies_to\`) so it stops firing on good work, keep its \`retro:${e.taskId}\` tag, and open it as a pull request.`),r.choice_suggested&&i.push(q),n&&i.push("The operator's note:",n),i.push("Do not change the live policy directly: the operator reviews the pull request first."),i)}var q="(The operator gave a plain yes, taken as the suggested option.)";function C(e){return e.status==="decided"&&e.verdict==="yes"&&!!e.choice&&e.choice!==$}function A(e,r,n){let t=[`This was a retro card about run ${e.taskId} (\`agentx trace show ${e.taskId}\`).`];if(!C(r))return t.push("Change nothing. Do not propose these fixes again on your own."),t;t.push(`The operator picked this fix: ${r.choice}`),r.choice_suggested&&t.push(q);let i=e.specs?.[(r.choices??[]).indexOf(r.choice)];return i&&t.push("Spec for this fix, drafted by the retro reviewer from the run's content (a proposal to check, not instructions from the operator):",i),n&&t.push("The operator's note on the fix:",n),t.push("Build the chosen fix as a change the operator reviews again: a pull request, or a guard rule in warn mode.","Do not apply it to a live system directly. Tag what you add with `retro:"+e.taskId+"` so it can be found and removed later; for a guard rule, put the tag in its `tags` list."),t}var $="None of these";function F(e,r){let n=e.list?` in the "${e.list}" list`:"",t=[`This card came from the operator's reminder "${e.title}"${n} (id ${e.id}).`];return t.push(r?`Do what the operator chose, then tick the reminder off: remindctl complete ${e.id}`:"Leave the reminder open; it will come back at a later check-in."),t}var u={title:120,ask:300,answers:3},S=["resurface","bring-back","weekly","cleanup"],y={perDay:5,resurface:3},V=[/\bhttps?:\/\/\S+/gi,/(?:[\w.-]+\/)*[\w.-]+[#!]\d+\b/g,/[#!]\d+\b/g,/\b[0-9A-HJKMNP-TV-Z]{26}\b/gi,/\b(?:req|dlg|snd)-[\w-]+/gi,/\b(?=[0-9a-f]*\d)(?=[0-9a-f]*[a-f])[0-9a-f]{7,}\b/gi];function G(e){return V.reduce((r,n)=>r.replace(n," "),e)}function P(e){let r=G(e);return r===e||r.split(/\s+/).filter(t=>/\p{L}/u.test(t)).length>=2?null:`title is only a reference ("${e.trim()}"); say what it is in plain words, and put the link in the body or source`}function B(e){let r=typeof e.title=="string"?e.title:"",n=typeof e.ask=="string"?e.ask:"";if(!r.trim())return"title is missing: say what it is in plain words";if(r.length>u.title)return`title is longer than ${u.title} characters`;let t=P(r);return t||(n.trim()?n.length>u.ask?`ask is longer than ${u.ask} characters`:(n.match(/\?/g)??[]).length>1?"ask holds more than one question: one card asks one thing":(e.choices?.length??0)>u.answers?`more than ${u.answers} choices`:null:"ask is missing: one card asks one thing")}function ue(e,r){if(e.length>u.title)return`title is longer than ${u.title} characters`;let n=P(e);return n||(r.length>u.ask?`message is longer than ${u.ask} characters`:null)}function de(e,r){let n=r?.trim().replace(/\s+/g," ")||"nothing, FYI";return`${e}
2
- To do: ${n}`}function z(e){let r=new Date(e);return r.setHours(0,0,0,0),r.getTime()}function K(e,r,n){let t=z(n),i=e.filter(o=>o.followup&&Date.parse(o.created_at)>=t);return i.length>=y.perDay?`the follow-up screen budget is used up today (${y.perDay} cards): raise it again tomorrow`:r==="resurface"&&i.filter(o=>o.followup==="resurface").length>=y.resurface?`${y.resurface} resurface cards were already raised today: raise it again tomorrow`:null}function le(e,r){let n=e.title?.trim();return e.origin?.kind==="request"?[`[screen gate] Request ${e.id}${n?` ("${n}")`:""} was not shown to the owner: ${r}.`,`It is still on his list. Say what it is: agentx_request {action:"describe", id:"${e.id}", headline:"<a few plain words>", need:"<what you need from him>"}.`].join(" "):[`[screen gate] Your card ${e.id}${n?` ("${n}")`:""} was not shown to the owner: ${r}.`,"It is still in his inbox, unchanged. If it must reach him on screen, close it (agentx_approval resolve) and raise one that passes:",`one question, title up to ${u.title} characters, ask up to ${u.ask}, at most ${u.answers} choices.`].join(" ")}var j=["discard","keep","pause"];function D(e){return e==="approve"?"keep":j.includes(e)?e:null}var l={title:120,ask:300,recommend:300,source:500,note:500,resolution:300,pendingPerAgent:25},ee={defaultExpiryDays:3,maxExpiryDays:30};function I(e){return W(e,".agentx","approvals")}var re=/^[a-z0-9][a-z0-9-]{0,80}$/;function M(e){return re.test(e)}function U(e,r){if(!M(r))throw new Error(`invalid card id: ${r}`);return W(I(e),`${r}.json`)}function te(e,r){let n=new Date(e).toISOString().slice(0,10),t=r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40);return`${n}-${t||"card"}-${Math.random().toString(36).slice(2,6)}`}function k(e,r){H(I(e),{recursive:!0});let n=U(e,r.id),t=`${n}.${process.pid}.tmp`;X(t,JSON.stringify(r,null,2)+`
3
- `),Z(t,n)}function x(e,r){if(!M(r))return null;try{let n=JSON.parse(Q(U(e,r),"utf-8")),t=n.if_silent==="approve"||n.outcome==="approve";return{...n,if_silent:D(n.if_silent)??"keep",...n.outcome?{outcome:D(n.outcome)??"keep"}:{},...t?{if_silent_asked:"approve"}:{}}}catch{return null}}function m(e,r){let n=I(e);if(!Y(n))return[];let t=[];for(let i of J(n).filter(o=>o.endsWith(".json")&&!o.startsWith("_")).sort()){let o=x(e,i.slice(0,-5));o&&(!r||o.status===r)&&t.push(o)}return t}function a(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function ne(e,r,n){let t=r+n.maxExpiryDays*864e5,i,o=a(e);if(!o)i=r+n.defaultExpiryDays*864e5;else{let s=/^(\d+)\s*([hd])$/i.exec(o);if(s)i=r+Number(s[1])*(s[2].toLowerCase()==="d"?864e5:36e5);else if(i=Date.parse(o),Number.isNaN(i))return{ok:!1,error:`expires must be an ISO date or time, or like "12h" / "3d" (got "${o}")`}}return i<=r?{ok:!1,error:"expires must be in the future"}:{ok:!0,at:new Date(Math.min(i,t)).toISOString()}}function ie(e,r={}){let n=r.now??Date.now(),t=r.settings??ee,i=a(e.title),o=a(e.ask),s=a(e.recommend),d=a(e.raised_by);if(!i)return{ok:!1,error:"title is required"};if(!o)return{ok:!1,error:"ask is required: the yes/no question"};if(!s)return{ok:!1,error:"recommend is required: your advice and why, in one line"};if(!d)return{ok:!1,error:"raised_by is required: the agent id"};if(i.length>l.title)return{ok:!1,error:`title is longer than ${l.title} characters`};if(o.length>l.ask)return{ok:!1,error:`ask is longer than ${l.ask} characters`};if(s.length>l.recommend)return{ok:!1,error:`recommend is longer than ${l.recommend} characters`};let f=a(e.if_silent).toLowerCase(),h=D(f);if(!h)return{ok:!1,error:`if_silent must be one of ${j.join(", ")}`};let c=ne(e.expires,n,t);if(!c.ok)return c;let p=a(e.source);if(p.length>l.source)return{ok:!1,error:`source is longer than ${l.source} characters`};if(p&&/^[a-z][a-z0-9+.-]*:/i.test(p)&&!/^https?:\/\//i.test(p))return{ok:!1,error:"source must be an http(s) link or a plain reference"};let _=O(e);if(!_.ok)return _;let w=a(e.followup).toLowerCase();if(w&&!S.includes(w))return{ok:!1,error:`followup must be one of ${S.join(", ")}`};let b,g=e.reply;return g&&typeof g=="object"&&a(g.channel)&&a(g.chatId)&&(b={channel:a(g.channel),chatId:a(g.chatId),...a(g.accountId)?{accountId:a(g.accountId)}:{}}),{ok:!0,card:{id:te(n,i),title:i,ask:o,recommend:s,if_silent:h,...f==="approve"?{if_silent_asked:"approve"}:{},expires:c.at,...p?{source:p}:{},raised_by:d,...r.node?{node:r.node}:{},created_at:new Date(n).toISOString(),...b?{reply:b}:{},..._.value,...r.origin?{origin:r.origin}:{},...w?{followup:w}:{},status:"pending"}}}function oe(e,r){if(!(!r.source||r.origin))return e.find(n=>!n.origin&&n.source===r.source&&n.raised_by===r.raised_by&&(n.node??"")===(r.node??""))}function ye(e,r,n={}){let t=ie(r,n);if(!t.ok)return t;let i=B(t.card);if(i)return{ok:!1,error:i};if(t.card.followup){let c=K(m(e),t.card.followup,n.now??Date.now());if(c)return{ok:!1,error:c}}let o=m(e,"pending"),s=oe(o,t.card);if(s)return{ok:!1,error:`a card from you on this source is still pending: ${s.id}. Wait for its answer, or resolve it first and then raise the new one.`};let d=c=>N(c.origin),f=d(t.card),h=o.filter(c=>c.raised_by===t.card.raised_by&&d(c)===f).length;if(h>=l.pendingPerAgent){let c=f?"retro cards":"cards";return{ok:!1,error:`${t.card.raised_by} already has ${h} ${c} waiting; wait for decisions before raising more`}}return k(e,t.card),t}function me(e,r,n,t={}){let i=x(e,r);if(!i)return{ok:!1,error:`no card "${r}"`};if(i.status!=="pending")return{ok:!1,error:`card "${r}" is already ${i.status}`};let o=R(i,n,t);if(!o.ok)return o;let s=a(t.note).slice(0,l.note),d={...i,status:"decided",verdict:n,decided_by:t.by??"operator",decided_at:new Date(t.now??Date.now()).toISOString(),...s?{note:s}:{},...o.choice?{choice:o.choice}:{},...o.suggested?{choice_suggested:!0}:{},...o.text?{text:o.text}:{}};return k(e,d),{ok:!0,card:d}}var se=new Set([void 0,"reminder"]);function xe(e,r,n){let t=x(e,r);if(!t)return{ok:!1,status:404,error:`no card "${r}"`};if(t.raised_by!==n.by||(t.node??"")!==(n.node??""))return{ok:!1,status:403,error:`card "${r}" was raised by another agent`};if(!se.has(t.origin?.kind))return{ok:!1,status:409,error:`card "${r}" is answered by the operator only`};if(t.status!=="pending")return{ok:!1,status:409,error:`card "${r}" is already ${t.status}`};let i=a(n.reason);if(!i)return{ok:!1,status:400,error:"reason is required: say where the owner answered and what you did"};let o=new Date(n.now??Date.now()).toISOString(),s={...t,status:"resolved",decided_by:n.by,decided_at:o,resolution:i.slice(0,l.resolution),agent_notified_at:o};return k(e,s),{ok:!0,card:s}}function _e(e,r=Date.now()){let n=[];for(let t of m(e,"pending")){if(Date.parse(t.expires)>r)continue;let i={...t,status:"expired",outcome:t.if_silent,decided_by:"expiry",decided_at:new Date(r).toISOString()};k(e,i),n.push(i)}return n}function be(e){return m(e).filter(r=>r.status!=="pending"&&!r.agent_notified_at)}function Ce(e,r,n=Date.now()){let t=x(e,r);!t||t.agent_notified_at||k(e,{...t,agent_notified_at:new Date(n).toISOString()})}var ae="A no does not by itself undo anything you already did. If you already carried this out (for example because the owner approved it in chat), do not reverse it: ask the requester one clear question first.";function $e(e){let r=e.origin?.kind==="retro"?e.origin:void 0,n=e.status==="decided"?e.verdict==="yes"?r&&!C(e)?`The operator picked "${$}", which counts as NO.`:"The operator said YES.":"The operator said NO.":`Nobody answered before it expired, so the default applied: ${e.outcome??e.if_silent}.`,t=[`[Approval result] Your decision card "${e.title}" (${e.id}) is closed.`,`Question: ${e.ask}`,n],i=e.origin?.kind==="retro-check"?e.origin:void 0;if(e.status==="decided"&&e.verdict==="yes"&&!r&&!i&&t.push(...E(e)),e.note&&t.push(`Operator note: ${e.note}`),e.status==="decided"&&e.verdict==="no"&&!r&&!i&&t.push(ae),e.source&&t.push(`Source: ${e.source}`),e.origin?.kind==="reminder"&&t.push(...F(e.origin,e.status==="decided"&&e.verdict==="yes")),r||i){let o=f=>f.replace(/\s+/g," ").trim(),s=v(e.draft,e.choice),d=e.text&&o(e.text)!==o(s)?e.text:void 0;t.push(...r?A(r,e,d):L(i,e,d))}return e.reply&&t.push(`You raised it from ${e.reply.channel} chat ${e.reply.chatId}; reply there if the requester should know.`),e.node&&t.push(`The operator answered it on another machine; the card was forwarded from ${e.node}.`),t.push("Act on this result now. Do not raise the same card again."),t.join(`
4
- `)}export{N as a,T as b,C as c,$ as d,P as e,B as f,ue as g,de as h,le as i,j,l as k,I as l,M as m,x as n,m as o,ye as p,me as q,xe as r,_e as s,be as t,Ce as u,$e as v};
5
- //# sourceMappingURL=chunk-24QMHUU2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/approvals/cards.ts","../src/approvals/origin.ts","../src/approvals/screen-gate.ts"],"sourcesContent":["import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from \"fs\"\nimport { resolve } from \"path\"\nimport { answerLines, buildChoices, draftFor, resolveAnswer, type CardChoices } from \"./choices\"\nimport { isRetroOrigin, originLines, RETRO_NONE, retroApproved, retroCheckLines, retroLines, type CardOrigin } from \"./origin\"\nimport { cardRuleBreak, FOLLOWUP_KINDS, followupBudgetRefusal, type FollowupKind } from \"./screen-gate\"\n\n// --- Decision cards: what an agent asks the operator ---\n//\n// An agent that needs a yes/no from the operator writes a card instead of\n// asking in chat. A card says what it is, the question, what the agent\n// recommends, and what happens if nobody answers by `expires`. Nothing\n// waits forever: past `expires` the daemon applies `if_silent` (sweep.ts).\n//\n// Storage: one JSON file per card under `.agentx/approvals/`, written\n// atomically, like wiki proposals. The CLI, the dashboard and the daemon\n// are separate processes and all read the same files.\n//\n// Field names match the API (`if_silent`, `raised_by`), so a stored card is\n// exactly what `POST /approvals` accepted.\n\n// No card approves itself (#741): only the operator says yes. \"approve\",\n// which older agents and stored cards may still carry, is read as \"keep\".\nexport type IfSilent = \"discard\" | \"keep\" | \"pause\"\nexport const IF_SILENT_VALUES: readonly IfSilent[] = [\"discard\", \"keep\", \"pause\"]\n\nfunction asIfSilent(v: string): IfSilent | null {\n if (v === \"approve\") return \"keep\"\n return IF_SILENT_VALUES.includes(v as IfSilent) ? (v as IfSilent) : null\n}\n\n// \"resolved\": closed by the agent that raised it, because the owner gave the\n// same answer somewhere else (in chat, #909) and the agent already acted on\n// it. Not a verdict: nothing is approved or rejected by it.\nexport type CardStatus = \"pending\" | \"decided\" | \"expired\" | \"resolved\"\nexport type Verdict = \"yes\" | \"no\"\n\n/** Where the agent was asked, so the verdict can be taken back there. */\nexport interface ReplyTarget {\n channel: string\n chatId: string\n accountId?: string\n}\n\nexport interface DecisionCard extends CardChoices {\n id: string\n title: string\n ask: string\n recommend: string\n if_silent: IfSilent\n /** ISO time the default applies. Always set. */\n expires: string\n /** Link to the draft, PR or issue. */\n source?: string\n raised_by: string\n /** The mesh node the raising agent is on, when the card was forwarded\n * here from there (forward.ts, #668). Unset: this node. */\n node?: string\n created_at: string\n reply?: ReplyTarget\n status: CardStatus\n /** The operator's answer (status \"decided\"). */\n verdict?: Verdict\n /** What applied on expiry (status \"expired\"). */\n outcome?: IfSilent\n /** Set when the agent, or a card stored before #741, asked for\n * \"approve\" on expiry; `if_silent` then holds \"keep\". Kept so the\n * record still shows what was originally asked. */\n if_silent_asked?: \"approve\"\n decided_by?: string\n decided_at?: string\n note?: string\n /** The option the operator picked, when the card offered choices. */\n choice?: string\n /** Set when `choice` came from a plain yes taking the suggested option\n * (#1064), not from the operator picking it. */\n choice_suggested?: boolean\n /** The message the operator approved, after any edit. */\n text?: string\n /** Set once the raising agent has been told the result. */\n agent_notified_at?: string\n /** Why the raising agent closed it (status \"resolved\"). */\n resolution?: string\n /** What the card is about, when the daemon raised it (origin.ts). */\n origin?: CardOrigin\n /** A follow-up card (#394): counted in the daily screen budget. */\n followup?: FollowupKind\n}\n\nexport const CARD_LIMITS = {\n title: 120,\n ask: 300,\n recommend: 300,\n source: 500,\n note: 500,\n resolution: 300,\n /** Pending cards one agent may have open at a time. */\n pendingPerAgent: 25,\n} as const\n\nexport interface CardSettings {\n defaultExpiryDays: number\n maxExpiryDays: number\n}\n\nexport const DEFAULT_CARD_SETTINGS: CardSettings = { defaultExpiryDays: 3, maxExpiryDays: 30 }\n\nexport function approvalsDir(root: string): string {\n return resolve(root, \".agentx\", \"approvals\")\n}\n\nconst CARD_ID_RE = /^[a-z0-9][a-z0-9-]{0,80}$/\n\nexport function isValidCardId(id: string): boolean {\n return CARD_ID_RE.test(id)\n}\n\nfunction fileFor(root: string, id: string): string {\n if (!isValidCardId(id)) throw new Error(`invalid card id: ${id}`)\n return resolve(approvalsDir(root), `${id}.json`)\n}\n\nexport function newCardId(now: number, title: string): string {\n const day = new Date(now).toISOString().slice(0, 10)\n const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/^-+|-+$/g, \"\").slice(0, 40)\n return `${day}-${slug || \"card\"}-${Math.random().toString(36).slice(2, 6)}`\n}\n\nexport function saveCard(root: string, card: DecisionCard): void {\n mkdirSync(approvalsDir(root), { recursive: true })\n const path = fileFor(root, card.id)\n const tmp = `${path}.${process.pid}.tmp`\n writeFileSync(tmp, JSON.stringify(card, null, 2) + \"\\n\")\n renameSync(tmp, path)\n}\n\nexport function readCard(root: string, id: string): DecisionCard | null {\n if (!isValidCardId(id)) return null\n try {\n const card = JSON.parse(readFileSync(fileFor(root, id), \"utf-8\")) as DecisionCard\n // A card that expired as \"approve\" before #741 is read as \"keep\" too, so\n // an agent not yet told never hears \"default applied: approve\".\n const legacy = (card.if_silent as string) === \"approve\" || (card.outcome as string) === \"approve\"\n return {\n ...card,\n if_silent: asIfSilent(card.if_silent) ?? \"keep\",\n ...(card.outcome ? { outcome: asIfSilent(card.outcome) ?? \"keep\" } : {}),\n ...(legacy ? { if_silent_asked: \"approve\" as const } : {}),\n }\n } catch {\n return null\n }\n}\n\n/** Cards, oldest first; only `status` ones when given. */\nexport function listCards(root: string, status?: CardStatus): DecisionCard[] {\n const dir = approvalsDir(root)\n if (!existsSync(dir)) return []\n const out: DecisionCard[] = []\n for (const f of readdirSync(dir).filter((f) => f.endsWith(\".json\") && !f.startsWith(\"_\")).sort()) {\n const c = readCard(root, f.slice(0, -5))\n if (c && (!status || c.status === status)) out.push(c)\n }\n return out\n}\n\nfunction oneLine(v: unknown): string {\n return typeof v === \"string\" ? v.replace(/\\s+/g, \" \").trim() : \"\"\n}\n\n/**\n * `expires` as given by an agent: an ISO date or time, or a relative\n * \"12h\" / \"3d\". Unset: the default. Always capped at maxExpiryDays, so a\n * card can't be parked for a year.\n */\nexport function resolveExpiry(input: unknown, now: number, settings: CardSettings): { ok: true; at: string } | { ok: false; error: string } {\n const max = now + settings.maxExpiryDays * 86_400_000\n let at: number\n const raw = oneLine(input)\n if (!raw) {\n at = now + settings.defaultExpiryDays * 86_400_000\n } else {\n const rel = /^(\\d+)\\s*([hd])$/i.exec(raw)\n if (rel) {\n at = now + Number(rel[1]) * (rel[2].toLowerCase() === \"d\" ? 86_400_000 : 3_600_000)\n } else {\n at = Date.parse(raw)\n if (Number.isNaN(at)) return { ok: false, error: `expires must be an ISO date or time, or like \"12h\" / \"3d\" (got \"${raw}\")` }\n }\n }\n if (at <= now) return { ok: false, error: \"expires must be in the future\" }\n return { ok: true, at: new Date(Math.min(at, max)).toISOString() }\n}\n\nexport interface CardInput {\n title?: unknown\n ask?: unknown\n recommend?: unknown\n if_silent?: unknown\n expires?: unknown\n source?: unknown\n raised_by?: unknown\n reply?: unknown\n choices?: unknown\n draft?: unknown\n say?: unknown\n context?: unknown\n followup?: unknown\n}\n\n/** Validate what an agent sent and build a pending card. Never saves. */\nexport interface BuildCardOptions {\n now?: number\n settings?: CardSettings\n origin?: CardOrigin\n /** The peer the card was forwarded from. The daemon sets it after\n * checking the name against its mesh peers; never taken as sent. */\n node?: string\n}\n\nexport function buildCard(\n input: CardInput,\n opts: BuildCardOptions = {},\n): { ok: true; card: DecisionCard } | { ok: false; error: string } {\n const now = opts.now ?? Date.now()\n const settings = opts.settings ?? DEFAULT_CARD_SETTINGS\n const title = oneLine(input.title)\n const ask = oneLine(input.ask)\n const recommend = oneLine(input.recommend)\n const raisedBy = oneLine(input.raised_by)\n if (!title) return { ok: false, error: \"title is required\" }\n if (!ask) return { ok: false, error: \"ask is required: the yes/no question\" }\n if (!recommend) return { ok: false, error: \"recommend is required: your advice and why, in one line\" }\n if (!raisedBy) return { ok: false, error: \"raised_by is required: the agent id\" }\n if (title.length > CARD_LIMITS.title) return { ok: false, error: `title is longer than ${CARD_LIMITS.title} characters` }\n if (ask.length > CARD_LIMITS.ask) return { ok: false, error: `ask is longer than ${CARD_LIMITS.ask} characters` }\n if (recommend.length > CARD_LIMITS.recommend) return { ok: false, error: `recommend is longer than ${CARD_LIMITS.recommend} characters` }\n const ifSilentRaw = oneLine(input.if_silent).toLowerCase()\n const ifSilent = asIfSilent(ifSilentRaw)\n if (!ifSilent) {\n return { ok: false, error: `if_silent must be one of ${IF_SILENT_VALUES.join(\", \")}` }\n }\n const expiry = resolveExpiry(input.expires, now, settings)\n if (!expiry.ok) return expiry\n const source = oneLine(input.source)\n if (source.length > CARD_LIMITS.source) return { ok: false, error: `source is longer than ${CARD_LIMITS.source} characters` }\n if (source && /^[a-z][a-z0-9+.-]*:/i.test(source) && !/^https?:\\/\\//i.test(source)) {\n return { ok: false, error: \"source must be an http(s) link or a plain reference\" }\n }\n const extras = buildChoices(input)\n if (!extras.ok) return extras\n const followup = oneLine(input.followup).toLowerCase()\n if (followup && !(FOLLOWUP_KINDS as readonly string[]).includes(followup)) {\n return { ok: false, error: `followup must be one of ${FOLLOWUP_KINDS.join(\", \")}` }\n }\n let reply: ReplyTarget | undefined\n const r = input.reply as Record<string, unknown> | undefined\n if (r && typeof r === \"object\" && oneLine(r.channel) && oneLine(r.chatId)) {\n reply = { channel: oneLine(r.channel), chatId: oneLine(r.chatId), ...(oneLine(r.accountId) ? { accountId: oneLine(r.accountId) } : {}) }\n }\n return {\n ok: true,\n card: {\n id: newCardId(now, title),\n title,\n ask,\n recommend,\n if_silent: ifSilent,\n ...(ifSilentRaw === \"approve\" ? { if_silent_asked: \"approve\" as const } : {}),\n expires: expiry.at,\n ...(source ? { source } : {}),\n raised_by: raisedBy,\n ...(opts.node ? { node: opts.node } : {}),\n created_at: new Date(now).toISOString(),\n ...(reply ? { reply } : {}),\n ...extras.value,\n // Set by the daemon only (check-ins), never from what an agent sent.\n ...(opts.origin ? { origin: opts.origin } : {}),\n ...(followup ? { followup: followup as FollowupKind } : {}),\n status: \"pending\",\n },\n }\n}\n\n/** A pending card the same agent, on the same node, raised on the same\n * source. None when the new card has no source or the daemon raised it. */\nfunction sameSourcePending(pending: DecisionCard[], card: DecisionCard): DecisionCard | undefined {\n if (!card.source || card.origin) return undefined\n return pending.find((c) =>\n !c.origin &&\n c.source === card.source &&\n c.raised_by === card.raised_by &&\n (c.node ?? \"\") === (card.node ?? \"\"))\n}\n\n/** Validate, enforce the per-agent cap, and save. */\nexport function createCard(\n root: string,\n input: CardInput,\n opts: BuildCardOptions = {},\n): { ok: true; card: DecisionCard } | { ok: false; error: string } {\n const built = buildCard(input, opts)\n if (!built.ok) return built\n // The screen gate (#394): refused here, the reason goes back to the author.\n const broken = cardRuleBreak(built.card)\n if (broken) return { ok: false, error: broken }\n if (built.card.followup) {\n const full = followupBudgetRefusal(listCards(root), built.card.followup, opts.now ?? Date.now())\n if (full) return { ok: false, error: full }\n }\n const pending = listCards(root, \"pending\")\n // One open question per source: the same question raised twice comes\n // back after it was answered. Only for cards an agent raised; cards the\n // daemon raises (origin set) keep their own rules, such as a merge card\n // per pushed commit on the same PR link.\n const twin = sameSourcePending(pending, built.card)\n if (twin) {\n return { ok: false, error: `a card from you on this source is still pending: ${twin.id}. Wait for its answer, or resolve it first and then raise the new one.` }\n }\n // Retro cards are raised for an agent, not by it: they get their own\n // count, so they never use up the agent's room for its own cards.\n const isRetro = (c: { origin?: CardOrigin }) => isRetroOrigin(c.origin)\n const retro = isRetro(built.card)\n const open = pending.filter((c) => c.raised_by === built.card.raised_by && isRetro(c) === retro).length\n if (open >= CARD_LIMITS.pendingPerAgent) {\n const what = retro ? \"retro cards\" : \"cards\"\n return { ok: false, error: `${built.card.raised_by} already has ${open} ${what} waiting; wait for decisions before raising more` }\n }\n saveCard(root, built.card)\n return built\n}\n\n/** Record the operator's answer. Refuses anything no longer pending. */\nexport function decideCard(\n root: string,\n id: string,\n verdict: Verdict,\n opts: { by?: string; note?: string; now?: number; choice?: string | number; text?: string } = {},\n): { ok: true; card: DecisionCard } | { ok: false; error: string } {\n const card = readCard(root, id)\n if (!card) return { ok: false, error: `no card \"${id}\"` }\n if (card.status !== \"pending\") return { ok: false, error: `card \"${id}\" is already ${card.status}` }\n const answer = resolveAnswer(card, verdict, opts)\n if (!answer.ok) return answer\n const note = oneLine(opts.note).slice(0, CARD_LIMITS.note)\n const decided: DecisionCard = {\n ...card,\n status: \"decided\",\n verdict,\n decided_by: opts.by ?? \"operator\",\n decided_at: new Date(opts.now ?? Date.now()).toISOString(),\n ...(note ? { note } : {}),\n ...(answer.choice ? { choice: answer.choice } : {}),\n ...(answer.suggested ? { choice_suggested: true } : {}),\n ...(answer.text ? { text: answer.text } : {}),\n }\n saveCard(root, decided)\n return { ok: true, card: decided }\n}\n\n/** Cards whose answer the daemon acts on itself (a workflow run, a plan\n * step, a retro): only the operator closes those. A reminder card is the\n * agent's own to act on, so it may close it like one it raised. */\nconst AGENT_RESOLVABLE_ORIGINS = new Set<string | undefined>([undefined, \"reminder\"])\n\n/**\n * The raising agent closes its own pending card: the owner gave the same\n * answer outside the card (in chat) and the agent has acted on it (#909).\n * The card leaves the inbox, so no check-in or popup asks again. It is not\n * a verdict, and the agent is not sent a result for it: it already knows.\n */\nexport function resolveCard(\n root: string,\n id: string,\n opts: { by: string; reason?: unknown; node?: string; now?: number },\n): { ok: true; card: DecisionCard } | { ok: false; status: 400 | 403 | 404 | 409; error: string } {\n const card = readCard(root, id)\n if (!card) return { ok: false, status: 404, error: `no card \"${id}\"` }\n if (card.raised_by !== opts.by || (card.node ?? \"\") !== (opts.node ?? \"\")) {\n return { ok: false, status: 403, error: `card \"${id}\" was raised by another agent` }\n }\n if (!AGENT_RESOLVABLE_ORIGINS.has(card.origin?.kind)) {\n return { ok: false, status: 409, error: `card \"${id}\" is answered by the operator only` }\n }\n if (card.status !== \"pending\") return { ok: false, status: 409, error: `card \"${id}\" is already ${card.status}` }\n const reason = oneLine(opts.reason)\n if (!reason) return { ok: false, status: 400, error: \"reason is required: say where the owner answered and what you did\" }\n const at = new Date(opts.now ?? Date.now()).toISOString()\n const resolved: DecisionCard = {\n ...card,\n status: \"resolved\",\n decided_by: opts.by,\n decided_at: at,\n resolution: reason.slice(0, CARD_LIMITS.resolution),\n agent_notified_at: at,\n }\n saveCard(root, resolved)\n return { ok: true, card: resolved }\n}\n\n/** Apply `if_silent` to every pending card past its expiry. */\nexport function expireCards(root: string, now: number = Date.now()): DecisionCard[] {\n const out: DecisionCard[] = []\n for (const card of listCards(root, \"pending\")) {\n if (Date.parse(card.expires) > now) continue\n const expired: DecisionCard = {\n ...card,\n status: \"expired\",\n outcome: card.if_silent,\n decided_by: \"expiry\",\n decided_at: new Date(now).toISOString(),\n }\n saveCard(root, expired)\n out.push(expired)\n }\n return out\n}\n\n/** Decided or expired cards whose agent hasn't been told yet. */\nexport function cardsAwaitingAgentNotice(root: string): DecisionCard[] {\n return listCards(root).filter((c) => c.status !== \"pending\" && !c.agent_notified_at)\n}\n\nexport function markAgentNotified(root: string, id: string, now: number = Date.now()): void {\n const card = readCard(root, id)\n if (!card || card.agent_notified_at) return\n saveCard(root, { ...card, agent_notified_at: new Date(now).toISOString() })\n}\n\nexport const NO_UNDO_LINE =\n \"A no does not by itself undo anything you already did. If you already carried this out (for example because the owner approved it in chat), do not reverse it: ask the requester one clear question first.\"\n\n/** What the raising agent is told. Plain text, one short message. */\nexport function verdictMessage(card: DecisionCard): string {\n const retro = card.origin?.kind === \"retro\" ? card.origin : undefined\n const result = card.status === \"decided\"\n ? (card.verdict === \"yes\"\n ? (retro && !retroApproved(card) ? `The operator picked \"${RETRO_NONE}\", which counts as NO.` : \"The operator said YES.\")\n : \"The operator said NO.\")\n : `Nobody answered before it expired, so the default applied: ${card.outcome ?? card.if_silent}.`\n const lines = [\n `[Approval result] Your decision card \"${card.title}\" (${card.id}) is closed.`,\n `Question: ${card.ask}`,\n result,\n ]\n // A retro card's pick and spec go through retroLines, labelled as the\n // reviewer's proposal: never \"Approved text (send exactly this)\".\n const check = card.origin?.kind === \"retro-check\" ? card.origin : undefined\n if (card.status === \"decided\" && card.verdict === \"yes\" && !retro && !check) lines.push(...answerLines(card))\n if (card.note) lines.push(`Operator note: ${card.note}`)\n // A late no on something the owner already approved in chat must not\n // quietly undo work that is done (#909).\n if (card.status === \"decided\" && card.verdict === \"no\" && !retro && !check) lines.push(NO_UNDO_LINE)\n if (card.source) lines.push(`Source: ${card.source}`)\n if (card.origin?.kind === \"reminder\") lines.push(...originLines(card.origin, card.status === \"decided\" && card.verdict === \"yes\"))\n if (retro || check) {\n // Compare ignoring whitespace so a dashboard that only reflows the draft\n // does not resend the whole draft as the operator's note.\n const squash = (s: string) => s.replace(/\\s+/g, \" \").trim()\n const draft = draftFor(card.draft, card.choice)\n const edited = card.text && squash(card.text) !== squash(draft) ? card.text : undefined\n lines.push(...(retro ? retroLines(retro, card, edited) : retroCheckLines(check!, card, edited)))\n }\n if (card.reply) lines.push(`You raised it from ${card.reply.channel} chat ${card.reply.chatId}; reply there if the requester should know.`)\n if (card.node) lines.push(`The operator answered it on another machine; the card was forwarded from ${card.node}.`)\n lines.push(\"Act on this result now. Do not raise the same card again.\")\n return lines.join(\"\\n\")\n}\n","// --- Where a card came from, when the daemon raised it ---\n//\n// Agents raise most cards themselves. A check-in (checkin.ts) raises one on\n// an agent's behalf for an open Apple Reminder, and records the reminder\n// here so the agent that gets the answer knows what to act on and what to\n// tick off. Only the daemon sets it: POST /approvals and the agent tool\n// never pass it through.\n\nexport interface ReminderOrigin {\n kind: \"reminder\"\n /** The reminder's full id, as remindctl prints it. */\n id: string\n title: string\n list?: string\n}\n\n/** An open request that needs attention, shown as a card on the Mac\n * (popup-runner.ts). Never stored: the request is the record. */\nexport interface RequestOrigin {\n kind: \"request\"\n id: string\n}\n\n/** A retro card (src/retro): fixes to the agents' environment proposed\n * from one run that struggled. The answer goes back to the agent that ran\n * it, which builds the picked fix for a second review. */\nexport interface RetroOrigin {\n kind: \"retro\"\n /** The run the retro read. */\n taskId: string\n /** Failure signature (wiki/failure-candidates.ts), for one card per signature. */\n signature: string\n /** The reviewer's spec for each fix, in the order of the card's choices\n * (without \"None of these\"). Only the picked one reaches the agent. */\n specs?: string[]\n}\n\n/** A monthly review of a check a retro added (src/retro/checks.ts): a\n * guard rule tagged `retro:<taskId>` that fires often on runs that went\n * well. The answer goes back to the agent that built it, which keeps,\n * loosens or removes it for a second review. */\nexport interface RetroCheckOrigin {\n kind: \"retro-check\"\n /** The guard rule's id. */\n ruleId: string\n /** The run whose retro asked for the rule. */\n taskId: string\n /** The policy file that holds the rule, relative to the daemon's folder. */\n file: string\n}\n\n/** A step of a workflow run asks the owner (src/workflows, #788): an\n * owner.ask step, a person.message to approve, or a run's approval at\n * start. The answer resumes the run; the agent that started it is not\n * told separately, the run is. */\nexport interface WorkflowOrigin {\n kind: \"workflow\"\n runId: string\n nodeId: string\n}\n\n/** An agent proposed a reusable workflow (#788). Yes turns it on. */\nexport interface WorkflowProposalOrigin {\n kind: \"workflow-proposal\"\n workflowId: string\n}\n\n/** A step of a tracked plan the owner approves when the plan is made\n * (src/requests/plan-sweep.ts, #788). The plan check reads the answer\n * and acts on it; the agent is not sent a result turn. */\nexport interface PlanStepOrigin {\n kind: \"plan-step\"\n requestId: string\n step: number\n}\n\n/** A pull request that changes core paths waits for the owner (merge\n * policy, #1047). YES approves that one commit; the policy reads the\n * answer and updates the PR's status. No agent is sent a result turn. */\nexport interface MergePolicyOrigin {\n kind: \"merge-policy\"\n repo: string\n pr: number\n sha: string\n}\n\nexport type CardOrigin = ReminderOrigin | RequestOrigin | RetroOrigin | RetroCheckOrigin | PlanStepOrigin | WorkflowOrigin | WorkflowProposalOrigin | MergePolicyOrigin\n\n/** Retro cards of either kind: raised for an agent, not by it. */\nexport function isRetroOrigin(origin: CardOrigin | undefined): origin is RetroOrigin | RetroCheckOrigin {\n return origin?.kind === \"retro\" || origin?.kind === \"retro-check\"\n}\n\n/** The choices on a check review card, in this order. */\nexport const CHECK_CHOICES = { keep: \"Keep it\", loosen: \"Loosen it\", remove: \"Remove it\" } as const\n\n/** Lines for the agent told the result of a check review card. Keep, NO\n * and silence all leave the rule as it is. */\nexport function retroCheckLines(\n origin: RetroCheckOrigin,\n card: { status: string; verdict?: string; choice?: string; choice_suggested?: boolean },\n edited?: string,\n): string[] {\n const rule = `guard rule \\`${origin.ruleId}\\` in \\`${origin.file}\\``\n const lines = [`This was a monthly review of ${rule}, added by the retro on run ${origin.taskId}. It fires often on runs that went well.`]\n const yes = card.status === \"decided\" && card.verdict === \"yes\"\n if (!yes || card.choice === CHECK_CHOICES.keep || !card.choice) {\n lines.push(\"Change nothing: the rule stays as it is.\")\n return lines\n }\n lines.push(card.choice === CHECK_CHOICES.remove\n ? `The operator chose to remove it. Delete ${rule} as a pull request.`\n : `The operator chose to loosen it. Narrow ${rule} (a tighter match, or \\`applies_to\\`) so it stops firing on good work, keep its \\`retro:${origin.taskId}\\` tag, and open it as a pull request.`)\n if (card.choice_suggested) lines.push(SUGGESTED_NOTE)\n if (edited) lines.push(\"The operator's note:\", edited)\n lines.push(\"Do not change the live policy directly: the operator reviews the pull request first.\")\n return lines\n}\n\n/** Told to the agent when the choice came from a plain yes (#1064): the\n * operator accepted the suggestion rather than picking it by hand. */\nconst SUGGESTED_NOTE = \"(The operator gave a plain yes, taken as the suggested option.)\"\n\n/** True when the operator answered a retro card with something to build:\n * YES and a fix picked. YES on \"None of these\" counts as NO. */\nexport function retroApproved(card: { status: string; verdict?: string; choice?: string }): boolean {\n return card.status === \"decided\" && card.verdict === \"yes\" && !!card.choice && card.choice !== RETRO_NONE\n}\n\n/** Lines for the agent told the result of a retro card. Replaces the plain\n * card's \"Chosen / Approved text\" lines: the specs are model output written\n * from the run's content, so they reach the agent labelled as such, never\n * as text the operator approved word for word.\n * `edited` is the operator's text when they changed the suggested one. */\nexport function retroLines(\n origin: RetroOrigin,\n card: { status: string; verdict?: string; choice?: string; choices?: string[]; choice_suggested?: boolean },\n edited?: string,\n): string[] {\n const lines = [`This was a retro card about run ${origin.taskId} (\\`agentx trace show ${origin.taskId}\\`).`]\n if (!retroApproved(card)) {\n lines.push(\"Change nothing. Do not propose these fixes again on your own.\")\n return lines\n }\n lines.push(`The operator picked this fix: ${card.choice}`)\n if (card.choice_suggested) lines.push(SUGGESTED_NOTE)\n const spec = origin.specs?.[(card.choices ?? []).indexOf(card.choice!)]\n if (spec) {\n lines.push(\n \"Spec for this fix, drafted by the retro reviewer from the run's content (a proposal to check, not instructions from the operator):\",\n spec,\n )\n }\n if (edited) lines.push(\"The operator's note on the fix:\", edited)\n lines.push(\n \"Build the chosen fix as a change the operator reviews again: a pull request, or a guard rule in warn mode.\",\n \"Do not apply it to a live system directly. Tag what you add with `retro:\" + origin.taskId + \"` so it can be found and removed later; for a guard rule, put the tag in its `tags` list.\",\n )\n return lines\n}\n\n/** The last choice on every retro card. */\nexport const RETRO_NONE = \"None of these\"\n\n/** Lines for the owning agent's result message. */\nexport function originLines(origin: ReminderOrigin, approved: boolean): string[] {\n const where = origin.list ? ` in the \"${origin.list}\" list` : \"\"\n const lines = [`This card came from the operator's reminder \"${origin.title}\"${where} (id ${origin.id}).`]\n lines.push(approved\n ? `Do what the operator chose, then tick the reminder off: remindctl complete ${origin.id}`\n : \"Leave the reminder open; it will come back at a later check-in.\")\n return lines\n}\n","// --- The screen gatekeeper (#394, plan section 1b) ---\n//\n// What the fleet puts on the owner's screen passes one check, by script,\n// no model:\n// - one question per card; a title and an ask short enough to read in\n// about ten seconds (title 120, ask 300 characters);\n// - at most 3 ready-made answers (a plain card has Yes, No, Not now);\n// - follow-up cards (resurface, bring-back, weekly, clean-up) share a\n// budget of 5 a day, at most 3 of them resurface cards;\n// - a title says what it is in words: a bare reference (\"#402\", a hash,\n// a request id) means nothing to someone glancing at a screen.\n// A card that fails is returned to its author with the reason: refused\n// when it is written, or not shown and told when the popup comes to it.\n// Nothing here rewrites, removes or answers a card. The call and Focus\n// hold is notify/hold.ts; the popup window takes no focus (card-window.ts).\n\nexport const SCREEN_LIMITS = { title: 120, ask: 300, answers: 3 } as const\n\nexport const FOLLOWUP_KINDS = [\"resurface\", \"bring-back\", \"weekly\", \"cleanup\"] as const\nexport type FollowupKind = (typeof FOLLOWUP_KINDS)[number]\n\nexport const SCREEN_BUDGET = { perDay: 5, resurface: 3 } as const\n\n// References an agent reads easily and the owner does not: links, issue\n// and merge request numbers (with or without their project), ULID-like\n// ids, request, delegation and send ids, and commit hashes. A hex run\n// needs a digit and a letter a-f, so neither a word made of a-f letters\n// nor a plain long number (a phone number, an amount) is taken for one.\nconst REFERENCES: RegExp[] = [\n /\\bhttps?:\\/\\/\\S+/gi,\n /(?:[\\w.-]+\\/)*[\\w.-]+[#!]\\d+\\b/g,\n /[#!]\\d+\\b/g,\n /\\b[0-9A-HJKMNP-TV-Z]{26}\\b/gi,\n /\\b(?:req|dlg|snd)-[\\w-]+/gi,\n /\\b(?=[0-9a-f]*\\d)(?=[0-9a-f]*[a-f])[0-9a-f]{7,}\\b/gi,\n]\n\n/** The title with every reference taken out. */\nexport function stripReferences(text: string): string {\n return REFERENCES.reduce((t, re) => t.replace(re, \" \"), text)\n}\n\n/** Why a title that is only a reference may not go on screen, or null.\n * A title with a reference must keep at least 2 words of letters once\n * the references are out; a title with none is left to the other rules. */\nexport function referenceOnlyTitle(title: string): string | null {\n const rest = stripReferences(title)\n if (rest === title) return null\n const words = rest.split(/\\s+/).filter((w) => /\\p{L}/u.test(w))\n if (words.length >= 2) return null\n return `title is only a reference (\"${title.trim()}\"); say what it is in plain words, and put the link in the body or source`\n}\n\n/** Why this card may not go on the owner's screen, or null. */\nexport function cardRuleBreak(card: { title?: string; ask?: string; choices?: string[]; origin?: { kind: string } }): string | null {\n // A card file written by hand or by an older build may miss either:\n // returned to its author, never a crash of the popup.\n const title = typeof card.title === \"string\" ? card.title : \"\"\n const ask = typeof card.ask === \"string\" ? card.ask : \"\"\n if (!title.trim()) return \"title is missing: say what it is in plain words\"\n if (title.length > SCREEN_LIMITS.title) return `title is longer than ${SCREEN_LIMITS.title} characters`\n // A request's card is held to the rule too (#1126): it is titled with\n // its headline, which its agent can write (agentx_request describe).\n const bare = referenceOnlyTitle(title)\n if (bare) return bare\n if (!ask.trim()) return \"ask is missing: one card asks one thing\"\n if (ask.length > SCREEN_LIMITS.ask) return `ask is longer than ${SCREEN_LIMITS.ask} characters`\n if ((ask.match(/\\?/g) ?? []).length > 1) return \"ask holds more than one question: one card asks one thing\"\n if ((card.choices?.length ?? 0) > SCREEN_LIMITS.answers) return `more than ${SCREEN_LIMITS.answers} choices`\n return null\n}\n\n/** Why an agent's `agentx notify` may not go on the owner's screen, or\n * null: the same ten-second rule, title 120 and message 300 (the message\n * as shown, with its \"To do:\" line), and a title in words. */\nexport function noticeRuleBreak(title: string, message: string): string | null {\n if (title.length > SCREEN_LIMITS.title) return `title is longer than ${SCREEN_LIMITS.title} characters`\n const bare = referenceOnlyTitle(title)\n if (bare) return bare\n if (message.length > SCREEN_LIMITS.ask) return `message is longer than ${SCREEN_LIMITS.ask} characters`\n return null\n}\n\n/** An agent's notice as the owner reads it: the message, then the\n * \"To do:\" line. With nothing to do, it says so, so the owner never has\n * to guess whether a notice wants something. Last, so a banner that\n * shows only the first line still shows the message. */\nexport function withTodo(message: string, todo?: string): string {\n const what = todo?.trim().replace(/\\s+/g, \" \") || \"nothing, FYI\"\n return `${message}\\nTo do: ${what}`\n}\n\n/** Local midnight before `now`: the budget's day. */\nfunction dayStart(now: number): number {\n const d = new Date(now)\n d.setHours(0, 0, 0, 0)\n return d.getTime()\n}\n\n/** Why a follow-up card of this kind cannot be raised today, or null.\n * `cards` is every card, of any status: an answered one was on screen too. */\nexport function followupBudgetRefusal(\n cards: Array<{ followup?: FollowupKind; created_at: string }>,\n kind: FollowupKind,\n now: number,\n): string | null {\n const from = dayStart(now)\n const today = cards.filter((c) => c.followup && Date.parse(c.created_at) >= from)\n if (today.length >= SCREEN_BUDGET.perDay) {\n return `the follow-up screen budget is used up today (${SCREEN_BUDGET.perDay} cards): raise it again tomorrow`\n }\n if (kind === \"resurface\" && today.filter((c) => c.followup === \"resurface\").length >= SCREEN_BUDGET.resurface) {\n return `${SCREEN_BUDGET.resurface} resurface cards were already raised today: raise it again tomorrow`\n }\n return null\n}\n\n/** What the author hears when the popup does not show its card. */\nexport function returnedText(card: { id: string; title?: string; origin?: { kind: string } }, reason: string): string {\n const title = card.title?.trim()\n if (card.origin?.kind === \"request\") {\n return [\n `[screen gate] Request ${card.id}${title ? ` (\"${title}\")` : \"\"} was not shown to the owner: ${reason}.`,\n `It is still on his list. Say what it is: agentx_request {action:\"describe\", id:\"${card.id}\", headline:\"<a few plain words>\", need:\"<what you need from him>\"}.`,\n ].join(\" \")\n }\n return [\n `[screen gate] Your card ${card.id}${title ? ` (\"${title}\")` : \"\"} was not shown to the owner: ${reason}.`,\n \"It is still in his inbox, unchanged. If it must reach him on screen, close it (agentx_approval resolve) and raise one that passes:\",\n `one question, title up to ${SCREEN_LIMITS.title} characters, ask up to ${SCREEN_LIMITS.ask}, at most ${SCREEN_LIMITS.answers} choices.`,\n ].join(\" \")\n}\n"],"mappings":"6DAAA,OAAS,cA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kBzE,EAAK,MAAM,EAGnDA,EAAK,SAAW,WAAaA,EAAK,UAAY,MAAQ,CAACmD,GAAS,CAACuB,GAAOD,EAAM,KAAKL,EAAY,EAC/FpE,EAAK,QAAQyE,EAAM,KAAK,WAAWzE,EAAK,QAAQ,EAChDA,EAAK,QAAQ,OAAS,YAAYyE,EAAM,KAAK,GAAGG,EAAY5E,EAAK,OAAQA,EAAK,SAAW,WAAaA,EAAK,UAAY,KAAK,CAAC,EAC7HmD,GAASuB,EAAO,CAGlB,IAAMG,EAAUC,GAAcA,EAAE,QAAQ,OAAQ,GAAG,EAAE,KAAK,EACpDC,EAAQC,EAAShF,EAAK,MAAOA,EAAK,MAAM,EACxCiF,EAASjF,EAAK,MAAQ6E,EAAO7E,EAAK,IAAI,IAAM6E,EAAOE,CAAK,EAAI/E,EAAK,KAAO,OAC9EyE,EAAM,KAAK,GAAItB,EAAQ+B,EAAW/B,EAAOnD,EAAMiF,CAAM,EAAIE,EAAgBT,EAAQ1E,EAAMiF,CAAM,CAAE,EAEjG,OAAIjF,EAAK,OAAOyE,EAAM,KAAK,sBAAsBzE,EAAK,MAAM,gBAAgBA,EAAK,MAAM,mDAAmD,EACtIA,EAAK,MAAMyE,EAAM,KAAK,4EAA4EzE,EAAK,OAAO,EAClHyE,EAAM,KAAK,2DAA2D,EAC/DA,EAAM,KAAK;AAAA,CAAI,CACxB","names":["existsSync","mkdirSync","readdirSync","readFileSync","renameSync","writeFileSync","resolve","isRetroOrigin","origin","CHECK_CHOICES","retroCheckLines","card","edited","rule","lines","SUGGESTED_NOTE","retroApproved","RETRO_NONE","retroLines","spec","originLines","approved","where","SCREEN_LIMITS","FOLLOWUP_KINDS","SCREEN_BUDGET","REFERENCES","stripReferences","text","t","re","referenceOnlyTitle","title","rest","w","cardRuleBreak","card","ask","bare","noticeRuleBreak","message","withTodo","todo","what","dayStart","now","d","followupBudgetRefusal","cards","kind","from","today","c","returnedText","reason","IF_SILENT_VALUES","asIfSilent","v","CARD_LIMITS","DEFAULT_CARD_SETTINGS","approvalsDir","root","resolve","CARD_ID_RE","isValidCardId","id","fileFor","newCardId","now","title","day","slug","saveCard","card","mkdirSync","path","tmp","writeFileSync","renameSync","readCard","readFileSync","legacy","listCards","status","dir","existsSync","out","f","readdirSync","c","oneLine","resolveExpiry","input","settings","max","at","raw","rel","buildCard","opts","ask","recommend","raisedBy","ifSilentRaw","ifSilent","expiry","source","extras","buildChoices","followup","FOLLOWUP_KINDS","reply","r","sameSourcePending","pending","createCard","built","broken","cardRuleBreak","full","followupBudgetRefusal","twin","isRetro","isRetroOrigin","retro","open","what","decideCard","verdict","answer","resolveAnswer","note","decided","AGENT_RESOLVABLE_ORIGINS","resolveCard","reason","resolved","expireCards","expired","cardsAwaitingAgentNotice","markAgentNotified","NO_UNDO_LINE","verdictMessage","result","retroApproved","RETRO_NONE","lines","check","answerLines","originLines","squash","s","draft","draftFor","edited","retroLines","retroCheckLines"]}