@monoes/monomindcli 2.13.0 → 2.14.1

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 (251) hide show
  1. package/.claude/skills/monodesign/scripts/context.mjs +1 -1
  2. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +2 -2
  3. package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +2 -2
  4. package/.claude/skills/monodesign/scripts/live-browser.js +1 -1
  5. package/bin/cli.js +21 -1
  6. package/bin/mcp-server.js +21 -1
  7. package/dist/src/capabilities/cap-documents.d.ts.map +1 -1
  8. package/dist/src/capabilities/cap-documents.js +23 -0
  9. package/dist/src/capabilities/cap-documents.js.map +1 -1
  10. package/dist/src/commands/doc-filters.d.ts +19 -0
  11. package/dist/src/commands/doc-filters.d.ts.map +1 -0
  12. package/dist/src/commands/doc-filters.js +58 -0
  13. package/dist/src/commands/doc-filters.js.map +1 -0
  14. package/dist/src/commands/doc-library.d.ts +21 -0
  15. package/dist/src/commands/doc-library.d.ts.map +1 -0
  16. package/dist/src/commands/doc-library.js +390 -0
  17. package/dist/src/commands/doc-library.js.map +1 -0
  18. package/dist/src/commands/doc-list.d.ts +9 -0
  19. package/dist/src/commands/doc-list.d.ts.map +1 -0
  20. package/dist/src/commands/doc-list.js +99 -0
  21. package/dist/src/commands/doc-list.js.map +1 -0
  22. package/dist/src/commands/doc.d.ts.map +1 -1
  23. package/dist/src/commands/doc.js +49 -37
  24. package/dist/src/commands/doc.js.map +1 -1
  25. package/dist/src/commands/doctor-mcp-probe.d.ts +48 -0
  26. package/dist/src/commands/doctor-mcp-probe.d.ts.map +1 -0
  27. package/dist/src/commands/doctor-mcp-probe.js +205 -0
  28. package/dist/src/commands/doctor-mcp-probe.js.map +1 -0
  29. package/dist/src/commands/doctor-project-checks.d.ts +12 -1
  30. package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
  31. package/dist/src/commands/doctor-project-checks.js +55 -4
  32. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  33. package/dist/src/commands/doctor.d.ts.map +1 -1
  34. package/dist/src/commands/doctor.js +10 -1
  35. package/dist/src/commands/doctor.js.map +1 -1
  36. package/dist/src/commands/init.d.ts.map +1 -1
  37. package/dist/src/commands/init.js +17 -0
  38. package/dist/src/commands/init.js.map +1 -1
  39. package/dist/src/commands/mcp.d.ts.map +1 -1
  40. package/dist/src/commands/mcp.js +4 -3
  41. package/dist/src/commands/mcp.js.map +1 -1
  42. package/dist/src/commands/org-observe.d.ts.map +1 -1
  43. package/dist/src/commands/org-observe.js +14 -0
  44. package/dist/src/commands/org-observe.js.map +1 -1
  45. package/dist/src/commands/org.d.ts.map +1 -1
  46. package/dist/src/commands/org.js +12 -2
  47. package/dist/src/commands/org.js.map +1 -1
  48. package/dist/src/init/claudemd-generator.d.ts.map +1 -1
  49. package/dist/src/init/claudemd-generator.js +2 -1
  50. package/dist/src/init/claudemd-generator.js.map +1 -1
  51. package/dist/src/init/mcp-generator.d.ts.map +1 -1
  52. package/dist/src/init/mcp-generator.js +3 -3
  53. package/dist/src/init/mcp-generator.js.map +1 -1
  54. package/dist/src/init/types.d.ts +6 -0
  55. package/dist/src/init/types.d.ts.map +1 -1
  56. package/dist/src/init/types.js.map +1 -1
  57. package/dist/src/init/write-runtime-config.d.ts.map +1 -1
  58. package/dist/src/init/write-runtime-config.js +12 -2
  59. package/dist/src/init/write-runtime-config.js.map +1 -1
  60. package/dist/src/knowledge/capture-envelope.d.ts +80 -0
  61. package/dist/src/knowledge/capture-envelope.d.ts.map +1 -0
  62. package/dist/src/knowledge/capture-envelope.js +165 -0
  63. package/dist/src/knowledge/capture-envelope.js.map +1 -0
  64. package/dist/src/knowledge/capture-text.d.ts +23 -0
  65. package/dist/src/knowledge/capture-text.d.ts.map +1 -0
  66. package/dist/src/knowledge/capture-text.js +49 -0
  67. package/dist/src/knowledge/capture-text.js.map +1 -0
  68. package/dist/src/knowledge/citation.d.ts +121 -0
  69. package/dist/src/knowledge/citation.d.ts.map +1 -0
  70. package/dist/src/knowledge/citation.js +252 -0
  71. package/dist/src/knowledge/citation.js.map +1 -0
  72. package/dist/src/knowledge/document-pipeline.d.ts +60 -0
  73. package/dist/src/knowledge/document-pipeline.d.ts.map +1 -1
  74. package/dist/src/knowledge/document-pipeline.js +188 -4
  75. package/dist/src/knowledge/document-pipeline.js.map +1 -1
  76. package/dist/src/knowledge/html-extract.d.ts +43 -0
  77. package/dist/src/knowledge/html-extract.d.ts.map +1 -0
  78. package/dist/src/knowledge/html-extract.js +286 -0
  79. package/dist/src/knowledge/html-extract.js.map +1 -0
  80. package/dist/src/knowledge/html-tags.d.ts +30 -0
  81. package/dist/src/knowledge/html-tags.d.ts.map +1 -0
  82. package/dist/src/knowledge/html-tags.js +229 -0
  83. package/dist/src/knowledge/html-tags.js.map +1 -0
  84. package/dist/src/knowledge/library.d.ts +106 -0
  85. package/dist/src/knowledge/library.d.ts.map +1 -0
  86. package/dist/src/knowledge/library.js +195 -0
  87. package/dist/src/knowledge/library.js.map +1 -0
  88. package/dist/src/knowledge/mhtml.d.ts +60 -0
  89. package/dist/src/knowledge/mhtml.d.ts.map +1 -0
  90. package/dist/src/knowledge/mhtml.js +154 -0
  91. package/dist/src/knowledge/mhtml.js.map +1 -0
  92. package/dist/src/knowledge/related.d.ts +58 -0
  93. package/dist/src/knowledge/related.d.ts.map +1 -0
  94. package/dist/src/knowledge/related.js +222 -0
  95. package/dist/src/knowledge/related.js.map +1 -0
  96. package/dist/src/knowledge/section-diff.d.ts +48 -0
  97. package/dist/src/knowledge/section-diff.d.ts.map +1 -0
  98. package/dist/src/knowledge/section-diff.js +151 -0
  99. package/dist/src/knowledge/section-diff.js.map +1 -0
  100. package/dist/src/knowledge/watch.d.ts +92 -0
  101. package/dist/src/knowledge/watch.d.ts.map +1 -0
  102. package/dist/src/knowledge/watch.js +221 -0
  103. package/dist/src/knowledge/watch.js.map +1 -0
  104. package/dist/src/mcp-server.d.ts.map +1 -1
  105. package/dist/src/mcp-server.js +44 -87
  106. package/dist/src/mcp-server.js.map +1 -1
  107. package/dist/src/mcp-tools/browser-instrument-tools.d.ts +35 -0
  108. package/dist/src/mcp-tools/browser-instrument-tools.d.ts.map +1 -0
  109. package/dist/src/mcp-tools/browser-instrument-tools.js +359 -0
  110. package/dist/src/mcp-tools/browser-instrument-tools.js.map +1 -0
  111. package/dist/src/mcp-tools/browser-metrics.d.ts +42 -0
  112. package/dist/src/mcp-tools/browser-metrics.d.ts.map +1 -0
  113. package/dist/src/mcp-tools/browser-metrics.js +91 -0
  114. package/dist/src/mcp-tools/browser-metrics.js.map +1 -0
  115. package/dist/src/mcp-tools/browser-profile-tools.d.ts +16 -0
  116. package/dist/src/mcp-tools/browser-profile-tools.d.ts.map +1 -0
  117. package/dist/src/mcp-tools/browser-profile-tools.js +324 -0
  118. package/dist/src/mcp-tools/browser-profile-tools.js.map +1 -0
  119. package/dist/src/mcp-tools/browser-session.d.ts +68 -0
  120. package/dist/src/mcp-tools/browser-session.d.ts.map +1 -0
  121. package/dist/src/mcp-tools/browser-session.js +224 -0
  122. package/dist/src/mcp-tools/browser-session.js.map +1 -0
  123. package/dist/src/mcp-tools/browser-tools.d.ts.map +1 -1
  124. package/dist/src/mcp-tools/browser-tools.js +10 -176
  125. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  126. package/dist/src/mcp-tools/capture-resource-read.d.ts +115 -0
  127. package/dist/src/mcp-tools/capture-resource-read.d.ts.map +1 -0
  128. package/dist/src/mcp-tools/capture-resource-read.js +296 -0
  129. package/dist/src/mcp-tools/capture-resource-read.js.map +1 -0
  130. package/dist/src/mcp-tools/capture-resource-tools.d.ts +22 -0
  131. package/dist/src/mcp-tools/capture-resource-tools.d.ts.map +1 -0
  132. package/dist/src/mcp-tools/capture-resource-tools.js +182 -0
  133. package/dist/src/mcp-tools/capture-resource-tools.js.map +1 -0
  134. package/dist/src/mcp-tools/capture-resources.d.ts +142 -0
  135. package/dist/src/mcp-tools/capture-resources.d.ts.map +1 -0
  136. package/dist/src/mcp-tools/capture-resources.js +289 -0
  137. package/dist/src/mcp-tools/capture-resources.js.map +1 -0
  138. package/dist/src/mcp-tools/index.d.ts +3 -0
  139. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  140. package/dist/src/mcp-tools/index.js +6 -0
  141. package/dist/src/mcp-tools/index.js.map +1 -1
  142. package/dist/src/mcp-tools/knowledge-tools.d.ts.map +1 -1
  143. package/dist/src/mcp-tools/knowledge-tools.js +9 -1
  144. package/dist/src/mcp-tools/knowledge-tools.js.map +1 -1
  145. package/dist/src/mcp-tools/resource-router.d.ts +86 -0
  146. package/dist/src/mcp-tools/resource-router.d.ts.map +1 -0
  147. package/dist/src/mcp-tools/resource-router.js +181 -0
  148. package/dist/src/mcp-tools/resource-router.js.map +1 -0
  149. package/dist/src/memory/memory-bridge.js +1 -1
  150. package/dist/src/memory/memory-bridge.js.map +1 -1
  151. package/dist/src/orgrt/agent-runner.d.ts +38 -0
  152. package/dist/src/orgrt/agent-runner.d.ts.map +1 -1
  153. package/dist/src/orgrt/agent-runner.js +47 -0
  154. package/dist/src/orgrt/agent-runner.js.map +1 -1
  155. package/dist/src/orgrt/checkpoint.d.ts +12 -1
  156. package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
  157. package/dist/src/orgrt/checkpoint.js +15 -6
  158. package/dist/src/orgrt/checkpoint.js.map +1 -1
  159. package/dist/src/orgrt/completion-gate.d.ts +74 -0
  160. package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
  161. package/dist/src/orgrt/completion-gate.js +45 -0
  162. package/dist/src/orgrt/completion-gate.js.map +1 -1
  163. package/dist/src/orgrt/cost-tier.d.ts +144 -0
  164. package/dist/src/orgrt/cost-tier.d.ts.map +1 -0
  165. package/dist/src/orgrt/cost-tier.js +183 -0
  166. package/dist/src/orgrt/cost-tier.js.map +1 -0
  167. package/dist/src/orgrt/cross-org.d.ts.map +1 -1
  168. package/dist/src/orgrt/cross-org.js +14 -0
  169. package/dist/src/orgrt/cross-org.js.map +1 -1
  170. package/dist/src/orgrt/daemon.d.ts +12 -1
  171. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  172. package/dist/src/orgrt/daemon.js +216 -49
  173. package/dist/src/orgrt/daemon.js.map +1 -1
  174. package/dist/src/orgrt/decisions.d.ts +14 -2
  175. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  176. package/dist/src/orgrt/decisions.js +216 -10
  177. package/dist/src/orgrt/decisions.js.map +1 -1
  178. package/dist/src/orgrt/file-roots.d.ts +7 -0
  179. package/dist/src/orgrt/file-roots.d.ts.map +1 -1
  180. package/dist/src/orgrt/file-roots.js +38 -1
  181. package/dist/src/orgrt/file-roots.js.map +1 -1
  182. package/dist/src/orgrt/forwarder.d.ts.map +1 -1
  183. package/dist/src/orgrt/forwarder.js +16 -2
  184. package/dist/src/orgrt/forwarder.js.map +1 -1
  185. package/dist/src/orgrt/idle-deadline.d.ts +74 -1
  186. package/dist/src/orgrt/idle-deadline.d.ts.map +1 -1
  187. package/dist/src/orgrt/idle-deadline.js +52 -2
  188. package/dist/src/orgrt/idle-deadline.js.map +1 -1
  189. package/dist/src/orgrt/loadouts.d.ts +38 -0
  190. package/dist/src/orgrt/loadouts.d.ts.map +1 -0
  191. package/dist/src/orgrt/loadouts.js +129 -0
  192. package/dist/src/orgrt/loadouts.js.map +1 -0
  193. package/dist/src/orgrt/mailbox.d.ts +17 -1
  194. package/dist/src/orgrt/mailbox.d.ts.map +1 -1
  195. package/dist/src/orgrt/mailbox.js +50 -3
  196. package/dist/src/orgrt/mailbox.js.map +1 -1
  197. package/dist/src/orgrt/policy.d.ts +42 -2
  198. package/dist/src/orgrt/policy.d.ts.map +1 -1
  199. package/dist/src/orgrt/policy.js +53 -8
  200. package/dist/src/orgrt/policy.js.map +1 -1
  201. package/dist/src/orgrt/prompt-vars.d.ts +11 -0
  202. package/dist/src/orgrt/prompt-vars.d.ts.map +1 -0
  203. package/dist/src/orgrt/prompt-vars.js +49 -0
  204. package/dist/src/orgrt/prompt-vars.js.map +1 -0
  205. package/dist/src/orgrt/questions.d.ts +22 -1
  206. package/dist/src/orgrt/questions.d.ts.map +1 -1
  207. package/dist/src/orgrt/questions.js +24 -3
  208. package/dist/src/orgrt/questions.js.map +1 -1
  209. package/dist/src/orgrt/review-packet.d.ts +29 -0
  210. package/dist/src/orgrt/review-packet.d.ts.map +1 -0
  211. package/dist/src/orgrt/review-packet.js +67 -0
  212. package/dist/src/orgrt/review-packet.js.map +1 -0
  213. package/dist/src/orgrt/role-sandbox.d.ts.map +1 -1
  214. package/dist/src/orgrt/role-sandbox.js +16 -3
  215. package/dist/src/orgrt/role-sandbox.js.map +1 -1
  216. package/dist/src/orgrt/session-ledger.d.ts +68 -0
  217. package/dist/src/orgrt/session-ledger.d.ts.map +1 -0
  218. package/dist/src/orgrt/session-ledger.js +128 -0
  219. package/dist/src/orgrt/session-ledger.js.map +1 -0
  220. package/dist/src/orgrt/session.d.ts +45 -5
  221. package/dist/src/orgrt/session.d.ts.map +1 -1
  222. package/dist/src/orgrt/session.js +397 -27
  223. package/dist/src/orgrt/session.js.map +1 -1
  224. package/dist/src/orgrt/task-dag.d.ts +34 -1
  225. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  226. package/dist/src/orgrt/task-dag.js +58 -7
  227. package/dist/src/orgrt/task-dag.js.map +1 -1
  228. package/dist/src/orgrt/tool-spill.d.ts +94 -0
  229. package/dist/src/orgrt/tool-spill.d.ts.map +1 -0
  230. package/dist/src/orgrt/tool-spill.js +180 -0
  231. package/dist/src/orgrt/tool-spill.js.map +1 -0
  232. package/dist/src/orgrt/types.d.ts +138 -0
  233. package/dist/src/orgrt/types.d.ts.map +1 -1
  234. package/dist/src/orgrt/types.js +148 -0
  235. package/dist/src/orgrt/types.js.map +1 -1
  236. package/dist/src/platform-adapters/renderers/mcp.d.ts +20 -2
  237. package/dist/src/platform-adapters/renderers/mcp.d.ts.map +1 -1
  238. package/dist/src/platform-adapters/renderers/mcp.js +25 -5
  239. package/dist/src/platform-adapters/renderers/mcp.js.map +1 -1
  240. package/dist/src/protocol-capabilities.d.ts +2 -1
  241. package/dist/src/protocol-capabilities.d.ts.map +1 -1
  242. package/dist/src/protocol-capabilities.js +2 -1
  243. package/dist/src/protocol-capabilities.js.map +1 -1
  244. package/dist/src/ui/dashboard.html +450 -164
  245. package/dist/src/ui/org-hil.mjs +276 -0
  246. package/dist/src/ui/org-runtime.mjs +350 -0
  247. package/dist/src/ui/orgs.html +15 -4
  248. package/dist/src/ui/routes-org.mjs +290 -541
  249. package/dist/src/ui/server.mjs +25 -5
  250. package/dist/tsconfig.tsbuildinfo +1 -1
  251. package/package.json +9 -8
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Tag and entity tables for the HTML extractor (RCL-01).
3
+ *
4
+ * Split out of `html-extract.ts` purely for size: these are data, the file
5
+ * next door is the algorithm.
6
+ *
7
+ * @module v1/cli/knowledge/html-tags
8
+ */
9
+ export const VOID_TAGS = new Set([
10
+ 'area',
11
+ 'base',
12
+ 'br',
13
+ 'col',
14
+ 'embed',
15
+ 'hr',
16
+ 'img',
17
+ 'input',
18
+ 'link',
19
+ 'meta',
20
+ 'param',
21
+ 'source',
22
+ 'track',
23
+ 'wbr',
24
+ ]);
25
+ /** Elements whose content is never prose. Dropped regardless of options. */
26
+ export const NON_TEXT_TAGS = new Set([
27
+ 'script',
28
+ 'style',
29
+ 'noscript',
30
+ 'svg',
31
+ 'math',
32
+ 'template',
33
+ 'canvas',
34
+ 'iframe',
35
+ 'object',
36
+ 'applet',
37
+ 'audio',
38
+ 'video',
39
+ ]);
40
+ /** Structural chrome. Dropped only when `stripBoilerplate` is on. */
41
+ export const CHROME_TAGS = new Set([
42
+ 'nav',
43
+ 'header',
44
+ 'footer',
45
+ 'aside',
46
+ 'menu',
47
+ 'dialog',
48
+ 'button',
49
+ 'select',
50
+ 'textarea',
51
+ ]);
52
+ /** ARIA landmark roles that mark chrome rather than content. */
53
+ export const CHROME_ROLES = new Set([
54
+ 'navigation',
55
+ 'banner',
56
+ 'contentinfo',
57
+ 'complementary',
58
+ 'search',
59
+ 'menubar',
60
+ 'menu',
61
+ 'toolbar',
62
+ 'dialog',
63
+ 'alertdialog',
64
+ ]);
65
+ /**
66
+ * Class/id word list. Matched against `-`/`_`/space/camelCase-split tokens, so
67
+ * `site-header`, `cookieBanner` and `ad_slot` all hit and `content-wrapper`
68
+ * does not.
69
+ */
70
+ export const CHROME_WORDS = new Set([
71
+ 'cookie',
72
+ 'cookies',
73
+ 'consent',
74
+ 'gdpr',
75
+ 'ccpa',
76
+ 'cmp',
77
+ 'banner',
78
+ 'promo',
79
+ 'promotion',
80
+ 'ad',
81
+ 'ads',
82
+ 'advert',
83
+ 'advertisement',
84
+ 'adsbygoogle',
85
+ 'sponsored',
86
+ 'newsletter',
87
+ 'subscribe',
88
+ 'signup',
89
+ 'paywall',
90
+ 'popup',
91
+ 'modal',
92
+ 'overlay',
93
+ 'lightbox',
94
+ 'nav',
95
+ 'navbar',
96
+ 'navigation',
97
+ 'menu',
98
+ 'breadcrumb',
99
+ 'breadcrumbs',
100
+ 'masthead',
101
+ 'topbar',
102
+ 'toolbar',
103
+ 'sidebar',
104
+ 'skiplink',
105
+ 'pagination',
106
+ 'paginate',
107
+ 'pager',
108
+ 'share',
109
+ 'sharing',
110
+ 'social',
111
+ 'socials',
112
+ 'footer',
113
+ 'header',
114
+ 'copyright',
115
+ 'related',
116
+ 'recommended',
117
+ 'recirc',
118
+ 'trending',
119
+ 'comments',
120
+ 'disqus',
121
+ ]);
122
+ /** Elements that start a new output block. */
123
+ export const BLOCK_TAGS = new Set([
124
+ 'address',
125
+ 'article',
126
+ 'blockquote',
127
+ 'br',
128
+ 'dd',
129
+ 'details',
130
+ 'div',
131
+ 'dl',
132
+ 'dt',
133
+ 'fieldset',
134
+ 'figcaption',
135
+ 'figure',
136
+ 'footer',
137
+ 'form',
138
+ 'h1',
139
+ 'h2',
140
+ 'h3',
141
+ 'h4',
142
+ 'h5',
143
+ 'h6',
144
+ 'header',
145
+ 'hr',
146
+ 'li',
147
+ 'main',
148
+ 'nav',
149
+ 'ol',
150
+ 'p',
151
+ 'pre',
152
+ 'section',
153
+ 'summary',
154
+ 'table',
155
+ 'tbody',
156
+ 'tfoot',
157
+ 'thead',
158
+ 'tr',
159
+ 'ul',
160
+ ]);
161
+ /** Table cells are joined into their row with ` | ` rather than broken out
162
+ * into blocks of their own, so a row survives as one readable line. */
163
+ export const CELL_TAGS = new Set(['td', 'th']);
164
+ /** Elements whose content is raw text — `<` inside them is not markup. */
165
+ export const RAW_TEXT_TAGS = new Set(['script', 'style', 'textarea', 'title']);
166
+ // ── Entities ───────────────────────────────────────────────────────
167
+ const NAMED_ENTITIES = {
168
+ amp: '&',
169
+ lt: '<',
170
+ gt: '>',
171
+ quot: '"',
172
+ apos: "'",
173
+ nbsp: ' ',
174
+ ensp: ' ',
175
+ emsp: ' ',
176
+ thinsp: ' ',
177
+ shy: '',
178
+ mdash: '—',
179
+ ndash: '–',
180
+ hellip: '…',
181
+ lsquo: '‘',
182
+ rsquo: '’',
183
+ ldquo: '“',
184
+ rdquo: '”',
185
+ bull: '•',
186
+ middot: '·',
187
+ laquo: '«',
188
+ raquo: '»',
189
+ copy: '©',
190
+ reg: '®',
191
+ trade: '™',
192
+ deg: '°',
193
+ euro: '€',
194
+ pound: '£',
195
+ yen: '¥',
196
+ cent: '¢',
197
+ sect: '§',
198
+ para: '¶',
199
+ dagger: '†',
200
+ times: '×',
201
+ divide: '÷',
202
+ plusmn: '±',
203
+ frac12: '½',
204
+ prime: '′',
205
+ larr: '←',
206
+ rarr: '→',
207
+ harr: '↔',
208
+ };
209
+ export function decodeEntities(s) {
210
+ if (!s.includes('&'))
211
+ return s;
212
+ return s.replace(/&(#[xX]?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]{1,31});/g, (whole, body) => {
213
+ if (body[0] === '#') {
214
+ const hex = body[1] === 'x' || body[1] === 'X';
215
+ const code = Number.parseInt(hex ? body.slice(2) : body.slice(1), hex ? 16 : 10);
216
+ if (!Number.isFinite(code) || code <= 0 || code > 0x10ffff)
217
+ return whole;
218
+ try {
219
+ return String.fromCodePoint(code);
220
+ }
221
+ catch {
222
+ return whole;
223
+ }
224
+ }
225
+ const hit = NAMED_ENTITIES[body] ?? NAMED_ENTITIES[body.toLowerCase()];
226
+ return hit === undefined ? whole : hit;
227
+ });
228
+ }
229
+ //# sourceMappingURL=html-tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-tags.js","sourceRoot":"","sources":["../../../src/knowledge/html-tags.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IAC/B,MAAM;IACN,MAAM;IACN,IAAI;IACJ,KAAK;IACL,OAAO;IACP,IAAI;IACJ,KAAK;IACL,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,QAAQ;IACR,OAAO;IACP,KAAK;CACN,CAAC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IACnC,QAAQ;IACR,OAAO;IACP,UAAU;IACV,KAAK;IACL,MAAM;IACN,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AAEH,qEAAqE;AACrE,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACjC,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;CACX,CAAC,CAAC;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAClC,YAAY;IACZ,QAAQ;IACR,aAAa;IACb,eAAe;IACf,QAAQ;IACR,SAAS;IACT,MAAM;IACN,SAAS;IACT,QAAQ;I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,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,CAAC,OAAO,CAAC,mDAAmD,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QAC5F,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;YAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,GAAG,QAAQ;gBAAE,OAAO,KAAK,CAAC;YACzE,IAAI,CAAC;gBACH,OAAO,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACvE,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * The capture library (RCL-09) — browsing what has been captured, rather than
3
+ * searching it.
4
+ *
5
+ * `listDocuments` answers "what is indexed". A library answers a different
6
+ * question: everything from this site, captured last week, tagged `reading`,
7
+ * newest first. The facets come from the capture envelope's `meta.json`
8
+ * (RCL-07), which is already on every record — this module is the query layer
9
+ * over them, and the data layer the desktop GUI renders.
10
+ *
11
+ * Rules, once, here:
12
+ * - within a facet values are OR'd, across facets AND'd (`--site a --site b
13
+ * --tag x` = "from a or b, tagged x");
14
+ * - `--site example.com` matches `www.example.com` and `docs.example.com`,
15
+ * because nobody browsing their own library means the bare host only;
16
+ * - a document with no provenance (an ordinary file on disk) sorts by its
17
+ * index time and matches no capture facet — it is not a capture.
18
+ *
19
+ * @module v1/cli/knowledge/library
20
+ */
21
+ import type { CaptureProvenance } from './capture-envelope.js';
22
+ import type { DocumentMeta } from './document-pipeline.js';
23
+ export interface LibraryFilter {
24
+ /** Host, or a parent domain of it. */
25
+ site?: string[];
26
+ tag?: string[];
27
+ collection?: string[];
28
+ /** `extension` | `monobrowse` | `crawl`. */
29
+ source?: string[];
30
+ /** ISO date/time, or a relative age: `7d`, `24h`, `30m`. */
31
+ since?: string;
32
+ until?: string;
33
+ /** Only documents that came from a capture envelope. */
34
+ capturedOnly?: boolean;
35
+ scope?: string;
36
+ /** Substring over title, URL and path. */
37
+ text?: string;
38
+ }
39
+ export type LibrarySort = 'captured' | 'indexed' | 'title' | 'path' | 'size';
40
+ export interface LibraryEntry {
41
+ filePath: string;
42
+ scope: string;
43
+ title: string;
44
+ url?: string;
45
+ site?: string;
46
+ capturedAt: string;
47
+ indexedAt: string;
48
+ source?: string;
49
+ collection?: string;
50
+ tags: string[];
51
+ chunkCount: number;
52
+ size: number;
53
+ version?: number;
54
+ /** False for ordinary files on disk: no capture envelope backed this one. */
55
+ captured: boolean;
56
+ }
57
+ /** The host a document was captured from, or undefined for a local file. */
58
+ export declare function documentSite(meta: {
59
+ canonicalUrl?: string;
60
+ provenance?: CaptureProvenance;
61
+ }): string | undefined;
62
+ /** When the page was captured; falls back to when it was indexed. */
63
+ export declare function documentCapturedAt(meta: {
64
+ indexedAt?: string;
65
+ provenance?: CaptureProvenance;
66
+ }): string;
67
+ /**
68
+ * A point in time from `2026-09-01`, a full ISO stamp, or an AGE like `7d`
69
+ * (meaning "7 days ago"). Returns null for anything unparseable so a typo
70
+ * cannot silently filter the whole library away.
71
+ */
72
+ export declare function parseWhen(value: string | undefined, now?: number): number | null;
73
+ /** True when a document belongs in this view. */
74
+ export declare function matchesLibraryFilter(meta: DocumentMeta, filter?: LibraryFilter, now?: number): boolean;
75
+ export declare function filterDocuments(docs: DocumentMeta[], filter?: LibraryFilter, now?: number): DocumentMeta[];
76
+ export declare function sortDocuments(docs: DocumentMeta[], sort?: LibrarySort, order?: 'asc' | 'desc'): DocumentMeta[];
77
+ /** The flat, JSON-friendly row the GUI and `--json` consumers read. */
78
+ export declare function libraryEntry(meta: DocumentMeta): LibraryEntry;
79
+ export interface ListLibraryOptions extends LibraryFilter {
80
+ sort?: LibrarySort;
81
+ order?: 'asc' | 'desc';
82
+ limit?: number;
83
+ now?: number;
84
+ }
85
+ /** Browse the library: filter, sort, cap. Never throws on an empty store. */
86
+ export declare function listLibrary(docs: DocumentMeta[], opts?: ListLibraryOptions): LibraryEntry[];
87
+ /** Facet counts for the current view — what a sidebar renders. */
88
+ export declare function libraryFacets(docs: DocumentMeta[]): {
89
+ sites: Array<{
90
+ value: string;
91
+ count: number;
92
+ }>;
93
+ tags: Array<{
94
+ value: string;
95
+ count: number;
96
+ }>;
97
+ collections: Array<{
98
+ value: string;
99
+ count: number;
100
+ }>;
101
+ sources: Array<{
102
+ value: string;
103
+ count: number;
104
+ }>;
105
+ };
106
+ //# sourceMappingURL=library.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../src/knowledge/library.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,IAAI,CAAC,EA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KAAE,CAAC,CAAC;IAC9C,WAAW,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD,CAiBA"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * The capture library (RCL-09) — browsing what has been captured, rather than
3
+ * searching it.
4
+ *
5
+ * `listDocuments` answers "what is indexed". A library answers a different
6
+ * question: everything from this site, captured last week, tagged `reading`,
7
+ * newest first. The facets come from the capture envelope's `meta.json`
8
+ * (RCL-07), which is already on every record — this module is the query layer
9
+ * over them, and the data layer the desktop GUI renders.
10
+ *
11
+ * Rules, once, here:
12
+ * - within a facet values are OR'd, across facets AND'd (`--site a --site b
13
+ * --tag x` = "from a or b, tagged x");
14
+ * - `--site example.com` matches `www.example.com` and `docs.example.com`,
15
+ * because nobody browsing their own library means the bare host only;
16
+ * - a document with no provenance (an ordinary file on disk) sorts by its
17
+ * index time and matches no capture facet — it is not a capture.
18
+ *
19
+ * @module v1/cli/knowledge/library
20
+ */
21
+ import * as path from 'node:path';
22
+ // ── Facet extraction ───────────────────────────────────────────────
23
+ /** The host a document was captured from, or undefined for a local file. */
24
+ export function documentSite(meta) {
25
+ const url = meta.canonicalUrl ?? meta.provenance?.canonicalUrl ?? meta.provenance?.url;
26
+ if (!url)
27
+ return undefined;
28
+ try {
29
+ return new URL(url).hostname.toLowerCase().replace(/^www\./, '');
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ }
35
+ /** When the page was captured; falls back to when it was indexed. */
36
+ export function documentCapturedAt(meta) {
37
+ return meta.provenance?.capturedAt ?? meta.indexedAt ?? '';
38
+ }
39
+ const RELATIVE_RE = /^(\d+(?:\.\d+)?)\s*(m|h|d|w)$/i;
40
+ const UNIT_MS = {
41
+ m: 60_000,
42
+ h: 3_600_000,
43
+ d: 86_400_000,
44
+ w: 604_800_000,
45
+ };
46
+ /**
47
+ * A point in time from `2026-09-01`, a full ISO stamp, or an AGE like `7d`
48
+ * (meaning "7 days ago"). Returns null for anything unparseable so a typo
49
+ * cannot silently filter the whole library away.
50
+ */
51
+ export function parseWhen(value, now = Date.now()) {
52
+ const raw = (value ?? '').trim();
53
+ if (!raw)
54
+ return null;
55
+ const rel = RELATIVE_RE.exec(raw);
56
+ if (rel)
57
+ return now - Number(rel[1]) * UNIT_MS[rel[2].toLowerCase()];
58
+ const parsed = Date.parse(raw.length === 10 ? `${raw}T00:00:00.000Z` : raw);
59
+ return Number.isNaN(parsed) ? null : parsed;
60
+ }
61
+ function siteMatches(host, wanted) {
62
+ if (!host)
63
+ return false;
64
+ return wanted.some((w) => {
65
+ const want = w
66
+ .trim()
67
+ .toLowerCase()
68
+ .replace(/^www\./, '');
69
+ return !!want && (host === want || host.endsWith(`.${want}`));
70
+ });
71
+ }
72
+ function anyOf(values, wanted) {
73
+ const have = (values ?? []).map((v) => v.toLowerCase());
74
+ return wanted.some((w) => have.includes(w.trim().toLowerCase()));
75
+ }
76
+ /** True when a document belongs in this view. */
77
+ export function matchesLibraryFilter(meta, filter = {}, now = Date.now()) {
78
+ if (filter.scope && meta.scope !== filter.scope)
79
+ return false;
80
+ const prov = meta.provenance;
81
+ const isCapture = !!prov || !!meta.canonicalUrl;
82
+ if (filter.capturedOnly && !isCapture)
83
+ return false;
84
+ if (filter.site?.length && !siteMatches(documentSite(meta), filter.site))
85
+ return false;
86
+ if (filter.tag?.length && !anyOf(prov?.tags, filter.tag))
87
+ return false;
88
+ if (filter.collection?.length &&
89
+ !anyOf(prov?.collection ? [prov.collection] : [], filter.collection))
90
+ return false;
91
+ if (filter.source?.length && !anyOf(prov?.source ? [prov.source] : [], filter.source))
92
+ return false;
93
+ if (filter.since || filter.until) {
94
+ const at = Date.parse(documentCapturedAt(meta));
95
+ const since = parseWhen(filter.since, now);
96
+ const until = parseWhen(filter.until, now);
97
+ if (Number.isNaN(at))
98
+ return false;
99
+ if (since !== null && at < since)
100
+ return false;
101
+ if (until !== null && at > until)
102
+ return false;
103
+ }
104
+ if (filter.text) {
105
+ const needle = filter.text.toLowerCase();
106
+ const hay = [
107
+ prov?.title ?? '',
108
+ meta.canonicalUrl ?? prov?.url ?? '',
109
+ meta.filePath,
110
+ prov?.note ?? '',
111
+ ]
112
+ .join(' ')
113
+ .toLowerCase();
114
+ if (!hay.includes(needle))
115
+ return false;
116
+ }
117
+ return true;
118
+ }
119
+ export function filterDocuments(docs, filter = {}, now = Date.now()) {
120
+ return docs.filter((d) => matchesLibraryFilter(d, filter, now));
121
+ }
122
+ export function sortDocuments(docs, sort = 'captured', order = 'desc') {
123
+ const dir = order === 'asc' ? 1 : -1;
124
+ const key = (d) => {
125
+ switch (sort) {
126
+ case 'indexed':
127
+ return d.indexedAt ?? '';
128
+ case 'title':
129
+ return (d.provenance?.title ?? path.basename(d.filePath)).toLowerCase();
130
+ case 'path':
131
+ return d.filePath;
132
+ case 'size':
133
+ return d.size ?? 0;
134
+ default:
135
+ return documentCapturedAt(d);
136
+ }
137
+ };
138
+ return [...docs].sort((a, b) => {
139
+ const ka = key(a);
140
+ const kb = key(b);
141
+ if (ka === kb)
142
+ return a.filePath.localeCompare(b.filePath);
143
+ return ka < kb ? -dir : dir;
144
+ });
145
+ }
146
+ /** The flat, JSON-friendly row the GUI and `--json` consumers read. */
147
+ export function libraryEntry(meta) {
148
+ const prov = meta.provenance;
149
+ const url = meta.canonicalUrl ?? prov?.canonicalUrl ?? prov?.url;
150
+ return {
151
+ filePath: meta.filePath,
152
+ scope: meta.scope,
153
+ title: prov?.title ?? path.basename(meta.filePath),
154
+ ...(url ? { url } : {}),
155
+ ...(documentSite(meta) ? { site: documentSite(meta) } : {}),
156
+ capturedAt: documentCapturedAt(meta),
157
+ indexedAt: meta.indexedAt,
158
+ ...(prov?.source ? { source: prov.source } : {}),
159
+ ...(prov?.collection ? { collection: prov.collection } : {}),
160
+ tags: prov?.tags ?? [],
161
+ chunkCount: meta.chunkCount,
162
+ size: meta.size,
163
+ ...(meta.version ? { version: meta.version } : {}),
164
+ captured: !!prov || !!meta.canonicalUrl,
165
+ };
166
+ }
167
+ /** Browse the library: filter, sort, cap. Never throws on an empty store. */
168
+ export function listLibrary(docs, opts = {}) {
169
+ const now = opts.now ?? Date.now();
170
+ const filtered = filterDocuments(docs, opts, now);
171
+ const sorted = sortDocuments(filtered, opts.sort ?? 'captured', opts.order ?? 'desc');
172
+ const capped = opts.limit && opts.limit > 0 ? sorted.slice(0, opts.limit) : sorted;
173
+ return capped.map(libraryEntry);
174
+ }
175
+ /** Facet counts for the current view — what a sidebar renders. */
176
+ export function libraryFacets(docs) {
177
+ const tally = (values) => {
178
+ const counts = new Map();
179
+ for (const v of values) {
180
+ if (!v)
181
+ continue;
182
+ counts.set(v, (counts.get(v) ?? 0) + 1);
183
+ }
184
+ return [...counts.entries()]
185
+ .map(([value, count]) => ({ value, count }))
186
+ .sort((a, b) => b.count - a.count || a.value.localeCompare(b.value));
187
+ };
188
+ return {
189
+ sites: tally(docs.map(documentSite)),
190
+ tags: tally(docs.flatMap((d) => d.provenance?.tags ?? [])),
191
+ collections: tally(docs.map((d) => d.provenance?.collection)),
192
+ sources: tally(docs.map((d) => d.provenance?.source)),
193
+ };
194
+ }
195
+ //# sourceMappingURL=library.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library.js","sourceRoot":"","sources":["../../../src/knowledge/library.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAyClC,sEAAsE;AAEtE,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,IAG5B;IACC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,UAAU,EAAE,YAAY,IAAI,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC;IACvF,I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C,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;KACtD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MHTML / MHT container parsing (RCL-01).
3
+ *
4
+ * An MHTML archive is an RFC 2557 `multipart/related` MIME message: the page
5
+ * plus every subresource it referenced, each part carrying its own transfer
6
+ * encoding and charset. Chrome's `Page.captureSnapshot` writes them
7
+ * quoted-printable; Internet Explorer and most "save as web archive" tools
8
+ * write base64.
9
+ *
10
+ * Only the ROOT frame is prose. Picking the first `text/html` part instead is
11
+ * how an ad iframe ends up indexed as the article, so the root is resolved
12
+ * from the container's `Snapshot-Content-Location` / `Content-Location` when
13
+ * one is present.
14
+ *
15
+ * Read the file as `latin1` (or pass a Buffer): byte fidelity matters before
16
+ * transfer decoding, and the real charset is only known per part.
17
+ *
18
+ * @module v1/cli/knowledge/mhtml
19
+ */
20
+ export interface MhtmlPart {
21
+ /** Lowercased MIME type without parameters, e.g. `text/html`. */
22
+ contentType: string;
23
+ /** Charset from the part's Content-Type, lowercased, or null. */
24
+ charset: string | null;
25
+ /** Content-Location, or null. */
26
+ location: string | null;
27
+ /** Lowercased Content-Transfer-Encoding; `binary` when unstated. */
28
+ encoding: string;
29
+ /** Raw bytes after transfer decoding. */
30
+ body: Buffer;
31
+ headers: Record<string, string>;
32
+ }
33
+ export interface ParsedMhtml {
34
+ /** The part holding the page itself, or null when there is no HTML part. */
35
+ root: MhtmlPart | null;
36
+ parts: MhtmlPart[];
37
+ /** Container `Snapshot-Content-Location`/`Content-Location` header. */
38
+ snapshotLocation: string | null;
39
+ /** Container `Subject` header — Chrome writes the page title here. */
40
+ subject: string | null;
41
+ }
42
+ /** Decode a quoted-printable body to bytes: soft line breaks vanish, `=XX`
43
+ * becomes one byte, everything else is its own latin1 byte. */
44
+ export declare function decodeQuotedPrintable(input: string): Buffer;
45
+ /** Decode bytes under a MIME charset, falling back to UTF-8 (then latin1)
46
+ * rather than failing an ingest over an exotic label. */
47
+ export declare function decodeCharset(bytes: Buffer, charset: string | null): string;
48
+ /**
49
+ * Parse an MHTML container. Anything that is not a well-formed multipart
50
+ * message is treated as a single part, so a plain `.html` file renamed to
51
+ * `.mhtml` still ingests.
52
+ */
53
+ export declare function parseMhtml(raw: string | Buffer): ParsedMhtml;
54
+ /** Parse a container and return its root frame decoded to a string. */
55
+ export declare function mhtmlToHtml(raw: string | Buffer): {
56
+ html: string;
57
+ location: string | null;
58
+ subject: string | null;
59
+ };
60
+ //# sourceMappingURL=mhtml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mhtml.d.ts","sourceRoot":"","sources":["../../../src/knowledge/mhtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,SAAS;IACxB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,uEAAuE;IACvE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,sEAAsE;IACtE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;gEACgE;AAChE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyB3D;AAaD;0DAC0D;AAC1D,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAA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