@afaik-lab/weigh 0.0.0 → 0.6.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 (349) hide show
  1. package/.env.example +49 -0
  2. package/LICENSE +373 -0
  3. package/README.md +103 -1
  4. package/dist/agent.d.ts +83 -0
  5. package/dist/agent.d.ts.map +1 -0
  6. package/dist/agent.js +204 -0
  7. package/dist/agent.js.map +1 -0
  8. package/dist/ceilings.d.ts +32 -0
  9. package/dist/ceilings.d.ts.map +1 -0
  10. package/dist/ceilings.js +61 -0
  11. package/dist/ceilings.js.map +1 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +530 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/config-cli.d.ts +15 -0
  17. package/dist/config-cli.d.ts.map +1 -0
  18. package/dist/config-cli.js +141 -0
  19. package/dist/config-cli.js.map +1 -0
  20. package/dist/config.d.ts +198 -0
  21. package/dist/config.d.ts.map +1 -0
  22. package/dist/config.js +373 -0
  23. package/dist/config.js.map +1 -0
  24. package/dist/context-cli.d.ts +35 -0
  25. package/dist/context-cli.d.ts.map +1 -0
  26. package/dist/context-cli.js +251 -0
  27. package/dist/context-cli.js.map +1 -0
  28. package/dist/context.d.ts +118 -0
  29. package/dist/context.d.ts.map +1 -0
  30. package/dist/context.js +159 -0
  31. package/dist/context.js.map +1 -0
  32. package/dist/corrections/correction-set.d.ts +67 -0
  33. package/dist/corrections/correction-set.d.ts.map +1 -0
  34. package/dist/corrections/correction-set.js +104 -0
  35. package/dist/corrections/correction-set.js.map +1 -0
  36. package/dist/corrections/correction.d.ts +74 -0
  37. package/dist/corrections/correction.d.ts.map +1 -0
  38. package/dist/corrections/correction.js +154 -0
  39. package/dist/corrections/correction.js.map +1 -0
  40. package/dist/corrections/follow-up.d.ts +69 -0
  41. package/dist/corrections/follow-up.d.ts.map +1 -0
  42. package/dist/corrections/follow-up.js +217 -0
  43. package/dist/corrections/follow-up.js.map +1 -0
  44. package/dist/corrections/index.d.ts +31 -0
  45. package/dist/corrections/index.d.ts.map +1 -0
  46. package/dist/corrections/index.js +31 -0
  47. package/dist/corrections/index.js.map +1 -0
  48. package/dist/corrections/ledger.d.ts +78 -0
  49. package/dist/corrections/ledger.d.ts.map +1 -0
  50. package/dist/corrections/ledger.js +117 -0
  51. package/dist/corrections/ledger.js.map +1 -0
  52. package/dist/corrections/promotion.d.ts +119 -0
  53. package/dist/corrections/promotion.d.ts.map +1 -0
  54. package/dist/corrections/promotion.js +221 -0
  55. package/dist/corrections/promotion.js.map +1 -0
  56. package/dist/corrections/schema.d.ts +125 -0
  57. package/dist/corrections/schema.d.ts.map +1 -0
  58. package/dist/corrections/schema.js +100 -0
  59. package/dist/corrections/schema.js.map +1 -0
  60. package/dist/corrections-cli.d.ts +28 -0
  61. package/dist/corrections-cli.d.ts.map +1 -0
  62. package/dist/corrections-cli.js +157 -0
  63. package/dist/corrections-cli.js.map +1 -0
  64. package/dist/diff.d.ts +105 -0
  65. package/dist/diff.d.ts.map +1 -0
  66. package/dist/diff.js +202 -0
  67. package/dist/diff.js.map +1 -0
  68. package/dist/doctor.d.ts +38 -0
  69. package/dist/doctor.d.ts.map +1 -0
  70. package/dist/doctor.js +197 -0
  71. package/dist/doctor.js.map +1 -0
  72. package/dist/events.d.ts +21 -0
  73. package/dist/events.d.ts.map +1 -0
  74. package/dist/events.js +5 -0
  75. package/dist/events.js.map +1 -0
  76. package/dist/findings.d.ts +510 -0
  77. package/dist/findings.d.ts.map +1 -0
  78. package/dist/findings.js +645 -0
  79. package/dist/findings.js.map +1 -0
  80. package/dist/follow-up-cli.d.ts +88 -0
  81. package/dist/follow-up-cli.d.ts.map +1 -0
  82. package/dist/follow-up-cli.js +208 -0
  83. package/dist/follow-up-cli.js.map +1 -0
  84. package/dist/harness.d.ts +64 -0
  85. package/dist/harness.d.ts.map +1 -0
  86. package/dist/harness.js +71 -0
  87. package/dist/harness.js.map +1 -0
  88. package/dist/help/command-help.d.ts +9 -0
  89. package/dist/help/command-help.d.ts.map +1 -0
  90. package/dist/help/command-help.js +21 -0
  91. package/dist/help/command-help.js.map +1 -0
  92. package/dist/help/commands/answer.d.ts +3 -0
  93. package/dist/help/commands/answer.d.ts.map +1 -0
  94. package/dist/help/commands/answer.js +39 -0
  95. package/dist/help/commands/answer.js.map +1 -0
  96. package/dist/help/commands/config.d.ts +3 -0
  97. package/dist/help/commands/config.d.ts.map +1 -0
  98. package/dist/help/commands/config.js +25 -0
  99. package/dist/help/commands/config.js.map +1 -0
  100. package/dist/help/commands/context.d.ts +3 -0
  101. package/dist/help/commands/context.d.ts.map +1 -0
  102. package/dist/help/commands/context.js +44 -0
  103. package/dist/help/commands/context.js.map +1 -0
  104. package/dist/help/commands/corrections.d.ts +3 -0
  105. package/dist/help/commands/corrections.d.ts.map +1 -0
  106. package/dist/help/commands/corrections.js +30 -0
  107. package/dist/help/commands/corrections.js.map +1 -0
  108. package/dist/help/commands/doctor.d.ts +3 -0
  109. package/dist/help/commands/doctor.d.ts.map +1 -0
  110. package/dist/help/commands/doctor.js +12 -0
  111. package/dist/help/commands/doctor.js.map +1 -0
  112. package/dist/help/commands/index.d.ts +4 -0
  113. package/dist/help/commands/index.d.ts.map +1 -0
  114. package/dist/help/commands/index.js +27 -0
  115. package/dist/help/commands/index.js.map +1 -0
  116. package/dist/help/commands/memory.d.ts +3 -0
  117. package/dist/help/commands/memory.d.ts.map +1 -0
  118. package/dist/help/commands/memory.js +33 -0
  119. package/dist/help/commands/memory.js.map +1 -0
  120. package/dist/help/commands/models.d.ts +3 -0
  121. package/dist/help/commands/models.d.ts.map +1 -0
  122. package/dist/help/commands/models.js +17 -0
  123. package/dist/help/commands/models.js.map +1 -0
  124. package/dist/help/commands/options.d.ts +4 -0
  125. package/dist/help/commands/options.d.ts.map +1 -0
  126. package/dist/help/commands/options.js +13 -0
  127. package/dist/help/commands/options.js.map +1 -0
  128. package/dist/help/commands/review.d.ts +3 -0
  129. package/dist/help/commands/review.d.ts.map +1 -0
  130. package/dist/help/commands/review.js +50 -0
  131. package/dist/help/commands/review.js.map +1 -0
  132. package/dist/help/commands/sessions.d.ts +3 -0
  133. package/dist/help/commands/sessions.d.ts.map +1 -0
  134. package/dist/help/commands/sessions.js +23 -0
  135. package/dist/help/commands/sessions.js.map +1 -0
  136. package/dist/help/commands/show.d.ts +3 -0
  137. package/dist/help/commands/show.d.ts.map +1 -0
  138. package/dist/help/commands/show.js +18 -0
  139. package/dist/help/commands/show.js.map +1 -0
  140. package/dist/help/help.d.ts +16 -0
  141. package/dist/help/help.d.ts.map +1 -0
  142. package/dist/help/help.js +68 -0
  143. package/dist/help/help.js.map +1 -0
  144. package/dist/help/index.d.ts +4 -0
  145. package/dist/help/index.d.ts.map +1 -0
  146. package/dist/help/index.js +7 -0
  147. package/dist/help/index.js.map +1 -0
  148. package/dist/index.d.ts +80 -0
  149. package/dist/index.d.ts.map +1 -0
  150. package/dist/index.js +51 -0
  151. package/dist/index.js.map +1 -0
  152. package/dist/knowledge/block.d.ts +65 -0
  153. package/dist/knowledge/block.d.ts.map +1 -0
  154. package/dist/knowledge/block.js +89 -0
  155. package/dist/knowledge/block.js.map +1 -0
  156. package/dist/knowledge/claim.d.ts +143 -0
  157. package/dist/knowledge/claim.d.ts.map +1 -0
  158. package/dist/knowledge/claim.js +303 -0
  159. package/dist/knowledge/claim.js.map +1 -0
  160. package/dist/knowledge/index.d.ts +32 -0
  161. package/dist/knowledge/index.d.ts.map +1 -0
  162. package/dist/knowledge/index.js +29 -0
  163. package/dist/knowledge/index.js.map +1 -0
  164. package/dist/knowledge/novelty.d.ts +65 -0
  165. package/dist/knowledge/novelty.d.ts.map +1 -0
  166. package/dist/knowledge/novelty.js +100 -0
  167. package/dist/knowledge/novelty.js.map +1 -0
  168. package/dist/knowledge/recall.d.ts +134 -0
  169. package/dist/knowledge/recall.d.ts.map +1 -0
  170. package/dist/knowledge/recall.js +229 -0
  171. package/dist/knowledge/recall.js.map +1 -0
  172. package/dist/knowledge/recalled-claim.d.ts +35 -0
  173. package/dist/knowledge/recalled-claim.d.ts.map +1 -0
  174. package/dist/knowledge/recalled-claim.js +67 -0
  175. package/dist/knowledge/recalled-claim.js.map +1 -0
  176. package/dist/knowledge/recalled.d.ts +70 -0
  177. package/dist/knowledge/recalled.d.ts.map +1 -0
  178. package/dist/knowledge/recalled.js +149 -0
  179. package/dist/knowledge/recalled.js.map +1 -0
  180. package/dist/knowledge/schema.d.ts +83 -0
  181. package/dist/knowledge/schema.d.ts.map +1 -0
  182. package/dist/knowledge/schema.js +96 -0
  183. package/dist/knowledge/schema.js.map +1 -0
  184. package/dist/knowledge/staleness.d.ts +48 -0
  185. package/dist/knowledge/staleness.d.ts.map +1 -0
  186. package/dist/knowledge/staleness.js +85 -0
  187. package/dist/knowledge/staleness.js.map +1 -0
  188. package/dist/knowledge/store.d.ts +100 -0
  189. package/dist/knowledge/store.d.ts.map +1 -0
  190. package/dist/knowledge/store.js +184 -0
  191. package/dist/knowledge/store.js.map +1 -0
  192. package/dist/memory/compose-file.d.ts +14 -0
  193. package/dist/memory/compose-file.d.ts.map +1 -0
  194. package/dist/memory/compose-file.js +25 -0
  195. package/dist/memory/compose-file.js.map +1 -0
  196. package/dist/memory/index.d.ts +43 -0
  197. package/dist/memory/index.d.ts.map +1 -0
  198. package/dist/memory/index.js +119 -0
  199. package/dist/memory/index.js.map +1 -0
  200. package/dist/memory/oss.d.ts +62 -0
  201. package/dist/memory/oss.d.ts.map +1 -0
  202. package/dist/memory/oss.js +230 -0
  203. package/dist/memory/oss.js.map +1 -0
  204. package/dist/memory/platform.d.ts +37 -0
  205. package/dist/memory/platform.d.ts.map +1 -0
  206. package/dist/memory/platform.js +131 -0
  207. package/dist/memory/platform.js.map +1 -0
  208. package/dist/memory/scope.d.ts +49 -0
  209. package/dist/memory/scope.d.ts.map +1 -0
  210. package/dist/memory/scope.js +70 -0
  211. package/dist/memory/scope.js.map +1 -0
  212. package/dist/memory/types.d.ts +113 -0
  213. package/dist/memory/types.d.ts.map +1 -0
  214. package/dist/memory/types.js +18 -0
  215. package/dist/memory/types.js.map +1 -0
  216. package/dist/memory-cli.d.ts +17 -0
  217. package/dist/memory-cli.d.ts.map +1 -0
  218. package/dist/memory-cli.js +107 -0
  219. package/dist/memory-cli.js.map +1 -0
  220. package/dist/models-cli.d.ts +12 -0
  221. package/dist/models-cli.d.ts.map +1 -0
  222. package/dist/models-cli.js +54 -0
  223. package/dist/models-cli.js.map +1 -0
  224. package/dist/models.d.ts +111 -0
  225. package/dist/models.d.ts.map +1 -0
  226. package/dist/models.js +228 -0
  227. package/dist/models.js.map +1 -0
  228. package/dist/paths.d.ts +35 -0
  229. package/dist/paths.d.ts.map +1 -0
  230. package/dist/paths.js +65 -0
  231. package/dist/paths.js.map +1 -0
  232. package/dist/profile.d.ts +28 -0
  233. package/dist/profile.d.ts.map +1 -0
  234. package/dist/profile.js +154 -0
  235. package/dist/profile.js.map +1 -0
  236. package/dist/progress.d.ts +70 -0
  237. package/dist/progress.d.ts.map +1 -0
  238. package/dist/progress.js +132 -0
  239. package/dist/progress.js.map +1 -0
  240. package/dist/quiet.d.ts +2 -0
  241. package/dist/quiet.d.ts.map +1 -0
  242. package/dist/quiet.js +21 -0
  243. package/dist/quiet.js.map +1 -0
  244. package/dist/reconcile/continuation.d.ts +132 -0
  245. package/dist/reconcile/continuation.d.ts.map +1 -0
  246. package/dist/reconcile/continuation.js +306 -0
  247. package/dist/reconcile/continuation.js.map +1 -0
  248. package/dist/reconcile/index.d.ts +26 -0
  249. package/dist/reconcile/index.d.ts.map +1 -0
  250. package/dist/reconcile/index.js +28 -0
  251. package/dist/reconcile/index.js.map +1 -0
  252. package/dist/reconcile/outcome-set.d.ts +53 -0
  253. package/dist/reconcile/outcome-set.d.ts.map +1 -0
  254. package/dist/reconcile/outcome-set.js +124 -0
  255. package/dist/reconcile/outcome-set.js.map +1 -0
  256. package/dist/reconcile/outcome.d.ts +56 -0
  257. package/dist/reconcile/outcome.d.ts.map +1 -0
  258. package/dist/reconcile/outcome.js +60 -0
  259. package/dist/reconcile/outcome.js.map +1 -0
  260. package/dist/reconcile/reconciliation.d.ts +49 -0
  261. package/dist/reconcile/reconciliation.d.ts.map +1 -0
  262. package/dist/reconcile/reconciliation.js +88 -0
  263. package/dist/reconcile/reconciliation.js.map +1 -0
  264. package/dist/reconcile/schema.d.ts +157 -0
  265. package/dist/reconcile/schema.d.ts.map +1 -0
  266. package/dist/reconcile/schema.js +97 -0
  267. package/dist/reconcile/schema.js.map +1 -0
  268. package/dist/record/index.d.ts +23 -0
  269. package/dist/record/index.d.ts.map +1 -0
  270. package/dist/record/index.js +25 -0
  271. package/dist/record/index.js.map +1 -0
  272. package/dist/record/review-record.d.ts +28 -0
  273. package/dist/record/review-record.d.ts.map +1 -0
  274. package/dist/record/review-record.js +78 -0
  275. package/dist/record/review-record.js.map +1 -0
  276. package/dist/record/schema.d.ts +153 -0
  277. package/dist/record/schema.d.ts.map +1 -0
  278. package/dist/record/schema.js +87 -0
  279. package/dist/record/schema.js.map +1 -0
  280. package/dist/record/store.d.ts +83 -0
  281. package/dist/record/store.d.ts.map +1 -0
  282. package/dist/record/store.js +162 -0
  283. package/dist/record/store.js.map +1 -0
  284. package/dist/record/stored-review.d.ts +36 -0
  285. package/dist/record/stored-review.d.ts.map +1 -0
  286. package/dist/record/stored-review.js +90 -0
  287. package/dist/record/stored-review.js.map +1 -0
  288. package/dist/refute.d.ts +318 -0
  289. package/dist/refute.d.ts.map +1 -0
  290. package/dist/refute.js +513 -0
  291. package/dist/refute.js.map +1 -0
  292. package/dist/render.d.ts +212 -0
  293. package/dist/render.d.ts.map +1 -0
  294. package/dist/render.js +544 -0
  295. package/dist/render.js.map +1 -0
  296. package/dist/review-cli.d.ts +181 -0
  297. package/dist/review-cli.d.ts.map +1 -0
  298. package/dist/review-cli.js +598 -0
  299. package/dist/review-cli.js.map +1 -0
  300. package/dist/reviewer.d.ts +297 -0
  301. package/dist/reviewer.d.ts.map +1 -0
  302. package/dist/reviewer.js +584 -0
  303. package/dist/reviewer.js.map +1 -0
  304. package/dist/session-cli.d.ts +17 -0
  305. package/dist/session-cli.d.ts.map +1 -0
  306. package/dist/session-cli.js +62 -0
  307. package/dist/session-cli.js.map +1 -0
  308. package/dist/session.d.ts +36 -0
  309. package/dist/session.d.ts.map +1 -0
  310. package/dist/session.js +105 -0
  311. package/dist/session.js.map +1 -0
  312. package/dist/settings.d.ts +68 -0
  313. package/dist/settings.d.ts.map +1 -0
  314. package/dist/settings.js +175 -0
  315. package/dist/settings.js.map +1 -0
  316. package/dist/show-cli.d.ts +39 -0
  317. package/dist/show-cli.d.ts.map +1 -0
  318. package/dist/show-cli.js +56 -0
  319. package/dist/show-cli.js.map +1 -0
  320. package/dist/stdout.d.ts +28 -0
  321. package/dist/stdout.d.ts.map +1 -0
  322. package/dist/stdout.js +44 -0
  323. package/dist/stdout.js.map +1 -0
  324. package/dist/target.d.ts +58 -0
  325. package/dist/target.d.ts.map +1 -0
  326. package/dist/target.js +96 -0
  327. package/dist/target.js.map +1 -0
  328. package/dist/tools/index.d.ts +93 -0
  329. package/dist/tools/index.d.ts.map +1 -0
  330. package/dist/tools/index.js +146 -0
  331. package/dist/tools/index.js.map +1 -0
  332. package/dist/tools/root.d.ts +62 -0
  333. package/dist/tools/root.d.ts.map +1 -0
  334. package/dist/tools/root.js +51 -0
  335. package/dist/tools/root.js.map +1 -0
  336. package/dist/usage.d.ts +75 -0
  337. package/dist/usage.d.ts.map +1 -0
  338. package/dist/usage.js +100 -0
  339. package/dist/usage.js.map +1 -0
  340. package/dist/version.d.ts +14 -0
  341. package/dist/version.d.ts.map +1 -0
  342. package/dist/version.js +26 -0
  343. package/dist/version.js.map +1 -0
  344. package/dist/workspace.d.ts +48 -0
  345. package/dist/workspace.d.ts.map +1 -0
  346. package/dist/workspace.js +126 -0
  347. package/dist/workspace.js.map +1 -0
  348. package/docker-compose.yml +61 -0
  349. package/package.json +72 -1
