agentix-cli 0.133.0 → 0.135.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 (199) hide show
  1. package/dist/{App-WQPA77VJ.js → App-4UVAI5C5.js} +2 -2
  2. package/dist/{ChatApp-TGW66I4Y.js → ChatApp-COO67WIR.js} +2 -2
  3. package/dist/absorb-eval-WY3YMLS4.js +2 -0
  4. package/dist/{agent-FWHYHXWC.js → agent-3R5NY7I3.js} +2 -2
  5. package/dist/{board-dashboard-GKE4KWJH.js → board-dashboard-U3ZSCO62.js} +24 -8
  6. package/dist/board-dashboard-U3ZSCO62.js.map +1 -0
  7. package/dist/{chunk-ZN5DC6WS.js → chunk-3XVST5XX.js} +2 -2
  8. package/dist/{note-reader-LPPIYYLT.js → chunk-4LWFJ4MZ.js} +3 -3
  9. package/dist/{note-reader-LPPIYYLT.js.map → chunk-4LWFJ4MZ.js.map} +1 -1
  10. package/dist/{chunk-F5PVUB4Y.js → chunk-4XMALK7X.js} +2 -2
  11. package/dist/{chunk-VH2ASPFQ.js → chunk-5NT44FKL.js} +2 -2
  12. package/dist/{chunk-HIUHKOKK.js → chunk-6WF56ME6.js} +2 -2
  13. package/dist/{chunk-MCBTVNPX.js → chunk-BQIWMQNU.js} +2 -2
  14. package/dist/{chunk-2BF6HJJD.js → chunk-DYGQF3MI.js} +4 -4
  15. package/dist/chunk-DYGQF3MI.js.map +1 -0
  16. package/dist/{chunk-4NEO5KB2.js → chunk-EEBK4F6E.js} +15 -15
  17. package/dist/chunk-EEBK4F6E.js.map +1 -0
  18. package/dist/{chunk-JA5Y4LDP.js → chunk-ERULJ2ZL.js} +2 -2
  19. package/dist/{chunk-RJFPCW7T.js → chunk-FWDRBUMS.js} +2 -2
  20. package/dist/{chunk-SJPQQ4OF.js → chunk-GSKJ57XY.js} +234 -234
  21. package/dist/chunk-GSKJ57XY.js.map +1 -0
  22. package/dist/{chunk-4XPVU3N2.js → chunk-H6VWU2HN.js} +2 -2
  23. package/dist/chunk-JRS5QRZG.js +2 -0
  24. package/dist/chunk-JRS5QRZG.js.map +1 -0
  25. package/dist/{chunk-5BI2T3WD.js → chunk-JTDUTCUE.js} +3 -3
  26. package/dist/chunk-JTDUTCUE.js.map +1 -0
  27. package/dist/{chunk-KUOH5MFS.js → chunk-K445URSN.js} +2 -2
  28. package/dist/{chunk-4VVHGR7H.js → chunk-KEXBEUSU.js} +1 -1
  29. package/dist/{chunk-4VVHGR7H.js.map → chunk-KEXBEUSU.js.map} +1 -1
  30. package/dist/chunk-L5UGH4T4.js +160 -0
  31. package/dist/chunk-L5UGH4T4.js.map +1 -0
  32. package/dist/{chunk-V4IFJLQS.js → chunk-LU7GDHGD.js} +2 -2
  33. package/dist/{chunk-D5IHICX3.js → chunk-LUYN6RAC.js} +2 -2
  34. package/dist/chunk-MI7WOGH6.js +4 -0
  35. package/dist/chunk-MI7WOGH6.js.map +1 -0
  36. package/dist/chunk-NY7NHGVT.js +105 -0
  37. package/dist/chunk-NY7NHGVT.js.map +1 -0
  38. package/dist/chunk-NZQBS7GN.js +2 -0
  39. package/dist/{chunk-KBJNJGBP.js.map → chunk-NZQBS7GN.js.map} +1 -1
  40. package/dist/{chunk-3TETB22A.js → chunk-P3I7AATX.js} +2 -2
  41. package/dist/chunk-QAWKN2N4.js +3 -0
  42. package/dist/chunk-QAWKN2N4.js.map +1 -0
  43. package/dist/chunk-QDWEM4DG.js +41 -0
  44. package/dist/chunk-QDWEM4DG.js.map +1 -0
  45. package/dist/{chunk-JP5OAMWQ.js → chunk-RGZARSHV.js} +1 -1
  46. package/dist/{chunk-JP5OAMWQ.js.map → chunk-RGZARSHV.js.map} +1 -1
  47. package/dist/{chunk-GZY5DYXT.js → chunk-RRGITX5B.js} +2 -2
  48. package/dist/{chunk-PHCWYKQW.js → chunk-RVEMX5MJ.js} +2 -2
  49. package/dist/{chunk-PHCWYKQW.js.map → chunk-RVEMX5MJ.js.map} +1 -1
  50. package/dist/{chunk-GUEIF7ZF.js → chunk-SMAI7U6H.js} +2 -2
  51. package/dist/{chunk-S2UXDEGW.js → chunk-SSQMFHSM.js} +2 -2
  52. package/dist/chunk-WWDYDLY2.js +55 -0
  53. package/dist/chunk-WWDYDLY2.js.map +1 -0
  54. package/dist/{chunk-ANC5QXFB.js → chunk-XOUO4XNA.js} +2 -2
  55. package/dist/chunk-YA3P77LV.js +87 -0
  56. package/dist/chunk-YA3P77LV.js.map +1 -0
  57. package/dist/{chunk-OQV3LWJI.js → chunk-ZFRXFUP7.js} +2 -2
  58. package/dist/{chunk-F7GKG5ZO.js → chunk-ZGVVYJIK.js} +3 -3
  59. package/dist/chunk-ZGVVYJIK.js.map +1 -0
  60. package/dist/cli.js +1 -1
  61. package/dist/{client-7UW2ELPP.js → client-NFPBE6L4.js} +2 -2
  62. package/dist/{config-TNYVPT4R.js → config-GHMRBRDL.js} +2 -2
  63. package/dist/{config-mutate-GV7BVG3I.js → config-mutate-2XV27EFV.js} +2 -2
  64. package/dist/config-mutator-6ITNU5DT.js +2 -0
  65. package/dist/{contributions-J57B3KIX.js → contributions-KLRJ4ZXV.js} +2 -2
  66. package/dist/{contributions-J57B3KIX.js.map → contributions-KLRJ4ZXV.js.map} +1 -1
  67. package/dist/{doctor-ROKIYJRT.js → doctor-UBXVMGJG.js} +2 -2
  68. package/dist/{enrich-NH3WHKD6.js → enrich-ZB5I7KHN.js} +2 -2
  69. package/dist/event-levels-CQWHSLMT.js +3 -0
  70. package/dist/event-levels-CQWHSLMT.js.map +1 -0
  71. package/dist/{follow-up-tool-S2U7DFSW.js → follow-up-tool-EARVITTS.js} +2 -2
  72. package/dist/graph-ZVKV3JBD.js +2 -0
  73. package/dist/hub-TILTOOSS.js +2 -0
  74. package/dist/index.d.ts +281 -84
  75. package/dist/index.js +1 -1
  76. package/dist/index.js.map +1 -1
  77. package/dist/load-EOZUZK7U.js +2 -0
  78. package/dist/model-call-PKV5UAQ7.js +2 -0
  79. package/dist/note-reader-IDE6RI34.js +2 -0
  80. package/dist/notes-settings-VPXI5IIS.js +2 -0
  81. package/dist/{program-LAOU5DQ3.js → program-U3HJY7E5.js} +262 -264
  82. package/dist/program-U3HJY7E5.js.map +1 -0
  83. package/dist/{promote-FVWRM4BE.js → promote-RHVZB2QZ.js} +2 -2
  84. package/dist/push-bridge-325SXDGN.js +1 -1
  85. package/dist/query-OZXZVLO7.js +2 -0
  86. package/dist/query-runs-7VX3YAC3.js +4 -0
  87. package/dist/query-runs-7VX3YAC3.js.map +1 -0
  88. package/dist/query-settings-2MGUS6AY.js +3 -0
  89. package/dist/query-settings-2MGUS6AY.js.map +1 -0
  90. package/dist/registry-LZLIPP7N.js +2 -0
  91. package/dist/{request-planner-JOXSAAHO.js → request-planner-MFAIVLUQ.js} +2 -2
  92. package/dist/{review-candidates-6N5435V7.js → review-candidates-6WMDVVIZ.js} +2 -2
  93. package/dist/roster-BZGKG2ZA.js +2 -0
  94. package/dist/{routing-6G2QVFIG.js → routing-OPCLHIYW.js} +2 -2
  95. package/dist/schedule-tool-KPVTMYL3.js +2 -0
  96. package/dist/{scheduler-WOH2O3EP.js → scheduler-G3WWYETY.js} +2 -2
  97. package/dist/score-DZGPLHCL.js +3 -0
  98. package/dist/score-DZGPLHCL.js.map +1 -0
  99. package/dist/{seat-I2FBJDTV.js → seat-3HM4J7IX.js} +2 -2
  100. package/dist/{select-5YZQJLLD.js → select-VEFE2ESF.js} +2 -2
  101. package/dist/{set-enabled-CQEUZLHU.js → set-enabled-US5BYKFZ.js} +2 -2
  102. package/dist/{tool-PIJXUBEC.js → tool-HUSCHORN.js} +2 -2
  103. package/dist/{tool-R77KFLZ3.js → tool-XLWLXGB5.js} +2 -2
  104. package/dist/types-ARP27T6T.js +2 -0
  105. package/dist/types-LJZ2YY5W.js +2 -0
  106. package/dist/types-LJZ2YY5W.js.map +1 -0
  107. package/dist/wiki-GCRRINW3.js +2 -0
  108. package/dist/wiki-GCRRINW3.js.map +1 -0
  109. package/dist/wiki-enrich-P5TNWACZ.js +2 -0
  110. package/dist/wiki-enrich-P5TNWACZ.js.map +1 -0
  111. package/package.json +1 -1
  112. package/dist/absorb-eval-37XZJACN.js +0 -2
  113. package/dist/board-dashboard-GKE4KWJH.js.map +0 -1
  114. package/dist/chunk-2BF6HJJD.js.map +0 -1
  115. package/dist/chunk-4NEO5KB2.js.map +0 -1
  116. package/dist/chunk-57Y2WZT2.js +0 -55
  117. package/dist/chunk-57Y2WZT2.js.map +0 -1
  118. package/dist/chunk-5BI2T3WD.js.map +0 -1
  119. package/dist/chunk-7VLLZQ3N.js +0 -2
  120. package/dist/chunk-7VLLZQ3N.js.map +0 -1
  121. package/dist/chunk-BI6VG4DV.js +0 -37
  122. package/dist/chunk-BI6VG4DV.js.map +0 -1
  123. package/dist/chunk-F7GKG5ZO.js.map +0 -1
  124. package/dist/chunk-IDZXAOBC.js +0 -156
  125. package/dist/chunk-IDZXAOBC.js.map +0 -1
  126. package/dist/chunk-IZDKRNXC.js +0 -52
  127. package/dist/chunk-IZDKRNXC.js.map +0 -1
  128. package/dist/chunk-KBJNJGBP.js +0 -2
  129. package/dist/chunk-KFIJDLQ5.js +0 -3
  130. package/dist/chunk-KFIJDLQ5.js.map +0 -1
  131. package/dist/chunk-RTHZQGFC.js +0 -105
  132. package/dist/chunk-RTHZQGFC.js.map +0 -1
  133. package/dist/chunk-SJPQQ4OF.js.map +0 -1
  134. package/dist/config-mutator-AKCR3VKM.js +0 -2
  135. package/dist/graph-EXDH7EPZ.js +0 -2
  136. package/dist/hub-HOVJC4HR.js +0 -2
  137. package/dist/load-5DNMGHFW.js +0 -2
  138. package/dist/model-call-BGTDPWZD.js +0 -2
  139. package/dist/notes-settings-WMOH2V75.js +0 -2
  140. package/dist/program-LAOU5DQ3.js.map +0 -1
  141. package/dist/query-HBCL3FHO.js +0 -2
  142. package/dist/query-settings-RD6GEN2V.js +0 -3
  143. package/dist/query-settings-RD6GEN2V.js.map +0 -1
  144. package/dist/registry-NT4H7HYP.js +0 -2
  145. package/dist/roster-IRXP32XF.js +0 -2
  146. package/dist/schedule-tool-3NYUPKSC.js +0 -2
  147. package/dist/score-KDNIUTNV.js +0 -3
  148. package/dist/score-KDNIUTNV.js.map +0 -1
  149. package/dist/types-ROL44T62.js +0 -2
  150. package/dist/wiki-GCOFERTB.js +0 -2
  151. /package/dist/{App-WQPA77VJ.js.map → App-4UVAI5C5.js.map} +0 -0
  152. /package/dist/{ChatApp-TGW66I4Y.js.map → ChatApp-COO67WIR.js.map} +0 -0
  153. /package/dist/{absorb-eval-37XZJACN.js.map → absorb-eval-WY3YMLS4.js.map} +0 -0
  154. /package/dist/{agent-FWHYHXWC.js.map → agent-3R5NY7I3.js.map} +0 -0
  155. /package/dist/{chunk-ZN5DC6WS.js.map → chunk-3XVST5XX.js.map} +0 -0
  156. /package/dist/{chunk-F5PVUB4Y.js.map → chunk-4XMALK7X.js.map} +0 -0
  157. /package/dist/{chunk-VH2ASPFQ.js.map → chunk-5NT44FKL.js.map} +0 -0
  158. /package/dist/{chunk-HIUHKOKK.js.map → chunk-6WF56ME6.js.map} +0 -0
  159. /package/dist/{chunk-MCBTVNPX.js.map → chunk-BQIWMQNU.js.map} +0 -0
  160. /package/dist/{chunk-JA5Y4LDP.js.map → chunk-ERULJ2ZL.js.map} +0 -0
  161. /package/dist/{chunk-RJFPCW7T.js.map → chunk-FWDRBUMS.js.map} +0 -0
  162. /package/dist/{chunk-4XPVU3N2.js.map → chunk-H6VWU2HN.js.map} +0 -0
  163. /package/dist/{chunk-KUOH5MFS.js.map → chunk-K445URSN.js.map} +0 -0
  164. /package/dist/{chunk-V4IFJLQS.js.map → chunk-LU7GDHGD.js.map} +0 -0
  165. /package/dist/{chunk-D5IHICX3.js.map → chunk-LUYN6RAC.js.map} +0 -0
  166. /package/dist/{chunk-3TETB22A.js.map → chunk-P3I7AATX.js.map} +0 -0
  167. /package/dist/{chunk-GZY5DYXT.js.map → chunk-RRGITX5B.js.map} +0 -0
  168. /package/dist/{chunk-GUEIF7ZF.js.map → chunk-SMAI7U6H.js.map} +0 -0
  169. /package/dist/{chunk-S2UXDEGW.js.map → chunk-SSQMFHSM.js.map} +0 -0
  170. /package/dist/{chunk-ANC5QXFB.js.map → chunk-XOUO4XNA.js.map} +0 -0
  171. /package/dist/{chunk-OQV3LWJI.js.map → chunk-ZFRXFUP7.js.map} +0 -0
  172. /package/dist/{client-7UW2ELPP.js.map → client-NFPBE6L4.js.map} +0 -0
  173. /package/dist/{config-TNYVPT4R.js.map → config-GHMRBRDL.js.map} +0 -0
  174. /package/dist/{config-mutate-GV7BVG3I.js.map → config-mutate-2XV27EFV.js.map} +0 -0
  175. /package/dist/{config-mutator-AKCR3VKM.js.map → config-mutator-6ITNU5DT.js.map} +0 -0
  176. /package/dist/{doctor-ROKIYJRT.js.map → doctor-UBXVMGJG.js.map} +0 -0
  177. /package/dist/{enrich-NH3WHKD6.js.map → enrich-ZB5I7KHN.js.map} +0 -0
  178. /package/dist/{follow-up-tool-S2U7DFSW.js.map → follow-up-tool-EARVITTS.js.map} +0 -0
  179. /package/dist/{graph-EXDH7EPZ.js.map → graph-ZVKV3JBD.js.map} +0 -0
  180. /package/dist/{hub-HOVJC4HR.js.map → hub-TILTOOSS.js.map} +0 -0
  181. /package/dist/{load-5DNMGHFW.js.map → load-EOZUZK7U.js.map} +0 -0
  182. /package/dist/{model-call-BGTDPWZD.js.map → model-call-PKV5UAQ7.js.map} +0 -0
  183. /package/dist/{notes-settings-WMOH2V75.js.map → note-reader-IDE6RI34.js.map} +0 -0
  184. /package/dist/{promote-FVWRM4BE.js.map → notes-settings-VPXI5IIS.js.map} +0 -0
  185. /package/dist/{query-HBCL3FHO.js.map → promote-RHVZB2QZ.js.map} +0 -0
  186. /package/dist/{registry-NT4H7HYP.js.map → query-OZXZVLO7.js.map} +0 -0
  187. /package/dist/{roster-IRXP32XF.js.map → registry-LZLIPP7N.js.map} +0 -0
  188. /package/dist/{request-planner-JOXSAAHO.js.map → request-planner-MFAIVLUQ.js.map} +0 -0
  189. /package/dist/{review-candidates-6N5435V7.js.map → review-candidates-6WMDVVIZ.js.map} +0 -0
  190. /package/dist/{routing-6G2QVFIG.js.map → roster-BZGKG2ZA.js.map} +0 -0
  191. /package/dist/{schedule-tool-3NYUPKSC.js.map → routing-OPCLHIYW.js.map} +0 -0
  192. /package/dist/{scheduler-WOH2O3EP.js.map → schedule-tool-KPVTMYL3.js.map} +0 -0
  193. /package/dist/{seat-I2FBJDTV.js.map → scheduler-G3WWYETY.js.map} +0 -0
  194. /package/dist/{types-ROL44T62.js.map → seat-3HM4J7IX.js.map} +0 -0
  195. /package/dist/{select-5YZQJLLD.js.map → select-VEFE2ESF.js.map} +0 -0
  196. /package/dist/{set-enabled-CQEUZLHU.js.map → set-enabled-US5BYKFZ.js.map} +0 -0
  197. /package/dist/{tool-PIJXUBEC.js.map → tool-HUSCHORN.js.map} +0 -0
  198. /package/dist/{tool-R77KFLZ3.js.map → tool-XLWLXGB5.js.map} +0 -0
  199. /package/dist/{wiki-GCOFERTB.js.map → types-ARP27T6T.js.map} +0 -0
@@ -1,2 +1,2 @@
1
1
  var e=["minor","normal","major"];export{e as a};