@@ -0,0 +1,584 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ import { query } from '@anthropic-ai/claude-agent-sdk';
5
+ import { looksGenerated, renderContext } from './context.js';
6
+ import { refreshCatalogue } from './models.js';
7
+ import { FindingSet, Verdict, WorkspaceFiles, reviewOutputSchema, strictJsonSchema, } from './findings.js';
8
+ import { harnessOptions } from './harness.js';
9
+ import { Ceilings } from './ceilings.js';
10
+ import { Spend } from './usage.js';
11
+ import { OutcomeSet, continuationOutputSchema, } from './reconcile/index.js';
12
+ import { CorrectionSet } from './corrections/index.js';
13
+ /**
14
+ * Which changed files the reviewer actually opened.
15
+ *
16
+ * One loop reading what it chooses is cheaper and reasons across files, but it
17
+ * gives up the guarantee that every changed file was looked at. This is the
18
+ * accounting taken in exchange: a number printed beside the review, rather than
19
+ * a promise nobody can check. A run that read four of forty files and said
20
+ * nothing is not a clean review, and without this it would read like one.
21
+ */
22
+ export class CoverageLedger {
23
+ _sinceLastReview;
24
+ _changed;
25
+ _opened = new Set();
26
+ /**
27
+ * `sinceLastReview` says the changed files are those since the last review,
28
+ * not the whole branch. Said in the line rather than left implied: "3 of 3"
29
+ * on a fifty-file branch reads as a thorough review of all of it.
30
+ */
31
+ constructor(changed, _sinceLastReview = false) {
32
+ this._sinceLastReview = _sinceLastReview;
33
+ this._changed = new Set(changed);
34
+ }
35
+ /** Records a path the reviewer asked for. Paths it invented are ignored. */
36
+ record(path) {
37
+ if (!path)
38
+ return;
39
+ const normalised = path.replace(/^\.\//, '');
40
+ if (this._changed.has(normalised))
41
+ this._opened.add(normalised);
42
+ }
43
+ get opened() {
44
+ return [...this._opened].sort();
45
+ }
46
+ get unopened() {
47
+ return [...this._changed].filter((p) => !this._opened.has(p)).sort();
48
+ }
49
+ get changedCount() {
50
+ return this._changed.size;
51
+ }
52
+ /** Nothing changed is full coverage, not a division by zero. */
53
+ get ratio() {
54
+ return this._changed.size === 0 ? 1 : this._opened.size / this._changed.size;
55
+ }
56
+ describe() {
57
+ if (this._changed.size === 0)
58
+ return 'no changed files';
59
+ const unopened = this.unopened;
60
+ const files = this._sinceLastReview ? 'files changed since the last review' : 'changed files';
61
+ const head = `read ${this._opened.size} of ${this._changed.size} ${files}`;
62
+ return unopened.length === 0 ? head : `${head} · unread: ${unopened.join(', ')}`;
63
+ }
64
+ }
65
+ /**
66
+ * What the reviewer is held to, as opposed to what it was shown.
67
+ *
68
+ * A deleted file has nothing to open, a binary has nothing to read, and a
69
+ * lockfile is not what anyone means by "did you look at the change". Holding a
70
+ * run to those would send it back to fetch files that cannot inform it, and
71
+ * the nudge would name paths it is bound to fail on.
72
+ *
73
+ * Reported coverage still counts every changed file — that number is meant to
74
+ * be honest about the diff, not flattering about the run.
75
+ */
76
+ export function readableFiles(files) {
77
+ return files.filter((f) => f.status !== 'deleted' && !f.binary && !looksGenerated(f.path)).map((f) => f.path);
78
+ }
79
+ /**
80
+ * Sends a review back when it reports on code it never opened.
81
+ *
82
+ * `hasToolCall('report_review')` used to make reporting the end of a review,
83
+ * and nothing in the Agent SDK replaces it: the model fills in the schema
84
+ * whenever it feels ready, and measured runs did so after four reads of a
85
+ * fifty-five file diff. A ceiling stops a run that reads too much; this is the
86
+ * floor that catches one that reads too little.
87
+ *
88
+ * It nudges rather than enforces. The floor is not reached by insisting — a
89
+ * run that has been sent back twice and is still short gets to report anyway,
90
+ * with its coverage stated beside the findings. The alternative is a review
91
+ * that never returns, which is worse than a shallow one that admits it.
92
+ */
93
+ export class CoverageGate {
94
+ _ledger;
95
+ _expected;
96
+ _floor;
97
+ _maxNudges;
98
+ _onEvent;
99
+ _nudges = 0;
100
+ constructor(_ledger,
101
+ /** The files a run can fairly be held to. */
102
+ _expected, _floor,
103
+ /**
104
+ * Two, and fixed. Each nudge costs a round of reading, and a model that
105
+ * ignored the first two is not going to yield to a third — it is going to
106
+ * spend the budget that should have paid for the review.
107
+ */
108
+ _maxNudges = 2, _onEvent) {
109
+ this._ledger = _ledger;
110
+ this._expected = _expected;
111
+ this._floor = _floor;
112
+ this._maxNudges = _maxNudges;
113
+ this._onEvent = _onEvent;
114
+ }
115
+ /** How many times the run was sent back. Reported beside the coverage. */
116
+ get nudges() {
117
+ return this._nudges;
118
+ }
119
+ /**
120
+ * The files still unopened, or undefined when the run may finish.
121
+ *
122
+ * Nothing to be held to, no floor asked for, or already sent back as often
123
+ * as it is worth. `stop_hook_active` is deliberately not the guard: it says
124
+ * only that some stop hook is mid-retry, which cannot express "twice".
125
+ */
126
+ _shortfall() {
127
+ if (this._floor <= 0 || this._expected.length === 0 || this._nudges >= this._maxNudges)
128
+ return undefined;
129
+ const opened = new Set(this._ledger.opened);
130
+ const unread = this._expected.filter((path) => !opened.has(path));
131
+ const read = this._expected.length - unread.length;
132
+ if (read / this._expected.length >= this._floor)
133
+ return undefined;
134
+ return { read, unread };
135
+ }
136
+ _nudge(short) {
137
+ this._nudges++;
138
+ this._onEvent?.({ type: 'coverage_nudge', read: short.read, expected: this._expected.length });
139
+ return this._reason(short.read, short.unread);
140
+ }
141
+ /**
142
+ * Bound for `options.hooks.PreToolUse`, matched to the report tool.
143
+ *
144
+ * This is the half that works, and the reason both halves exist. With
145
+ * `outputFormat` set, submitting the review is an *end-turn* tool call: the
146
+ * turn is over the moment it succeeds. Measured — a Stop hook fires and
147
+ * blocks, and the run ends one second later anyway, because by then the
148
+ * output has committed and there is no turn left to send back. Refusing the
149
+ * call is early enough; blocking the stop is not.
150
+ */
151
+ report = async (input) => {
152
+ const pre = input;
153
+ if (pre.hook_event_name !== 'PreToolUse')
154
+ return {};
155
+ const short = this._shortfall();
156
+ if (!short)
157
+ return {};
158
+ return {
159
+ hookSpecificOutput: {
160
+ hookEventName: 'PreToolUse',
161
+ permissionDecision: 'deny',
162
+ permissionDecisionReason: this._nudge(short),
163
+ },
164
+ };
165
+ };
166
+ /**
167
+ * Bound for `options.hooks.Stop`.
168
+ *
169
+ * Kept for the exit the tool hook cannot see: a run that stops without
170
+ * submitting a review at all, having written its findings as prose. That
171
+ * turn has not ended on a tool, so blocking it still has somewhere to go.
172
+ */
173
+ stop = async (input) => {
174
+ const stop = input;
175
+ if (stop.hook_event_name !== 'Stop')
176
+ return {};
177
+ const short = this._shortfall();
178
+ if (!short)
179
+ return {};
180
+ return { decision: 'block', reason: this._nudge(short) };
181
+ };
182
+ /**
183
+ * Why it is going back, and what would satisfy it.
184
+ *
185
+ * The last two sentences are load-bearing. Told only that it has not read
186
+ * enough, a model reads more and then justifies the trip with findings it
187
+ * would not otherwise have written — which converts a coverage problem into
188
+ * a false-positive problem, and the second is harder to notice.
189
+ */
190
+ _reason(read, unread) {
191
+ const shown = unread.slice(0, 12);
192
+ const rest = unread.length - shown.length;
193
+ // A second nudge that reads identically to the first is a message the
194
+ // model has already declined to act on. Say that it is the second, and
195
+ // that it is the last — the wording is the only lever left.
196
+ const again = this._nudges > 1
197
+ ? [
198
+ 'You were asked this once already and reported again without reading. This is the',
199
+ 'last time you will be sent back; the next report is accepted whatever it rests on.',
200
+ '',
201
+ ]
202
+ : [];
203
+ return [
204
+ `You have opened ${read} of ${this._expected.length} changed files. A review that reports`,
205
+ 'on code it has not read is a guess wearing the clothes of a judgement.',
206
+ '',
207
+ ...again,
208
+ '',
209
+ 'Open these with Read before reporting — a grep over a directory does not count,',
210
+ 'because matching lines are not the code around them:',
211
+ ...shown.map((path) => ` ${path}`),
212
+ ...(rest > 0 ? [` …and ${rest} more`] : []),
213
+ '',
214
+ 'Then submit the review. If they turn out to be correct, say nothing about them —',
215
+ 'an empty review is a good review when the change is sound. Do not write findings',
216
+ 'to justify the extra reading.',
217
+ ].join('\n');
218
+ }
219
+ }
220
+ /**
221
+ * Reads a review out of whatever text is left when the structured channel
222
+ * produced nothing.
223
+ *
224
+ * It used to be the main path, back when the schema was a request a provider
225
+ * could decline. It is not any more — `outputFormat` returns the review as a
226
+ * parsed object, and a measured run wrote zero characters outside it. What
227
+ * keeps this here is the run that ends early: hit the turn ceiling or the
228
+ * budget and there is no structured output, only the prose the model had
229
+ * written by then. Recovering a review from that beats discarding one that was
230
+ * actually carried out.
231
+ */
232
+ export class ReviewOutputParser {
233
+ parse(text) {
234
+ const data = this._extractJson(text);
235
+ if (data === undefined) {
236
+ throw new Error(`The model did not return a review. Expected JSON matching the review schema, got ${text.length ? `${text.length} characters starting "${text.slice(0, 80)}"` : 'nothing'}.`);
237
+ }
238
+ const parsed = reviewOutputSchema.safeParse(data);
239
+ if (!parsed.success) {
240
+ const issue = parsed.error.issues[0];
241
+ throw new Error(`The model's review did not match the schema: ${issue?.message}${issue?.path.length ? ` at ${issue.path.join('.')}` : ''}`);
242
+ }
243
+ return parsed.data;
244
+ }
245
+ /** The whole string, a fenced block, or the widest brace-delimited span. */
246
+ _extractJson(text) {
247
+ const candidates = [text.trim()];
248
+ // Found by index rather than by a pattern: on a long reply full of stray
249
+ // fences, a regex with two repeats that can match the same whitespace
250
+ // backtracks polynomially, and this text is whatever the model wrote.
251
+ const open = text.indexOf('```');
252
+ const close = open === -1 ? -1 : text.indexOf('```', open + 3);
253
+ if (close !== -1)
254
+ candidates.push(text.slice(open + 3, close).replace(/^json/, '').trim());
255
+ const first = text.indexOf('{');
256
+ const last = text.lastIndexOf('}');
257
+ if (first !== -1 && last > first)
258
+ candidates.push(text.slice(first, last + 1));
259
+ for (const candidate of candidates) {
260
+ if (!candidate)
261
+ continue;
262
+ try {
263
+ return JSON.parse(candidate);
264
+ }
265
+ catch {
266
+ continue;
267
+ }
268
+ }
269
+ return undefined;
270
+ }
271
+ }
272
+ /**
273
+ * Runs one review.
274
+ *
275
+ * A single model call over the assembled context, with the read-only tools and
276
+ * hard ceilings on steps and spend. The model decides what to open; the
277
+ * pipeline decides what it is looking at, what it may touch, and when to stop.
278
+ */
279
+ export class Reviewer {
280
+ _config;
281
+ constructor(_config) {
282
+ this._config = _config;
283
+ }
284
+ /**
285
+ * The reviewer's standing instructions.
286
+ *
287
+ * Separate from the context so the two can be tuned independently: this says
288
+ * how to review, the context says what is being reviewed. Both are prompt,
289
+ * and this phase is where their wording actually decides quality.
290
+ */
291
+ _instructions(context, options = {}) {
292
+ return [
293
+ 'You are reviewing a specific set of changes in a repository you have read-only access to.',
294
+ '',
295
+ 'Your job is to find defects a careful colleague would catch, and to say nothing otherwise.',
296
+ 'An empty review is a good review when the change is sound — reviewers who always find',
297
+ 'something train people to stop reading.',
298
+ '',
299
+ 'Method:',
300
+ '- The diff tells you what changed. It does not tell you whether it is correct.',
301
+ ' Open the surrounding code: the definition being called, the callers of what changed,',
302
+ ' the tests that cover it.',
303
+ '- Judge the change against this repository as it is, not against a style you prefer.',
304
+ ' The conventions above were read from the repository itself.',
305
+ '- Every finding must cite the code it rests on, by path and line, quoted exactly.',
306
+ ' A claim you cannot cite is a claim you have not checked.',
307
+ '- Report what is wrong, not what is missing from your understanding. If you could not',
308
+ ' read something you needed, say so in the summary rather than guessing.',
309
+ '',
310
+ 'Severity means consequence, not effort:',
311
+ '- critical: data loss, a security hole, or a break in production.',
312
+ '- high: wrong behaviour a user or caller will hit.',
313
+ '- medium: wrong behaviour under conditions that are plausible but not routine.',
314
+ '- low: correct today, fragile tomorrow.',
315
+ '- nit: readability and consistency. Use sparingly; these are the findings people resent.',
316
+ '',
317
+ 'Confidence is your own estimate that the finding is real and that you have understood',
318
+ 'the code correctly. Below 0.5, you are guessing — investigate further or drop it.',
319
+ '',
320
+ 'Finish with a recommendation on the change as a whole:',
321
+ '- block: something here will break, lose data, or open a hole. Do not merge as it stands.',
322
+ '- needs_work: wrong behaviour worth fixing before merge, none of it dangerous.',
323
+ '- approve: nothing to fix, or only low and nit findings. Code that is correct today does',
324
+ ' not hold a change back; report those findings and approve.',
325
+ 'Judge the change, not the count — a handful of low findings is an approve, and one critical',
326
+ 'is a block however small the diff. If several low findings together amount to wrong',
327
+ 'behaviour, say so by rating that finding medium, not by withholding the approval.',
328
+ '',
329
+ 'Open the summary with the thing that matters most. Someone who reads one sentence and',
330
+ 'stops should still know what it is.',
331
+ '',
332
+ 'When you have finished investigating, fill in the review schema: every finding, plus a',
333
+ 'short summary. That schema is the only way a review is returned — there is nothing to',
334
+ 'call and no prose version. No findings is an empty list, not silence.',
335
+ '',
336
+ `Repository root: ${context.repo.root}`,
337
+ 'Paths you pass to tools are relative to that root.',
338
+ // Appended rather than interleaved: the standing instructions are what a
339
+ // review is, and these are each one more thing to do within it. What is
340
+ // remembered comes first because it changes how the whole change is
341
+ // read; continuing a review is a task on top of that.
342
+ ...(options.knowledge && !options.knowledge.isEmpty ? [options.knowledge.instructions()] : []),
343
+ // Empty for a continuation with nothing to rule on that was shown the
344
+ // whole branch: that is a fresh review, and adds nothing to say.
345
+ ...[options.continuation?.instructions(context)].filter((text) => Boolean(text)),
346
+ ].join('\n');
347
+ }
348
+ /**
349
+ * The message the review arrives in.
350
+ *
351
+ * What is remembered, then the change, then the findings being ruled on. All
352
+ * three are material to read rather than instructions about how to read it,
353
+ * which is why they are one message and not three — and the claims lead
354
+ * because a judgement is formed in the order it is given.
355
+ */
356
+ _prompt(context, options) {
357
+ return [options.knowledge?.render(), renderContext(context), options.continuation?.render(context)]
358
+ .filter(Boolean)
359
+ .join('\n\n');
360
+ }
361
+ async review(context, options = {}) {
362
+ const startedAt = Date.now();
363
+ const model = options.model ?? this._config.model;
364
+ const coverage = new CoverageLedger(context.files.map((f) => f.path), Boolean(context.since));
365
+ const gate = new CoverageGate(coverage, readableFiles(context.files), this._config.coverageFloor, 2, options.onEvent);
366
+ const controller = new AbortController();
367
+ const onAbort = () => controller.abort();
368
+ options.signal?.addEventListener('abort', onAbort);
369
+ if (options.signal?.aborted)
370
+ controller.abort();
371
+ let result;
372
+ let text = '';
373
+ /**
374
+ * Usage as it accrues, keyed by message id.
375
+ *
376
+ * The result message carries the authoritative totals, and a run that hits
377
+ * a ceiling never produces one — the iterator throws instead. Keeping a
378
+ * running tally is what lets a truncated review still report what it
379
+ * spent. Keyed rather than summed because a streamed assistant message is
380
+ * re-sent as it grows, and adding each arrival would count it twice.
381
+ */
382
+ const spent = new Map();
383
+ let ceiling;
384
+ const continuation = options.continuation;
385
+ const run = query({
386
+ prompt: this._prompt(context, options),
387
+ options: {
388
+ ...harnessOptions({
389
+ root: context.repo.root,
390
+ instructions: this._instructions(context, options),
391
+ model,
392
+ effort: options.effort ?? this._config.effort,
393
+ maxSteps: this._config.maxSteps,
394
+ maxCost: this._config.maxCost,
395
+ hooks: {
396
+ recorder: coverage,
397
+ ...(options.onEvent && {
398
+ onCall: (name, detail) => options.onEvent({ type: 'tool_call', name, ...(detail && { detail }) }),
399
+ }),
400
+ },
401
+ onStop: gate.stop,
402
+ onReport: gate.report,
403
+ }),
404
+ // The review comes back as a parsed object rather than as prose to
405
+ // be mined for one. The same schema the findings model defines, so
406
+ // there is no second description of a finding to drift from it — and
407
+ // when the run is a continuation, that schema with somewhere to put a
408
+ // ruling on each finding it was handed.
409
+ outputFormat: {
410
+ type: 'json_schema',
411
+ schema: strictJsonSchema(continuation?.rulesOn ? continuationOutputSchema : reviewOutputSchema),
412
+ },
413
+ abortController: controller,
414
+ },
415
+ });
416
+ // Costs nothing: the answer is ready before the stream is consumed, and
417
+ // this subprocess exists either way. It is what keeps `-m opus` pointing
418
+ // at the current Opus rather than the one this code was written against.
419
+ refreshCatalogue(run);
420
+ try {
421
+ for await (const message of run) {
422
+ if (message.type === 'assistant') {
423
+ for (const block of message.message.content) {
424
+ if (block.type === 'text')
425
+ text += block.text;
426
+ }
427
+ const usage = message.message.usage;
428
+ if (usage) {
429
+ spent.set(message.message.id, {
430
+ input: usage.input_tokens ?? 0,
431
+ output: usage.output_tokens ?? 0,
432
+ cacheRead: usage.cache_read_input_tokens ?? 0,
433
+ cacheWrite: usage.cache_creation_input_tokens ?? 0,
434
+ });
435
+ }
436
+ }
437
+ else if (message.type === 'result') {
438
+ result = message;
439
+ }
440
+ }
441
+ }
442
+ catch (err) {
443
+ // A ceiling is an outcome, not a failure: the run did the work, it just
444
+ // ran out of room. Anything else — no credentials, a broken workspace —
445
+ // is a failure, and dressing one up as an empty review would hide it.
446
+ ceiling = this._ceilings.fromError(err);
447
+ if (!ceiling)
448
+ throw err;
449
+ }
450
+ finally {
451
+ options.signal?.removeEventListener('abort', onAbort);
452
+ }
453
+ if (!result && !ceiling) {
454
+ throw new Error('The review ended without a result. This is a bug in the harness.');
455
+ }
456
+ // Everything below survives a run that stopped early, because everything
457
+ // below was already paid for. A review cut off by its budget has still
458
+ // read files, still spent tokens, and may still have written findings —
459
+ // throwing all of that away to report "exceeded max cost" tells the user
460
+ // the one thing they already know and none of the things they do not.
461
+ const stopped = ceiling ?? (result.subtype === 'success' ? undefined : this._describeStop(result));
462
+ const output = result ? this._readOutput(result, text, continuation) : this._recover(text);
463
+ // Deduped, then floored. The floor runs before the verdict is formed, so a
464
+ // finding too uncertain to report is also too uncertain to compel a
465
+ // recommendation — a `high` the model rated 0.3 should not be the reason a
466
+ // change is blocked while going unmentioned in the report.
467
+ const reported = FindingSet.from(output?.findings ?? [], new WorkspaceFiles(context.repo.root))
468
+ .deduped()
469
+ .atLeastConfident(this._config.confidenceFloor);
470
+ // A continuation was told not to restate what it was handed, so what it
471
+ // reported is not the whole review. Whatever it did not resolve goes back
472
+ // in before anything downstream counts findings — the verdict below is
473
+ // formed from this set, and a carried critical finding has to reach it.
474
+ const outcomes = continuation
475
+ ? OutcomeSet.match(this._rulings(output), continuation, reported)
476
+ : undefined;
477
+ const reconciled = outcomes ? outcomes.applyTo(reported) : reported;
478
+ // Applied last, and before the verdict.
479
+ //
480
+ // Last, because the set of findings is not settled until what the
481
+ // continuation carried is back in it. A `wont-fix` has to catch the
482
+ // carried copy as well as a fresh report of the same thing.
483
+ //
484
+ // Before the verdict, because a defect someone deliberately deprioritised
485
+ // must not be the reason this change is blocked. Blocking on it would be
486
+ // the loudest possible way of reporting a finding the report itself is not
487
+ // allowed to mention.
488
+ const findings = (options.corrections ?? CorrectionSet.empty()).applyTo(reconciled);
489
+ options.onEvent?.({ type: 'done', findings: findings.size });
490
+ return {
491
+ findings,
492
+ summary: output?.summary ?? this._summarise(stopped, coverage),
493
+ // A run that did not finish cannot claim nothing else is wrong, however
494
+ // clean what it did read looked.
495
+ verdict: stopped ? Verdict.stopped(findings) : Verdict.from(output?.verdict, findings),
496
+ coverage,
497
+ nudges: gate.nudges,
498
+ ...(outcomes && { reconciled: outcomes.reconciliation(context.since?.sha) }),
499
+ ...(stopped && { stopped }),
500
+ usage: result ? Spend.fromResult(result) : Spend.fromMessages(spent),
501
+ durationMs: Date.now() - startedAt,
502
+ model,
503
+ effort: options.effort ?? this._config.effort,
504
+ channel: output === undefined ? 'none' : result ? this._channel(result) : 'recovered',
505
+ };
506
+ }
507
+ _channel(result) {
508
+ return result.subtype === 'success' && result.structured_output !== undefined ? 'structured' : 'recovered';
509
+ }
510
+ /**
511
+ * The review, from whichever channel has one — or nothing.
512
+ *
513
+ * Returning undefined rather than throwing is the point: a truncated run
514
+ * whose prose holds no parseable review is not an error to be raised, it is
515
+ * a review with no findings and a reason. The reason is reported; the
516
+ * coverage and the spend are reported with it.
517
+ */
518
+ _readOutput(result, text, continuation) {
519
+ const structured = result.subtype === 'success' ? result.structured_output : undefined;
520
+ if (structured !== undefined)
521
+ return this._parseStructured(structured, continuation);
522
+ if (!text)
523
+ return undefined;
524
+ try {
525
+ return new ReviewOutputParser().parse(text);
526
+ }
527
+ catch {
528
+ return undefined;
529
+ }
530
+ }
531
+ /** The ceilings this review was given, for reading back out of a run that hit one. */
532
+ get _ceilings() {
533
+ return new Ceilings(this._config.maxSteps, this._config.maxCost);
534
+ }
535
+ /** Whatever prose survived a run that threw before reporting. */
536
+ _recover(text) {
537
+ if (!text)
538
+ return undefined;
539
+ try {
540
+ return new ReviewOutputParser().parse(text);
541
+ }
542
+ catch {
543
+ return undefined;
544
+ }
545
+ }
546
+ /** Said in place of a summary the run never wrote. */
547
+ _summarise(stopped, coverage) {
548
+ if (!stopped)
549
+ return 'The model returned no summary.';
550
+ // Counts only. The unread list is already on the coverage line below, and
551
+ // repeating it here pushes the sentence that matters off the screen.
552
+ return [
553
+ `This review did not finish: ${stopped.detail}`,
554
+ `It opened ${coverage.opened.length} of ${coverage.changedCount} changed files and reported nothing before it stopped.`,
555
+ 'Treat the absence of findings as unknown, not as approval.',
556
+ ].join(' ');
557
+ }
558
+ _describeStop(result) {
559
+ return this._ceilings.fromResult({
560
+ subtype: result.subtype,
561
+ ...('errors' in result && { errors: result.errors }),
562
+ });
563
+ }
564
+ /**
565
+ * The rulings a continuation returned, if it returned any.
566
+ *
567
+ * Absent whenever the answer came back as prose — a run recovered after a
568
+ * ceiling has findings but no outcomes, and `OutcomeSet` reads that as
569
+ * nothing having been ruled on, which carries everything.
570
+ */
571
+ _rulings(output) {
572
+ return output && 'outcomes' in output ? output.outcomes : undefined;
573
+ }
574
+ /** The structured channel is schema-constrained, not schema-guaranteed. */
575
+ _parseStructured(data, continuation) {
576
+ const parsed = (continuation?.rulesOn ? continuationOutputSchema : reviewOutputSchema).safeParse(data);
577
+ if (!parsed.success) {
578
+ const issue = parsed.error.issues[0];
579
+ throw new Error(`The model's review did not match the schema: ${issue?.message}${issue?.path.length ? ` at ${issue.path.join('.')}` : ''}`);
580
+ }
581
+ return parsed.data;
582
+ }
583
+ }
584
+ //# sourceMappingURL=reviewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviewer.js","sourceRoot":"","sources":["../src/reviewer.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,KAAK,EAAuC,MAAM,gCAAgC,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAE,aAAa,EAAwC,MAAM,cAAc,CAAC;AACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,UAAU,EACV,OAAO,EACP,cAAc,EACd,kBAAkB,EAClB,gBAAgB,GAEjB,MAAM,eA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CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EACvD,EAAE,CACH,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ import type { AgentConfig } from './config.js';
2
+ export declare const SESSION_VERBS: readonly ['list', 'prune'];
3
+ export type SessionVerb = (typeof SESSION_VERBS)[number];
4
+ export declare function isSessionVerb(value: string | undefined): value is SessionVerb;
5
+ export interface SessionCommandOptions {
6
+ json: boolean;
7
+ limit?: number;
8
+ keep?: number;
9
+ yes: boolean;
10
+ }
11
+ /**
12
+ * `weigh sessions <verb>` — inspect and prune local transcripts.
13
+ * The memory-side counterpart is `weigh memory <verb>`; the two are separate
14
+ * stores and are pruned separately.
15
+ */
16
+ export declare function runSessionCommand(verb: SessionVerb, config: AgentConfig, options: SessionCommandOptions): Promise<number>;
17
+ //# sourceMappingURL=session-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-cli.d.ts","sourceRoot":"","sources":["../src/session-cli.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,aAAa,YAAI,MAAM,EAAE,OAAO,CAAU,CAAC;AACxD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,IAAI,WAAW,CAE7E;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAkDjB"}