2
- //# sourceMappingURL=chunk-JP5OAMWQ.js.map
2
+ //# sourceMappingURL=chunk-RGZARSHV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/wiki/ontology/types.ts"],"sourcesContent":["// --- Wiki ontology types (#811) ---\n//\n// The ontology says what kinds of things the wiki holds (types grouped\n// into pillars), how they relate (properties), how important an event is,\n// and how each type's page is viewed (lenses). Every value here comes\n// from `ontology.yaml` in the wiki root, falling back to the generic\n// defaults in `defaults.ts`. Nothing about a particular organisation\n// belongs in code.\n\nexport type Importance = \"minor\" | \"normal\" | \"major\"\n\nexport const IMPORTANCE_LEVELS: readonly Importance[] = [\"minor\", \"normal\", \"major\"] as const\n\nexport interface PillarDef {\n id: string\n label: string\n /** One line under the pillar title. */\n description?: string\n /** Icon name from the view's small built-in icon set. */\n icon?: string\n /** Shown in the sidebar. A fallback pillar such as Topics sets false. */\n sidebar?: boolean\n}\n\nexport interface TypeDef {\n id: string\n label: string\n plural?: string\n pillar: string\n /** schema.org class, shown as a hint on the page. */\n schema?: string\n icon?: string\n /** Panels the page opens with, in order. */\n lens?: LensPanel[]\n}\n\nexport interface PropertyDef {\n id: string\n /** Read from the subject: \"Person — role at → Organization\". */\n label: string\n /** Read from the value's side: \"Organization — people ← Person\". */\n inverse?: string\n /** Wikidata property id, kept as a mapping hint. */\n wikidata?: string\n /** Types the value is expected to be. Informational. */\n range?: string[]\n /** Types the subject may be. A lens shows other subjects' statements\n * through the inverse; `wiki enrich` writes it only on these (#820). */\n domain?: string[]\n}\n\nexport type PanelSource = \"statements\" | \"linked\" | \"history\" | \"discussed\" | \"readings\" | \"notes\"\n\nexport interface LensPanel {\n /** Panel id. Used in the zoom URL, so keep it short and stable. */\n panel: string\n title?: string\n /** Where items come from. Inferred from the other fields when omitted. */\n source?: PanelSource\n /** Properties to show (statements panels). `related` covers plain links. */\n from?: string | string[]\n /** Keep only items whose other end has one of these types. */\n types?: string[]\n /** Items shown at the overview level (Z2). The full list is Z3. */\n show?: number\n group_by?: \"role\" | \"property\"\n display?: \"list\" | \"timeline\"\n /** History: importance levels shown unfolded. */\n importance?: Importance[]\n /** History: levels folded under a count. */\n fold?: Importance\n /** History: repeated minor events shown as one recurring line. */\n rollup?: { min: number; days: number }\n /** Readings: only the latest value per metric. */\n latest?: boolean\n /** `owner` marks the panel as private to the owner. */\n access?: \"owner\"\n}\n\nexport interface ClassifyRule {\n /** Type the matching page gets. */\n type: string\n /** Match when the page's legacy `type` is one of these. */\n legacy?: string[]\n /** Match when the page path starts with one of these folders. */\n path?: string[]\n /** Match when the page has any of these tags. */\n tags?: string[]\n /** Case-insensitive regular expression on the title. */\n title?: string\n}\n\nexport interface Ontology {\n version: number\n pillars: PillarDef[]\n types: TypeDef[]\n properties: PropertyDef[]\n importance: {\n default: Importance\n /** Who may set `major`: \"owner\" means agents can only propose it. */\n major_set_by: \"owner\" | \"anyone\"\n rollup: { min: number; days: number }\n }\n sidebar: {\n pins_max: number\n /** Page titles the owner pinned, in order. */\n pins: string[]\n }\n /** Rules that give a page a type, tried in order. The first match wins. */\n classify: ClassifyRule[]\n /** Type for pages no rule matches. */\n fallback_type: string\n /** Extra names of the fleet's agents, for agents that run on another\n * node or answer to a persona name (#819). The node's own agent ids,\n * configured names and persona names are found without this. */\n agent_names?: string[]\n}\n\n/** One typed fact about a page: subject (the page) → property → value. */\nexport interface WikiStatement {\n property: string\n /** A page title (becomes a link) or a literal value. */\n value: string\n role?: string\n since?: string\n until?: string\n /** Metric name for readings (disk_used, uptime). */\n metric?: string\n /** When a reading was taken. */\n at?: string\n /** Where it comes from: entry id, document, gazette reference, article. */\n source?: string\n access?: \"public\" | \"shared\" | \"private\"\n status?: \"proposed\" | \"confirmed\"\n confirmed_by?: string\n checked_at?: string\n /** The job that wrote it, e.g. \"wiki-enrich\"; its next run replaces it. */\n by?: string\n note?: string\n}\n"],"mappings":"AAWO,IAAMA,EAA2C,CAAC,QAAS,SAAU,OAAO","names":["IMPORTANCE_LEVELS"]}
1
+ {"version":3,"sources":["../src/wiki/ontology/types.ts"],"sourcesContent":["// --- Wiki ontology types (#811) ---\n//\n// The ontology says what kinds of things the wiki holds (types grouped\n// into pillars), how they relate (properties), how important an event is,\n// and how each type's page is viewed (lenses). Every value here comes\n// from `ontology.yaml` in the wiki root, falling back to the generic\n// defaults in `defaults.ts`. Nothing about a particular organisation\n// belongs in code.\n\nexport type Importance = \"minor\" | \"normal\" | \"major\"\n\nexport const IMPORTANCE_LEVELS: readonly Importance[] = [\"minor\", \"normal\", \"major\"] as const\n\nexport interface PillarDef {\n id: string\n label: string\n /** One line under the pillar title. */\n description?: string\n /** Icon name from the view's small built-in icon set. */\n icon?: string\n /** Shown in the sidebar. A fallback pillar such as Topics sets false. */\n sidebar?: boolean\n}\n\nexport interface TypeDef {\n id: string\n label: string\n plural?: string\n pillar: string\n /** schema.org class, shown as a hint on the page. */\n schema?: string\n icon?: string\n /** Panels the page opens with, in order. */\n lens?: LensPanel[]\n}\n\nexport interface PropertyDef {\n id: string\n /** Read from the subject: \"Person — role at → Organization\". */\n label: string\n /** Read from the value's side: \"Organization — people ← Person\". */\n inverse?: string\n /** Wikidata property id, kept as a mapping hint. */\n wikidata?: string\n /** Types the value is expected to be. Informational. */\n range?: string[]\n /** Types the subject may be. A lens shows other subjects' statements\n * through the inverse; `wiki enrich` writes it only on these (#820). */\n domain?: string[]\n}\n\nexport type PanelSource = \"statements\" | \"linked\" | \"history\" | \"discussed\" | \"readings\" | \"notes\"\n\nexport interface LensPanel {\n /** Panel id. Used in the zoom URL, so keep it short and stable. */\n panel: string\n title?: string\n /** Where items come from. Inferred from the other fields when omitted. */\n source?: PanelSource\n /** Properties to show (statements panels). `related` covers plain links. */\n from?: string | string[]\n /** Keep only items whose other end has one of these types. */\n types?: string[]\n /** Items shown at the overview level (Z2). The full list is Z3. */\n show?: number\n group_by?: \"role\" | \"property\"\n display?: \"list\" | \"timeline\"\n /** History: importance levels shown unfolded. */\n importance?: Importance[]\n /** History: levels folded under a count. */\n fold?: Importance\n /** History: repeated minor events shown as one recurring line. */\n rollup?: { min: number; days: number }\n /** Readings: only the latest value per metric. */\n latest?: boolean\n /** `owner` marks the panel as private to the owner. */\n access?: \"owner\"\n}\n\nexport interface ClassifyRule {\n /** Type the matching page gets. */\n type: string\n /** Match when the page's legacy `type` is one of these. */\n legacy?: string[]\n /** Match when the page path starts with one of these folders. */\n path?: string[]\n /** Match when the page has any of these tags. */\n tags?: string[]\n /** Case-insensitive regular expression on the title. */\n title?: string\n}\n\n/** Gives an event its importance without a model call (#811). */\nexport interface ImportanceRule {\n level: Importance\n /** Case-insensitive regular expression on the event title. */\n title?: string\n /** Match when the event page has any of these tags. */\n tags?: string[]\n}\n\nexport interface Ontology {\n version: number\n pillars: PillarDef[]\n types: TypeDef[]\n properties: PropertyDef[]\n importance: {\n default: Importance\n /** Who may set `major`: \"owner\" means agents can only propose it. */\n major_set_by: \"owner\" | \"anyone\"\n rollup: { min: number; days: number }\n /** Tried in order by `wiki events` before it asks a model. The first\n * match wins. */\n rules?: ImportanceRule[]\n }\n sidebar: {\n pins_max: number\n /** Page titles the owner pinned, in order. */\n pins: string[]\n }\n /** Rules that give a page a type, tried in order. The first match wins. */\n classify: ClassifyRule[]\n /** Type for pages no rule matches. */\n fallback_type: string\n /** Extra names of the fleet's agents, for agents that run on another\n * node or answer to a persona name (#819). The node's own agent ids,\n * configured names and persona names are found without this. */\n agent_names?: string[]\n}\n\n/** One typed fact about a page: subject (the page) → property → value. */\nexport interface WikiStatement {\n property: string\n /** A page title (becomes a link) or a literal value. */\n value: string\n role?: string\n since?: string\n until?: string\n /** Metric name for readings (disk_used, uptime). */\n metric?: string\n /** When a reading was taken. */\n at?: string\n /** Where it comes from: entry id, document, gazette reference, article. */\n source?: string\n access?: \"public\" | \"shared\" | \"private\"\n status?: \"proposed\" | \"confirmed\"\n confirmed_by?: string\n checked_at?: string\n /** The job that wrote it, e.g. \"wiki-enrich\"; its next run replaces it. */\n by?: string\n note?: string\n}\n"],"mappings":"AAWO,IAAMA,EAA2C,CAAC,QAAS,SAAU,OAAO","names":["IMPORTANCE_LEVELS"]}
@@ -1,8 +1,8 @@
1
- import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-RJFPCW7T.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-D5IHICX3.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function S(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",f=[`- ${n} [${h}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&f.push(` notify: ${e.notify.channel} ${e.notify.chatId}${e.deliverResult===!1?" (failures only)":" (results and failures)"}`),e.command?f.push(` command: ${S(String(e.command))}`):e.prompt&&f.push(` prompt: ${S(String(e.prompt))}`),f.join(`
1
+ import{a as D,b as _}from"./chunk-RKPAVWXF.js";import{a as R,b as q,c as O,d as B,f as k,g as v,h as E,i as w,j as y}from"./chunk-FWDRBUMS.js";import{a as T,b as C,c as I,d as x,e as P}from"./chunk-LUYN6RAC.js";import{existsSync as X,readFileSync as F}from"fs";var J=new Set(["cron","heartbeat","api","a2a","mesh"]),M=160;function s(n){return typeof n=="string"&&n.trim()?n.trim():void 0}function S(n,e=M){let t=n.replace(/\s+/g," ").trim();return t.length>e?`${t.slice(0,e-1)}\u2026`:t}function V(n){let e=T(n);if(!X(e))throw new Error(`config not found at ${e}`);return JSON.parse(F(e,"utf-8"))}function W(n,e){return n?.agents?.[e]?.admin===!0}function Y(n,e,t){return W(n,t.agentId)||e?.createdBy===t.agentId}function Z(n,e){let t=e?.createdBy?`agent "${e.createdBy}"`:"the operator";return`Not allowed: "${n}" was created by ${t}. Agents manage only schedules they created (unless configured admin).`}function K(n,e){let t=s(n.notify);if(t!=="none"){if(t&&t!=="here"){let r=t.split(":");return r.length<2||!r[0]||!r[1]?"invalid":{channel:r[0],chatId:r.slice(1).join(":")}}if(e.channel&&e.chatId&&!J.has(e.channel))return{channel:e.channel,chatId:e.chatId,...e.accountId?{accountId:e.accountId}:{}}}}function Q(n,e,t){let r=e.timezone||"UTC",d=e.enabled&&!y(e)?w(E(e.schedule,r,t),r):"\u2014",h=e.approval?`pending ${e.approval.action} approval`:e.enabled?"active":"paused",f=[`- ${n} [${h}] ${e.schedule} \u2014 ${v(e.schedule)} (${r})`,` agent: ${e.agent}; created by: ${e.createdBy||"operator"}; next: ${d}`];return e.notify&&f.push(` notify: ${e.notify.channel} ${e.notify.chatId}${e.deliverResult===!1?" (failures only)":" (results and failures)"}`),e.command?f.push(` command: ${S(String(e.command))}`):e.prompt&&f.push(` prompt: ${S(String(e.prompt))}`),f.join(`
2
2
  `)}async function b(n,e,t){let r=n?.notifications?.destination;if(!r?.channel||!r?.chatId)return"No operator notification destination is configured (notifications.destination); the operator must check `agentx schedule list`.";if(!e.notifyOperator)return"Operator notification is unavailable in this context.";try{return await e.notifyOperator({channel:r.channel,chatId:r.chatId,accountId:r.accountId},t),"The operator has been notified."}catch(d){return`Could not notify the operator (${d?.message??d}); the request is still recorded.`}}async function re(n,e,t={}){let r=(s(n.action)||"list").toLowerCase(),d=t.now?t.now():new Date,h;try{h=V(t.configPath)}catch(a){return`Error: ${a.message}`}let f=h.crons||{};if(r==="list"){let a=n.mine===!0,l=Object.entries(f).filter(([,i])=>!a||e&&i?.createdBy===e.agentId);return l.length?l.map(([i,p])=>Q(i,p,d)).join(`
3
3
  `):a?"You have no schedules.":"No schedules."}if(!e?.agentId)return"Error: caller agent is unknown (AGENTX_AGENT_ID not set). Pass callerAgentId.";if(!h.agents?.[e.agentId])return`Error: caller "${e.agentId}" is not an agent on this node.`;let o=s(n.id),m=a=>C(a,{configPath:t.configPath,reload:t.reload});if(r==="create"){let a=s(n.when),l=s(n.prompt);if(!a||!l)return"Error: create needs `when` (plain English) and `prompt`.";let i=D(a);if(!i)return`Error: couldn't parse "${a}". ${q}.`;let p=s(n.agent)||e.agentId;if(!h.agents?.[p])return`Error: agent "${p}" not found on this node.`;let g=s(n.timezone)||R;if(!B(g))return`Error: unknown timezone "${g}".`;let u=o||_(i.matched,p);if(!O(u))return`Error: invalid id "${u}" (letters, digits, "-" and "_" only).`;if(f[u])return`Error: a schedule "${u}" already exists. Pick another \`id\`.`;let $=K(n,e);if($==="invalid")return'Error: `notify` must be "here", "none", or "channel:chatId".';let z={action:"create",requestedBy:e.agentId,requestedAt:d.toISOString()},L=k({parsed:i,agent:p,prompt:l,timezone:g,notify:$,enabled:!1,createdBy:e.agentId,approval:z}),A=await m(U=>I(U,`crons.${u}`,L));if(!A.success)return`Error: ${A.error}`;let N=w(E(i.cron,g,d),g),G=[`Schedule approval requested by ${e.agentId}`,`Create: ${u}`,`When: ${i.human} \u2014 cron \`${i.cron}\` (${g})`,`Next fire: ${N}`,`Agent: ${p}`,$?`Results and failures go to: ${$.channel} ${$.chatId}${$.channel==="voice"?" (as a push notification)":""}`:"Results go to: run log only (no chat)",`Prompt: ${S(l,400)}`,"",`Approve: agentx schedule approve ${u}`,`Reject: agentx schedule reject ${u}`].join(`
4
4
  `),H=await b(h,t,G);return[`Requested schedule "${u}": ${i.human} (cron ${i.cron}, ${g}); next fire would be ${N}.`,"It is saved DISABLED and will not run until the operator approves it.",H].join(`
5
5
  `)}if(!o)return`Error: ${r} needs \`id\`.`;let c=f[o];if(!c)return`Error: schedule "${o}" not found.`;if(!Y(h,c,e))return Z(o,c);if(r==="pause"||r==="resume"){let a=r==="resume";if(a&&y(c))return`"${o}" is still awaiting operator approval; it can't be resumed until approved.`;if(c.enabled===a)return`"${o}" is already ${a?"active":"paused"}.`;let l=await m(i=>I(i,`crons.${o}.enabled`,a));return l.success?`"${o}" ${a?"resumed":"paused"}.`:`Error: ${l.error}`}if(r==="delete"){if(y(c)&&c.approval.requestedBy===e.agentId){let u=await m($=>P($,`crons.${o}`));return u.success?`Withdrew the pending request "${o}".`:`Error: ${u.error}`}if(y(c))return`"${o}" is a creation request still awaiting approval; only its requester or the operator (\`agentx schedule reject ${o}\`) can drop it.`;if(c.approval?.action==="delete")return`Deletion of "${o}" is already awaiting approval.`;let a={action:"delete",requestedBy:e.agentId,requestedAt:d.toISOString()},l=await m(u=>{if(!x(u,`crons.${o}`))throw new Error(`schedule "${o}" not found`);I(u,`crons.${o}.approval`,a)});if(!l.success)return`Error: ${l.error}`;let i=c.timezone||"UTC",p=[`Schedule approval requested by ${e.agentId}`,`Delete: ${o}`,`When: ${v(c.schedule)} \u2014 cron \`${c.schedule}\` (${i})`,`Next fire: ${c.enabled?w(E(c.schedule,i,d),i):"\u2014 (paused)"}`,`Agent: ${c.agent}`,"",`Approve: agentx schedule approve ${o}`,`Reject: agentx schedule reject ${o}`].join(`
6
6
  `),g=await b(h,t,p);return[`Deletion of "${o}" requested. It keeps its current state until the operator approves.`,g].join(`
7
7
  `)}return`Error: unknown action "${r}". Use list, create, pause, resume or delete.`}function oe(n,e=process.env){let t=s(e.AGENTX_AGENT_ID)||s(n.callerAgentId);if(!t)return null;let r=!!(s(e.AGENTX_CHANNEL)&&s(e.AGENTX_CHAT_ID)),d=s(r?e.AGENTX_CHANNEL:n.channel),h=s(r?e.AGENTX_CHAT_ID:n.chatId),f=s(n.accountId);return{agentId:t,channel:d,chatId:h,...f?{accountId:f}:{}}}export{re as a,oe as b};
8
- //# sourceMappingURL=chunk-GZY5DYXT.js.map
8
+ //# sourceMappingURL=chunk-RRGITX5B.js.map
@@ -1,4 +1,4 @@
1
- import{c as w}from"./chunk-OQV3LWJI.js";function T(t){let r=1779033703^t.length;for(let s=0;s<t.length;s++)r=Math.imul(r^t.charCodeAt(s),3432918353),r=r<<13|r>>>19;let o=r>>>0;return()=>{o=o+1831565813>>>0;let s=o;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}function _(t,r,o){let s=T(o),i=[...t].sort((e,u)=>e.path.localeCompare(u.path));for(let e=i.length-1;e>0;e--){let u=Math.floor(s()*(e+1));[i[e],i[u]]=[i[u],i[e]]}return i.slice(0,Math.max(0,r)).sort((e,u)=>e.path.localeCompare(u.path))}var R=new Set("about after again also because been before being between could does doing during each from have having here into just more most only other over same should some such than that their them then there these they this those through under until very were what when where which while will with would your yours user assistant agent message entry please thanks".split(" "));function k(t){let r=new Set;for(let o of t.toLowerCase().matchAll(/[\p{L}\p{N}][\p{L}\p{N}_-]{3,}/gu))R.has(o[0])||r.add(o[0]);return r}function E(t,r){let o=k(t);if(o.size===0)return 1;let s=k(r),i=0;for(let e of o)s.has(e)&&i++;return i/o.size}var W=.15;function $(t){let r=w(t);return{commits:r.commits,urls:r.urls,numbers:r.numbers}}function j(t,r,o){return t.includes(r)||o.some(s=>s.startsWith(r)||r.startsWith(s))}var y=t=>t.toLowerCase().replace(/\/+$/,"");function N(t,r,o){let s=t.sources.map(a=>r.get(a)).filter(a=>!!a),i=t.sources.filter(a=>!r.has(a)),e=s.filter(a=>k(a.content).size>=5&&E(a.content,t.content)<W).map(a=>a.id),u=[...s.map(a=>`${a.date??""}
1
+ import{c as w}from"./chunk-ZFRXFUP7.js";function T(t){let r=1779033703^t.length;for(let s=0;s<t.length;s++)r=Math.imul(r^t.charCodeAt(s),3432918353),r=r<<13|r>>>19;let o=r>>>0;return()=>{o=o+1831565813>>>0;let s=o;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}function _(t,r,o){let s=T(o),i=[...t].sort((e,u)=>e.path.localeCompare(u.path));for(let e=i.length-1;e>0;e--){let u=Math.floor(s()*(e+1));[i[e],i[u]]=[i[u],i[e]]}return i.slice(0,Math.max(0,r)).sort((e,u)=>e.path.localeCompare(u.path))}var R=new Set("about after again also because been before being between could does doing during each from have having here into just more most only other over same should some such than that their them then there these they this those through under until very were what when where which while will with would your yours user assistant agent message entry please thanks".split(" "));function k(t){let r=new Set;for(let o of t.toLowerCase().matchAll(/[\p{L}\p{N}][\p{L}\p{N}_-]{3,}/gu))R.has(o[0])||r.add(o[0]);return r}function E(t,r){let o=k(t);if(o.size===0)return 1;let s=k(r),i=0;for(let e of o)s.has(e)&&i++;return i/o.size}var W=.15;function $(t){let r=w(t);return{commits:r.commits,urls:r.urls,numbers:r.numbers}}function j(t,r,o){return t.includes(r)||o.some(s=>s.startsWith(r)||r.startsWith(s))}var y=t=>t.toLowerCase().replace(/\/+$/,"");function N(t,r,o){let s=t.sources.map(a=>r.get(a)).filter(a=>!!a),i=t.sources.filter(a=>!r.has(a)),e=s.filter(a=>k(a.content).size>=5&&E(a.content,t.content)<W).map(a=>a.id),u=[...s.map(a=>`${a.date??""}
2
2
  ${a.content}`),t.previous??""].join(`
3
3
  `),l=u.toLowerCase(),d=$(u),p=new Set(d.urls.map(y)),g=new Set(d.numbers),n=$(t.content),c=[];for(let a of n.commits)j(l,a,d.commits)||c.push(`commit ${a}`);for(let a of n.urls)!p.has(y(a))&&!l.includes(y(a))&&c.push(`link ${a}`);for(let a of n.numbers)/^\d{1,2}$/.test(a)||!g.has(a)&&!l.includes(a)&&c.push(`number ${a}`);let h=[];for(let a of s){let m=$(a.content);if(m.commits.length===0&&m.urls.length===0)continue;let v=o(a.id),S=(v.length>0?v:[t.content]).join(`
4
4
  `).toLowerCase(),x=$(S);for(let b of m.commits)j(S,b,x.commits)||h.push({entry:a.id,fact:`commit ${b}`});for(let b of m.urls)S.includes(y(b))||h.push({entry:a.id,fact:`link ${b}`})}return{path:t.path,title:t.title,type:t.type,sources:t.sources.length,missingSources:i,weakSources:e,ungrounded:c,lost:h}}function U(t,r){let o=r.toLowerCase(),s=w(r).commits,i=[];for(let e of t){let u=w(e.content),l=[...u.commits.filter(d=>!j(o,d,s)).map(d=>`commit ${d}`),...u.urls.filter(d=>!o.includes(y(d))).map(d=>`link ${d}`)];l.length>0&&i.push({entry:e.id,facts:l})}return i}var P=new Set("the and for with from into of on in at to by an a".split(" "));function L(t){return new Set((t||"").toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(r=>(r.length>1||/\d/.test(r))&&!P.has(r)&&!R.has(r)))}function M(t,r){if(t.size===0||r.size===0)return 0;let o=0;for(let s of t)r.has(s)&&o++;return o/(t.size+r.size-o)}function D(t,r,o={}){let s=o.titleMin??.75,i=o.sourcesMin??.5,e=t.map(l=>({...l,tt:L(l.title),ss:new Set(l.sources??[])})),u=[];for(let l=0;l<e.length;l++)for(let d=l+1;d<e.length;d++){let p=e[l],g=e[d];if(r&&!r.has(p.path)&&!r.has(g.path))continue;let n=(p.type??"")===(g.type??"")?M(p.tt,g.tt):0;if(n>=s){u.push({a:p.path,b:g.path,reason:"title",score:n});continue}if(p.ss.size>=2&&g.ss.size>=2){let c=M(p.ss,g.ss);c>=i&&u.push({a:p.path,b:g.path,reason:"sources",score:c})}}return u.sort((l,d)=>d.score-l.score||l.a.localeCompare(d.a))}var A=4e3;function J(t,r){let o=r.map(i=>{let e=i.content.length>A?`${i.content.slice(0,A)}
@@ -33,4 +33,4 @@ Reply with JSON only, no fencing:
33
33
  {"claims": 0, "supported": 0, "unsupported": [], "contradicted": [], "off_subject": [], "missing": [], "verdict": "good"}`}function z(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let r=t,o=l=>Array.isArray(l)?l.map(d=>String(d)):[],s=l=>typeof l=="number"&&Number.isFinite(l)&&l>=0?Math.round(l):NaN,i=s(r.claims);if(Number.isNaN(i))return null;let e=Math.min(i,Number.isNaN(s(r.supported))?i-o(r.unsupported).length:s(r.supported)),u=r.verdict==="good"||r.verdict==="minor"||r.verdict==="major"?r.verdict:null;return u?{claims:i,supported:Math.max(0,e),unsupported:o(r.unsupported),contradicted:o(r.contradicted),offSubject:o(r.off_subject??r.offSubject),missing:o(r.missing),verdict:u}:null}function I(t,r,o,s=[],i=5,e){let u={};for(let n of t)u[n.type??"untyped"]=(u[n.type??"untyped"]??0)+1;let l=new Set,d=new Set;for(let n of t)for(let c of n.lost)l.add(c.entry),d.add(`${c.entry}|${c.fact}`);let p=new Set(r.flatMap(n=>[n.a,n.b]).filter(n=>t.some(c=>c.path===n))),g={sample:{articles:t.length,seed:o.seed,since:o.since,byType:u},citations:{withSources:t.filter(n=>n.sources>0).length,missingSources:t.reduce((n,c)=>n+c.missingSources.length,0),weakSources:t.reduce((n,c)=>n+c.weakSources.length,0),articlesWithWeak:t.filter(n=>n.weakSources.length>0).length},grounding:{articlesWithUngrounded:t.filter(n=>n.ungrounded.length>0).length,ungroundedFacts:t.reduce((n,c)=>n+c.ungrounded.length,0)},lost:{entriesWithLostFacts:l.size,lostFacts:d.size},duplicates:{pairs:r.length,articlesInPair:p.size},...e?{uncited:{entries:e.entries,withLostFacts:e.lost.length}}:{},examples:{ungrounded:t.filter(n=>n.ungrounded.length>0).slice(0,i).map(n=>({path:n.path,facts:n.ungrounded.slice(0,6)})),lost:t.flatMap(n=>n.lost.map(c=>({path:n.path,...c}))).slice(0,i),weak:t.filter(n=>n.weakSources.length>0).slice(0,i).map(n=>({path:n.path,entries:n.weakSources})),duplicates:r.slice(0,i),uncited:(e?.lost??[]).slice(0,i).map(n=>({entry:n.entry,facts:n.facts.slice(0,4)})),judged:s.filter(n=>n.verdict.verdict!=="good").slice(0,i).map(n=>({path:n.path,verdict:n.verdict.verdict,unsupported:n.verdict.unsupported.slice(0,4),contradicted:n.verdict.contradicted.slice(0,4),offSubject:n.verdict.offSubject,missing:n.verdict.missing.slice(0,4)}))}};if(s.length>0){let n=s.map(a=>a.verdict),c=n.reduce((a,m)=>a+m.claims,0),h=n.reduce((a,m)=>a+m.supported,0);g.judge={judged:n.length,claims:c,supported:h,supportRate:c>0?h/c:1,unsupported:n.reduce((a,m)=>a+m.unsupported.length,0),contradicted:n.reduce((a,m)=>a+m.contradicted.length,0),articlesWithWrongMerge:n.filter(a=>a.offSubject.length>0).length,missingFacts:n.reduce((a,m)=>a+m.missing.length,0),verdicts:{good:n.filter(a=>a.verdict==="good").length,minor:n.filter(a=>a.verdict==="minor").length,major:n.filter(a=>a.verdict==="major").length}}}return g}var f=(t,r)=>r>0?`${Math.round(t/r*100)}%`:"\u2013";function O(t){let r=t.sample.articles,o=["# Wiki absorb scorecard","",`Sample: ${r} articles (seed \`${t.sample.seed}\`${t.sample.since?`, changed since ${t.sample.since}`:""}). Types: ${Object.entries(t.sample.byType).map(([e,u])=>`${e} ${u}`).join(", ")||"\u2013"}.`,"","| Check | Result | Lower is better? |","|---|---|---|",`| Articles citing at least one entry | ${t.citations.withSources}/${r} (${f(t.citations.withSources,r)}) | no |`,`| Cited ids with no entry | ${t.citations.missingSources} | yes |`,`| Articles with a weak citation (entry shares <${Math.round(W*100)}% of its words) | ${t.citations.articlesWithWeak}/${r} (${f(t.citations.articlesWithWeak,r)}) | yes |`,`| Articles with an ungrounded commit, link or number | ${t.grounding.articlesWithUngrounded}/${r} (${f(t.grounding.articlesWithUngrounded,r)}) | yes |`,`| Ungrounded facts | ${t.grounding.ungroundedFacts} | yes |`,`| Commits or links lost from cited entries | ${t.lost.lostFacts} across ${t.lost.entriesWithLostFacts} entries | yes |`,`| Sampled articles in a likely duplicate pair | ${t.duplicates.articlesInPair}/${r} (${f(t.duplicates.articlesInPair,r)}) | yes |`];if(t.uncited&&o.push(`| Entries read in the window but cited by no article | ${t.uncited.entries} | \u2013 |`,`| \u2026of which carry a commit or link no article has | ${t.uncited.withLostFacts} | yes |`),t.judge){let e=t.judge;o.push(`| Judge: claims supported by the cited entries | ${e.supported}/${e.claims} (${f(e.supported,e.claims)}) | no |`,`| Judge: unsupported / contradicted claims | ${e.unsupported} / ${e.contradicted} | yes |`,`| Judge: articles with an off-subject source (wrong merge) | ${e.articlesWithWrongMerge}/${e.judged} (${f(e.articlesWithWrongMerge,e.judged)}) | yes |`,`| Judge: facts missing from the article | ${e.missingFacts} | yes |`,`| Judge verdicts good / minor / major | ${e.verdicts.good} / ${e.verdicts.minor} / ${e.verdicts.major} | \u2013 |`)}let s=t.examples,i=(e,u)=>{u.length!==0&&o.push("",`## ${e}`,"",...u)};return i("Examples: ungrounded facts",s.ungrounded.map(e=>`- \`${e.path}\`: ${e.facts.join("; ")}`)),i("Examples: lost facts",s.lost.map(e=>`- \`${e.path}\` \u2190 entry \`${e.entry}\`: ${e.fact}`)),i("Examples: weak citations",s.weak.map(e=>`- \`${e.path}\`: ${e.entries.map(u=>`\`${u}\``).join(", ")}`)),i("Examples: uncited entries with facts no article has",s.uncited.map(e=>`- \`${e.entry}\`: ${e.facts.join("; ")}`)),i("Examples: likely duplicates",s.duplicates.map(e=>`- \`${e.a}\` \u2194 \`${e.b}\` (${e.reason}, ${e.score.toFixed(2)})`)),i("Examples: judge findings",s.judged.map(e=>{let u=[e.unsupported.length?`unsupported: ${e.unsupported.join(" | ")}`:"",e.contradicted.length?`contradicted: ${e.contradicted.join(" | ")}`:"",e.offSubject.length?`off-subject: ${e.offSubject.join(", ")}`:"",e.missing.length?`missing: ${e.missing.join(" | ")}`:""].filter(Boolean);return`- \`${e.path}\` (${e.verdict}): ${u.join("; ")}`})),o.push("","## Method","","- The sample is drawn with a seeded shuffle from the articles changed in the window, so the same seed and window give the same articles.","- Ungrounded: a commit hash, link or number (three digits or more, or a date) in the article that no cited entry and no earlier version of the article contains.","- Lost: a commit hash or link in a cited entry that no article citing that entry contains.","- Uncited: entries the absorb ledger marks as read in the window that no article cites; those carrying a commit or link that no article on the node has are counted as lost, since absorb will not offer them again.","- Weak citation: a cited entry sharing fewer than 15% of its distinctive words with the article.","- Duplicate: two articles of the same type whose titles share at least 75% of their words, or which share at least half their sources.","- Judge (optional): one model call per article reads the article and its cited entries and lists unsupported, contradicted, off-subject and missing items."),o.join(`
34
34
  `)+`
35
35
  `}function V(t){if(!t||typeof t!="object")return{};let r=t,o=r.usage??{},s=i=>typeof i=="number"&&Number.isFinite(i)?i:void 0;return{costUsd:s(r.total_cost_usd)??s(r.cost_usd),apiMs:s(r.duration_api_ms),inputTokens:s(o.input_tokens),outputTokens:s(o.output_tokens),cacheReadTokens:s(o.cache_read_input_tokens),cacheWriteTokens:s(o.cache_creation_input_tokens)}}function C(t,r){return t.length===0?0:t[Math.min(t.length-1,Math.floor(r*t.length))]}function Y(t){let r=new Map,o=i=>{let e=i||"(none)",u=r.get(e);return u||r.set(e,u={calls:[],runs:[]}),u};for(let i of t)i.kind==="call"?o(i.label).calls.push(i):i.kind==="run"&&o(i.label).runs.push(i);let s=[];for(let[i,{calls:e,runs:u}]of r){if(e.length===0)continue;let l=e.map(n=>n.wallMs).sort((n,c)=>n-c),d;if(u.length>0)d=u.reduce((n,c)=>n+(Date.parse(c.endedAt)-Date.parse(c.startedAt)),0);else{let n=e.map(h=>Date.parse(h.at)-h.wallMs),c=e.map(h=>Date.parse(h.at));d=Math.max(...c)-Math.min(...n)}let p=e.reduce((n,c)=>n+c.entries,0),g=e.reduce((n,c)=>n+(c.costUsd??0),0);s.push({label:i,calls:e.length,failed:e.filter(n=>n.failed).length,entries:p,articles:e.reduce((n,c)=>n+c.articles,0),refused:e.reduce((n,c)=>n+c.refused,0),heldCited:e.reduce((n,c)=>n+(c.heldCited??0),0),wallMs:d,callMsP50:C(l,.5),callMsP95:C(l,.95),prepMs:e.reduce((n,c)=>n+(c.prepMs??0),0),costUsd:g,costPerEntry:p>0?g/p:0,entriesPerMinute:d>0?p/d*6e4:0,promptChars:e.reduce((n,c)=>n+c.promptChars,0)})}return s.sort((i,e)=>i.label.localeCompare(e.label))}export{T as a,_ as b,k as c,E as d,W as e,N as f,U as g,D as h,A as i,J as j,z as k,I as l,O as m,V as n,Y as o};
36
- //# sourceMappingURL=chunk-PHCWYKQW.js.map
36
+ //# sourceMappingURL=chunk-RVEMX5MJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/wiki/absorb-eval.ts"],"sourcesContent":["// Measuring what `agentx wiki absorb` writes (#808).\n//\n// Absorb turns raw entries into articles, and until now nothing checked\n// the result against the entries it came from. This module is the\n// scorecard: a fixed, seeded sample of articles, five checks per article,\n// and an optional model judge for the questions a string match cannot\n// answer (is this claim supported, does this source belong here).\n//\n// The deterministic checks are deliberately narrow. A commit hash or URL\n// in an article that no cited entry and no earlier version carries is\n// almost certainly made up or mis-attributed; a commit or URL in a cited\n// entry that no article carries was almost certainly lost. Prose claims\n// are left to the judge.\n\nimport { extractFacts } from \"./absorb-context\"\n\nexport interface EvalArticle {\n path: string\n title: string\n type?: string\n content: string\n sources: string[]\n lastUpdated?: string\n /** The article body before this absorb touched it, when one exists. */\n previous?: string\n}\n\nexport interface EvalEntry {\n id: string\n date?: string\n content: string\n}\n\n// --- Sample ---\n\n/** A small seeded PRNG, so a sample can be drawn again from the same seed. */\nexport function seededRandom(seed: string): () => number {\n let h = 1779033703 ^ seed.length\n for (let i = 0; i < seed.length; i++) {\n h = Math.imul(h ^ seed.charCodeAt(i), 3432918353)\n h = (h << 13) | (h >>> 19)\n }\n let a = h >>> 0\n return () => {\n a = (a + 0x6d2b79f5) >>> 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/** `n` items picked without replacement. Same items and seed, same pick. */\nexport function pickSample<T extends { path: string }>(items: T[], n: number, seed: string): T[] {\n const rng = seededRandom(seed)\n const pool = [...items].sort((a, b) => a.path.localeCompare(b.path))\n for (let i = pool.length - 1; i > 0; i--) {\n const j = Math.floor(rng() * (i + 1))\n ;[pool[i], pool[j]] = [pool[j], pool[i]]\n }\n return pool.slice(0, Math.max(0, n)).sort((a, b) => a.path.localeCompare(b.path))\n}\n\n// --- Terms ---\n\nconst STOP = new Set(\n (\"about after again also because been before being between could does doing during each from have having here into \"\n + \"just more most only other over same should some such than that their them then there these they this those \"\n + \"through under until very were what when where which while will with would your yours user assistant agent \"\n + \"message entry please thanks\").split(\" \"),\n)\n\n/** Distinctive words: four letters or more, lower-cased, minus common ones. */\nexport function terms(text: string): Set<string> {\n const out = new Set<string>()\n for (const m of text.toLowerCase().matchAll(/[\\p{L}\\p{N}][\\p{L}\\p{N}_-]{3,}/gu)) {\n if (!STOP.has(m[0])) out.add(m[0])\n }\n return out\n}\n\n/** Share of `entry`'s distinctive words that appear in `article`. */\nexport function termOverlap(entry: string, article: string): number {\n const e = terms(entry)\n if (e.size === 0) return 1\n const a = terms(article)\n let hit = 0\n for (const t of e) if (a.has(t)) hit++\n return hit / e.size\n}\n\n// --- Per-article checks ---\n\n/** Below this share of shared words a cited entry is flagged as weak. */\nexport const WEAK_CITATION = 0.15\n\nexport interface ArticleCheck {\n path: string\n title: string\n type?: string\n sources: number\n /** Cited ids with no entry behind them. */\n missingSources: string[]\n /** Cited entries that share almost no words with the article. */\n weakSources: string[]\n /** Commits, links and numbers in the article that neither a cited entry\n * nor the earlier version carries. */\n ungrounded: string[]\n /** Commits and links in a cited entry that no article citing it carries. */\n lost: Array<{ entry: string; fact: string }>\n}\n\n/** What a fact looks like when matched against grounding text. */\nfunction factStrings(text: string): { commits: string[]; urls: string[]; numbers: string[] } {\n const f = extractFacts(text)\n return { commits: f.commits, urls: f.urls, numbers: f.numbers }\n}\n\nfunction hasCommit(haystack: string, commit: string, known: string[]): boolean {\n return haystack.includes(commit) || known.some((k) => k.startsWith(commit) || commit.startsWith(k))\n}\n\nconst urlKey = (u: string) => u.toLowerCase().replace(/\\/+$/, \"\")\n\n/**\n * Check one article against its cited entries.\n *\n * `citersOf` returns every article (in the whole wiki, not only the\n * sample) that cites an entry, so a fact moved to a sibling article is\n * not counted as lost.\n */\nexport function checkArticle(\n article: EvalArticle,\n entries: Map<string, EvalEntry>,\n citersOf: (entryId: string) => string[],\n): ArticleCheck {\n const cited = article.sources.map((id) => entries.get(id)).filter((e): e is EvalEntry => !!e)\n const missingSources = article.sources.filter((id) => !entries.has(id))\n\n const weakSources = cited\n .filter((e) => terms(e.content).size >= 5 && termOverlap(e.content, article.content) < WEAK_CITATION)\n .map((e) => e.id)\n\n // Grounding: entry text with its date (absorb is shown the date in the\n // entry header), plus the earlier version of the article.\n const grounding = [...cited.map((e) => `${e.date ?? \"\"}\\n${e.content}`), article.previous ?? \"\"].join(\"\\n\")\n const groundLower = grounding.toLowerCase()\n const g = factStrings(grounding)\n const groundUrls = new Set(g.urls.map(urlKey))\n const groundNumbers = new Set(g.numbers)\n const mine = factStrings(article.content)\n const ungrounded: string[] = []\n for (const c of mine.commits) if (!hasCommit(groundLower, c, g.commits)) ungrounded.push(`commit ${c}`)\n for (const u of mine.urls) if (!groundUrls.has(urlKey(u)) && !groundLower.includes(urlKey(u))) ungrounded.push(`link ${u}`)\n for (const n of mine.numbers) {\n // Bare small integers (\"2 tests\", \"3 people\") are too common to judge.\n if (/^\\d{1,2}$/.test(n)) continue\n if (!groundNumbers.has(n) && !groundLower.includes(n)) ungrounded.push(`number ${n}`)\n }\n\n const lost: Array<{ entry: string; fact: string }> = []\n for (const e of cited) {\n const facts = factStrings(e.content)\n if (facts.commits.length === 0 && facts.urls.length === 0) continue\n const carriers = citersOf(e.id)\n const text = (carriers.length > 0 ? carriers : [article.content]).join(\"\\n\").toLowerCase()\n const carrierFacts = factStrings(text)\n for (const c of facts.commits) if (!hasCommit(text, c, carrierFacts.commits)) lost.push({ entry: e.id, fact: `commit ${c}` })\n for (const u of facts.urls) if (!text.includes(urlKey(u))) lost.push({ entry: e.id, fact: `link ${u}` })\n }\n\n return {\n path: article.path,\n title: article.title,\n type: article.type,\n sources: article.sources.length,\n missingSources,\n weakSources,\n ungrounded,\n lost,\n }\n}\n\n// --- Uncited entries ---\n\n/**\n * Entries absorb read and cited nowhere that carry a commit or link no\n * article on the node has. A successful run marks every entry it read as\n * done (#762), so a fact in an entry the model passed over is gone from\n * the queue for good; the per-article \"lost\" check cannot see it because\n * no article points back at the entry.\n */\nexport function uncitedWithFacts(\n uncited: EvalEntry[],\n allArticles: string,\n): Array<{ entry: string; facts: string[] }> {\n const lower = allArticles.toLowerCase()\n const known = extractFacts(allArticles).commits\n const out: Array<{ entry: string; facts: string[] }> = []\n for (const e of uncited) {\n const f = extractFacts(e.content)\n const missing = [\n ...f.commits.filter((c) => !hasCommit(lower, c, known)).map((c) => `commit ${c}`),\n ...f.urls.filter((u) => !lower.includes(urlKey(u))).map((u) => `link ${u}`),\n ]\n if (missing.length > 0) out.push({ entry: e.id, facts: missing })\n }\n return out\n}\n\n// --- Duplicates ---\n\nexport interface DuplicatePair {\n a: string\n b: string\n reason: \"title\" | \"sources\"\n score: number\n}\n\nconst TITLE_STOP = new Set(\"the and for with from into of on in at to by an a\".split(\" \"))\n\nfunction titleTerms(title: string): Set<string> {\n return new Set(\n (title || \"\").toLowerCase().split(/[^\\p{L}\\p{N}]+/u).filter((w) => (w.length > 1 || /\\d/.test(w)) && !TITLE_STOP.has(w) && !STOP.has(w)),\n )\n}\n\nfunction jaccard<T>(a: Set<T>, b: Set<T>): number {\n if (a.size === 0 || b.size === 0) return 0\n let inter = 0\n for (const x of a) if (b.has(x)) inter++\n return inter / (a.size + b.size - inter)\n}\n\n/**\n * Pairs of articles that look like one subject filed twice: the same type\n * and near-identical title words, or most of their sources in common.\n * Only pairs touching `focus` are returned when it is given.\n */\nexport function findDuplicates(\n catalog: Array<{ path: string; title: string; type?: string; sources?: string[] }>,\n focus?: Set<string>,\n opts: { titleMin?: number; sourcesMin?: number } = {},\n): DuplicatePair[] {\n const titleMin = opts.titleMin ?? 0.75\n const sourcesMin = opts.sourcesMin ?? 0.5\n const rows = catalog.map((a) => ({ ...a, tt: titleTerms(a.title), ss: new Set(a.sources ?? []) }))\n const pairs: DuplicatePair[] = []\n for (let i = 0; i < rows.length; i++) {\n for (let j = i + 1; j < rows.length; j++) {\n const x = rows[i], y = rows[j]\n if (focus && !focus.has(x.path) && !focus.has(y.path)) continue\n const t = (x.type ?? \"\") === (y.type ?? \"\") ? jaccard(x.tt, y.tt) : 0\n if (t >= titleMin) { pairs.push({ a: x.path, b: y.path, reason: \"title\", score: t }); continue }\n if (x.ss.size >= 2 && y.ss.size >= 2) {\n const s = jaccard(x.ss, y.ss)\n if (s >= sourcesMin) pairs.push({ a: x.path, b: y.path, reason: \"sources\", score: s })\n }\n }\n }\n return pairs.sort((p, q) => q.score - p.score || p.a.localeCompare(q.a))\n}\n\n// --- Model judge ---\n\nexport interface JudgeVerdict {\n claims: number\n supported: number\n unsupported: string[]\n contradicted: string[]\n /** Cited entry ids that are about a different subject (a wrong merge). */\n offSubject: string[]\n /** Facts in the entries that belong in this article and are missing. */\n missing: string[]\n verdict: \"good\" | \"minor\" | \"major\"\n}\n\n/** Per-entry cap in the judge prompt, so one long transcript cannot crowd out the rest. */\nexport const JUDGE_ENTRY_CHARS = 4000\n\nexport function buildJudgePrompt(article: EvalArticle, entries: EvalEntry[]): string {\n const sourceBlock = entries\n .map((e) => {\n const body = e.content.length > JUDGE_ENTRY_CHARS ? `${e.content.slice(0, JUDGE_ENTRY_CHARS)}\\n[…cut]` : e.content\n return `--- ENTRY ${e.id} [${e.date ?? \"\"}] ---\\n${body}\\n--- END ENTRY ---`\n })\n .join(\"\\n\\n\")\n const earlier = article.previous\n ? `\\n## Earlier version of the article (facts here count as supported)\\n\\n${article.previous}\\n`\n : \"\"\n return `You are auditing one wiki article against the raw entries it cites. Do not use outside knowledge.\n\n## Article: ${article.title} (${article.type ?? \"untyped\"}, ${article.path})\n\n${article.content}\n${earlier}\n## Cited entries (${entries.length})\n\n${sourceBlock || \"(none)\"}\n\n## What to report\n\n1. Split the article into factual claims (one per sentence or bullet; skip headings and \"unknown\" placeholders). Count them.\n2. A claim is supported when a cited entry or the earlier version states it or plainly implies it. List each claim that is not supported, quoted briefly.\n3. List each claim an entry contradicts.\n4. List the cited entry ids that are about a different subject than the article (they were merged in by mistake).\n5. List facts from the entries that belong in this article and are missing (names, numbers, identifiers, decisions). Ignore small talk.\n6. Verdict: \"good\" (nothing wrong), \"minor\" (wording or a small omission), \"major\" (an unsupported or contradicted fact, a wrong merge, or a lost identifier).\n\nReply with JSON only, no fencing:\n{\"claims\": 0, \"supported\": 0, \"unsupported\": [], \"contradicted\": [], \"off_subject\": [], \"missing\": [], \"verdict\": \"good\"}`\n}\n\nexport function parseJudgeReply(value: unknown): JudgeVerdict | null {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return null\n const v = value as Record<string, unknown>\n const list = (x: unknown) => (Array.isArray(x) ? x.map((s) => String(s)) : [])\n const num = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) && x >= 0 ? Math.round(x) : NaN)\n const claims = num(v.claims)\n if (Number.isNaN(claims)) return null\n const supported = Math.min(claims, Number.isNaN(num(v.supported)) ? claims - list(v.unsupported).length : num(v.supported))\n const verdict = v.verdict === \"good\" || v.verdict === \"minor\" || v.verdict === \"major\" ? v.verdict : null\n if (!verdict) return null\n return {\n claims,\n supported: Math.max(0, supported),\n unsupported: list(v.unsupported),\n contradicted: list(v.contradicted),\n offSubject: list(v.off_subject ?? v.offSubject),\n missing: list(v.missing),\n verdict,\n }\n}\n\n// --- Scorecard ---\n\nexport interface Scorecard {\n sample: { articles: number; seed: string; since?: string; byType: Record<string, number> }\n citations: { withSources: number; missingSources: number; weakSources: number; articlesWithWeak: number }\n grounding: { articlesWithUngrounded: number; ungroundedFacts: number }\n lost: { entriesWithLostFacts: number; lostFacts: number }\n duplicates: { pairs: number; articlesInPair: number }\n /** Entries read in the window that no article cites. */\n uncited?: { entries: number; withLostFacts: number }\n judge?: {\n judged: number\n claims: number\n supported: number\n supportRate: number\n unsupported: number\n contradicted: number\n articlesWithWrongMerge: number\n missingFacts: number\n verdicts: Record<\"good\" | \"minor\" | \"major\", number>\n }\n examples: {\n ungrounded: Array<{ path: string; facts: string[] }>\n lost: Array<{ path: string; entry: string; fact: string }>\n weak: Array<{ path: string; entries: string[] }>\n duplicates: DuplicatePair[]\n uncited: Array<{ entry: string; facts: string[] }>\n judged: Array<{ path: string; verdict: string; unsupported: string[]; contradicted: string[]; offSubject: string[]; missing: string[] }>\n }\n}\n\nexport function buildScorecard(\n checks: ArticleCheck[],\n duplicates: DuplicatePair[],\n meta: { seed: string; since?: string },\n judged: Array<{ path: string; verdict: JudgeVerdict }> = [],\n maxExamples = 5,\n uncited?: { entries: number; lost: Array<{ entry: string; facts: string[] }> },\n): Scorecard {\n const byType: Record<string, number> = {}\n for (const c of checks) byType[c.type ?? \"untyped\"] = (byType[c.type ?? \"untyped\"] ?? 0) + 1\n const lostEntries = new Set<string>()\n const lostKeys = new Set<string>()\n for (const c of checks) for (const l of c.lost) { lostEntries.add(l.entry); lostKeys.add(`${l.entry}|${l.fact}`) }\n const inPair = new Set(duplicates.flatMap((d) => [d.a, d.b]).filter((p) => checks.some((c) => c.path === p)))\n\n const card: Scorecard = {\n sample: { articles: checks.length, seed: meta.seed, since: meta.since, byType },\n citations: {\n withSources: checks.filter((c) => c.sources > 0).length,\n missingSources: checks.reduce((s, c) => s + c.missingSources.length, 0),\n weakSources: checks.reduce((s, c) => s + c.weakSources.length, 0),\n articlesWithWeak: checks.filter((c) => c.weakSources.length > 0).length,\n },\n grounding: {\n articlesWithUngrounded: checks.filter((c) => c.ungrounded.length > 0).length,\n ungroundedFacts: checks.reduce((s, c) => s + c.ungrounded.length, 0),\n },\n lost: { entriesWithLostFacts: lostEntries.size, lostFacts: lostKeys.size },\n duplicates: { pairs: duplicates.length, articlesInPair: inPair.size },\n ...(uncited ? { uncited: { entries: uncited.entries, withLostFacts: uncited.lost.length } } : {}),\n examples: {\n ungrounded: checks.filter((c) => c.ungrounded.length > 0).slice(0, maxExamples).map((c) => ({ path: c.path, facts: c.ungrounded.slice(0, 6) })),\n lost: checks.flatMap((c) => c.lost.map((l) => ({ path: c.path, ...l }))).slice(0, maxExamples),\n weak: checks.filter((c) => c.weakSources.length > 0).slice(0, maxExamples).map((c) => ({ path: c.path, entries: c.weakSources })),\n duplicates: duplicates.slice(0, maxExamples),\n uncited: (uncited?.lost ?? []).slice(0, maxExamples).map((u) => ({ entry: u.entry, facts: u.facts.slice(0, 4) })),\n judged: judged\n .filter((j) => j.verdict.verdict !== \"good\")\n .slice(0, maxExamples)\n .map((j) => ({\n path: j.path,\n verdict: j.verdict.verdict,\n unsupported: j.verdict.unsupported.slice(0, 4),\n contradicted: j.verdict.contradicted.slice(0, 4),\n offSubject: j.verdict.offSubject,\n missing: j.verdict.missing.slice(0, 4),\n })),\n },\n }\n\n if (judged.length > 0) {\n const v = judged.map((j) => j.verdict)\n const claims = v.reduce((s, x) => s + x.claims, 0)\n const supported = v.reduce((s, x) => s + x.supported, 0)\n card.judge = {\n judged: v.length,\n claims,\n supported,\n supportRate: claims > 0 ? supported / claims : 1,\n unsupported: v.reduce((s, x) => s + x.unsupported.length, 0),\n contradicted: v.reduce((s, x) => s + x.contradicted.length, 0),\n articlesWithWrongMerge: v.filter((x) => x.offSubject.length > 0).length,\n missingFacts: v.reduce((s, x) => s + x.missing.length, 0),\n verdicts: {\n good: v.filter((x) => x.verdict === \"good\").length,\n minor: v.filter((x) => x.verdict === \"minor\").length,\n major: v.filter((x) => x.verdict === \"major\").length,\n },\n }\n }\n return card\n}\n\nconst pct = (n: number, d: number) => (d > 0 ? `${Math.round((n / d) * 100)}%` : \"–\")\n\n/** The scorecard as Markdown, for the issue or a PR comment. */\nexport function renderScorecard(card: Scorecard): string {\n const n = card.sample.articles\n const lines = [\n `# Wiki absorb scorecard`,\n \"\",\n `Sample: ${n} articles (seed \\`${card.sample.seed}\\`${card.sample.since ? `, changed since ${card.sample.since}` : \"\"}). `\n + `Types: ${Object.entries(card.sample.byType).map(([t, k]) => `${t} ${k}`).join(\", \") || \"–\"}.`,\n \"\",\n \"| Check | Result | Lower is better? |\",\n \"|---|---|---|\",\n `| Articles citing at least one entry | ${card.citations.withSources}/${n} (${pct(card.citations.withSources, n)}) | no |`,\n `| Cited ids with no entry | ${card.citations.missingSources} | yes |`,\n `| Articles with a weak citation (entry shares <${Math.round(WEAK_CITATION * 100)}% of its words) | ${card.citations.articlesWithWeak}/${n} (${pct(card.citations.articlesWithWeak, n)}) | yes |`,\n `| Articles with an ungrounded commit, link or number | ${card.grounding.articlesWithUngrounded}/${n} (${pct(card.grounding.articlesWithUngrounded, n)}) | yes |`,\n `| Ungrounded facts | ${card.grounding.ungroundedFacts} | yes |`,\n `| Commits or links lost from cited entries | ${card.lost.lostFacts} across ${card.lost.entriesWithLostFacts} entries | yes |`,\n `| Sampled articles in a likely duplicate pair | ${card.duplicates.articlesInPair}/${n} (${pct(card.duplicates.articlesInPair, n)}) | yes |`,\n ]\n if (card.uncited) {\n lines.push(\n `| Entries read in the window but cited by no article | ${card.uncited.entries} | – |`,\n `| …of which carry a commit or link no article has | ${card.uncited.withLostFacts} | yes |`,\n )\n }\n if (card.judge) {\n const j = card.judge\n lines.push(\n `| Judge: claims supported by the cited entries | ${j.supported}/${j.claims} (${pct(j.supported, j.claims)}) | no |`,\n `| Judge: unsupported / contradicted claims | ${j.unsupported} / ${j.contradicted} | yes |`,\n `| Judge: articles with an off-subject source (wrong merge) | ${j.articlesWithWrongMerge}/${j.judged} (${pct(j.articlesWithWrongMerge, j.judged)}) | yes |`,\n `| Judge: facts missing from the article | ${j.missingFacts} | yes |`,\n `| Judge verdicts good / minor / major | ${j.verdicts.good} / ${j.verdicts.minor} / ${j.verdicts.major} | – |`,\n )\n }\n const ex = card.examples\n const section = (title: string, rows: string[]) => {\n if (rows.length === 0) return\n lines.push(\"\", `## ${title}`, \"\", ...rows)\n }\n section(\"Examples: ungrounded facts\", ex.ungrounded.map((e) => `- \\`${e.path}\\`: ${e.facts.join(\"; \")}`))\n section(\"Examples: lost facts\", ex.lost.map((e) => `- \\`${e.path}\\` ← entry \\`${e.entry}\\`: ${e.fact}`))\n section(\"Examples: weak citations\", ex.weak.map((e) => `- \\`${e.path}\\`: ${e.entries.map((x) => `\\`${x}\\``).join(\", \")}`))\n section(\"Examples: uncited entries with facts no article has\", ex.uncited.map((u) => `- \\`${u.entry}\\`: ${u.facts.join(\"; \")}`))\n section(\"Examples: likely duplicates\", ex.duplicates.map((d) => `- \\`${d.a}\\` ↔ \\`${d.b}\\` (${d.reason}, ${d.score.toFixed(2)})`))\n section(\n \"Examples: judge findings\",\n ex.judged.map((e) => {\n const parts = [\n e.unsupported.length ? `unsupported: ${e.unsupported.join(\" | \")}` : \"\",\n e.contradicted.length ? `contradicted: ${e.contradicted.join(\" | \")}` : \"\",\n e.offSubject.length ? `off-subject: ${e.offSubject.join(\", \")}` : \"\",\n e.missing.length ? `missing: ${e.missing.join(\" | \")}` : \"\",\n ].filter(Boolean)\n return `- \\`${e.path}\\` (${e.verdict}): ${parts.join(\"; \")}`\n }),\n )\n lines.push(\n \"\",\n \"## Method\",\n \"\",\n \"- The sample is drawn with a seeded shuffle from the articles changed in the window, so the same seed and window give the same articles.\",\n \"- Ungrounded: a commit hash, link or number (three digits or more, or a date) in the article that no cited entry and no earlier version of the article contains.\",\n \"- Lost: a commit hash or link in a cited entry that no article citing that entry contains.\",\n \"- Uncited: entries the absorb ledger marks as read in the window that no article cites; those carrying a commit or link that no article on the node has are counted as lost, since absorb will not offer them again.\",\n \"- Weak citation: a cited entry sharing fewer than 15% of its distinctive words with the article.\",\n \"- Duplicate: two articles of the same type whose titles share at least 75% of their words, or which share at least half their sources.\",\n \"- Judge (optional): one model call per article reads the article and its cited entries and lists unsupported, contradicted, off-subject and missing items.\",\n )\n return lines.join(\"\\n\") + \"\\n\"\n}\n\n// --- Run telemetry ---\n\n/** One compile call, as appended to `_absorb-runs.jsonl`. */\nexport interface AbsorbCallRecord {\n kind: \"call\"\n at: string\n label?: string\n agent: string\n model: string\n entries: number\n articles: number\n refused: number\n /** Entries held by a refused save that another saved article cites:\n * they leave the queue, so the refused update is never retried. */\n heldCited?: number\n /** Wiki notes (#831) the call was given, patched, and recorded. */\n notes?: number\n notesPatched?: number\n notesRecorded?: number\n failed: boolean\n /** The model call alone. */\n wallMs: number\n /** Retrieval, fact lookups and prompt building before the call. */\n prepMs?: number\n promptChars: number\n promptParts?: Record<string, number>\n costUsd?: number\n apiMs?: number\n inputTokens?: number\n outputTokens?: number\n cacheReadTokens?: number\n cacheWriteTokens?: number\n}\n\n/** One whole `wiki absorb` invocation. */\nexport interface AbsorbRunRecord {\n kind: \"run\"\n label?: string\n startedAt: string\n endedAt: string\n max: number\n model: string\n}\n\n/** Cost and timing fields from the claude CLI's `--output-format json` envelope. */\nexport function envelopeUsage(envelope: unknown): Partial<AbsorbCallRecord> {\n if (!envelope || typeof envelope !== \"object\") return {}\n const e = envelope as Record<string, any>\n const u = (e.usage ?? {}) as Record<string, unknown>\n const n = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) ? x : undefined)\n return {\n costUsd: n(e.total_cost_usd) ?? n(e.cost_usd),\n apiMs: n(e.duration_api_ms),\n inputTokens: n(u.input_tokens),\n outputTokens: n(u.output_tokens),\n cacheReadTokens: n(u.cache_read_input_tokens),\n cacheWriteTokens: n(u.cache_creation_input_tokens),\n }\n}\n\nexport interface RunSummary {\n label: string\n calls: number\n failed: number\n entries: number\n articles: number\n refused: number\n heldCited: number\n /** First call start to last call end, or the run records' span when present. */\n wallMs: number\n callMsP50: number\n callMsP95: number\n /** Time spent before the model calls, summed. */\n prepMs: number\n costUsd: number\n costPerEntry: number\n entriesPerMinute: number\n promptChars: number\n}\n\nfunction percentile(sorted: number[], p: number): number {\n if (sorted.length === 0) return 0\n return sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))]\n}\n\n/** Totals per run label from the telemetry lines. Calls without a label group under \"(none)\". */\nexport function summariseRuns(records: Array<AbsorbCallRecord | AbsorbRunRecord>): RunSummary[] {\n const groups = new Map<string, { calls: AbsorbCallRecord[]; runs: AbsorbRunRecord[] }>()\n const group = (label?: string) => {\n const key = label || \"(none)\"\n let g = groups.get(key)\n if (!g) groups.set(key, (g = { calls: [], runs: [] }))\n return g\n }\n for (const r of records) {\n if (r.kind === \"call\") group(r.label).calls.push(r)\n else if (r.kind === \"run\") group(r.label).runs.push(r)\n }\n const out: RunSummary[] = []\n for (const [label, { calls, runs }] of groups) {\n if (calls.length === 0) continue\n const ms = calls.map((c) => c.wallMs).sort((a, b) => a - b)\n let wallMs: number\n if (runs.length > 0) {\n wallMs = runs.reduce((s, r) => s + (Date.parse(r.endedAt) - Date.parse(r.startedAt)), 0)\n } else {\n const starts = calls.map((c) => Date.parse(c.at) - c.wallMs)\n const ends = calls.map((c) => Date.parse(c.at))\n wallMs = Math.max(...ends) - Math.min(...starts)\n }\n const entries = calls.reduce((s, c) => s + c.entries, 0)\n const costUsd = calls.reduce((s, c) => s + (c.costUsd ?? 0), 0)\n out.push({\n label,\n calls: calls.length,\n failed: calls.filter((c) => c.failed).length,\n entries,\n articles: calls.reduce((s, c) => s + c.articles, 0),\n refused: calls.reduce((s, c) => s + c.refused, 0),\n heldCited: calls.reduce((s, c) => s + (c.heldCited ?? 0), 0),\n wallMs,\n callMsP50: percentile(ms, 0.5),\n callMsP95: percentile(ms, 0.95),\n prepMs: calls.reduce((s, c) => s + (c.prepMs ?? 0), 0),\n costUsd,\n costPerEntry: entries > 0 ? costUsd / entries : 0,\n entriesPerMinute: wallMs > 0 ? (entries / wallMs) * 60_000 : 0,\n promptChars: calls.reduce((s, c) => s + c.promptChars, 0),\n })\n }\n return out.sort((a, b) => a.label.localeCompare(b.label))\n}\n"],"mappings":"wCAoCO,SAASA,EAAaC,EAA4B,CACvD,IAAIC,EAAI,WAAaD,EAAK,OAC1B,QAASE,EAAI,EAAGA,EAAIF,EAAK,OAAQE,IAC/BD,EAAI,KAAK,KAAKA,EAAID,EAAK,WAAWE,CAAC,EAAG,UAAU,EAChDD,EAAKA,GAAK,GAAOA,IAAM,GAEzB,IAAIE,EAAIF,IAAM,EACd,MAAO,IAAM,CACXE,EAAKA,EAAI,aAAgB,EACzB,IAAIC,EAAID,EACR,OAAAC,EAAI,KAAK,KAAKA,EAAKA,IAAM,GAAKA,EAAI,CAAC,EACnCA,GAAKA,EAAI,KAA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CAAM,EAEjD,IAAMzF,EAAUqF,EAAM,OAAO,CAAC9C,EAAG,IAAMA,EAAI,EAAE,QAAS,CAAC,EACjDoD,EAAUN,EAAM,OAAO,CAAC9C,EAAG,IAAMA,GAAK,EAAE,SAAW,GAAI,CAAC,EAC9D1D,EAAI,KAAK,CACP,MAAAqG,EACA,MAAOG,EAAM,OACb,OAAQA,EAAM,OAAQxE,GAAMA,EAAE,MAAM,EAAE,OACtC,QAAAb,EACA,SAAUqF,EAAM,OAAO,CAAC9C,EAAG,IAAMA,EAAI,EAAE,SAAU,CAAC,EAClD,QAAS8C,EAAM,OAAO,CAAC9C,EAAG,IAAMA,EAAI,EAAE,QAAS,CAAC,EAChD,UAAW8C,EAAM,OAAO,CAAC9C,EAAG,IAAMA,GAAK,EAAE,WAAa,GAAI,CAAC,EAC3D,OAAAiD,EACA,UAAWZ,EAAWW,EAAI,EAAG,EAC7B,UAAWX,EAAWW,EAAI,GAAI,EAC9B,OAAQF,EAAM,OAAO,CAAC9C,EAAG,IAAMA,GAAK,EAAE,QAAU,GAAI,CAAC,EACrD,QAAAoD,EACA,aAAc3F,EAAU,EAAI2F,EAAU3F,EAAU,EAChD,iBAAkBwF,EAAS,EAAKxF,EAAUwF,EAAU,IAAS,EAC7D,YAAaH,EAAM,OAAO,CAAC9C,EAAG,IAAMA,EAAI,EAAE,YAAa,CAAC,CAC1D,CAAC,EAEH,OAAO1D,EAAI,KAAK,CAACZ,EAAGO,IAAMP,EAAE,MAAM,cAAcO,EAAE,KAAK,CAAC,CAC1D","names":["seededRandom","seed","h","i","a","t","pickSample","items","n","rng","pool","b","j","STOP","terms","text","out","m","termOverlap","entry","article","e","hit","WEAK_CITATION","factStrings","f","extractFacts","hasCommit","haystack","commit","known","k","urlKey","u","checkArticle","entries","citersOf","cited","id","missingSources","weakSources","grounding","groundLower","g","groundUrls","groundNumbers","mine","ungrounded","c","lost","facts","carriers","carrierFacts","uncitedWithFacts","uncited","allArticles","lower","missing","TITLE_STOP","titleTerms","title","w","jaccard","inter","x","findDuplicates","catalog","focus","opts","titleMin","sourcesMin","rows","pairs","y","s","p","q","JUDGE_ENTRY_CHARS","buildJudgePrompt","sourceBlock","body","earlier","parseJudgeReply","value","v","list","num","claims","supported","verdict","buildScorecard","checks","duplicates","meta","judged","maxExamples","byType","lostEntries","lostKeys","l","inPair","d","card","pct","renderScorecard","lines","ex","section","parts","envelopeUsage","envelope","percentile","sorted","summariseRuns","records","groups","group","label","key","r","calls","runs","ms","wallMs","starts","ends","costUsd"]}
1
+ {"version":3,"sources":["../src/wiki/absorb-eval.ts"],"sourcesContent":["// Measuring what `agentx wiki absorb` writes (#808).\n//\n// Absorb turns raw entries into articles, and until now nothing checked\n// the result against the entries it came from. This module is the\n// scorecard: a fixed, seeded sample of articles, five checks per article,\n// and an optional model judge for the questions a string match cannot\n// answer (is this claim supported, does this source belong here).\n//\n// The deterministic checks are deliberately narrow. A commit hash or URL\n// in an article that no cited entry and no earlier version carries is\n// almost certainly made up or mis-attributed; a commit or URL in a cited\n// entry that no article carries was almost certainly lost. Prose claims\n// are left to the judge.\n\nimport { extractFacts } from \"./absorb-context\"\n\nexport interface EvalArticle {\n path: string\n title: string\n type?: string\n content: string\n sources: string[]\n lastUpdated?: string\n /** The article body before this absorb touched it, when one exists. */\n previous?: string\n}\n\nexport interface EvalEntry {\n id: string\n date?: string\n content: string\n}\n\n// --- Sample ---\n\n/** A small seeded PRNG, so a sample can be drawn again from the same seed. */\nexport function seededRandom(seed: string): () => number {\n let h = 1779033703 ^ seed.length\n for (let i = 0; i < seed.length; i++) {\n h = Math.imul(h ^ seed.charCodeAt(i), 3432918353)\n h = (h << 13) | (h >>> 19)\n }\n let a = h >>> 0\n return () => {\n a = (a + 0x6d2b79f5) >>> 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/** `n` items picked without replacement. Same items and seed, same pick. */\nexport function pickSample<T extends { path: string }>(items: T[], n: number, seed: string): T[] {\n const rng = seededRandom(seed)\n const pool = [...items].sort((a, b) => a.path.localeCompare(b.path))\n for (let i = pool.length - 1; i > 0; i--) {\n const j = Math.floor(rng() * (i + 1))\n ;[pool[i], pool[j]] = [pool[j], pool[i]]\n }\n return pool.slice(0, Math.max(0, n)).sort((a, b) => a.path.localeCompare(b.path))\n}\n\n// --- Terms ---\n\nconst STOP = new Set(\n (\"about after again also because been before being between could does doing during each from have having here into \"\n + \"just more most only other over same should some such than that their them then there these they this those \"\n + \"through under until very were what when where which while will with would your yours user assistant agent \"\n + \"message entry please thanks\").split(\" \"),\n)\n\n/** Distinctive words: four letters or more, lower-cased, minus common ones. */\nexport function terms(text: string): Set<string> {\n const out = new Set<string>()\n for (const m of text.toLowerCase().matchAll(/[\\p{L}\\p{N}][\\p{L}\\p{N}_-]{3,}/gu)) {\n if (!STOP.has(m[0])) out.add(m[0])\n }\n return out\n}\n\n/** Share of `entry`'s distinctive words that appear in `article`. */\nexport function termOverlap(entry: string, article: string): number {\n const e = terms(entry)\n if (e.size === 0) return 1\n const a = terms(article)\n let hit = 0\n for (const t of e) if (a.has(t)) hit++\n return hit / e.size\n}\n\n// --- Per-article checks ---\n\n/** Below this share of shared words a cited entry is flagged as weak. */\nexport const WEAK_CITATION = 0.15\n\nexport interface ArticleCheck {\n path: string\n title: string\n type?: string\n sources: number\n /** Cited ids with no entry behind them. */\n missingSources: string[]\n /** Cited entries that share almost no words with the article. */\n weakSources: string[]\n /** Commits, links and numbers in the article that neither a cited entry\n * nor the earlier version carries. */\n ungrounded: string[]\n /** Commits and links in a cited entry that no article citing it carries. */\n lost: Array<{ entry: string; fact: string }>\n}\n\n/** What a fact looks like when matched against grounding text. */\nfunction factStrings(text: string): { commits: string[]; urls: string[]; numbers: string[] } {\n const f = extractFacts(text)\n return { commits: f.commits, urls: f.urls, numbers: f.numbers }\n}\n\nfunction hasCommit(haystack: string, commit: string, known: string[]): boolean {\n return haystack.includes(commit) || known.some((k) => k.startsWith(commit) || commit.startsWith(k))\n}\n\nconst urlKey = (u: string) => u.toLowerCase().replace(/\\/+$/, \"\")\n\n/**\n * Check one article against its cited entries.\n *\n * `citersOf` returns every article (in the whole wiki, not only the\n * sample) that cites an entry, so a fact moved to a sibling article is\n * not counted as lost.\n */\nexport function checkArticle(\n article: EvalArticle,\n entries: Map<string, EvalEntry>,\n citersOf: (entryId: string) => string[],\n): ArticleCheck {\n const cited = article.sources.map((id) => entries.get(id)).filter((e): e is EvalEntry => !!e)\n const missingSources = article.sources.filter((id) => !entries.has(id))\n\n const weakSources = cited\n .filter((e) => terms(e.content).size >= 5 && termOverlap(e.content, article.content) < WEAK_CITATION)\n .map((e) => e.id)\n\n // Grounding: entry text with its date (absorb is shown the date in the\n // entry header), plus the earlier version of the article.\n const grounding = [...cited.map((e) => `${e.date ?? \"\"}\\n${e.content}`), article.previous ?? \"\"].join(\"\\n\")\n const groundLower = grounding.toLowerCase()\n const g = factStrings(grounding)\n const groundUrls = new Set(g.urls.map(urlKey))\n const groundNumbers = new Set(g.numbers)\n const mine = factStrings(article.content)\n const ungrounded: string[] = []\n for (const c of mine.commits) if (!hasCommit(groundLower, c, g.commits)) ungrounded.push(`commit ${c}`)\n for (const u of mine.urls) if (!groundUrls.has(urlKey(u)) && !groundLower.includes(urlKey(u))) ungrounded.push(`link ${u}`)\n for (const n of mine.numbers) {\n // Bare small integers (\"2 tests\", \"3 people\") are too common to judge.\n if (/^\\d{1,2}$/.test(n)) continue\n if (!groundNumbers.has(n) && !groundLower.includes(n)) ungrounded.push(`number ${n}`)\n }\n\n const lost: Array<{ entry: string; fact: string }> = []\n for (const e of cited) {\n const facts = factStrings(e.content)\n if (facts.commits.length === 0 && facts.urls.length === 0) continue\n const carriers = citersOf(e.id)\n const text = (carriers.length > 0 ? carriers : [article.content]).join(\"\\n\").toLowerCase()\n const carrierFacts = factStrings(text)\n for (const c of facts.commits) if (!hasCommit(text, c, carrierFacts.commits)) lost.push({ entry: e.id, fact: `commit ${c}` })\n for (const u of facts.urls) if (!text.includes(urlKey(u))) lost.push({ entry: e.id, fact: `link ${u}` })\n }\n\n return {\n path: article.path,\n title: article.title,\n type: article.type,\n sources: article.sources.length,\n missingSources,\n weakSources,\n ungrounded,\n lost,\n }\n}\n\n// --- Uncited entries ---\n\n/**\n * Entries absorb read and cited nowhere that carry a commit or link no\n * article on the node has. A successful run marks every entry it read as\n * done (#762), so a fact in an entry the model passed over is gone from\n * the queue for good; the per-article \"lost\" check cannot see it because\n * no article points back at the entry.\n */\nexport function uncitedWithFacts(\n uncited: EvalEntry[],\n allArticles: string,\n): Array<{ entry: string; facts: string[] }> {\n const lower = allArticles.toLowerCase()\n const known = extractFacts(allArticles).commits\n const out: Array<{ entry: string; facts: string[] }> = []\n for (const e of uncited) {\n const f = extractFacts(e.content)\n const missing = [\n ...f.commits.filter((c) => !hasCommit(lower, c, known)).map((c) => `commit ${c}`),\n ...f.urls.filter((u) => !lower.includes(urlKey(u))).map((u) => `link ${u}`),\n ]\n if (missing.length > 0) out.push({ entry: e.id, facts: missing })\n }\n return out\n}\n\n// --- Duplicates ---\n\nexport interface DuplicatePair {\n a: string\n b: string\n reason: \"title\" | \"sources\"\n score: number\n}\n\nconst TITLE_STOP = new Set(\"the and for with from into of on in at to by an a\".split(\" \"))\n\nfunction titleTerms(title: string): Set<string> {\n return new Set(\n (title || \"\").toLowerCase().split(/[^\\p{L}\\p{N}]+/u).filter((w) => (w.length > 1 || /\\d/.test(w)) && !TITLE_STOP.has(w) && !STOP.has(w)),\n )\n}\n\nfunction jaccard<T>(a: Set<T>, b: Set<T>): number {\n if (a.size === 0 || b.size === 0) return 0\n let inter = 0\n for (const x of a) if (b.has(x)) inter++\n return inter / (a.size + b.size - inter)\n}\n\n/**\n * Pairs of articles that look like one subject filed twice: the same type\n * and near-identical title words, or most of their sources in common.\n * Only pairs touching `focus` are returned when it is given.\n */\nexport function findDuplicates(\n catalog: Array<{ path: string; title: string; type?: string; sources?: string[] }>,\n focus?: Set<string>,\n opts: { titleMin?: number; sourcesMin?: number } = {},\n): DuplicatePair[] {\n const titleMin = opts.titleMin ?? 0.75\n const sourcesMin = opts.sourcesMin ?? 0.5\n const rows = catalog.map((a) => ({ ...a, tt: titleTerms(a.title), ss: new Set(a.sources ?? []) }))\n const pairs: DuplicatePair[] = []\n for (let i = 0; i < rows.length; i++) {\n for (let j = i + 1; j < rows.length; j++) {\n const x = rows[i], y = rows[j]\n if (focus && !focus.has(x.path) && !focus.has(y.path)) continue\n const t = (x.type ?? \"\") === (y.type ?? \"\") ? jaccard(x.tt, y.tt) : 0\n if (t >= titleMin) { pairs.push({ a: x.path, b: y.path, reason: \"title\", score: t }); continue }\n if (x.ss.size >= 2 && y.ss.size >= 2) {\n const s = jaccard(x.ss, y.ss)\n if (s >= sourcesMin) pairs.push({ a: x.path, b: y.path, reason: \"sources\", score: s })\n }\n }\n }\n return pairs.sort((p, q) => q.score - p.score || p.a.localeCompare(q.a))\n}\n\n// --- Model judge ---\n\nexport interface JudgeVerdict {\n claims: number\n supported: number\n unsupported: string[]\n contradicted: string[]\n /** Cited entry ids that are about a different subject (a wrong merge). */\n offSubject: string[]\n /** Facts in the entries that belong in this article and are missing. */\n missing: string[]\n verdict: \"good\" | \"minor\" | \"major\"\n}\n\n/** Per-entry cap in the judge prompt, so one long transcript cannot crowd out the rest. */\nexport const JUDGE_ENTRY_CHARS = 4000\n\nexport function buildJudgePrompt(article: EvalArticle, entries: EvalEntry[]): string {\n const sourceBlock = entries\n .map((e) => {\n const body = e.content.length > JUDGE_ENTRY_CHARS ? `${e.content.slice(0, JUDGE_ENTRY_CHARS)}\\n[…cut]` : e.content\n return `--- ENTRY ${e.id} [${e.date ?? \"\"}] ---\\n${body}\\n--- END ENTRY ---`\n })\n .join(\"\\n\\n\")\n const earlier = article.previous\n ? `\\n## Earlier version of the article (facts here count as supported)\\n\\n${article.previous}\\n`\n : \"\"\n return `You are auditing one wiki article against the raw entries it cites. Do not use outside knowledge.\n\n## Article: ${article.title} (${article.type ?? \"untyped\"}, ${article.path})\n\n${article.content}\n${earlier}\n## Cited entries (${entries.length})\n\n${sourceBlock || \"(none)\"}\n\n## What to report\n\n1. Split the article into factual claims (one per sentence or bullet; skip headings and \"unknown\" placeholders). Count them.\n2. A claim is supported when a cited entry or the earlier version states it or plainly implies it. List each claim that is not supported, quoted briefly.\n3. List each claim an entry contradicts.\n4. List the cited entry ids that are about a different subject than the article (they were merged in by mistake).\n5. List facts from the entries that belong in this article and are missing (names, numbers, identifiers, decisions). Ignore small talk.\n6. Verdict: \"good\" (nothing wrong), \"minor\" (wording or a small omission), \"major\" (an unsupported or contradicted fact, a wrong merge, or a lost identifier).\n\nReply with JSON only, no fencing:\n{\"claims\": 0, \"supported\": 0, \"unsupported\": [], \"contradicted\": [], \"off_subject\": [], \"missing\": [], \"verdict\": \"good\"}`\n}\n\nexport function parseJudgeReply(value: unknown): JudgeVerdict | null {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return null\n const v = value as Record<string, unknown>\n const list = (x: unknown) => (Array.isArray(x) ? x.map((s) => String(s)) : [])\n const num = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) && x >= 0 ? Math.round(x) : NaN)\n const claims = num(v.claims)\n if (Number.isNaN(claims)) return null\n const supported = Math.min(claims, Number.isNaN(num(v.supported)) ? claims - list(v.unsupported).length : num(v.supported))\n const verdict = v.verdict === \"good\" || v.verdict === \"minor\" || v.verdict === \"major\" ? v.verdict : null\n if (!verdict) return null\n return {\n claims,\n supported: Math.max(0, supported),\n unsupported: list(v.unsupported),\n contradicted: list(v.contradicted),\n offSubject: list(v.off_subject ?? v.offSubject),\n missing: list(v.missing),\n verdict,\n }\n}\n\n// --- Scorecard ---\n\nexport interface Scorecard {\n sample: { articles: number; seed: string; since?: string; byType: Record<string, number> }\n citations: { withSources: number; missingSources: number; weakSources: number; articlesWithWeak: number }\n grounding: { articlesWithUngrounded: number; ungroundedFacts: number }\n lost: { entriesWithLostFacts: number; lostFacts: number }\n duplicates: { pairs: number; articlesInPair: number }\n /** Entries read in the window that no article cites. */\n uncited?: { entries: number; withLostFacts: number }\n judge?: {\n judged: number\n claims: number\n supported: number\n supportRate: number\n unsupported: number\n contradicted: number\n articlesWithWrongMerge: number\n missingFacts: number\n verdicts: Record<\"good\" | \"minor\" | \"major\", number>\n }\n examples: {\n ungrounded: Array<{ path: string; facts: string[] }>\n lost: Array<{ path: string; entry: string; fact: string }>\n weak: Array<{ path: string; entries: string[] }>\n duplicates: DuplicatePair[]\n uncited: Array<{ entry: string; facts: string[] }>\n judged: Array<{ path: string; verdict: string; unsupported: string[]; contradicted: string[]; offSubject: string[]; missing: string[] }>\n }\n}\n\nexport function buildScorecard(\n checks: ArticleCheck[],\n duplicates: DuplicatePair[],\n meta: { seed: string; since?: string },\n judged: Array<{ path: string; verdict: JudgeVerdict }> = [],\n maxExamples = 5,\n uncited?: { entries: number; lost: Array<{ entry: string; facts: string[] }> },\n): Scorecard {\n const byType: Record<string, number> = {}\n for (const c of checks) byType[c.type ?? \"untyped\"] = (byType[c.type ?? \"untyped\"] ?? 0) + 1\n const lostEntries = new Set<string>()\n const lostKeys = new Set<string>()\n for (const c of checks) for (const l of c.lost) { lostEntries.add(l.entry); lostKeys.add(`${l.entry}|${l.fact}`) }\n const inPair = new Set(duplicates.flatMap((d) => [d.a, d.b]).filter((p) => checks.some((c) => c.path === p)))\n\n const card: Scorecard = {\n sample: { articles: checks.length, seed: meta.seed, since: meta.since, byType },\n citations: {\n withSources: checks.filter((c) => c.sources > 0).length,\n missingSources: checks.reduce((s, c) => s + c.missingSources.length, 0),\n weakSources: checks.reduce((s, c) => s + c.weakSources.length, 0),\n articlesWithWeak: checks.filter((c) => c.weakSources.length > 0).length,\n },\n grounding: {\n articlesWithUngrounded: checks.filter((c) => c.ungrounded.length > 0).length,\n ungroundedFacts: checks.reduce((s, c) => s + c.ungrounded.length, 0),\n },\n lost: { entriesWithLostFacts: lostEntries.size, lostFacts: lostKeys.size },\n duplicates: { pairs: duplicates.length, articlesInPair: inPair.size },\n ...(uncited ? { uncited: { entries: uncited.entries, withLostFacts: uncited.lost.length } } : {}),\n examples: {\n ungrounded: checks.filter((c) => c.ungrounded.length > 0).slice(0, maxExamples).map((c) => ({ path: c.path, facts: c.ungrounded.slice(0, 6) })),\n lost: checks.flatMap((c) => c.lost.map((l) => ({ path: c.path, ...l }))).slice(0, maxExamples),\n weak: checks.filter((c) => c.weakSources.length > 0).slice(0, maxExamples).map((c) => ({ path: c.path, entries: c.weakSources })),\n duplicates: duplicates.slice(0, maxExamples),\n uncited: (uncited?.lost ?? []).slice(0, maxExamples).map((u) => ({ entry: u.entry, facts: u.facts.slice(0, 4) })),\n judged: judged\n .filter((j) => j.verdict.verdict !== \"good\")\n .slice(0, maxExamples)\n .map((j) => ({\n path: j.path,\n verdict: j.verdict.verdict,\n unsupported: j.verdict.unsupported.slice(0, 4),\n contradicted: j.verdict.contradicted.slice(0, 4),\n offSubject: j.verdict.offSubject,\n missing: j.verdict.missing.slice(0, 4),\n })),\n },\n }\n\n if (judged.length > 0) {\n const v = judged.map((j) => j.verdict)\n const claims = v.reduce((s, x) => s + x.claims, 0)\n const supported = v.reduce((s, x) => s + x.supported, 0)\n card.judge = {\n judged: v.length,\n claims,\n supported,\n supportRate: claims > 0 ? supported / claims : 1,\n unsupported: v.reduce((s, x) => s + x.unsupported.length, 0),\n contradicted: v.reduce((s, x) => s + x.contradicted.length, 0),\n articlesWithWrongMerge: v.filter((x) => x.offSubject.length > 0).length,\n missingFacts: v.reduce((s, x) => s + x.missing.length, 0),\n verdicts: {\n good: v.filter((x) => x.verdict === \"good\").length,\n minor: v.filter((x) => x.verdict === \"minor\").length,\n major: v.filter((x) => x.verdict === \"major\").length,\n },\n }\n }\n return card\n}\n\nconst pct = (n: number, d: number) => (d > 0 ? `${Math.round((n / d) * 100)}%` : \"–\")\n\n/** The scorecard as Markdown, for the issue or a PR comment. */\nexport function renderScorecard(card: Scorecard): string {\n const n = card.sample.articles\n const lines = [\n `# Wiki absorb scorecard`,\n \"\",\n `Sample: ${n} articles (seed \\`${card.sample.seed}\\`${card.sample.since ? `, changed since ${card.sample.since}` : \"\"}). `\n + `Types: ${Object.entries(card.sample.byType).map(([t, k]) => `${t} ${k}`).join(\", \") || \"–\"}.`,\n \"\",\n \"| Check | Result | Lower is better? |\",\n \"|---|---|---|\",\n `| Articles citing at least one entry | ${card.citations.withSources}/${n} (${pct(card.citations.withSources, n)}) | no |`,\n `| Cited ids with no entry | ${card.citations.missingSources} | yes |`,\n `| Articles with a weak citation (entry shares <${Math.round(WEAK_CITATION * 100)}% of its words) | ${card.citations.articlesWithWeak}/${n} (${pct(card.citations.articlesWithWeak, n)}) | yes |`,\n `| Articles with an ungrounded commit, link or number | ${card.grounding.articlesWithUngrounded}/${n} (${pct(card.grounding.articlesWithUngrounded, n)}) | yes |`,\n `| Ungrounded facts | ${card.grounding.ungroundedFacts} | yes |`,\n `| Commits or links lost from cited entries | ${card.lost.lostFacts} across ${card.lost.entriesWithLostFacts} entries | yes |`,\n `| Sampled articles in a likely duplicate pair | ${card.duplicates.articlesInPair}/${n} (${pct(card.duplicates.articlesInPair, n)}) | yes |`,\n ]\n if (card.uncited) {\n lines.push(\n `| Entries read in the window but cited by no article | ${card.uncited.entries} | – |`,\n `| …of which carry a commit or link no article has | ${card.uncited.withLostFacts} | yes |`,\n )\n }\n if (card.judge) {\n const j = card.judge\n lines.push(\n `| Judge: claims supported by the cited entries | ${j.supported}/${j.claims} (${pct(j.supported, j.claims)}) | no |`,\n `| Judge: unsupported / contradicted claims | ${j.unsupported} / ${j.contradicted} | yes |`,\n `| Judge: articles with an off-subject source (wrong merge) | ${j.articlesWithWrongMerge}/${j.judged} (${pct(j.articlesWithWrongMerge, j.judged)}) | yes |`,\n `| Judge: facts missing from the article | ${j.missingFacts} | yes |`,\n `| Judge verdicts good / minor / major | ${j.verdicts.good} / ${j.verdicts.minor} / ${j.verdicts.major} | – |`,\n )\n }\n const ex = card.examples\n const section = (title: string, rows: string[]) => {\n if (rows.length === 0) return\n lines.push(\"\", `## ${title}`, \"\", ...rows)\n }\n section(\"Examples: ungrounded facts\", ex.ungrounded.map((e) => `- \\`${e.path}\\`: ${e.facts.join(\"; \")}`))\n section(\"Examples: lost facts\", ex.lost.map((e) => `- \\`${e.path}\\` ← entry \\`${e.entry}\\`: ${e.fact}`))\n section(\"Examples: weak citations\", ex.weak.map((e) => `- \\`${e.path}\\`: ${e.entries.map((x) => `\\`${x}\\``).join(\", \")}`))\n section(\"Examples: uncited entries with facts no article has\", ex.uncited.map((u) => `- \\`${u.entry}\\`: ${u.facts.join(\"; \")}`))\n section(\"Examples: likely duplicates\", ex.duplicates.map((d) => `- \\`${d.a}\\` ↔ \\`${d.b}\\` (${d.reason}, ${d.score.toFixed(2)})`))\n section(\n \"Examples: judge findings\",\n ex.judged.map((e) => {\n const parts = [\n e.unsupported.length ? `unsupported: ${e.unsupported.join(\" | \")}` : \"\",\n e.contradicted.length ? `contradicted: ${e.contradicted.join(\" | \")}` : \"\",\n e.offSubject.length ? `off-subject: ${e.offSubject.join(\", \")}` : \"\",\n e.missing.length ? `missing: ${e.missing.join(\" | \")}` : \"\",\n ].filter(Boolean)\n return `- \\`${e.path}\\` (${e.verdict}): ${parts.join(\"; \")}`\n }),\n )\n lines.push(\n \"\",\n \"## Method\",\n \"\",\n \"- The sample is drawn with a seeded shuffle from the articles changed in the window, so the same seed and window give the same articles.\",\n \"- Ungrounded: a commit hash, link or number (three digits or more, or a date) in the article that no cited entry and no earlier version of the article contains.\",\n \"- Lost: a commit hash or link in a cited entry that no article citing that entry contains.\",\n \"- Uncited: entries the absorb ledger marks as read in the window that no article cites; those carrying a commit or link that no article on the node has are counted as lost, since absorb will not offer them again.\",\n \"- Weak citation: a cited entry sharing fewer than 15% of its distinctive words with the article.\",\n \"- Duplicate: two articles of the same type whose titles share at least 75% of their words, or which share at least half their sources.\",\n \"- Judge (optional): one model call per article reads the article and its cited entries and lists unsupported, contradicted, off-subject and missing items.\",\n )\n return lines.join(\"\\n\") + \"\\n\"\n}\n\n// --- Run telemetry ---\n\n/** One compile call, as appended to `_absorb-runs.jsonl`. */\nexport interface AbsorbCallRecord {\n kind: \"call\"\n at: string\n label?: string\n agent: string\n model: string\n entries: number\n articles: number\n refused: number\n /** Entries held by a refused save that another saved article cites:\n * they leave the queue, so the refused update is never retried. */\n heldCited?: number\n /** Wiki notes (#831) the call was given, patched, and recorded. */\n notes?: number\n notesPatched?: number\n notesRecorded?: number\n failed: boolean\n /** The model call alone. */\n wallMs: number\n /** Retrieval, fact lookups and prompt building before the call. */\n prepMs?: number\n promptChars: number\n promptParts?: Record<string, number>\n costUsd?: number\n apiMs?: number\n inputTokens?: number\n outputTokens?: number\n cacheReadTokens?: number\n cacheWriteTokens?: number\n}\n\n/** One whole `wiki absorb` invocation. */\nexport interface AbsorbRunRecord {\n kind: \"run\"\n label?: string\n startedAt: string\n endedAt: string\n max: number\n model: string\n /** Compile calls in this run that failed. Absent on runs before #603. */\n failed?: number\n}\n\n/** Cost and timing fields from the claude CLI's `--output-format json` envelope. */\nexport function envelopeUsage(envelope: unknown): Partial<AbsorbCallRecord> {\n if (!envelope || typeof envelope !== \"object\") return {}\n const e = envelope as Record<string, any>\n const u = (e.usage ?? {}) as Record<string, unknown>\n const n = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) ? x : undefined)\n return {\n costUsd: n(e.total_cost_usd) ?? n(e.cost_usd),\n apiMs: n(e.duration_api_ms),\n inputTokens: n(u.input_tokens),\n outputTokens: n(u.output_tokens),\n cacheReadTokens: n(u.cache_read_input_tokens),\n cacheWriteTokens: n(u.cache_creation_input_tokens),\n }\n}\n\nexport interface RunSummary {\n label: string\n calls: number\n failed: number\n entries: number\n articles: number\n refused: number\n heldCited: number\n /** First call start to last call end, or the run records' span when present. */\n wallMs: number\n callMsP50: number\n callMsP95: number\n /** Time spent before the model calls, summed. */\n prepMs: number\n costUsd: number\n costPerEntry: number\n entriesPerMinute: number\n promptChars: number\n}\n\nfunction percentile(sorted: number[], p: number): number {\n if (sorted.length === 0) return 0\n return sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))]\n}\n\n/** Totals per run label from the telemetry lines. Calls without a label group under \"(none)\". */\nexport function summariseRuns(records: Array<AbsorbCallRecord | AbsorbRunRecord>): RunSummary[] {\n const groups = new Map<string, { calls: AbsorbCallRecord[]; runs: AbsorbRunRecord[] }>()\n const group = (label?: string) => {\n const key = label || \"(none)\"\n let g = groups.get(key)\n if (!g) groups.set(key, (g = { calls: [], runs: [] }))\n return g\n }\n for (const r of records) {\n if (r.kind === \"call\") group(r.label).calls.push(r)\n else if (r.kind === \"run\") group(r.label).runs.push(r)\n }\n const out: RunSummary[] = []\n for (const [label, { calls, runs }] of groups) {\n if (calls.length === 0) continue\n const ms = calls.map((c) => c.wallMs).sort((a, b) => a - b)\n let wallMs: number\n if (runs.length > 0) {\n wallMs = runs.reduce((s, r) => s + (Date.parse(r.endedAt) - Date.parse(r.startedAt)), 0)\n } else {\n const starts = calls.map((c) => Date.parse(c.at) - c.wallMs)\n const ends = calls.map((c) => Date.parse(c.at))\n wallMs = Math.max(...ends) - Math.min(...starts)\n }\n const entries = calls.reduce((s, c) => s + c.entries, 0)\n const costUsd = calls.reduce((s, c) => s + (c.costUsd ?? 0), 0)\n out.push({\n label,\n calls: calls.length,\n failed: calls.filter((c) => c.failed).length,\n entries,\n articles: calls.reduce((s, c) => s + c.articles, 0),\n refused: calls.reduce((s, c) => s + c.refused, 0),\n heldCited: calls.reduce((s, c) => s + (c.heldCited ?? 0), 0),\n wallMs,\n callMsP50: percentile(ms, 0.5),\n callMsP95: percentile(ms, 0.95),\n prepMs: calls.reduce((s, c) => s + (c.prepMs ?? 0), 0),\n costUsd,\n costPerEntry: entries > 0 ? costUsd / entries : 0,\n entriesPerMinute: wallMs > 0 ? (entries / wallMs) * 60_000 : 0,\n promptChars: calls.reduce((s, c) => s + c.prompt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AaH,EAAM,OAAO,CAAC9C,EAAG,IAAMA,EAAI,EAAE,YAAa,CAAC,CAC1D,CAAC,EAEH,OAAO1D,EAAI,KAAK,CAACZ,EAAGO,IAAMP,EAAE,MAAM,cAAcO,EAAE,KAAK,CAAC,CAC1D","names":["seededRandom","seed","h","i","a","t","pickSample","items","n","rng","pool","b","j","STOP","terms","text","out","m","termOverlap","entry","article","e","hit","WEAK_CITATION","factStrings","f","extractFacts","hasCommit","haystack","commit","known","k","urlKey","u","checkArticle","entries","citersOf","cited","id","missingSources","weakSources","grounding","groundLower","g","groundUrls","groundNumbers","mine","ungrounded","c","lost","facts","carriers","carrierFacts","uncitedWithFacts","uncited","allArticles","lower","missing","TITLE_STOP","titleTerms","title","w","jaccard","inter","x","findDuplicates","catalog","focus","opts","titleMin","sourcesMin","rows","pairs","y","s","p","q","JUDGE_ENTRY_CHARS","buildJudgePrompt","sourceBlock","body","earlier","parseJudgeReply","value","v","list","num","claims","supported","verdict","buildScorecard","checks","duplicates","meta","judged","maxExamples","byType","lostEntries","lostKeys","l","inPair","d","card","pct","renderScorecard","lines","ex","section","parts","envelopeUsage","envelope","percentile","sorted","summariseRuns","records","groups","group","label","key","r","calls","runs","ms","wallMs","starts","ends","costUsd"]}
@@ -1,4 +1,4 @@
1
- import{pa as l,xa as m}from"./chunk-2BF6HJJD.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
1
+ import{pa as l,xa as m}from"./chunk-DYGQF3MI.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
2
2
  `,f=t+".tmp";a(f,c,"utf-8");try{JSON.parse(u(f,"utf-8"))}catch(d){throw new Error(`config did not round-trip cleanly: ${d.message}`)}let r;return n.skipBackup||(r=`${t}.bak.${Date.now()}`,y(t,r)),a(t,c,"utf-8"),n.skipReload||h().catch(()=>{}),{summary:s.summary,payload:s.payload,backupPath:r}}function S(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(g(t)&&!n.overwrite)throw new Error(`agentx.json already exists at ${t}. Pass overwrite=true to replace it.`);return a(t,JSON.stringify(e,null,2)+`
3
3
  `,"utf-8"),{file:t}}async function h(){try{let n=l().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${n}/reload`,{method:"POST"}).catch(()=>null)}catch{}}export{P as a,S as b};
4
- //# sourceMappingURL=chunk-GUEIF7ZF.js.map
4
+ //# sourceMappingURL=chunk-SMAI7U6H.js.map
@@ -1,4 +1,4 @@
1
- import{b as S,c as O}from"./chunk-D5IHICX3.js";import{h as B,j as J}from"./chunk-3UOTLMXD.js";import{a as I,b as P}from"./chunk-FCPTN6NF.js";import{a as X,b as ue}from"./chunk-7I7IEX4S.js";import{d as F}from"./chunk-QIJLFPWE.js";import{execFile as Ae}from"child_process";import{writeFileSync as ie,mkdirSync as x,existsSync as b,readFileSync as ke}from"fs";import{resolve as v}from"path";var le=["off","shadow","authoritative"],ge={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},me="INTENT_LEDGER_MODE";function G(i,e=process.env){let t=U(e[ge[i]]);if(t)return t;let n=U(e[me]);return n||"off"}function U(i){if(typeof i!="string")return null;let e=i.trim().toLowerCase();return le.includes(e)?e:null}P();import he from"better-sqlite3";import{existsSync as Ue,mkdirSync as fe}from"fs";import{dirname as pe,resolve as Ee}from"path";var T=class{db;path;constructor(e={}){this.path=Ee(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),fe(pe(this.path),{recursive:!0}),this.db=new he(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),ye(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let n=this.findEventBySourceId(e.source,e.sourceEventId);if(n)return n}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
1
+ import{b as S,c as O}from"./chunk-LUYN6RAC.js";import{h as B,j as J}from"./chunk-3UOTLMXD.js";import{a as I,b as P}from"./chunk-FCPTN6NF.js";import{a as X,b as ue}from"./chunk-7I7IEX4S.js";import{d as F}from"./chunk-QIJLFPWE.js";import{execFile as Ae}from"child_process";import{writeFileSync as ie,mkdirSync as x,existsSync as b,readFileSync as ke}from"fs";import{resolve as v}from"path";var le=["off","shadow","authoritative"],ge={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},me="INTENT_LEDGER_MODE";function G(i,e=process.env){let t=U(e[ge[i]]);if(t)return t;let n=U(e[me]);return n||"off"}function U(i){if(typeof i!="string")return null;let e=i.trim().toLowerCase();return le.includes(e)?e:null}P();import he from"better-sqlite3";import{existsSync as Ue,mkdirSync as fe}from"fs";import{dirname as pe,resolve as Ee}from"path";var T=class{db;path;constructor(e={}){this.path=Ee(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),fe(pe(this.path),{recursive:!0}),this.db=new he(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),ye(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let n=this.findEventBySourceId(e.source,e.sourceEventId);if(n)return n}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
2
2
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(t.id,t.ts,t.source,t.sourceEventId,t.project,t.subject,t.intent,t.rawJson),t}findEventBySourceId(e,t){let n=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
3
3
  FROM intent_events WHERE source = ? AND source_event_id = ?`).get(e,t);return n?Y(n):null}getEventById(e){let t=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
4
4
  FROM intent_events WHERE id = ?`).get(e);return t?Y(t):null}recordDecision(e){this.db.prepare(`INSERT INTO intent_decisions (event_id, decided_at, decided_by, agent_id, outcome, reason)
@@ -125,4 +125,4 @@ ${se(o.block,r.prompt)}`,r.maxOutputTokens),agentId:r.agent,autonomy:r.autonomy,
125
125
  `);return t.length<=e?t.join(`
126
126
  `):t.slice(-e).join(`
127
127
  `)}function Xe(i,e,t){return new Promise((n,r)=>{Ae("/bin/sh",["-c",i],{timeout:e,maxBuffer:8*1024*1024,...t?{env:t}:{}},(s,a,o)=>{if(s&&s.killed){r(new Error(`command timed out after ${Math.round(e/1e3)}s`));return}n({stdout:String(a??""),stderr:String(o??""),code:s?typeof s.code=="number"?s.code:1:0})})})}export{T as a,V as b,ot as c,we as d,at as e,ct as f,$ as g,ee as h,G as i,We as j,z as k,Q as l,lt as m,Ce as n,oe as o,ae as p,ce as q,C as r,M as s};
128
- //# sourceMappingURL=chunk-S2UXDEGW.js.map
128
+ //# sourceMappingURL=chunk-SSQMFHSM.js.map
@@ -0,0 +1,55 @@
1
+ import{a as R,b as G,c as K,d as z,e as J}from"./chunk-YA3P77LV.js";import{a as N,b as I,c as V,d as Y,e as B,j as F}from"./chunk-ERULJ2ZL.js";import{a as H}from"./chunk-JRS5QRZG.js";import{y as T,z as ot}from"./chunk-4XMALK7X.js";import{g as j}from"./chunk-6TURWSMN.js";import{b as E,c as L}from"./chunk-QOYAX2FT.js";import{readFileSync as lt,existsSync as X}from"fs";ot();import{resolve as _}from"path";import{execSync as ct}from"child_process";var ht=.8;function dt(e,r,o,t){if(t.size===0)return 0;let c=e.listArticles(r||"").map(l=>l.path).filter(l=>!l.includes("/_versions/"));return c.length===0&&(c=o.sharedPool.map(l=>l.path)),c.length===0?0:c.filter(l=>t.has(l)).length/c.length}async function Et(e,r,o,t={}){let c=t.selectorModel??"haiku",l=t.synthModel??"sonnet",m=t.maxCandidates??3,g=t.maxHops??2,d=t.maxArticles??8,i=t.timeoutMs??6e4,s=t.log??console.error.bind(console,"[wiki-query]"),h=t.messagePath?.length?t.messagePath:void 0,n=t.graphWeight??W,a=_(r.baseDir,"_index.md"),p=tt(r,o,t.shared),b=t.method??"catalog";if(b!=="catalog"){let u=z(r,t.shared);if(b==="summaries"||dt(r,o,p,u)>=ht){let f=t.summaries??K,P=t.notes&&o&&t.notes.owner===o?G(t.notes):void 0,y=await J(e,P?pt(p,P):p,P?new Map([...u,...P.summaries]):u,{...f,navigatorModel:t.selectorModel??f.navigatorModel,answerModel:t.synthModel??f.answerModel},{call:t.call??H,fetch:t.fetch,timeoutMs:i,log:s}),$=y.picked.map(w=>({title:w.meta.title,path:w.path,type:R(w.path)?"note":w.meta.type,hop:w.hop}));return{answer:y.answer,citations:y.status==="ok"?$.map(({hop:w,...v})=>v):[],candidates:$.filter(w=>w.hop===0).map(({title:w,path:v})=>({title:w,path:v})),walked:$,status:y.status,method:"summaries",basis:y.basis,live:y.live,liveAsked:y.liveAsked,trace:y.trace,...y.error?{error:y.error}:{}}}}if(!X(a)&&p.sharedPool.length===0)return M("no-catalog",e,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let it=(X(a)?lt(a,"utf-8"):"")+ut(e,p.sharedPool,h,n),U=Date.now(),A=[],S="";try{let u=await nt(e,p.pool,o,m,h,n);u?(A=u,S=`[wiki-rerank seat] ${u.map(f=>f.title).join(" | ")}`):(S=await Z(ft(e,it,m,h),c,i),A=wt(S))}catch(u){return s("selector failed:",u?.message),{...M("error",e,`Selector: ${u?.message||"unknown"}`),trace:{selectorMs:Date.now()-U,synthesisMs:0,selectorOutput:S}}}let x=Date.now()-U;if(A.length===0)return{...M("no-candidates",e,"Selector returned no candidates."),trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let C=rt(A,p,g,d);if(C.length===0)return{...M("no-candidates",e,"Candidates did not resolve to readable articles."),candidates:A,trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let D=Date.now(),Q="";try{Q=await Z(yt(e,C),l,i*2)}catch(u){return s("synthesis failed:",u?.message),{...M("error",e,`Synthesis: ${u?.message||"unknown"}`),candidates:A,walked:C.map(f=>({title:f.meta.title,path:f.path,type:f.meta.type,hop:f.hop??0})),trace:{selectorMs:x,synthesisMs:Date.now()-D,selectorOutput:S}}}let st=Date.now()-D;return{answer:Q.trim(),citations:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type})),candidates:A,walked:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type,hop:u.hop??0})),status:"ok",trace:{selectorMs:x,synthesisMs:st,selectorOutput:S}}}async function Lt(e,r,o,t={}){let c=t.maxCandidates??3,l=t.graphWeight??W,m=t.messagePath?.length?t.messagePath:void 0,g=t.pool??q(r);if(g.length===0||!e.trim())return[];let d=await nt(e,g,o,c,m,l,t.stage??"retrieve");if(!d){let i=new Set(L(e,E(g.map(at))).map(s=>s.docIndex));d=O(e,g,m,l).filter(s=>i.has(s)).slice(0,c).map(s=>({title:g[s].title,path:g[s].path}))}return d.length===0?[]:rt(d,tt(r,o),t.maxHops??1,t.maxArticles??6)}function q(e){try{return(e.rebuildIndex().articles??[]).filter(r=>r.path&&!r.path.includes("/_versions/"))}catch{return[]}}function M(e,r,o){return{answer:"",citations:[],candidates:[],walked:[],status:e,error:o}}function tt(e,r,o=[]){let t=new Map,c=[];for(let i of e.listArticles(r||""))t.set(i.meta.title.toLowerCase(),i.path),c.push({path:i.path,related:i.meta.related??[],lastUpdated:i.meta.lastUpdated??""});let l=[],m=new Map;for(let i of o)if(i.store.baseDir!==e.baseDir){m.set(i.id,i);for(let s of i.store.listArticles(r||"")){if(s.path.includes("/_versions/")||i.skip?.(s.path))continue;let h=`@${i.id}/${s.path}`;l.push(mt(s,h)),c.push({path:h,related:s.meta.related??[],lastUpdated:s.meta.lastUpdated??""});let n=s.meta.title.toLowerCase();t.has(n)||t.set(n,h)}}let g=new Map;if(m.size>0)for(let i of[...c].sort((s,h)=>h.lastUpdated.localeCompare(s.lastUpdated)))for(let s of i.related){let h=s.toLowerCase(),n=g.get(h)??[];n.includes(i.path)||n.push(i.path),g.set(h,n)}let d;return{backlinks:g,readable:new Set(c.map(i=>i.path)),get pool(){return d??=[...q(e),...l]},sharedPool:l,titleIndex:t,read(i){let s=i.match(/^@([^/]+)\/(.+)$/),h=s?m.get(s[1]):void 0;if(s&&!h)return null;let n=h?.store??e,a=s?s[2]:i,p=r?n.readArticleAs(a,r):n.readArticle(a);return p?{...p,path:i}:null},links(i){let s=(i.meta.related??[]).map(a=>t.get(a.toLowerCase())).filter(a=>!!a),h=[i.meta.title,...i.meta.aliases??[]].map(a=>a.toLowerCase()),n=[...new Set(h.flatMap(a=>g.get(a)??[]))].filter(a=>a!==i.path).slice(0,et);return[...new Set([...s,...n])].filter(a=>a!==i.path)}}}function pt(e,r){return{...e,pool:[...e.pool,...r.pool],readable:new Set([...e.readable,...r.pool.map(o=>o.path)]),read:o=>R(o)?r.read(o):e.read(o)}}function mt(e,r){return{path:r,title:e.meta.title,type:e.meta.type,related:e.meta.related,tags:e.meta.tags||[],owner:e.meta.owner,access:e.meta.access,sharedWith:e.meta.sharedWith,aliases:[e.meta.title.toLowerCase(),...(e.meta.aliases??[]).map(o=>o.toLowerCase())],backlinks:0,sources:e.meta.sources,lastUpdated:e.meta.lastUpdated,graphPath:e.meta.graphPath}}var gt=150;function ut(e,r,o,t){return r.length===0?"":`
2
+
3
+ ## Shared wiki (other agents' articles)
4
+
5
+ ${O(e,r,o,t).slice(0,gt).map(l=>`- ${r[l].title}${r[l].type?` [${r[l].type}]`:""} (${r[l].path})`).join(`
6
+ `)}
7
+ `}var et=3;function rt(e,r,o,t){let c=r.titleIndex,l=n=>n.startsWith("@"),m=[...e.filter(n=>!l(n.path)),...e.filter(n=>l(n.path))],g=m.length>0&&!l(m[0].path)?Math.floor(t/2):t,d=new Map,i=0,s=m.map(n=>({path:n.path,hop:0})),h=[];for(;d.size<t;){if(!s.length){if(!h.length||g>=t)break;g=t,s=h.splice(0)}let n=s.shift();if(d.has(n.path)||n.hop>o)continue;if(l(n.path)&&i>=g){h.push(n);continue}let a=r.read(n.path);if(a&&(d.set(n.path,{...a,hop:n.hop}),l(n.path)&&i++,!(n.hop>=o))){if(n.hop===0){let p=[a.meta.title,...a.meta.aliases??[]].map(k=>k.toLowerCase()),b=[...new Set(p.flatMap(k=>r.backlinks.get(k)??[]))].filter(k=>k!==n.path&&!d.has(k)).slice(0,et);for(let k of b)s.push({path:k,hop:1})}for(let p of a.meta.related||[]){let b=c.get(p.toLowerCase());b&&!d.has(b)&&s.push({path:b,hop:n.hop+1})}}}return Array.from(d.values())}async function nt(e,r,o,t,c,l=W,m="catalog-selector"){try{if(r.length<2)return null;let d=O(e,r,c,l).slice(0,I).map(n=>({id:`k${n}`,title:r[n].title||r[n].path,tags:r[n].tags,excerpt:[r[n].type?`type: ${r[n].type}`:"",(r[n].related??[]).length?`related: ${(r[n].related??[]).join(", ")}`:"",(r[n].graphPath??[]).length?`graph: ${(r[n].graphPath??[]).join(" \u203A ")}`:""].filter(Boolean).join(" \xB7 ")})),i=await T(N,V({query:e,candidates:d,excerptChars:300}),Y(d),{features:{agent:o??"unknown",stage:m}});if(!i||i.mode!=="active")return null;let h=B(i.answers,d).ranked.slice(0,t).map(n=>r[Number(n.slice(1))]).filter(Boolean).map(n=>({title:n.title,path:n.path}));return h.length>0?h:null}catch{return null}}var W=.6;function O(e,r,o,t=W){let c=L(e,E(r.map(at))),l=c.reduce((a,p)=>Math.max(a,p.score),0),m=new Map(c.map(a=>[a.docIndex,l>0?a.score/l:0])),g=!!o?.length,d=a=>g&&a.graphPath?.length?F(o,a.graphPath):0,i=(a,p)=>p.score-a.score||a.i-p.i,s=r.map((a,p)=>({i:p,score:(m.get(p)??0)*(1+t*d(a))})).filter(a=>m.has(a.i)).sort(i),h=r.map((a,p)=>({i:p,score:d(a)})).filter(a=>!m.has(a.i)&&a.score>0).sort(i),n=[...s,...h].map(a=>a.i);for(let a=0;a<r.length;a++)n.includes(a)||n.push(a);return n}function at(e){return[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")}function ft(e,r,o,t){let c=t?.length?`
8
+ ## Intent
9
+
10
+ The request was classified under the intent-graph path "${t.join(" \u203A ")}". Prefer articles filed under the same branch when their titles are equally plausible.
11
+ `:"";return`You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.
12
+
13
+ ## Question
14
+
15
+ ${e}
16
+ ${c}
17
+ ## Catalog (_index.md \u2014 articles grouped by type, with wikilink previews)
18
+
19
+ ${r}
20
+
21
+ ## Your task
22
+
23
+ Pick up to ${o} articles from the catalog that are most likely to answer the question. Prefer:
24
+ - Articles whose title directly names a subject in the question.
25
+ - Articles of the right type (e.g. a "who owns X" question \u2192 person or project; a "what happened on DATE" \u2192 event).
26
+ - Articles whose wikilinks suggest they sit at the center of a relevant subgraph.
27
+
28
+ Return ONLY valid JSON, no markdown fencing, no prose:
29
+
30
+ [
31
+ {"title": "Exact Article Title", "path": "path/from/catalog.md"},
32
+ ...
33
+ ]
34
+
35
+ If none of the articles match, return [].`}function yt(e,r){let o=r.map(t=>{let c=[t.meta.owner?`owner: ${t.meta.owner}`:"",t.meta.lastUpdated?`updated: ${t.meta.lastUpdated}`:""].filter(Boolean).join(", "),l=`### ${t.meta.title} \u2014 ${t.meta.type||"untyped"} (${t.path}) [hop ${t.hop}]${c?` {${c}}`:""}`,m=t.meta.related?.length?`Related: ${t.meta.related.join(", ")}`:"";return[l,m,"",t.content].filter(Boolean).join(`
36
+ `)}).join(`
37
+
38
+ ---
39
+
40
+ `);return`You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.
41
+
42
+ ## Question
43
+
44
+ ${e}
45
+
46
+ ## Articles (${r.length} walked from the catalog)
47
+
48
+ ${o}
49
+
50
+ ## Your task
51
+
52
+ Answer the question in 2\u20136 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.
53
+
54
+ Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function wt(e){let r=e.match(/\[[\s\S]*?\]/);if(!r)return[];try{let o=JSON.parse(r[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Z(e,r,o){let{writeFileSync:t,mkdirSync:c,rmSync:l}=await import("fs"),{tmpdir:m}=await import("os"),g=_(m(),`agentx-wiki-query-${process.pid}`);c(g,{recursive:!0});let d=_(g,`prompt-${Date.now()}.txt`);t(d,e);try{let i=`cat '${d}' | claude -p - --output-format json --max-turns 1 --model ${r} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,s=ct(i,{env:j(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let h=JSON.parse(s);return String(h.result||h.content||"")}catch{return s}}finally{try{l(d,{force:!0})}catch{}}}async function Rt(e){try{let{loadDaemonConfig:r}=await import("./config-GHMRBRDL.js");return r(e).wiki.query.shared}catch{return!0}}export{ht as a,Et as b,Lt as c,q as d,gt as e,W as f,O as g,Rt as h};
55
+ //# sourceMappingURL=chunk-WWDYDLY2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wiki/query.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\"\nimport { buildIndex, scoreAll } from \"@/memory/bm25\"\nimport { askSeat } from \"@/decisions/seat\"\nimport { ancestryScore } from \"@/graph\"\nimport {\n DEFAULT_SHORTLIST,\n WIKI_RERANK_SEAT,\n rerankQuestions,\n rerankState,\n toRanking,\n type RerankCandidate,\n} from \"@/decisions/seats/wiki-rerank\"\nimport { claudeCliEnv } from \"@/utils/workspace-env\"\nimport { resolve } from \"path\"\nimport { execSync } from \"child_process\"\nimport type { WikiArticle, WikiIndex } from \"./types\"\nimport type { WikiStore } from \"./store\"\nimport { claudeModelCall, type ModelCall } from \"./model-call\"\nimport type { FetchLike, LiveLine } from \"./live-read\"\nimport { DEFAULT_SUMMARIES_QUERY, collectSummaries, summariesQuery, type PageView, type SummariesQuerySettings } from \"./query-summaries\"\nimport { isNotePath, notePool, type NoteSource } from \"./query-notes\"\nimport type { QueryMethod } from \"./query-settings\"\n\n/**\n * Agentic wiki query — the \"Farzapedia-faithful\" retrieval path.\n *\n * Two LLM calls + a deterministic graph walk:\n * 1. Selector (cheap): read `_index.md` + question → pick up to `maxCandidates`\n * candidate articles by title + type.\n * 2. Walk (pure code): starting from candidates, follow `related` wikilinks\n * up to `maxHops`, capped at `maxArticles` total.\n * 3. Synthesis (main): answer the question from the walked subgraph.\n *\n * Returns an answer with citations and a trace of which articles were walked,\n * so callers can audit the retrieval path.\n */\n\nexport interface AgenticQueryOptions {\n /** Candidate-selection model (cheap). Defaults to \"haiku\". */\n selectorModel?: string\n /** Synthesis model (main). Defaults to \"sonnet\". */\n synthModel?: string\n /** Number of candidates the selector is asked to return. Default 3. */\n maxCandidates?: number\n /** Wikilink hops from candidates. Default 2. */\n maxHops?: number\n /** Hard cap on total articles walked. Default 8. */\n maxArticles?: number\n /** Timeout per LLM call, ms. Default 60_000. */\n timeoutMs?: number\n /** Logger — defaults to console.error. */\n log?: (...args: unknown[]) => void\n /** Intent-graph path the question's request was classified under.\n * Articles on the same branch rank higher in candidate selection. */\n messagePath?: string[]\n /** Weight of the branch match against the text match, 0–1. Default 0.6\n * (`graph.retrievalWeights.graph`). */\n graphWeight?: number\n /** Other wikis to search besides `store`: the shared wiki (#824). Only\n * articles the requester may read are offered. Their paths come back\n * as `@<id>/<path>`. */\n shared?: SharedWikiStore[]\n /** How pages are picked (#855). `summaries`: from the one-line page\n * summaries, then a live read (query-summaries.ts). `auto`: that, once\n * most of the requester's own pages have a summary\n * (AUTO_SUMMARY_COVERAGE). Default \"catalog\". */\n method?: QueryMethod\n /** Settings of the summaries method. An explicit `selectorModel` or\n * `synthModel` overrides its models. */\n summaries?: SummariesQuerySettings\n /** The requester's own notes, searched beside its pages by the\n * summaries method (#862). A note is private to the agent that wrote\n * it: notes of any other agent are ignored. */\n notes?: NoteSource\n /** Model call and HTTP GET of the summaries method; tests pass their own. */\n call?: ModelCall\n fetch?: FetchLike\n}\n\n/** Share of the requester's own pages that must have a summary before\n * `auto` picks pages from summaries. Below it, an unsummarised page\n * would be ranked on its title and tags alone, so the catalog walk is\n * kept: one `wiki summarize --agent <id>` or `--limit` run must not\n * switch every agent that can read that store. */\nexport const AUTO_SUMMARY_COVERAGE = 0.8\n\n/** Share of the pages in reach that have a summary: the requester's own\n * pages, or the shared pages when the requester has none. */\nfunction summaryCoverage(store: WikiStore, requesterId: string | undefined, view: ScopeView, summaries: Map<string, string>): number {\n if (summaries.size === 0) return 0\n let paths = store.listArticles(requesterId || \"\").map((a) => a.path).filter((p) => !p.includes(\"/_versions/\"))\n if (paths.length === 0) paths = view.sharedPool.map((e) => e.path)\n if (paths.length === 0) return 0\n return paths.filter((p) => summaries.has(p)).length / paths.length\n}\n\n/** A wiki searched alongside the requester's own. */\nexport interface SharedWikiStore {\n /** Shown in citations as `@<id>/<path>`: an agent id, or \"shared\". */\n id: string\n store: WikiStore\n /** Paths to leave out, e.g. the agents/ tree under the root store. */\n skip?: (path: string) => boolean\n}\n\nexport interface AgenticQueryResult {\n answer: string\n citations: Array<{ title: string; path: string; type?: string }>\n /** Titles/paths the selector picked. */\n candidates: Array<{ title: string; path: string }>\n /** Full article subgraph the walk produced. */\n walked: Array<{ title: string; path: string; type?: string; hop: number }>\n /** \"no-catalog\" | \"no-candidates\" | \"ok\" */\n status: \"ok\" | \"no-catalog\" | \"no-candidates\" | \"error\"\n /** How the pages were picked. */\n method?: \"summaries\" | \"catalog\"\n /** Lines read at the source for this answer (summaries method). */\n live?: LiveLine[]\n /** Live reads the model named and the config allowed. */\n liveAsked?: number\n /** \"search\": no wiki page was used; the answer comes from a search at\n * the source (#861). */\n basis?: \"pages\" | \"search\"\n /** For operator debugging only. */\n trace?: {\n selectorMs: number\n synthesisMs: number\n selectorOutput?: string\n planMs?: number\n liveMs?: number\n }\n error?: string\n}\n\n/**\n * Run an agentic query against a specific agent's WikiStore.\n *\n * `requesterId` is used for permission checks — only articles the requester\n * can read will be included in the synthesis input.\n */\nexport async function agenticQuery(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n opts: AgenticQueryOptions = {},\n): Promise<AgenticQueryResult> {\n const selectorModel = opts.selectorModel ?? \"haiku\"\n const synthModel = opts.synthModel ?? \"sonnet\"\n const maxCandidates = opts.maxCandidates ?? 3\n const maxHops = opts.maxHops ?? 2\n const maxArticles = opts.maxArticles ?? 8\n const timeoutMs = opts.timeoutMs ?? 60_000\n const log = opts.log ?? console.error.bind(console, \"[wiki-query]\")\n const messagePath = opts.messagePath?.length ? opts.messagePath : undefined\n const graphWeight = opts.graphWeight ?? DEFAULT_GRAPH_WEIGHT\n\n // --- Step 1: Load the catalog ---\n const catalogPath = resolve(store.baseDir, \"_index.md\")\n const view = scopeView(store, requesterId, opts.shared)\n\n const method = opts.method ?? \"catalog\"\n if (method !== \"catalog\") {\n const summaries = collectSummaries(store, opts.shared)\n if (method === \"summaries\" || summaryCoverage(store, requesterId, view, summaries) >= AUTO_SUMMARY_COVERAGE) {\n const base = opts.summaries ?? DEFAULT_SUMMARIES_QUERY\n const notes = opts.notes && requesterId && opts.notes.owner === requesterId ? notePool(opts.notes) : undefined\n const out = await summariesQuery(question, notes ? withNotes(view, notes) : view, notes ? new Map([...summaries, ...notes.summaries]) : summaries, {\n ...base,\n navigatorModel: opts.selectorModel ?? base.navigatorModel,\n answerModel: opts.synthModel ?? base.answerModel,\n }, { call: opts.call ?? claudeModelCall, fetch: opts.fetch, timeoutMs, log })\n const pages = out.picked.map((a) => ({ title: a.meta.title, path: a.path, type: isNotePath(a.path) ? \"note\" : a.meta.type, hop: a.hop }))\n return {\n answer: out.answer,\n citations: out.status === \"ok\" ? pages.map(({ hop: _, ...p }) => p) : [],\n candidates: pages.filter((p) => p.hop === 0).map(({ title, path }) => ({ title, path })),\n walked: pages,\n status: out.status,\n method: \"summaries\",\n basis: out.basis,\n live: out.live,\n liveAsked: out.liveAsked,\n trace: out.trace,\n ...(out.error ? { error: out.error } : {}),\n }\n }\n }\n\n if (!existsSync(catalogPath) && view.sharedPool.length === 0) {\n return emptyResult(\"no-catalog\", question, \"No _index.md found — run `agentx wiki status` to rebuild.\")\n }\n const ownCatalog = existsSync(catalogPath) ? readFileSync(catalogPath, \"utf-8\") : \"\"\n const catalog = ownCatalog + renderSharedCatalog(question, view.sharedPool, messagePath, graphWeight)\n\n // --- Step 2: Selector — pick candidates ---\n const selectorStart = Date.now()\n let candidates: Array<{ title: string; path: string }> = []\n let selectorOutput = \"\"\n try {\n const viaSeat = await selectCandidatesViaSeat(question, view.pool, requesterId, maxCandidates, messagePath, graphWeight)\n if (viaSeat) {\n candidates = viaSeat\n selectorOutput = `[wiki-rerank seat] ${viaSeat.map((c) => c.title).join(\" | \")}`\n } else {\n selectorOutput = await runClaude(\n buildSelectorPrompt(question, catalog, maxCandidates, messagePath),\n selectorModel,\n timeoutMs,\n )\n candidates = parseCandidates(selectorOutput)\n }\n } catch (e: any) {\n log(\"selector failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Selector: ${e?.message || \"unknown\"}`), trace: { selectorMs: Date.now() - selectorStart, synthesisMs: 0, selectorOutput } }\n }\n const selectorMs = Date.now() - selectorStart\n\n if (candidates.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Selector returned no candidates.\"), trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 3: Walk the subgraph via `related` wikilinks ---\n const walked = walkSubgraph(candidates, view, maxHops, maxArticles)\n\n if (walked.length === 0) {\n return { ...emptyResult(\"no-candidates\", question, \"Candidates did not resolve to readable articles.\"), candidates, trace: { selectorMs, synthesisMs: 0, selectorOutput } }\n }\n\n // --- Step 4: Synthesize the answer ---\n const synthStart = Date.now()\n let answer = \"\"\n try {\n answer = await runClaude(\n buildSynthesisPrompt(question, walked),\n synthModel,\n timeoutMs * 2,\n )\n } catch (e: any) {\n log(\"synthesis failed:\", e?.message)\n return { ...emptyResult(\"error\", question, `Synthesis: ${e?.message || \"unknown\"}`), candidates, walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })), trace: { selectorMs, synthesisMs: Date.now() - synthStart, selectorOutput } }\n }\n const synthesisMs = Date.now() - synthStart\n\n return {\n answer: answer.trim(),\n citations: walked.map(a => ({ title: a.meta.title, path: a.path, type: a.meta.type })),\n candidates,\n walked: walked.map(w => ({ title: w.meta.title, path: w.path, type: w.meta.type, hop: (w as any).hop ?? 0 })),\n status: \"ok\",\n trace: { selectorMs, synthesisMs, selectorOutput },\n }\n}\n\nexport interface RetrieveOptions {\n /** Articles picked before the walk. Default 3. */\n maxCandidates?: number\n /** Wikilink hops from the picked articles. Default 1. */\n maxHops?: number\n /** Hard cap on articles returned. Default 6. */\n maxArticles?: number\n messagePath?: string[]\n graphWeight?: number\n /** The catalog to pick from. Pass it when retrieving many times in a row,\n * so the index is not rebuilt for every call. */\n pool?: CatalogEntry[]\n /** Seat telemetry label. */\n stage?: string\n}\n\n/**\n * The retrieval half of agenticQuery, without the synthesis call: BM25\n * shortlist, rerank seat, then the `related` wikilink walk. Returns the\n * walked articles, hop 0 first.\n *\n * When the seat is off or fails, the BM25 order decides on its own, and\n * only articles the text matched are picked: an article chosen for\n * nothing but its catalog position is noise here, not a candidate. There\n * is no CLI fallback, so this never spends an LLM call.\n */\nexport async function retrieveArticles(\n question: string,\n store: WikiStore,\n requesterId: string | undefined,\n opts: RetrieveOptions = {},\n): Promise<Array<WikiArticle & { hop: number }>> {\n const maxCandidates = opts.maxCandidates ?? 3\n const graphWeight = opts.graphWeight ?? DEFAULT_GRAPH_WEIGHT\n const messagePath = opts.messagePath?.length ? opts.messagePath : undefined\n const pool = opts.pool ?? catalogPool(store)\n if (pool.length === 0 || !question.trim()) return []\n\n let candidates = await selectCandidatesViaSeat(\n question, pool, requesterId, maxCandidates, messagePath, graphWeight, opts.stage ?? \"retrieve\",\n )\n if (!candidates) {\n const matched = new Set(scoreAll(question, buildIndex(pool.map(catalogDoc))).map((r) => r.docIndex))\n candidates = rankCatalogPool(question, pool, messagePath, graphWeight)\n .filter((i) => matched.has(i))\n .slice(0, maxCandidates)\n .map((i) => ({ title: pool[i].title, path: pool[i].path }))\n }\n if (candidates.length === 0) return []\n return walkSubgraph(candidates, scopeView(store, requesterId), opts.maxHops ?? 1, opts.maxArticles ?? 6)\n}\n\nexport type CatalogEntry = WikiIndex[\"articles\"][number]\n\n/** The catalog retrieval picks from: every indexed article but old versions. */\nexport function catalogPool(store: WikiStore): CatalogEntry[] {\n try {\n return (store.rebuildIndex().articles ?? []).filter((a) => a.path && !a.path.includes(\"/_versions/\"))\n } catch {\n return []\n }\n}\n\n// --- Helpers ---\n\nfunction emptyResult(\n status: AgenticQueryResult[\"status\"],\n _question: string,\n error?: string,\n): AgenticQueryResult {\n return {\n answer: \"\",\n citations: [],\n candidates: [],\n walked: [],\n status,\n error,\n }\n}\n\n/**\n * The articles a query may open: the requester's own wiki first, then\n * each shared one. Shared paths carry an `@<id>/` prefix so the walk\n * knows which store to read; a title the own wiki has resolves there.\n */\ninterface ScopeView {\n /** Own catalog, then the shared articles. */\n pool: CatalogEntry[]\n sharedPool: CatalogEntry[]\n titleIndex: Map<string, string>\n /** Title (lowercased) → pages whose `related` names it, newest first.\n * Built only when shared wikis are searched. */\n backlinks: Map<string, string[]>\n /** Paths the requester may read, own and shared. */\n readable: Set<string>\n read(path: string): WikiArticle | null\n /** Pages `article` names in `related`, then the newest that name it. */\n links(article: WikiArticle): string[]\n}\n\nfunction scopeView(store: WikiStore, requesterId: string | undefined, shared: SharedWikiStore[] = []): ScopeView {\n const titleIndex = new Map<string, string>()\n const linking: Array<{ path: string; related: string[]; lastUpdated: string }> = []\n for (const article of store.listArticles(requesterId || \"\")) {\n titleIndex.set(article.meta.title.toLowerCase(), article.path)\n linking.push({ path: article.path, related: article.meta.related ?? [], lastUpdated: article.meta.lastUpdated ?? \"\" })\n }\n const sharedPool: CatalogEntry[] = []\n const byId = new Map<string, SharedWikiStore>()\n for (const s of shared) {\n if (s.store.baseDir === store.baseDir) continue\n byId.set(s.id, s)\n // listArticles is cached and already drops what the requester can't\n // read; rebuilding every agent's index per query would not be.\n for (const a of s.store.listArticles(requesterId || \"\")) {\n if (a.path.includes(\"/_versions/\") || s.skip?.(a.path)) continue\n const path = `@${s.id}/${a.path}`\n sharedPool.push(catalogEntry(a, path))\n linking.push({ path, related: a.meta.related ?? [], lastUpdated: a.meta.lastUpdated ?? \"\" })\n const key = a.meta.title.toLowerCase()\n if (!titleIndex.has(key)) titleIndex.set(key, path)\n }\n }\n // In a fleet's shared pool the page that answers a question often links\n // TO the page the selector picked (a decision about a person), and the\n // forward walk never reaches it (#824 review: ranked 103rd of ~5,700).\n const backlinks = new Map<string, string[]>()\n if (byId.size > 0) {\n for (const l of [...linking].sort((a, b) => b.lastUpdated.localeCompare(a.lastUpdated))) {\n for (const t of l.related) {\n const key = t.toLowerCase()\n const list = backlinks.get(key) ?? []\n if (!list.includes(l.path)) list.push(l.path)\n backlinks.set(key, list)\n }\n }\n }\n let pool: CatalogEntry[] | undefined\n return {\n backlinks,\n readable: new Set(linking.map((l) => l.path)),\n // Lazy: retrieveArticles brings its own pool, and building this one\n // rebuilds the index.\n get pool() { return (pool ??= [...catalogPool(store), ...sharedPool]) },\n sharedPool,\n titleIndex,\n read(path) {\n const m = path.match(/^@([^/]+)\\/(.+)$/)\n const target = m ? byId.get(m[1]) : undefined\n if (m && !target) return null\n const s = target?.store ?? store\n const rel = m ? m[2] : path\n const article = requesterId ? s.readArticleAs(rel, requesterId) : s.readArticle(rel)\n return article ? { ...article, path } : null\n },\n links(article) {\n const forward = (article.meta.related ?? []).map((t) => titleIndex.get(t.toLowerCase())).filter((p): p is string => !!p)\n const names = [article.meta.title, ...(article.meta.aliases ?? [])].map((n) => n.toLowerCase())\n const back = [...new Set(names.flatMap((n) => backlinks.get(n) ?? []))].filter((p) => p !== article.path).slice(0, BACKLINKS_PER_PICK)\n return [...new Set([...forward, ...back])].filter((p) => p !== article.path)\n },\n }\n}\n\n/** The view with the requester's notes added: in the pool, readable,\n * and opened from the notes folder. Everything else the view carries\n * (such as the title index linked pages follow) is kept. */\nfunction withNotes(view: ScopeView, notes: ReturnType<typeof notePool>): PageView {\n return {\n ...view,\n pool: [...view.pool, ...notes.pool],\n readable: new Set([...view.readable, ...notes.pool.map((n) => n.path)]),\n read: (path) => (isNotePath(path) ? notes.read(path) : view.read(path)),\n }\n}\n\nfunction catalogEntry(a: WikiArticle, path: string): CatalogEntry {\n return {\n path,\n title: a.meta.title,\n type: a.meta.type,\n related: a.meta.related,\n tags: a.meta.tags || [],\n owner: a.meta.owner,\n access: a.meta.access,\n sharedWith: a.meta.sharedWith,\n aliases: [a.meta.title.toLowerCase(), ...(a.meta.aliases ?? []).map((x) => x.toLowerCase())],\n backlinks: 0,\n sources: a.meta.sources,\n lastUpdated: a.meta.lastUpdated,\n graphPath: a.meta.graphPath,\n }\n}\n\n/** Shared articles most related to the question, for the CLI selector.\n * Capped: a fleet's shared catalog would not fit one prompt. */\nexport const SHARED_CATALOG_LINES = 150\n\nfunction renderSharedCatalog(question: string, pool: CatalogEntry[], messagePath: string[] | undefined, graphWeight: number): string {\n if (pool.length === 0) return \"\"\n const lines = rankCatalogPool(question, pool, messagePath, graphWeight)\n .slice(0, SHARED_CATALOG_LINES)\n .map((i) => `- ${pool[i].title}${pool[i].type ? ` [${pool[i].type}]` : \"\"} (${pool[i].path})`)\n return `\\n\\n## Shared wiki (other agents' articles)\\n\\n${lines.join(\"\\n\")}\\n`\n}\n\n/** Pages that link to a picked page, opened per picked page. */\nconst BACKLINKS_PER_PICK = 3\n\nfunction walkSubgraph(\n candidates: Array<{ title: string; path: string }>,\n view: ScopeView,\n maxHops: number,\n maxArticles: number,\n): Array<WikiArticle & { hop: number }> {\n const titleIndex = view.titleIndex\n const isShared = (path: string) => path.startsWith(\"@\")\n\n // The agent's own pages come first, and shared pages may take at most\n // half the walk when it has any: in the #824 trial shared pages took\n // the slots of the agent's own correct pages and its score dropped.\n const ordered = [...candidates.filter((c) => !isShared(c.path)), ...candidates.filter((c) => isShared(c.path))]\n let sharedCap = ordered.length > 0 && !isShared(ordered[0].path) ? Math.floor(maxArticles / 2) : maxArticles\n\n const opened = new Map<string, WikiArticle & { hop: number }>()\n let sharedOpened = 0\n let frontier: Array<{ path: string; hop: number }> = ordered.map((c) => ({ path: c.path, hop: 0 }))\n // Shared pages turned away by the cap, in walk order. When the agent's\n // own pages run out first they get the slots left: an own pick with no\n // own neighbours must not leave the walk short of shared pages that answer.\n const deferred: Array<{ path: string; hop: number }> = []\n\n while (opened.size < maxArticles) {\n if (!frontier.length) {\n if (!deferred.length || sharedCap >= maxArticles) break\n sharedCap = maxArticles\n frontier = deferred.splice(0)\n }\n const next = frontier.shift()!\n if (opened.has(next.path)) continue\n if (next.hop > maxHops) continue\n if (isShared(next.path) && sharedOpened >= sharedCap) { deferred.push(next); continue }\n\n const article = view.read(next.path)\n if (!article) continue\n\n opened.set(next.path, { ...article, hop: next.hop })\n if (isShared(next.path)) sharedOpened++\n if (next.hop >= maxHops) continue\n\n if (next.hop === 0) {\n // Pages link to a subject by any of its names; skip what is already\n // open before taking the newest few, or an opened page uses a slot.\n const names = [article.meta.title, ...(article.meta.aliases ?? [])].map((n) => n.toLowerCase())\n const linking = [...new Set(names.flatMap((n) => view.backlinks.get(n) ?? []))]\n .filter((path) => path !== next.path && !opened.has(path))\n .slice(0, BACKLINKS_PER_PICK)\n for (const path of linking) frontier.push({ path, hop: 1 })\n }\n for (const target of article.meta.related || []) {\n const path = titleIndex.get(target.toLowerCase())\n if (path && !opened.has(path)) {\n frontier.push({ path, hop: next.hop + 1 })\n }\n }\n }\n\n return Array.from(opened.values())\n}\n\n// --- Prompts ---\n\n/**\n * Pick candidates with the wiki-rerank seat instead of a Claude CLI call.\n *\n * The selector is 56% of a wiki query — 14.1s of a 25s total, measured —\n * and its whole job is \"pick 3 articles from this catalog\", which is a\n * Choice with per-option probabilities. Jev answers that in about a\n * second. Synthesis stays on Sonnet; it writes prose, which Jev cannot.\n *\n * BM25 shortlists first because the shared catalog carries 971 entries,\n * past the 255-option cap. Same two-stage shape as findRelevantReranked,\n * and it reuses that seat rather than introducing a second one.\n *\n * Returns null whenever the seat is off, errors, or has nothing to rank,\n * and the caller falls back to the CLI selector — so this is strictly an\n * accelerator, never a new way to fail.\n */\nasync function selectCandidatesViaSeat(\n question: string,\n pool: CatalogEntry[],\n requesterId: string | undefined,\n maxCandidates: number,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n stage = \"catalog-selector\",\n): Promise<Array<{ title: string; path: string }> | null> {\n try {\n if (pool.length < 2) return null\n\n const shortlist = rankCatalogPool(question, pool, messagePath, graphWeight).slice(0, DEFAULT_SHORTLIST)\n\n const candidates: RerankCandidate[] = shortlist.map((i) => ({\n id: `k${i}`,\n title: pool[i].title || pool[i].path,\n tags: pool[i].tags,\n // The catalog has no body — a title, its type, its wikilinks and its\n // branch of the intent graph are what the selector chooses on.\n excerpt: [\n pool[i].type ? `type: ${pool[i].type}` : \"\",\n (pool[i].related ?? []).length ? `related: ${(pool[i].related ?? []).join(\", \")}` : \"\",\n (pool[i].graphPath ?? []).length ? `graph: ${(pool[i].graphPath ?? []).join(\" › \")}` : \"\",\n ].filter(Boolean).join(\" · \"),\n }))\n\n const result = await askSeat(\n WIKI_RERANK_SEAT,\n rerankState({ query: question, candidates, excerptChars: 300 }),\n rerankQuestions(candidates),\n { features: { agent: requesterId ?? \"unknown\", stage } },\n )\n if (!result || result.mode !== \"active\") return null\n\n const ranking = toRanking(result.answers as never, candidates)\n const picked = ranking.ranked\n .slice(0, maxCandidates)\n .map((id) => pool[Number(id.slice(1))])\n .filter(Boolean)\n .map((a) => ({ title: a.title, path: a.path }))\n return picked.length > 0 ? picked : null\n } catch {\n return null\n }\n}\n\n/** Weight of the intent-graph branch match against the text match when\n * shortlisting catalog candidates. Mirrors `graph.retrievalWeights.graph`. */\nexport const DEFAULT_GRAPH_WEIGHT = 0.6\n\n/**\n * Order the catalog pool for a question. Three bands, never mixed:\n *\n * 1. articles the text match scored, ordered by `text * (1 + w * branch)`\n * when the request was classified: the branch reorders text matches\n * but cannot lift an unrelated article above one;\n * 2. articles on the request's branch that the text never matched, by\n * how much of the path they share;\n * 3. the rest, in catalog order.\n *\n * Band 1 comes first in full because the shortlist the reranker sees is\n * finite (DEFAULT_SHORTLIST): a busy category holds more same-branch\n * articles than that, and a blended score let them push the article that\n * actually answers the question out of the list.\n *\n * Exported for tests; the seat and the CLI selector both consume the order.\n */\nexport function rankCatalogPool(\n question: string,\n pool: Array<{ title: string; tags?: string[]; related?: string[]; graphPath?: string[] }>,\n messagePath?: string[],\n graphWeight: number = DEFAULT_GRAPH_WEIGHT,\n): number[] {\n const bm25 = scoreAll(question, buildIndex(pool.map(catalogDoc)))\n const maxBm25 = bm25.reduce((m, r) => Math.max(m, r.score), 0)\n const text = new Map(bm25.map((r) => [r.docIndex, maxBm25 > 0 ? r.score / maxBm25 : 0]))\n const useGraph = !!messagePath?.length\n const branch = (a: { graphPath?: string[] }) =>\n useGraph && a.graphPath?.length ? ancestryScore(messagePath!, a.graphPath) : 0\n\n const byScore = (x: { i: number; score: number }, y: { i: number; score: number }) => y.score - x.score || x.i - y.i\n const matched = pool\n .map((a, i) => ({ i, score: (text.get(i) ?? 0) * (1 + graphWeight * branch(a)) }))\n .filter((c) => text.has(c.i))\n .sort(byScore)\n const branchOnly = pool\n .map((a, i) => ({ i, score: branch(a) }))\n .filter((c) => !text.has(c.i) && c.score > 0)\n .sort(byScore)\n const ranked = [...matched, ...branchOnly].map((c) => c.i)\n for (let i = 0; i < pool.length; i++) if (!ranked.includes(i)) ranked.push(i)\n return ranked\n}\n\n/** What BM25 sees of a catalog entry: the catalog carries no body. */\nfunction catalogDoc(a: { title: string; tags?: string[]; related?: string[] }): string {\n return [a.title, (a.tags ?? []).join(\" \"), (a.related ?? []).join(\" \")].join(\" \")\n}\n\nfunction buildSelectorPrompt(question: string, catalog: string, maxCandidates: number, messagePath?: string[]): string {\n const branch = messagePath?.length\n ? `\\n## Intent\\n\\nThe request was classified under the intent-graph path \"${messagePath.join(\" › \")}\". Prefer articles filed under the same branch when their titles are equally plausible.\\n`\n : \"\"\n return `You are picking candidate articles from a wiki catalog to answer a question. You do NOT answer the question. You pick which articles the answer is likely to come from.\n\n## Question\n\n${question}\n${branch}\n## Catalog (_index.md — articles grouped by type, with wikilink previews)\n\n${catalog}\n\n## Your task\n\nPick up to ${maxCandidates} articles from the catalog that are most likely to answer the question. Prefer:\n- Articles whose title directly names a subject in the question.\n- Articles of the right type (e.g. a \"who owns X\" question → person or project; a \"what happened on DATE\" → event).\n- Articles whose wikilinks suggest they sit at the center of a relevant subgraph.\n\nReturn ONLY valid JSON, no markdown fencing, no prose:\n\n[\n {\"title\": \"Exact Article Title\", \"path\": \"path/from/catalog.md\"},\n ...\n]\n\nIf none of the articles match, return [].`\n}\n\nfunction buildSynthesisPrompt(\n question: string,\n articles: Array<WikiArticle & { hop: number }>,\n): string {\n const articlesBlock = articles\n .map(a => {\n // Owner and date let the answer say where a fact came from and pick\n // the newer page when two disagree (#824).\n const from = [a.meta.owner ? `owner: ${a.meta.owner}` : \"\", a.meta.lastUpdated ? `updated: ${a.meta.lastUpdated}` : \"\"].filter(Boolean).join(\", \")\n const header = `### ${a.meta.title} — ${a.meta.type || \"untyped\"} (${a.path}) [hop ${a.hop}]${from ? ` {${from}}` : \"\"}`\n const related = a.meta.related?.length ? `Related: ${a.meta.related.join(\", \")}` : \"\"\n return [header, related, \"\", a.content].filter(Boolean).join(\"\\n\")\n })\n .join(\"\\n\\n---\\n\\n\")\n\n return `You are answering a question using a small subgraph of wiki articles. The articles were walked from the catalog; trust them over your prior knowledge.\n\n## Question\n\n${question}\n\n## Articles (${articles.length} walked from the catalog)\n\n${articlesBlock}\n\n## Your task\n\nAnswer the question in 2–6 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.\n\nOutput ONLY the answer — no preamble, no \"here is my answer:\", no markdown fencing.`\n}\n\nfunction parseCandidates(raw: string): Array<{ title: string; path: string }> {\n const match = raw.match(/\\[[\\s\\S]*?\\]/)\n if (!match) return []\n try {\n const parsed = JSON.parse(match[0])\n if (!Array.isArray(parsed)) return []\n return parsed\n .filter((x: any) => x && typeof x.title === \"string\" && typeof x.path === \"string\")\n .map((x: any) => ({ title: x.title, path: x.path }))\n } catch {\n return []\n }\n}\n\nasync function runClaude(prompt: string, model: string, timeoutMs: number): Promise<string> {\n // Use stdin via a temp-file pipe to avoid shell-escaping a huge prompt.\n // Prompts can exceed the `-E` arg buffer on macOS, so we always pipe.\n const { writeFileSync, mkdirSync, rmSync } = await import(\"fs\")\n const { tmpdir } = await import(\"os\")\n const dir = resolve(tmpdir(), `agentx-wiki-query-${process.pid}`)\n mkdirSync(dir, { recursive: true })\n const promptPath = resolve(dir, `prompt-${Date.now()}.txt`)\n writeFileSync(promptPath, prompt)\n try {\n const cmd = `cat '${promptPath}' | claude -p - --output-format json --max-turns 1 --model ${model} --disallowedTools \"Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit\"`\n const raw = execSync(cmd, { env: claudeCliEnv(), encoding: \"utf-8\", timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 })\n try {\n const envelope = JSON.parse(raw)\n return String(envelope.result || envelope.content || \"\")\n } catch {\n return raw\n }\n } finally {\n try { rmSync(promptPath, { force: true }) } catch {}\n }\n}\n\n/** `wiki.query.shared` from agentx.json: whether a query also searches the\n * shared wiki. On when there is no config to read. The CLI and the\n * `agentx_wiki_query` tool both ask here, so the switch reaches both. */\nexport async function sharedQueryEnabled(configPath?: string): Promise<boolean> {\n try {\n const { loadDaemonConfig } = await import(\"@/daemon/config\")\n return loadDaemonConfig(configPath).wiki.query.shared\n } catch {\n return true\n }\n}\n"],"mappings":"8TAAA,OAAS,gBAAAA,GAAc,cAAAC,MAAkB,KAEzCC,KAWA,OAAS,WAAAC,MAAe,OACxB,OAAS,YAAAC,OAAgB,gBAsElB,IAAMC,GAAwB,GAIrC,SAASC,GAAgBC,EA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AAC,CAAE,MAAE,CAAO,CACrD,CACF,CAKA,eAAsBK,GAAmBC,EAAuC,CAC9E,GAAI,CACF,GAAM,CAAE,iBAAAC,CAAiB,EAAI,KAAM,QAAO,sBAAiB,EAC3D,OAAOA,EAAiBD,CAAU,EAAE,KAAK,MAAM,MACjD,MAAE,CACA,MAAO,EACT,CACF","names":["readFileSync","existsSync","init_seat","resolve","execSync","AUTO_SUMMARY_COVERAGE","summaryCoverage","store","requesterId","view","summaries","paths","a","p","e","agenticQuery","question","opts","selectorModel","synthModel","maxCandidates","maxHops","maxArticles","timeoutMs","log","messagePath","graphWeight","DEFAULT_GRAPH_WEIGHT","catalogPath","resolve","scopeView","method","collectSummaries","base","DEFAULT_SUMMARIES_QUERY","notes","notePool","out","summariesQuery","withNotes","claudeModelCall","pages","isNotePath","_","title","path","existsSync","emptyResult","catalog","readFileSync","renderSharedCatalog","selectorStart","candidates","selectorOutput","viaSeat","selectCandidatesViaSeat","c","runClaude","buildSelectorPrompt","parseCandidates","selectorMs","walked","walkSubgraph","synthStart","answer","buildSynthesisPrompt","w","synthesisMs","retrieveArticles","pool","catalogPool","matched","scoreAll","buildIndex","catalogDoc","r","rankCatalogPool","i","status","_question","error","shared","titleIndex","linking","article","sharedPool","byId","s","catalogEntry","key","backlinks","l","b","t","list","m","target","rel","forward","names","n","back","BACKLINKS_PER_PICK","x","SHARED_CATALOG_LINES","isShared","ordered","sharedCap","opened","sharedOpened","frontier","deferred","next","stage","DEFAULT_SHORTLIST","result","askSeat","WIKI_RERANK_SEAT","rerankState","rerankQuestions","picked","toRanking","id","bm25","maxBm25","text","useGraph","branch","ancestryScore","byScore","y","branchOnly","ranked","articles","articlesBlock","from","header","related","raw","match","parsed","prompt","model","writeFileSync","mkdirSync","rmSync","tmpdir","dir","promptPath","cmd","execSync","claudeCliEnv","envelope","sharedQueryEnabled","configPath","loadDaemonConfig"]}