@resolveio/server-lib 22.3.150 → 22.3.152

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 (745) hide show
  1. package/ai/assistant-core-heuristics.d.ts +11 -0
  2. package/ai/assistant-core-heuristics.js +356 -0
  3. package/ai/assistant-core-heuristics.js.map +1 -0
  4. package/ai/resolveio-platform-intelligence-memory-corpus.d.ts +3 -0
  5. package/ai/resolveio-platform-intelligence-memory-corpus.js +214 -0
  6. package/ai/resolveio-platform-intelligence-memory-corpus.js.map +1 -0
  7. package/ai/resolveio-platform-intelligence-memory.d.ts +20 -0
  8. package/ai/resolveio-platform-intelligence-memory.js +341 -0
  9. package/ai/resolveio-platform-intelligence-memory.js.map +1 -0
  10. package/{src/ai/resolveio-platform-intelligence-types.ts → ai/resolveio-platform-intelligence-types.d.ts} +15 -20
  11. package/ai/resolveio-platform-intelligence-types.js +4 -0
  12. package/ai/resolveio-platform-intelligence-types.js.map +1 -0
  13. package/ai/resolveio-platform-intelligence.d.ts +6 -0
  14. package/ai/resolveio-platform-intelligence.js +463 -0
  15. package/ai/resolveio-platform-intelligence.js.map +1 -0
  16. package/client-server-app.d.ts +1 -0
  17. package/client-server-app.js +68 -0
  18. package/client-server-app.js.map +1 -0
  19. package/collections/ai-run.collection.d.ts +3 -0
  20. package/collections/ai-run.collection.js +170 -0
  21. package/collections/ai-run.collection.js.map +1 -0
  22. package/collections/ai-terminal-conversation.collection.d.ts +2 -0
  23. package/collections/ai-terminal-conversation.collection.js +140 -0
  24. package/collections/ai-terminal-conversation.collection.js.map +1 -0
  25. package/collections/ai-terminal-issue-report.collection.d.ts +2 -0
  26. package/collections/ai-terminal-issue-report.collection.js +148 -0
  27. package/collections/ai-terminal-issue-report.collection.js.map +1 -0
  28. package/collections/ai-terminal-message.collection.d.ts +2 -0
  29. package/collections/ai-terminal-message.collection.js +121 -0
  30. package/collections/ai-terminal-message.collection.js.map +1 -0
  31. package/collections/app-setting.collection.d.ts +3 -0
  32. package/collections/app-setting.collection.js +103 -0
  33. package/collections/app-setting.collection.js.map +1 -0
  34. package/collections/app-status.collection.d.ts +3 -0
  35. package/collections/app-status.collection.js +57 -0
  36. package/collections/app-status.collection.js.map +1 -0
  37. package/collections/communication-metric.collection.d.ts +2 -0
  38. package/collections/communication-metric.collection.js +133 -0
  39. package/collections/communication-metric.collection.js.map +1 -0
  40. package/collections/counter.collection.d.ts +3 -0
  41. package/collections/counter.collection.js +56 -0
  42. package/collections/counter.collection.js.map +1 -0
  43. package/collections/cron-job-history.collection.d.ts +3 -0
  44. package/collections/cron-job-history.collection.js +137 -0
  45. package/collections/cron-job-history.collection.js.map +1 -0
  46. package/collections/cron-job.collection.d.ts +3 -0
  47. package/collections/cron-job.collection.js +92 -0
  48. package/collections/cron-job.collection.js.map +1 -0
  49. package/collections/customer-notification.collection.d.ts +3 -0
  50. package/collections/customer-notification.collection.js +130 -0
  51. package/collections/customer-notification.collection.js.map +1 -0
  52. package/collections/customer-portal-password.collection.d.ts +3 -0
  53. package/collections/customer-portal-password.collection.js +75 -0
  54. package/collections/customer-portal-password.collection.js.map +1 -0
  55. package/collections/email-history.collection.d.ts +3 -0
  56. package/collections/email-history.collection.js +134 -0
  57. package/collections/email-history.collection.js.map +1 -0
  58. package/collections/email-verified.collection.d.ts +3 -0
  59. package/collections/email-verified.collection.js +62 -0
  60. package/collections/email-verified.collection.js.map +1 -0
  61. package/collections/file.collection.d.ts +3 -0
  62. package/collections/file.collection.js +74 -0
  63. package/collections/file.collection.js.map +1 -0
  64. package/collections/flag-update.collection.d.ts +3 -0
  65. package/collections/flag-update.collection.js +57 -0
  66. package/collections/flag-update.collection.js.map +1 -0
  67. package/collections/flag.collection.d.ts +3 -0
  68. package/collections/flag.collection.js +57 -0
  69. package/collections/flag.collection.js.map +1 -0
  70. package/collections/log-method-latency.collection.d.ts +3 -0
  71. package/collections/log-method-latency.collection.js +77 -0
  72. package/collections/log-method-latency.collection.js.map +1 -0
  73. package/collections/log-subscription.collection.d.ts +3 -0
  74. package/collections/log-subscription.collection.js +80 -0
  75. package/collections/log-subscription.collection.js.map +1 -0
  76. package/collections/log.collection.d.ts +3 -0
  77. package/collections/log.collection.js +93 -0
  78. package/collections/log.collection.js.map +1 -0
  79. package/collections/logged-in-users.collection.d.ts +3 -0
  80. package/collections/logged-in-users.collection.js +67 -0
  81. package/collections/logged-in-users.collection.js.map +1 -0
  82. package/collections/monitor-cpu.collection.d.ts +3 -0
  83. package/collections/monitor-cpu.collection.js +65 -0
  84. package/collections/monitor-cpu.collection.js.map +1 -0
  85. package/collections/monitor-function.collection.d.ts +3 -0
  86. package/collections/monitor-function.collection.js +74 -0
  87. package/collections/monitor-function.collection.js.map +1 -0
  88. package/collections/monitor-memory.collection.d.ts +3 -0
  89. package/collections/monitor-memory.collection.js +77 -0
  90. package/collections/monitor-memory.collection.js.map +1 -0
  91. package/collections/monitor-mongo.collection.d.ts +3 -0
  92. package/collections/monitor-mongo.collection.js +71 -0
  93. package/collections/monitor-mongo.collection.js.map +1 -0
  94. package/collections/notification.collection.d.ts +3 -0
  95. package/collections/notification.collection.js +57 -0
  96. package/collections/notification.collection.js.map +1 -0
  97. package/collections/openai-usage-ledger.collection.d.ts +2 -0
  98. package/collections/openai-usage-ledger.collection.js +188 -0
  99. package/collections/openai-usage-ledger.collection.js.map +1 -0
  100. package/collections/report-builder-dashboard-builder.collection.d.ts +3 -0
  101. package/collections/report-builder-dashboard-builder.collection.js +109 -0
  102. package/collections/report-builder-dashboard-builder.collection.js.map +1 -0
  103. package/collections/report-builder-library.collection.d.ts +3 -0
  104. package/collections/report-builder-library.collection.js +87 -0
  105. package/collections/report-builder-library.collection.js.map +1 -0
  106. package/collections/report-builder-report.collection.d.ts +4 -0
  107. package/collections/report-builder-report.collection.js +184 -0
  108. package/collections/report-builder-report.collection.js.map +1 -0
  109. package/collections/user-group.collection.d.ts +4 -0
  110. package/collections/user-group.collection.js +89 -0
  111. package/collections/user-group.collection.js.map +1 -0
  112. package/collections/user-guide.collection.d.ts +3 -0
  113. package/collections/user-guide.collection.js +57 -0
  114. package/collections/user-guide.collection.js.map +1 -0
  115. package/collections/user.collection.d.ts +4 -0
  116. package/collections/user.collection.js +180 -0
  117. package/collections/user.collection.js.map +1 -0
  118. package/cron/cron.d.ts +14 -0
  119. package/cron/cron.js +216 -0
  120. package/cron/cron.js.map +1 -0
  121. package/fixtures/cron-jobs.d.ts +1 -0
  122. package/fixtures/cron-jobs.js +150 -0
  123. package/fixtures/cron-jobs.js.map +1 -0
  124. package/fixtures/init.d.ts +1 -0
  125. package/fixtures/init.js +91 -0
  126. package/fixtures/init.js.map +1 -0
  127. package/http/auth.d.ts +2 -0
  128. package/http/auth.js +951 -0
  129. package/http/auth.js.map +1 -0
  130. package/http/health.d.ts +1 -0
  131. package/http/health.js +11 -0
  132. package/http/health.js.map +1 -0
  133. package/http/home.d.ts +1 -0
  134. package/http/home.js +134 -0
  135. package/http/home.js.map +1 -0
  136. package/http/slow-query-publication.d.ts +2 -0
  137. package/http/slow-query-publication.js +99 -0
  138. package/http/slow-query-publication.js.map +1 -0
  139. package/index.d.ts +1 -0
  140. package/index.js +19 -0
  141. package/index.js.map +1 -0
  142. package/managers/ai-assistant-codex-manager.manager.d.ts +67 -0
  143. package/managers/ai-assistant-codex-manager.manager.js +1113 -0
  144. package/managers/ai-assistant-codex-manager.manager.js.map +1 -0
  145. package/managers/ai-run-evidence.manager.d.ts +36 -0
  146. package/managers/ai-run-evidence.manager.js +377 -0
  147. package/managers/ai-run-evidence.manager.js.map +1 -0
  148. package/managers/communication-metric.manager.d.ts +16 -0
  149. package/managers/communication-metric.manager.js +134 -0
  150. package/managers/communication-metric.manager.js.map +1 -0
  151. package/managers/cron.manager.d.ts +20 -0
  152. package/managers/cron.manager.js +534 -0
  153. package/managers/cron.manager.js.map +1 -0
  154. package/managers/customer-notification-content.manager.d.ts +55 -0
  155. package/managers/customer-notification-content.manager.js +158 -0
  156. package/managers/customer-notification-content.manager.js.map +1 -0
  157. package/managers/diagnostic-manager-bootstrap.d.ts +9 -0
  158. package/managers/diagnostic-manager-bootstrap.js +260 -0
  159. package/managers/diagnostic-manager-bootstrap.js.map +1 -0
  160. package/managers/error-auto-fix.manager.d.ts +149 -0
  161. package/managers/error-auto-fix.manager.js +3064 -0
  162. package/managers/error-auto-fix.manager.js.map +1 -0
  163. package/managers/local-log.manager.d.ts +18 -0
  164. package/managers/local-log.manager.js +88 -0
  165. package/managers/local-log.manager.js.map +1 -0
  166. package/managers/method.manager.d.ts +84 -0
  167. package/managers/method.manager.js +1964 -0
  168. package/managers/method.manager.js.map +1 -0
  169. package/managers/mongo.manager.d.ts +224 -0
  170. package/managers/mongo.manager.js +5000 -0
  171. package/managers/mongo.manager.js.map +1 -0
  172. package/managers/monitor.manager.d.ts +70 -0
  173. package/managers/monitor.manager.js +550 -0
  174. package/managers/monitor.manager.js.map +1 -0
  175. package/managers/openai-usage-ledger.manager.d.ts +30 -0
  176. package/managers/openai-usage-ledger.manager.js +142 -0
  177. package/managers/openai-usage-ledger.manager.js.map +1 -0
  178. package/managers/slow-query-verifier.manager.d.ts +144 -0
  179. package/managers/slow-query-verifier.manager.js +3857 -0
  180. package/managers/slow-query-verifier.manager.js.map +1 -0
  181. package/managers/slow-query.manager.d.ts +28 -0
  182. package/managers/slow-query.manager.js +468 -0
  183. package/managers/slow-query.manager.js.map +1 -0
  184. package/managers/subscription.manager.d.ts +169 -0
  185. package/managers/subscription.manager.js +3434 -0
  186. package/managers/subscription.manager.js.map +1 -0
  187. package/managers/websocket.manager.d.ts +73 -0
  188. package/managers/websocket.manager.js +673 -0
  189. package/managers/websocket.manager.js.map +1 -0
  190. package/managers/worker-dispatcher.manager.d.ts +120 -0
  191. package/managers/worker-dispatcher.manager.js +1266 -0
  192. package/managers/worker-dispatcher.manager.js.map +1 -0
  193. package/managers/worker-server.manager.d.ts +35 -0
  194. package/managers/worker-server.manager.js +582 -0
  195. package/managers/worker-server.manager.js.map +1 -0
  196. package/methods/accounts.d.ts +2 -0
  197. package/methods/accounts.js +624 -0
  198. package/methods/accounts.js.map +1 -0
  199. package/methods/ai-terminal.d.ts +337 -0
  200. package/methods/ai-terminal.js +23193 -0
  201. package/methods/ai-terminal.js.map +1 -0
  202. package/methods/app-settings.d.ts +2 -0
  203. package/methods/app-settings.js +169 -0
  204. package/methods/app-settings.js.map +1 -0
  205. package/methods/aws.d.ts +2 -0
  206. package/methods/aws.js +877 -0
  207. package/methods/aws.js.map +1 -0
  208. package/methods/collections.d.ts +2 -0
  209. package/methods/collections.js +719 -0
  210. package/methods/collections.js.map +1 -0
  211. package/methods/counters.d.ts +2 -0
  212. package/methods/counters.js +113 -0
  213. package/methods/counters.js.map +1 -0
  214. package/methods/cron-jobs.d.ts +2 -0
  215. package/methods/cron-jobs.js +2475 -0
  216. package/methods/cron-jobs.js.map +1 -0
  217. package/methods/customer-notifications.d.ts +2 -0
  218. package/methods/customer-notifications.js +528 -0
  219. package/methods/customer-notifications.js.map +1 -0
  220. package/methods/diagnostics.d.ts +2 -0
  221. package/methods/diagnostics.js +703 -0
  222. package/methods/diagnostics.js.map +1 -0
  223. package/methods/flag-updates.d.ts +2 -0
  224. package/methods/flag-updates.js +8 -0
  225. package/methods/flag-updates.js.map +1 -0
  226. package/methods/flags.d.ts +2 -0
  227. package/methods/flags.js +8 -0
  228. package/methods/flags.js.map +1 -0
  229. package/methods/logs.d.ts +2 -0
  230. package/methods/logs.js +751 -0
  231. package/methods/logs.js.map +1 -0
  232. package/methods/mongo-explorer.d.ts +2 -0
  233. package/methods/mongo-explorer.js +1808 -0
  234. package/methods/mongo-explorer.js.map +1 -0
  235. package/methods/monitor.d.ts +2 -0
  236. package/methods/monitor.js +543 -0
  237. package/methods/monitor.js.map +1 -0
  238. package/methods/pdf.d.ts +2 -0
  239. package/methods/pdf.js +1216 -0
  240. package/methods/pdf.js.map +1 -0
  241. package/methods/publications.d.ts +1 -0
  242. package/methods/publications.js +183 -0
  243. package/methods/publications.js.map +1 -0
  244. package/methods/report-builder.d.ts +2 -0
  245. package/methods/report-builder.js +3094 -0
  246. package/methods/report-builder.js.map +1 -0
  247. package/methods/support.d.ts +2 -0
  248. package/methods/support.js +430 -0
  249. package/methods/support.js.map +1 -0
  250. package/models/ai-run.model.d.ts +19 -0
  251. package/models/ai-run.model.js +4 -0
  252. package/models/ai-run.model.js.map +1 -0
  253. package/models/ai-terminal-conversation.model.d.ts +17 -0
  254. package/models/ai-terminal-conversation.model.js +4 -0
  255. package/models/ai-terminal-conversation.model.js.map +1 -0
  256. package/models/ai-terminal-issue-report.model.d.ts +19 -0
  257. package/models/ai-terminal-issue-report.model.js +4 -0
  258. package/models/ai-terminal-issue-report.model.js.map +1 -0
  259. package/models/ai-terminal-message.model.d.ts +22 -0
  260. package/models/ai-terminal-message.model.js +4 -0
  261. package/models/ai-terminal-message.model.js.map +1 -0
  262. package/models/app-setting.model.d.ts +16 -0
  263. package/models/app-setting.model.js +4 -0
  264. package/models/app-setting.model.js.map +1 -0
  265. package/{src/models/app-status.model.ts → models/app-status.model.d.ts} +2 -3
  266. package/models/app-status.model.js +4 -0
  267. package/models/app-status.model.js.map +1 -0
  268. package/{src/models/billing-logged-in-users.model.ts → models/billing-logged-in-users.model.d.ts} +4 -5
  269. package/models/billing-logged-in-users.model.js +4 -0
  270. package/models/billing-logged-in-users.model.js.map +1 -0
  271. package/models/collection-document.model.d.ts +21 -0
  272. package/models/collection-document.model.js +4 -0
  273. package/models/collection-document.model.js.map +1 -0
  274. package/models/communication-metric.model.d.ts +20 -0
  275. package/models/communication-metric.model.js +4 -0
  276. package/models/communication-metric.model.js.map +1 -0
  277. package/{src/models/counter.model.ts → models/counter.model.d.ts} +3 -4
  278. package/models/counter.model.js +4 -0
  279. package/models/counter.model.js.map +1 -0
  280. package/models/cron-job-history.model.d.ts +15 -0
  281. package/models/cron-job-history.model.js +4 -0
  282. package/models/cron-job-history.model.js.map +1 -0
  283. package/models/cron-job.model.d.ts +14 -0
  284. package/models/cron-job.model.js +4 -0
  285. package/models/cron-job.model.js.map +1 -0
  286. package/models/customer-notification.model.d.ts +26 -0
  287. package/models/customer-notification.model.js +4 -0
  288. package/models/customer-notification.model.js.map +1 -0
  289. package/models/customer-portal-password.model.d.ts +11 -0
  290. package/models/customer-portal-password.model.js +4 -0
  291. package/models/customer-portal-password.model.js.map +1 -0
  292. package/models/dialog.model.d.ts +23 -0
  293. package/models/dialog.model.js +4 -0
  294. package/models/dialog.model.js.map +1 -0
  295. package/models/email-history.model.d.ts +32 -0
  296. package/{src/models/email-history.model.ts → models/email-history.model.js} +4 -36
  297. package/models/email-history.model.js.map +1 -0
  298. package/{src/models/email-verified.model.ts → models/email-verified.model.d.ts} +5 -6
  299. package/models/email-verified.model.js +4 -0
  300. package/models/email-verified.model.js.map +1 -0
  301. package/{src/models/file.model.ts → models/file.model.d.ts} +7 -8
  302. package/models/file.model.js +4 -0
  303. package/models/file.model.js.map +1 -0
  304. package/{src/models/flag-update.model.ts → models/flag-update.model.d.ts} +3 -4
  305. package/models/flag-update.model.js +4 -0
  306. package/models/flag-update.model.js.map +1 -0
  307. package/{src/models/flag.model.ts → models/flag.model.d.ts} +3 -4
  308. package/models/flag.model.js +4 -0
  309. package/models/flag.model.js.map +1 -0
  310. package/models/log-method-latency.model.d.ts +10 -0
  311. package/models/log-method-latency.model.js +4 -0
  312. package/models/log-method-latency.model.js.map +1 -0
  313. package/{src/models/log-subscription.model.ts → models/log-subscription.model.d.ts} +9 -11
  314. package/models/log-subscription.model.js +4 -0
  315. package/models/log-subscription.model.js.map +1 -0
  316. package/models/log.model.d.ts +17 -0
  317. package/models/log.model.js +4 -0
  318. package/models/log.model.js.map +1 -0
  319. package/{src/models/logged-in-users.model.ts → models/logged-in-users.model.d.ts} +5 -6
  320. package/models/logged-in-users.model.js +4 -0
  321. package/models/logged-in-users.model.js.map +1 -0
  322. package/{src/models/method-response.model.ts → models/method-response.model.d.ts} +6 -7
  323. package/models/method-response.model.js +4 -0
  324. package/models/method-response.model.js.map +1 -0
  325. package/models/method.model.d.ts +26 -0
  326. package/models/method.model.js +4 -0
  327. package/models/method.model.js.map +1 -0
  328. package/{src/models/monitor-cpu.model.ts → models/monitor-cpu.model.d.ts} +7 -9
  329. package/models/monitor-cpu.model.js +4 -0
  330. package/models/monitor-cpu.model.js.map +1 -0
  331. package/models/monitor-function.model.d.ts +14 -0
  332. package/models/monitor-function.model.js +4 -0
  333. package/models/monitor-function.model.js.map +1 -0
  334. package/models/monitor-memory.model.d.ts +15 -0
  335. package/models/monitor-memory.model.js +4 -0
  336. package/models/monitor-memory.model.js.map +1 -0
  337. package/models/monitor-mongo.model.d.ts +13 -0
  338. package/models/monitor-mongo.model.js +4 -0
  339. package/models/monitor-mongo.model.js.map +1 -0
  340. package/{src/models/notification.model.ts → models/notification.model.d.ts} +4 -6
  341. package/models/notification.model.js +4 -0
  342. package/models/notification.model.js.map +1 -0
  343. package/models/openai-usage-ledger.model.d.ts +30 -0
  344. package/models/openai-usage-ledger.model.js +4 -0
  345. package/models/openai-usage-ledger.model.js.map +1 -0
  346. package/models/pagination.model.d.ts +11 -0
  347. package/models/pagination.model.js +28 -0
  348. package/models/pagination.model.js.map +1 -0
  349. package/models/permission.model.d.ts +12 -0
  350. package/models/permission.model.js +4 -0
  351. package/models/permission.model.js.map +1 -0
  352. package/models/report-builder-dashboard-builder.model.d.ts +25 -0
  353. package/models/report-builder-dashboard-builder.model.js +4 -0
  354. package/models/report-builder-dashboard-builder.model.js.map +1 -0
  355. package/models/report-builder-library.model.d.ts +17 -0
  356. package/models/report-builder-library.model.js +4 -0
  357. package/models/report-builder-library.model.js.map +1 -0
  358. package/models/report-builder-report.model.d.ts +121 -0
  359. package/models/report-builder-report.model.js +4 -0
  360. package/models/report-builder-report.model.js.map +1 -0
  361. package/models/report-builder.model.d.ts +61 -0
  362. package/models/report-builder.model.js +4 -0
  363. package/models/report-builder.model.js.map +1 -0
  364. package/models/select-data-label.model.d.ts +9 -0
  365. package/models/select-data-label.model.js +4 -0
  366. package/models/select-data-label.model.js.map +1 -0
  367. package/models/server-message.model.d.ts +32 -0
  368. package/models/server-message.model.js +4 -0
  369. package/models/server-message.model.js.map +1 -0
  370. package/models/slow-query-report.model.d.ts +23 -0
  371. package/models/slow-query-report.model.js +4 -0
  372. package/models/slow-query-report.model.js.map +1 -0
  373. package/models/subscription.model.d.ts +31 -0
  374. package/models/subscription.model.js +4 -0
  375. package/models/subscription.model.js.map +1 -0
  376. package/models/support-ticket.model.d.ts +87 -0
  377. package/models/support-ticket.model.js +4 -0
  378. package/models/support-ticket.model.js.map +1 -0
  379. package/models/user-group.model.d.ts +20 -0
  380. package/models/user-group.model.js +4 -0
  381. package/models/user-group.model.js.map +1 -0
  382. package/{src/models/user-guide.model.ts → models/user-guide.model.d.ts} +4 -5
  383. package/models/user-guide.model.js +4 -0
  384. package/models/user-guide.model.js.map +1 -0
  385. package/models/user.model.d.ts +84 -0
  386. package/models/user.model.js +4 -0
  387. package/models/user.model.js.map +1 -0
  388. package/package.json +1 -1
  389. package/private/images/ResolveIO.png +0 -0
  390. package/public_api.js +127 -0
  391. package/public_api.js.map +1 -0
  392. package/publications/ai-terminal.d.ts +1 -0
  393. package/publications/ai-terminal.js +122 -0
  394. package/publications/ai-terminal.js.map +1 -0
  395. package/publications/app-settings.d.ts +2 -0
  396. package/publications/app-settings.js +28 -0
  397. package/publications/app-settings.js.map +1 -0
  398. package/publications/app-status.d.ts +2 -0
  399. package/publications/app-status.js +16 -0
  400. package/publications/app-status.js.map +1 -0
  401. package/publications/cron-jobs.d.ts +2 -0
  402. package/publications/cron-jobs.js +88 -0
  403. package/publications/cron-jobs.js.map +1 -0
  404. package/publications/customer-notifications.d.ts +2 -0
  405. package/publications/customer-notifications.js +161 -0
  406. package/publications/customer-notifications.js.map +1 -0
  407. package/publications/files.d.ts +2 -0
  408. package/publications/files.js +36 -0
  409. package/publications/files.js.map +1 -0
  410. package/publications/flags-update.d.ts +2 -0
  411. package/publications/flags-update.js +22 -0
  412. package/publications/flags-update.js.map +1 -0
  413. package/publications/flags.d.ts +2 -0
  414. package/publications/flags.js +22 -0
  415. package/publications/flags.js.map +1 -0
  416. package/publications/logs.d.ts +2 -0
  417. package/publications/logs.js +164 -0
  418. package/publications/logs.js.map +1 -0
  419. package/publications/notifications.d.ts +2 -0
  420. package/publications/notifications.js +16 -0
  421. package/publications/notifications.js.map +1 -0
  422. package/publications/report-builder-dashboard-builders.d.ts +2 -0
  423. package/publications/report-builder-dashboard-builders.js +42 -0
  424. package/publications/report-builder-dashboard-builders.js.map +1 -0
  425. package/publications/report-builder-libraries.d.ts +2 -0
  426. package/publications/report-builder-libraries.js +90 -0
  427. package/publications/report-builder-libraries.js.map +1 -0
  428. package/publications/report-builder-reports.d.ts +2 -0
  429. package/publications/report-builder-reports.js +50 -0
  430. package/publications/report-builder-reports.js.map +1 -0
  431. package/publications/super-admin.d.ts +2 -0
  432. package/publications/super-admin.js +16 -0
  433. package/publications/super-admin.js.map +1 -0
  434. package/publications/user-groups.d.ts +1 -0
  435. package/publications/user-groups.js +16 -0
  436. package/publications/user-groups.js.map +1 -0
  437. package/publications/user-guides.d.ts +1 -0
  438. package/publications/user-guides.js +16 -0
  439. package/publications/user-guides.js.map +1 -0
  440. package/resolveio-server-app.d.ts +70 -0
  441. package/resolveio-server-app.js +801 -0
  442. package/resolveio-server-app.js.map +1 -0
  443. package/server-app.d.ts +228 -0
  444. package/server-app.js +3566 -0
  445. package/server-app.js.map +1 -0
  446. package/services/codex-client.d.ts +128 -0
  447. package/services/codex-client.js +1629 -0
  448. package/services/codex-client.js.map +1 -0
  449. package/services/openai-client.d.ts +46 -0
  450. package/services/openai-client.js +318 -0
  451. package/services/openai-client.js.map +1 -0
  452. package/types/error-report.d.ts +25 -0
  453. package/types/error-report.js +4 -0
  454. package/types/error-report.js.map +1 -0
  455. package/types/slow-query-report.d.ts +27 -0
  456. package/types/slow-query-report.js +6 -0
  457. package/types/slow-query-report.js.map +1 -0
  458. package/util/ai-qa-policy.d.ts +124 -0
  459. package/util/ai-qa-policy.js +736 -0
  460. package/util/ai-qa-policy.js.map +1 -0
  461. package/util/ai-run-evidence-adapters.d.ts +33 -0
  462. package/util/ai-run-evidence-adapters.js +838 -0
  463. package/util/ai-run-evidence-adapters.js.map +1 -0
  464. package/util/ai-run-evidence-dashboard.d.ts +84 -0
  465. package/util/ai-run-evidence-dashboard.js +336 -0
  466. package/util/ai-run-evidence-dashboard.js.map +1 -0
  467. package/util/ai-run-evidence-eval.d.ts +86 -0
  468. package/util/ai-run-evidence-eval.js +854 -0
  469. package/util/ai-run-evidence-eval.js.map +1 -0
  470. package/util/ai-run-evidence.d.ts +244 -0
  471. package/util/ai-run-evidence.js +731 -0
  472. package/util/ai-run-evidence.js.map +1 -0
  473. package/util/ai-runner-artifacts.d.ts +82 -0
  474. package/util/ai-runner-artifacts.js +713 -0
  475. package/util/ai-runner-artifacts.js.map +1 -0
  476. package/util/ai-runner-manager-autopilot.d.ts +112 -0
  477. package/util/ai-runner-manager-autopilot.js +313 -0
  478. package/util/ai-runner-manager-autopilot.js.map +1 -0
  479. package/util/ai-runner-manager-policy.d.ts +403 -0
  480. package/util/ai-runner-manager-policy.js +1763 -0
  481. package/util/ai-runner-manager-policy.js.map +1 -0
  482. package/util/ai-runner-qa-auth.d.ts +5 -0
  483. package/util/ai-runner-qa-auth.js +822 -0
  484. package/util/ai-runner-qa-auth.js.map +1 -0
  485. package/util/ai-runner-qa-tools.d.ts +26 -0
  486. package/util/ai-runner-qa-tools.js +3029 -0
  487. package/util/ai-runner-qa-tools.js.map +1 -0
  488. package/util/aicoder-runner-v6.d.ts +214 -0
  489. package/util/aicoder-runner-v6.js +507 -0
  490. package/util/aicoder-runner-v6.js.map +1 -0
  491. package/util/common.d.ts +31 -0
  492. package/util/common.js +683 -0
  493. package/util/common.js.map +1 -0
  494. package/util/customer-portal-password.d.ts +13 -0
  495. package/util/customer-portal-password.js +209 -0
  496. package/util/customer-portal-password.js.map +1 -0
  497. package/util/error-reporter.d.ts +52 -0
  498. package/util/error-reporter.js +326 -0
  499. package/util/error-reporter.js.map +1 -0
  500. package/util/error-tracking.d.ts +13 -0
  501. package/util/error-tracking.js +120 -0
  502. package/util/error-tracking.js.map +1 -0
  503. package/util/openai-usage-cost.d.ts +6 -0
  504. package/util/openai-usage-cost.js +103 -0
  505. package/util/openai-usage-cost.js.map +1 -0
  506. package/util/report-builder-unwinds.d.ts +15 -0
  507. package/util/report-builder-unwinds.js +156 -0
  508. package/util/report-builder-unwinds.js.map +1 -0
  509. package/util/runner-process-janitor.d.ts +27 -0
  510. package/util/runner-process-janitor.js +208 -0
  511. package/util/runner-process-janitor.js.map +1 -0
  512. package/util/schema-report-builder.d.ts +6 -0
  513. package/util/schema-report-builder.js +481 -0
  514. package/util/schema-report-builder.js.map +1 -0
  515. package/util/slow-query-reporter.d.ts +28 -0
  516. package/util/slow-query-reporter.js +226 -0
  517. package/util/slow-query-reporter.js.map +1 -0
  518. package/util/subscription-dependency-context.d.ts +34 -0
  519. package/util/subscription-dependency-context.js +1283 -0
  520. package/util/subscription-dependency-context.js.map +1 -0
  521. package/util/support-runner-v5.d.ts +451 -0
  522. package/util/support-runner-v5.js +1680 -0
  523. package/util/support-runner-v5.js.map +1 -0
  524. package/util/tokenizer.d.ts +5 -0
  525. package/util/tokenizer.js +41 -0
  526. package/util/tokenizer.js.map +1 -0
  527. package/workers/codex-runner.worker.d.ts +1 -0
  528. package/workers/codex-runner.worker.js +192 -0
  529. package/workers/codex-runner.worker.js.map +1 -0
  530. package/.nodemon.json +0 -5
  531. package/.vscode/settings.json +0 -21
  532. package/AGENTS.md +0 -195
  533. package/README.md +0 -22
  534. package/build_package.sh +0 -5
  535. package/compileDTS.pl +0 -64
  536. package/docs/ai-assistant-nightly-eval.md +0 -65
  537. package/docs/ai-assistant-preflight-checklist.md +0 -23
  538. package/docs/ai-assistant-report-builder-bridge-playbook.md +0 -115
  539. package/eslint-plugin-custom/index.js +0 -7
  540. package/eslint-plugin-custom/rules/no-filter-zero-index.js +0 -44
  541. package/eslint.config.js +0 -103
  542. package/gulpfile.js +0 -216
  543. package/methodAndPublicationListGenerator.py +0 -375
  544. package/mongodbensurers.js +0 -2
  545. package/mongostop.js +0 -3
  546. package/scripts/cleanup-bypassed-callmethod-logs.js +0 -616
  547. package/settings.development.json +0 -25
  548. package/settings.development.redacted.json +0 -25
  549. package/src/.env +0 -12
  550. package/src/ai/assistant-core-heuristics.ts +0 -379
  551. package/src/ai/resolveio-platform-intelligence-memory-corpus.ts +0 -185
  552. package/src/ai/resolveio-platform-intelligence-memory.ts +0 -325
  553. package/src/ai/resolveio-platform-intelligence.ts +0 -462
  554. package/src/client-server-app.ts +0 -12
  555. package/src/collections/ai-run.collection.ts +0 -117
  556. package/src/collections/ai-terminal-conversation.collection.ts +0 -91
  557. package/src/collections/ai-terminal-issue-report.collection.ts +0 -99
  558. package/src/collections/ai-terminal-message.collection.ts +0 -77
  559. package/src/collections/app-setting.collection.ts +0 -104
  560. package/src/collections/app-status.collection.ts +0 -58
  561. package/src/collections/communication-metric.collection.ts +0 -84
  562. package/src/collections/counter.collection.ts +0 -56
  563. package/src/collections/cron-job-history.collection.ts +0 -94
  564. package/src/collections/cron-job.collection.ts +0 -92
  565. package/src/collections/customer-notification.collection.ts +0 -131
  566. package/src/collections/customer-portal-password.collection.ts +0 -76
  567. package/src/collections/email-history.collection.ts +0 -134
  568. package/src/collections/email-verified.collection.ts +0 -62
  569. package/src/collections/file.collection.ts +0 -74
  570. package/src/collections/flag-update.collection.ts +0 -57
  571. package/src/collections/flag.collection.ts +0 -57
  572. package/src/collections/log-method-latency.collection.ts +0 -77
  573. package/src/collections/log-subscription.collection.ts +0 -80
  574. package/src/collections/log.collection.ts +0 -93
  575. package/src/collections/logged-in-users.collection.ts +0 -67
  576. package/src/collections/monitor-cpu.collection.ts +0 -65
  577. package/src/collections/monitor-function.collection.ts +0 -74
  578. package/src/collections/monitor-memory.collection.ts +0 -77
  579. package/src/collections/monitor-mongo.collection.ts +0 -71
  580. package/src/collections/notification.collection.ts +0 -57
  581. package/src/collections/openai-usage-ledger.collection.ts +0 -131
  582. package/src/collections/report-builder-dashboard-builder.collection.ts +0 -109
  583. package/src/collections/report-builder-library.collection.ts +0 -89
  584. package/src/collections/report-builder-report.collection.ts +0 -184
  585. package/src/collections/user-group.collection.ts +0 -89
  586. package/src/collections/user-guide.collection.ts +0 -57
  587. package/src/collections/user.collection.ts +0 -181
  588. package/src/cron/cron.ts +0 -117
  589. package/src/fixtures/cron-jobs.ts +0 -95
  590. package/src/fixtures/init.ts +0 -35
  591. package/src/http/auth.ts +0 -818
  592. package/src/http/health.ts +0 -7
  593. package/src/http/home.ts +0 -90
  594. package/src/http/slow-query-publication.ts +0 -49
  595. package/src/index.ts +0 -1
  596. package/src/managers/ai-assistant-codex-manager.manager.ts +0 -1131
  597. package/src/managers/ai-run-evidence.manager.ts +0 -264
  598. package/src/managers/communication-metric.manager.ts +0 -82
  599. package/src/managers/cron.manager.ts +0 -333
  600. package/src/managers/customer-notification-content.manager.ts +0 -236
  601. package/src/managers/diagnostic-manager-bootstrap.ts +0 -165
  602. package/src/managers/error-auto-fix.manager.ts +0 -2767
  603. package/src/managers/local-log.manager.ts +0 -113
  604. package/src/managers/method.manager.ts +0 -1857
  605. package/src/managers/mongo.manager.ts +0 -4575
  606. package/src/managers/monitor.manager.ts +0 -507
  607. package/src/managers/openai-usage-ledger.manager.ts +0 -112
  608. package/src/managers/slow-query-verifier.manager.ts +0 -3590
  609. package/src/managers/slow-query.manager.ts +0 -519
  610. package/src/managers/subscription.manager.ts +0 -3128
  611. package/src/managers/websocket.manager.ts +0 -746
  612. package/src/managers/worker-dispatcher.manager.ts +0 -1360
  613. package/src/managers/worker-server.manager.ts +0 -536
  614. package/src/methods/accounts.ts +0 -532
  615. package/src/methods/ai-terminal.ts +0 -23524
  616. package/src/methods/app-settings.ts +0 -114
  617. package/src/methods/aws.ts +0 -649
  618. package/src/methods/collections.ts +0 -641
  619. package/src/methods/counters.ts +0 -69
  620. package/src/methods/cron-jobs.ts +0 -2614
  621. package/src/methods/customer-notifications.ts +0 -458
  622. package/src/methods/diagnostics.ts +0 -616
  623. package/src/methods/flag-updates.ts +0 -7
  624. package/src/methods/flags.ts +0 -7
  625. package/src/methods/logs.ts +0 -657
  626. package/src/methods/mongo-explorer.ts +0 -1880
  627. package/src/methods/monitor.ts +0 -540
  628. package/src/methods/pdf.ts +0 -1236
  629. package/src/methods/publications.ts +0 -129
  630. package/src/methods/report-builder.ts +0 -3300
  631. package/src/methods/support.ts +0 -335
  632. package/src/models/ai-run.model.ts +0 -27
  633. package/src/models/ai-terminal-conversation.model.ts +0 -19
  634. package/src/models/ai-terminal-issue-report.model.ts +0 -21
  635. package/src/models/ai-terminal-message.model.ts +0 -24
  636. package/src/models/app-setting.model.ts +0 -17
  637. package/src/models/collection-document.model.ts +0 -24
  638. package/src/models/communication-metric.model.ts +0 -23
  639. package/src/models/cron-job-history.model.ts +0 -16
  640. package/src/models/cron-job.model.ts +0 -15
  641. package/src/models/customer-notification.model.ts +0 -28
  642. package/src/models/customer-portal-password.model.ts +0 -12
  643. package/src/models/dialog.model.ts +0 -25
  644. package/src/models/log-method-latency.model.ts +0 -11
  645. package/src/models/log.model.ts +0 -19
  646. package/src/models/method.model.ts +0 -25
  647. package/src/models/monitor-function.model.ts +0 -16
  648. package/src/models/monitor-memory.model.ts +0 -17
  649. package/src/models/monitor-mongo.model.ts +0 -15
  650. package/src/models/openai-usage-ledger.model.ts +0 -56
  651. package/src/models/pagination.model.ts +0 -35
  652. package/src/models/permission.model.ts +0 -14
  653. package/src/models/report-builder-dashboard-builder.model.ts +0 -29
  654. package/src/models/report-builder-library.model.ts +0 -20
  655. package/src/models/report-builder-report.model.ts +0 -136
  656. package/src/models/report-builder.model.ts +0 -68
  657. package/src/models/select-data-label.model.ts +0 -9
  658. package/src/models/server-message.model.ts +0 -31
  659. package/src/models/slow-query-report.model.ts +0 -23
  660. package/src/models/subscription.model.ts +0 -73
  661. package/src/models/support-ticket.model.ts +0 -104
  662. package/src/models/user-group.model.ts +0 -24
  663. package/src/models/user.model.ts +0 -96
  664. package/src/private/images/ResolveIO.png +0 -0
  665. package/src/publications/ai-terminal.ts +0 -73
  666. package/src/publications/app-settings.ts +0 -25
  667. package/src/publications/app-status.ts +0 -13
  668. package/src/publications/cron-jobs.ts +0 -40
  669. package/src/publications/customer-notifications.ts +0 -101
  670. package/src/publications/files.ts +0 -33
  671. package/src/publications/flags-update.ts +0 -19
  672. package/src/publications/flags.ts +0 -19
  673. package/src/publications/logs.ts +0 -163
  674. package/src/publications/notifications.ts +0 -13
  675. package/src/publications/report-builder-dashboard-builders.ts +0 -39
  676. package/src/publications/report-builder-libraries.ts +0 -41
  677. package/src/publications/report-builder-reports.ts +0 -47
  678. package/src/publications/super-admin.ts +0 -13
  679. package/src/publications/user-groups.ts +0 -12
  680. package/src/publications/user-guides.ts +0 -12
  681. package/src/resolveio-server-app.ts +0 -617
  682. package/src/server-app.ts +0 -3354
  683. package/src/services/codex-client.ts +0 -1231
  684. package/src/services/openai-client.ts +0 -265
  685. package/src/types/error-report.ts +0 -26
  686. package/src/types/js-tiktoken.d.ts +0 -11
  687. package/src/types/slow-query-report.ts +0 -28
  688. package/src/util/ai-qa-policy.ts +0 -925
  689. package/src/util/ai-run-evidence-adapters.ts +0 -684
  690. package/src/util/ai-run-evidence-dashboard.ts +0 -313
  691. package/src/util/ai-run-evidence-eval.ts +0 -885
  692. package/src/util/ai-run-evidence.ts +0 -1058
  693. package/src/util/ai-runner-artifacts.ts +0 -586
  694. package/src/util/ai-runner-manager-autopilot.ts +0 -434
  695. package/src/util/ai-runner-manager-policy.ts +0 -2733
  696. package/src/util/ai-runner-qa-auth.ts +0 -821
  697. package/src/util/ai-runner-qa-tools.ts +0 -3045
  698. package/src/util/aicoder-runner-v6.ts +0 -875
  699. package/src/util/common.ts +0 -649
  700. package/src/util/customer-portal-password.ts +0 -183
  701. package/src/util/error-reporter.ts +0 -332
  702. package/src/util/error-tracking.ts +0 -79
  703. package/src/util/openai-usage-cost.ts +0 -114
  704. package/src/util/report-builder-unwinds.ts +0 -180
  705. package/src/util/runner-process-janitor.ts +0 -219
  706. package/src/util/schema-report-builder.ts +0 -448
  707. package/src/util/slow-query-reporter.ts +0 -216
  708. package/src/util/subscription-dependency-context.ts +0 -1096
  709. package/src/util/support-runner-v5.ts +0 -2167
  710. package/src/util/tokenizer.ts +0 -38
  711. package/src/workers/codex-runner.worker.ts +0 -142
  712. package/start_server.sh +0 -5
  713. package/tests/ai-assistant-corpus-build.ts +0 -484
  714. package/tests/ai-assistant-corpus-replay-e2e.ts +0 -774
  715. package/tests/ai-assistant-data-parity-e2e.ts +0 -1989
  716. package/tests/ai-assistant-eval-triage.ts +0 -831
  717. package/tests/ai-assistant-openai-e2e.ts +0 -1061
  718. package/tests/ai-assistant-openai-git-e2e.ts +0 -155
  719. package/tests/ai-assistant-preflight-matrix.ts +0 -215
  720. package/tests/ai-assistant-routing-eval.test.ts +0 -560
  721. package/tests/ai-assistant-snf-live-eval.ts +0 -975
  722. package/tests/ai-assistant-utils.test.ts +0 -2968
  723. package/tests/ai-manager-autopilot-snapshot.test.ts +0 -177
  724. package/tests/ai-manager-recovery-checkpoint.test.ts +0 -595
  725. package/tests/ai-run-eval.test.ts +0 -88
  726. package/tests/ai-run-evidence.test.ts +0 -348
  727. package/tests/ai-runner-contract.test.ts +0 -488
  728. package/tests/aicoder-runner-v6.test.ts +0 -298
  729. package/tests/error-reporter.test.ts +0 -145
  730. package/tests/method-publication-generator.test.ts +0 -46
  731. package/tests/report-builder-linking.test.ts +0 -79
  732. package/tests/resolveio-platform-intelligence.test.ts +0 -352
  733. package/tests/server-app-cron-owner.test.ts +0 -127
  734. package/tests/subscription-connect-race.test.ts +0 -158
  735. package/tests/subscription-dependency-context.test.ts +0 -324
  736. package/tests/subscription-manager-collection-tracking.test.ts +0 -86
  737. package/tests/subscription-manager-invalidation.test.ts +0 -86
  738. package/tests/support-runner-v5.test.ts +0 -488
  739. package/tsconfig.json +0 -34
  740. /package/{src/private → private}/email-templates/enrollment.html +0 -0
  741. /package/{src/private → private}/email-templates/forgot-password.html +0 -0
  742. /package/{src/private → private}/email-templates/support-ticket-deleted.html +0 -0
  743. /package/{src/private → private}/email-templates/support-ticket-modified.html +0 -0
  744. /package/{src/private → private}/email-templates/support-ticket.html +0 -0
  745. /package/{src/public_api.ts → public_api.d.ts} +0 -0
@@ -0,0 +1,1680 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __values = (this && this.__values) || function(o) {
14
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
+ if (m) return m.call(o);
16
+ if (o && typeof o.length === "number") return {
17
+ next: function () {
18
+ if (o && i >= o.length) o = void 0;
19
+ return { value: o && o[i++], done: !o };
20
+ }
21
+ };
22
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23
+ };
24
+ var __read = (this && this.__read) || function (o, n) {
25
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
26
+ if (!m) return o;
27
+ var i = m.call(o), r, ar = [], e;
28
+ try {
29
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
30
+ }
31
+ catch (error) { e = { error: error }; }
32
+ finally {
33
+ try {
34
+ if (r && !r.done && (m = i["return"])) m.call(i);
35
+ }
36
+ finally { if (e) throw e.error; }
37
+ }
38
+ return ar;
39
+ };
40
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
+ if (ar || !(i in from)) {
43
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
+ ar[i] = from[i];
45
+ }
46
+ }
47
+ return to.concat(ar || Array.prototype.slice.call(from));
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.normalizeResolveIOSupportDiagnosisGate = normalizeResolveIOSupportDiagnosisGate;
51
+ exports.extractResolveIOSupportDiagnosisGateFromText = extractResolveIOSupportDiagnosisGateFromText;
52
+ exports.validateResolveIOSupportDiagnosisGate = validateResolveIOSupportDiagnosisGate;
53
+ exports.decideResolveIOSupportCustomerReplyPolicy = decideResolveIOSupportCustomerReplyPolicy;
54
+ exports.buildResolveIOSupportIssueClassProbes = buildResolveIOSupportIssueClassProbes;
55
+ exports.hashResolveIOSupportV5Evidence = hashResolveIOSupportV5Evidence;
56
+ exports.decideResolveIOSupportV5RepeatedFailureStop = decideResolveIOSupportV5RepeatedFailureStop;
57
+ exports.changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles = changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles;
58
+ exports.decideResolveIOSupportV5RepairGate = decideResolveIOSupportV5RepairGate;
59
+ exports.applyResolveIOSupportDiagnosisGateToMicrotasks = applyResolveIOSupportDiagnosisGateToMicrotasks;
60
+ exports.fingerprintResolveIOSupportV5Blocker = fingerprintResolveIOSupportV5Blocker;
61
+ exports.buildResolveIOSupportV5Budget = buildResolveIOSupportV5Budget;
62
+ exports.buildResolveIOSupportV5PromptBudget = buildResolveIOSupportV5PromptBudget;
63
+ exports.buildResolveIOSupportV5ScopeDigest = buildResolveIOSupportV5ScopeDigest;
64
+ exports.buildResolveIOSupportV5MicrotaskLedger = buildResolveIOSupportV5MicrotaskLedger;
65
+ exports.selectResolveIOSupportV5ActiveMicrotask = selectResolveIOSupportV5ActiveMicrotask;
66
+ exports.initializeResolveIOSupportV5State = initializeResolveIOSupportV5State;
67
+ exports.recordResolveIOSupportV5Step = recordResolveIOSupportV5Step;
68
+ exports.recordResolveIOSupportV5MicrotaskUsage = recordResolveIOSupportV5MicrotaskUsage;
69
+ exports.decideResolveIOSupportV5Continuation = decideResolveIOSupportV5Continuation;
70
+ exports.buildResolveIOSupportV5DiagnoseFirstPrompt = buildResolveIOSupportV5DiagnoseFirstPrompt;
71
+ exports.buildResolveIOSupportV5MicrotaskPrompt = buildResolveIOSupportV5MicrotaskPrompt;
72
+ exports.summarizeResolveIOSupportV5MicrotaskUsage = summarizeResolveIOSupportV5MicrotaskUsage;
73
+ exports.buildResolveIOSupportV5Incident = buildResolveIOSupportV5Incident;
74
+ var ai_runner_manager_policy_1 = require("./ai-runner-manager-policy");
75
+ function isoNow(value) {
76
+ if (value instanceof Date) {
77
+ return value.toISOString();
78
+ }
79
+ var parsed = value ? new Date(value) : new Date();
80
+ if (Number.isFinite(parsed.getTime())) {
81
+ return parsed.toISOString();
82
+ }
83
+ return new Date().toISOString();
84
+ }
85
+ function cleanText(value, max) {
86
+ if (max === void 0) { max = 2000; }
87
+ return String(value || '').replace(/\s+/g, ' ').trim().slice(0, max);
88
+ }
89
+ function cleanList(values, limit, max) {
90
+ var e_1, _a;
91
+ if (limit === void 0) { limit = 20; }
92
+ if (max === void 0) { max = 500; }
93
+ if (!Array.isArray(values)) {
94
+ return [];
95
+ }
96
+ var result = [];
97
+ try {
98
+ for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
99
+ var value = values_1_1.value;
100
+ var normalized = cleanText(value, max);
101
+ if (normalized && !result.includes(normalized)) {
102
+ result.push(normalized);
103
+ }
104
+ if (result.length >= limit) {
105
+ break;
106
+ }
107
+ }
108
+ }
109
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
110
+ finally {
111
+ try {
112
+ if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
113
+ }
114
+ finally { if (e_1) throw e_1.error; }
115
+ }
116
+ return result;
117
+ }
118
+ function cleanObject(value) {
119
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
120
+ }
121
+ function pickText(source, fields, max) {
122
+ var e_2, _a;
123
+ if (max === void 0) { max = 1000; }
124
+ try {
125
+ for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
126
+ var field = fields_1_1.value;
127
+ var normalized = cleanText(source === null || source === void 0 ? void 0 : source[field], max);
128
+ if (normalized) {
129
+ return normalized;
130
+ }
131
+ }
132
+ }
133
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
134
+ finally {
135
+ try {
136
+ if (fields_1_1 && !fields_1_1.done && (_a = fields_1.return)) _a.call(fields_1);
137
+ }
138
+ finally { if (e_2) throw e_2.error; }
139
+ }
140
+ return '';
141
+ }
142
+ function normalizeIssueClass(value) {
143
+ var normalized = cleanText(value, 80)
144
+ .toLowerCase()
145
+ .replace(/[\s-]+/g, '_');
146
+ var aliases = {
147
+ no_op: 'no_op_submit',
148
+ no_op_submit: 'no_op_submit',
149
+ submit_noop: 'no_op_submit',
150
+ missing_data: 'missing_wrong_data',
151
+ wrong_data: 'missing_wrong_data',
152
+ missing_wrong_data: 'missing_wrong_data',
153
+ filter_mismatch: 'filter_query_mismatch',
154
+ query_mismatch: 'filter_query_mismatch',
155
+ filter_query_mismatch: 'filter_query_mismatch',
156
+ invoice_pdf_export: 'invoice_pdf_export',
157
+ pdf_export: 'invoice_pdf_export',
158
+ export: 'invoice_pdf_export',
159
+ upload: 'upload_import',
160
+ import: 'upload_import',
161
+ upload_import: 'upload_import',
162
+ route_auth: 'route_auth_hydration',
163
+ auth_hydration: 'route_auth_hydration',
164
+ route_auth_hydration: 'route_auth_hydration',
165
+ slow_query: 'slow_query_performance',
166
+ performance: 'slow_query_performance',
167
+ slow_query_performance: 'slow_query_performance'
168
+ };
169
+ return aliases[normalized] || '';
170
+ }
171
+ function normalizeReproductionStatus(value) {
172
+ var normalized = cleanText(value, 80).toLowerCase();
173
+ if (/blocked|unable|cannot/.test(normalized)) {
174
+ return 'blocked';
175
+ }
176
+ if (/classif|triag|inferred/.test(normalized)) {
177
+ return 'classified';
178
+ }
179
+ return 'reproduced';
180
+ }
181
+ function normalizeSupportDiagnosisEvidence(values) {
182
+ var allowed = new Set(['ticket', 'browser', 'mongo', 'log', 'code', 'commit', 'qa', 'other']);
183
+ if (!Array.isArray(values)) {
184
+ var summary = cleanText(values, 1200);
185
+ return summary ? [{ type: 'other', summary: summary }] : [];
186
+ }
187
+ var stringEvidence = values
188
+ .filter(function (entry) { return typeof entry === 'string'; })
189
+ .map(function (entry) { return ({
190
+ type: 'other',
191
+ summary: cleanText(entry, 1200)
192
+ }); });
193
+ var objectEvidence = values
194
+ .filter(function (entry) { return entry && typeof entry === 'object' && !Array.isArray(entry); })
195
+ .map(function (entry) {
196
+ var type = cleanText(entry.type, 80).toLowerCase();
197
+ return {
198
+ type: (allowed.has(type) ? type : 'other'),
199
+ summary: cleanText(entry.summary || entry.message || entry.evidence || entry.reason, 1200),
200
+ artifactPath: cleanText(entry.artifactPath || entry.path || entry.file, 500)
201
+ };
202
+ });
203
+ return stringEvidence.concat(objectEvidence)
204
+ .filter(function (entry) { return entry.summary; })
205
+ .slice(0, 20);
206
+ }
207
+ function normalizeSupportDiagnosisHints(values) {
208
+ return (Array.isArray(values) ? values : [])
209
+ .map(function (entry) {
210
+ if (typeof entry === 'string') {
211
+ return { reason: cleanText(entry, 500) };
212
+ }
213
+ var value = cleanObject(entry);
214
+ return {
215
+ id: cleanText(value.id || value._id, 160),
216
+ ticketNumber: cleanText(value.ticketNumber || value.ticket_number || value.sourceTicketNumber, 80),
217
+ title: cleanText(value.title || value.summary, 300),
218
+ outcome: cleanText(value.outcome || value.status, 80),
219
+ issueClass: cleanText(value.issueClass || value.issue_class, 80),
220
+ ownerFiles: cleanList(value.ownerFiles || value.owner_files || value.files, 8, 240),
221
+ commitSha: cleanText(value.commitSha || value.commit_sha, 80),
222
+ commitMessage: cleanText(value.commitMessage || value.commit_message, 300),
223
+ reason: cleanText(value.reason || value.matchReason || value.match_reason, 500)
224
+ };
225
+ })
226
+ .filter(function (entry) { return entry.id || entry.ticketNumber || entry.title || entry.reason || entry.commitSha; })
227
+ .slice(0, 8);
228
+ }
229
+ function normalizeSupportDiagnosisBusinessProofContract(value, issueClassHint) {
230
+ var source = cleanObject(value);
231
+ if (!Object.keys(source).length) {
232
+ return undefined;
233
+ }
234
+ var issueClass = normalizeIssueClass(source.issue_class || source.issueClass || issueClassHint)
235
+ || normalizeIssueClass(issueClassHint)
236
+ || 'missing_wrong_data';
237
+ return {
238
+ issue_class: issueClass,
239
+ setup_state: pickText(source, ['setup_state', 'setupState', 'before', 'precondition'], 1000),
240
+ action_under_test: pickText(source, ['action_under_test', 'actionUnderTest', 'action', 'steps'], 1000),
241
+ expected_business_state_change: pickText(source, ['expected_business_state_change', 'expectedBusinessStateChange', 'expected_change', 'expectedChange', 'after'], 1000),
242
+ prohibited_false_pass: pickText(source, ['prohibited_false_pass', 'prohibitedFalsePass', 'false_pass', 'falsePass'], 1000),
243
+ proof_artifacts: cleanList(source.proof_artifacts || source.proofArtifacts || source.artifacts || source.artifact_paths || source.artifactPaths, 10, 500),
244
+ data_or_dom_assertion: pickText(source, ['data_or_dom_assertion', 'dataOrDomAssertion', 'data_assertion', 'dataAssertion', 'dom_assertion', 'domAssertion', 'assertion'], 1000)
245
+ };
246
+ }
247
+ function normalizeOwnerFilePath(value) {
248
+ return cleanText(value, 500)
249
+ .replace(/\\/g, '/')
250
+ .replace(/^\.\/+/, '')
251
+ .replace(/^\/+/, '')
252
+ .replace(/\s+$/g, '');
253
+ }
254
+ function ownerFileLooksBroad(value) {
255
+ var normalized = normalizeOwnerFilePath(value);
256
+ return !normalized
257
+ || normalized.includes('*')
258
+ || normalized.endsWith('/')
259
+ || !/\.[a-z0-9]+$/i.test(normalized)
260
+ || /^(\.|src|server|angular|client|app|lib|packages?)$/i.test(normalized)
261
+ || /(^|\/)(node_modules|dist|build|coverage|\.git)(\/|$)/i.test(normalized);
262
+ }
263
+ function proofPlanLooksRouteOnly(proofPlan) {
264
+ var assertionText = cleanText([
265
+ proofPlan.business_assertion,
266
+ proofPlan.action,
267
+ proofPlan.after,
268
+ proofPlan.data_assertion,
269
+ proofPlan.artifact_expectation
270
+ ].filter(Boolean).join(' '), 3000).toLowerCase();
271
+ if (!assertionText) {
272
+ return false;
273
+ }
274
+ var routeOnlySignal = /\b(route|page|screen|dashboard|url|component|shell)\b/.test(assertionText)
275
+ && /\b(loads?|loaded|renders?|rendered|opens?|opened|visible|visibility|hydrates?|hydrated|screenshot)\b/.test(assertionText);
276
+ var businessSignal = /\b(save|saved|persist|persisted|create|created|update|updated|delete|deleted|filter|filtered|exclude|excluded|include|included|row|rows|record|records|count|counts|total|totals|value|values|data|mongo|query|result|results|invoice|pdf|export|download|upload|import|dropdown|selection|selected|form|submit|submitted|validation|error message|customer|account|user|permission|auth|control|button|status|calculation|performance|duration|latency)\b/.test(assertionText);
277
+ return routeOnlySignal && !businessSignal;
278
+ }
279
+ function normalizeResolveIOSupportDiagnosisGate(value, now) {
280
+ var source = cleanObject(value);
281
+ if (!Object.keys(source).length) {
282
+ return undefined;
283
+ }
284
+ var issueCaseSource = cleanObject(source.issue_case || source.issueCase);
285
+ var hypothesisSource = cleanObject(source.accepted_hypothesis || source.acceptedHypothesis);
286
+ var failingPathSource = cleanObject(source.failing_path || source.failingPath);
287
+ var proofPlanSource = cleanObject(source.proof_plan || source.proofPlan);
288
+ var issueClass = normalizeIssueClass(source.issue_class || source.issueClass);
289
+ var businessProofContract = normalizeSupportDiagnosisBusinessProofContract(proofPlanSource.business_proof_contract || proofPlanSource.businessProofContract || source.business_proof_contract || source.businessProofContract, issueClass || source.issue_class || source.issueClass);
290
+ var ownerFiles = cleanList(source.owner_files || source.ownerFiles, 20, 500)
291
+ .map(normalizeOwnerFilePath)
292
+ .filter(Boolean);
293
+ var gate = {
294
+ issue_case: {
295
+ customer_complaint: pickText(issueCaseSource, ['customer_complaint', 'customerComplaint', 'complaint', 'request', 'summary'], 1200),
296
+ expected_result: pickText(issueCaseSource, ['expected_result', 'expectedResult', 'expected'], 1000),
297
+ observed_result: pickText(issueCaseSource, ['observed_result', 'observedResult', 'observed', 'actual'], 1000),
298
+ route_module: pickText(issueCaseSource, ['route_module', 'routeModule', 'route', 'module', 'screen'], 500),
299
+ account_customer_context: pickText(issueCaseSource, ['account_customer_context', 'accountCustomerContext', 'account', 'customer', 'user', 'context'], 800),
300
+ reproduction_status: normalizeReproductionStatus(issueCaseSource.reproduction_status || issueCaseSource.reproductionStatus || source.reproduction_status),
301
+ reproduction_blocker: pickText(issueCaseSource, ['reproduction_blocker', 'reproductionBlocker', 'blocked_reason', 'blockedReason'], 1000)
302
+ },
303
+ issue_class: issueClass || 'missing_wrong_data',
304
+ accepted_hypothesis: {
305
+ statement: pickText(hypothesisSource, ['statement', 'hypothesis', 'root_cause', 'rootCause', 'summary'], 1200)
306
+ || (typeof source.accepted_hypothesis === 'string' ? cleanText(source.accepted_hypothesis, 1200) : ''),
307
+ falsifiable_test: pickText(hypothesisSource, ['falsifiable_test', 'falsifiableTest', 'test', 'proof', 'falsifier'], 1000),
308
+ evidence: cleanList(hypothesisSource.evidence || source.hypothesis_evidence || source.hypothesisEvidence, 10, 800)
309
+ },
310
+ rejected_alternatives: cleanList(source.rejected_alternatives || source.rejectedAlternatives, 10, 700),
311
+ failing_path: {
312
+ frontend: pickText(failingPathSource, ['frontend', 'frontend_path', 'frontendPath', 'eventPath'], 700),
313
+ backend: pickText(failingPathSource, ['backend', 'backend_path', 'backendPath', 'methodPublicationPath'], 700),
314
+ shared_library: pickText(failingPathSource, ['shared_library', 'sharedLibrary', 'library', 'lib'], 700),
315
+ data_query: pickText(failingPathSource, ['data_query', 'dataQuery', 'query'], 700),
316
+ description: pickText(failingPathSource, ['description', 'path', 'summary'], 1200) || cleanText(source.failing_path, 1200)
317
+ },
318
+ owner_files: ownerFiles,
319
+ proof_plan: {
320
+ before: pickText(proofPlanSource, ['before', 'before_state', 'beforeState', 'precondition'], 1000),
321
+ before_state_unavailable_reason: pickText(proofPlanSource, ['before_state_unavailable_reason', 'beforeStateUnavailableReason', 'before_unavailable_reason'], 1000),
322
+ action: pickText(proofPlanSource, ['action', 'browser_action', 'browserAction', 'steps'], 1000),
323
+ after: pickText(proofPlanSource, ['after', 'after_state', 'afterState', 'expected_after'], 1000),
324
+ business_assertion: pickText(proofPlanSource, ['business_assertion', 'businessAssertion', 'assertion'], 1000),
325
+ route: pickText(proofPlanSource, ['route', 'url'], 500),
326
+ data_assertion: pickText(proofPlanSource, ['data_assertion', 'dataAssertion', 'mongo_delta', 'mongoDelta'], 1000),
327
+ artifact_expectation: pickText(proofPlanSource, ['artifact_expectation', 'artifactExpectation', 'artifact', 'screenshot'], 1000),
328
+ business_proof_contract: businessProofContract
329
+ },
330
+ similar_tickets: normalizeSupportDiagnosisHints(source.similar_tickets || source.similarTickets),
331
+ similar_commits: normalizeSupportDiagnosisHints(source.similar_commits || source.similarCommits),
332
+ evidence: normalizeSupportDiagnosisEvidence(source.evidence),
333
+ status: cleanText(source.status, 80).toLowerCase() || 'incomplete',
334
+ updatedAt: isoNow(now || source.updatedAt || source.updated_at)
335
+ };
336
+ if (!['missing', 'incomplete', 'blocked', 'passed'].includes(gate.status)) {
337
+ gate.status = 'incomplete';
338
+ }
339
+ return gate;
340
+ }
341
+ function extractResolveIOSupportDiagnosisGateFromText(value, now) {
342
+ var e_3, _a;
343
+ var text = String(value || '').trim();
344
+ if (!text) {
345
+ return undefined;
346
+ }
347
+ var candidates = [];
348
+ var fenced = Array.from(text.matchAll(/```(?:json)?\s*([\s\S]*?)```/gi)).map(function (match) { return match[1]; });
349
+ candidates.push.apply(candidates, __spreadArray([], __read(fenced), false));
350
+ var jsonBlock = text.match(/\{[\s\S]*\}/);
351
+ if (jsonBlock) {
352
+ candidates.push(jsonBlock[0]);
353
+ }
354
+ try {
355
+ for (var candidates_1 = __values(candidates), candidates_1_1 = candidates_1.next(); !candidates_1_1.done; candidates_1_1 = candidates_1.next()) {
356
+ var candidate = candidates_1_1.value;
357
+ try {
358
+ var parsed = JSON.parse(candidate);
359
+ var wrapped = (parsed === null || parsed === void 0 ? void 0 : parsed.support_diagnosis_gate) || (parsed === null || parsed === void 0 ? void 0 : parsed.supportDiagnosisGate) || (parsed === null || parsed === void 0 ? void 0 : parsed.diagnosis_gate) || (parsed === null || parsed === void 0 ? void 0 : parsed.diagnosisGate) || parsed;
360
+ var normalized = normalizeResolveIOSupportDiagnosisGate(wrapped, now);
361
+ if (normalized) {
362
+ return normalized;
363
+ }
364
+ }
365
+ catch (_b) {
366
+ // Continue trying less exact JSON candidates.
367
+ }
368
+ }
369
+ }
370
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
371
+ finally {
372
+ try {
373
+ if (candidates_1_1 && !candidates_1_1.done && (_a = candidates_1.return)) _a.call(candidates_1);
374
+ }
375
+ finally { if (e_3) throw e_3.error; }
376
+ }
377
+ return undefined;
378
+ }
379
+ function validateResolveIOSupportDiagnosisGate(value, options) {
380
+ if (options === void 0) { options = {}; }
381
+ var normalized = normalizeResolveIOSupportDiagnosisGate(value);
382
+ if (!normalized) {
383
+ return { valid: false, status: 'missing', blockers: ['SupportDiagnosisGate is missing.'] };
384
+ }
385
+ var blockers = [];
386
+ var maxOwnerFiles = Math.max(1, Number(options.maxOwnerFiles || 8) || 8);
387
+ if (!normalized.issue_case.customer_complaint) {
388
+ blockers.push('Diagnosis issue_case.customer_complaint is required.');
389
+ }
390
+ if (!normalized.issue_case.expected_result) {
391
+ blockers.push('Diagnosis issue_case.expected_result is required.');
392
+ }
393
+ if (!normalized.issue_case.observed_result) {
394
+ blockers.push('Diagnosis issue_case.observed_result is required.');
395
+ }
396
+ if (!normalized.issue_case.route_module) {
397
+ blockers.push('Diagnosis issue_case.route_module is required.');
398
+ }
399
+ if (!normalized.issue_case.account_customer_context) {
400
+ blockers.push('Diagnosis issue_case.account_customer_context is required.');
401
+ }
402
+ if (normalized.issue_case.reproduction_status === 'blocked' && !normalized.issue_case.reproduction_blocker) {
403
+ blockers.push('Diagnosis blocked reproduction requires issue_case.reproduction_blocker.');
404
+ }
405
+ if (!normalizeIssueClass(normalized.issue_class)) {
406
+ blockers.push('Diagnosis issue_class must be one of the supported issue-class probes.');
407
+ }
408
+ if (!normalized.accepted_hypothesis.statement) {
409
+ blockers.push('Diagnosis accepted_hypothesis.statement is required.');
410
+ }
411
+ if (!normalized.accepted_hypothesis.falsifiable_test) {
412
+ blockers.push('Diagnosis accepted_hypothesis.falsifiable_test is required.');
413
+ }
414
+ if (!normalized.accepted_hypothesis.evidence.length) {
415
+ blockers.push('Diagnosis accepted_hypothesis.evidence must cite proof.');
416
+ }
417
+ if (!normalized.rejected_alternatives.length) {
418
+ blockers.push('Diagnosis rejected_alternatives must include at least one rejected theory.');
419
+ }
420
+ if (!normalized.failing_path.description
421
+ && !normalized.failing_path.frontend
422
+ && !normalized.failing_path.backend
423
+ && !normalized.failing_path.shared_library
424
+ && !normalized.failing_path.data_query) {
425
+ blockers.push('Diagnosis failing_path must identify frontend, backend, query, shared library, or path description.');
426
+ }
427
+ if (!normalized.owner_files.length) {
428
+ blockers.push('Diagnosis owner_files must contain the small editable file set.');
429
+ }
430
+ if (normalized.owner_files.length > maxOwnerFiles) {
431
+ blockers.push("Diagnosis owner_files has ".concat(normalized.owner_files.length, " entries; maximum is ").concat(maxOwnerFiles, "."));
432
+ }
433
+ var broadFiles = normalized.owner_files.filter(ownerFileLooksBroad);
434
+ if (broadFiles.length) {
435
+ blockers.push("Diagnosis owner_files contains broad or unsafe path(s): ".concat(broadFiles.join(', '), "."));
436
+ }
437
+ if (!normalized.proof_plan.before && !normalized.proof_plan.before_state_unavailable_reason) {
438
+ blockers.push('Diagnosis proof_plan.before is required unless proof_plan.before_state_unavailable_reason explains why before-state proof is impossible.');
439
+ }
440
+ if (!normalized.proof_plan.action) {
441
+ blockers.push('Diagnosis proof_plan.action is required.');
442
+ }
443
+ if (!normalized.proof_plan.after) {
444
+ blockers.push('Diagnosis proof_plan.after is required.');
445
+ }
446
+ if (!normalized.proof_plan.business_assertion) {
447
+ blockers.push('Diagnosis proof_plan.business_assertion is required.');
448
+ }
449
+ if (proofPlanLooksRouteOnly(normalized.proof_plan)) {
450
+ blockers.push('Diagnosis proof_plan cannot be route-load, screen-visible, or screenshot-only; it must name the business state/data/control change that proves the issue is fixed.');
451
+ }
452
+ var proofContract = normalized.proof_plan.business_proof_contract;
453
+ if (!proofContract) {
454
+ blockers.push('Diagnosis proof_plan.business_proof_contract is required.');
455
+ }
456
+ else {
457
+ if (proofContract.issue_class !== normalized.issue_class) {
458
+ blockers.push("Diagnosis proof_plan.business_proof_contract.issue_class (".concat(proofContract.issue_class, ") must match diagnosis issue_class (").concat(normalized.issue_class, ")."));
459
+ }
460
+ if (!proofContract.setup_state) {
461
+ blockers.push('Diagnosis proof_plan.business_proof_contract.setup_state is required.');
462
+ }
463
+ if (!proofContract.action_under_test) {
464
+ blockers.push('Diagnosis proof_plan.business_proof_contract.action_under_test is required.');
465
+ }
466
+ if (!proofContract.expected_business_state_change) {
467
+ blockers.push('Diagnosis proof_plan.business_proof_contract.expected_business_state_change is required.');
468
+ }
469
+ if (!proofContract.prohibited_false_pass) {
470
+ blockers.push('Diagnosis proof_plan.business_proof_contract.prohibited_false_pass is required.');
471
+ }
472
+ if (!proofContract.proof_artifacts.length) {
473
+ blockers.push('Diagnosis proof_plan.business_proof_contract.proof_artifacts must include at least one required artifact.');
474
+ }
475
+ if (!proofContract.data_or_dom_assertion) {
476
+ blockers.push('Diagnosis proof_plan.business_proof_contract.data_or_dom_assertion is required.');
477
+ }
478
+ }
479
+ if (!normalized.evidence.length) {
480
+ blockers.push('Diagnosis evidence must include ticket/code/browser/log/Mongo proof.');
481
+ }
482
+ normalized.status = blockers.length ? 'incomplete' : 'passed';
483
+ return {
484
+ valid: blockers.length === 0,
485
+ status: normalized.status,
486
+ blockers: blockers,
487
+ normalized: normalized
488
+ };
489
+ }
490
+ function normalizeSupportConfidenceLevel(value) {
491
+ var _a, _b;
492
+ var normalized = cleanText((value === null || value === void 0 ? void 0 : value.level) || (value === null || value === void 0 ? void 0 : value.confidenceLevel) || (value === null || value === void 0 ? void 0 : value.confidence_level) || (value === null || value === void 0 ? void 0 : value.category) || value, 80).toLowerCase();
493
+ if (/^high$|^strong$|^accepted$|^a\+?$/.test(normalized)) {
494
+ return 'high';
495
+ }
496
+ if (/^medium$|^moderate$|^review$/.test(normalized)) {
497
+ return 'medium';
498
+ }
499
+ if (/^low$|^weak$|^blocked$|^unknown$/.test(normalized)) {
500
+ return normalized === 'unknown' ? 'unknown' : 'low';
501
+ }
502
+ var score = Number((_b = (_a = value === null || value === void 0 ? void 0 : value.score) !== null && _a !== void 0 ? _a : value === null || value === void 0 ? void 0 : value.confidenceScore) !== null && _b !== void 0 ? _b : value === null || value === void 0 ? void 0 : value.confidence_score);
503
+ if (Number.isFinite(score)) {
504
+ if (score >= 0.8) {
505
+ return 'high';
506
+ }
507
+ if (score >= 0.55) {
508
+ return 'medium';
509
+ }
510
+ return 'low';
511
+ }
512
+ return normalized ? 'unknown' : 'unknown';
513
+ }
514
+ function supportReleaseLooksBlocked(value) {
515
+ return /\b(fail|failed|error|blocked|missing|empty|stale|denied|timeout|pending_manual|requested|in_progress|queued)\b/i.test(cleanText(value, 200));
516
+ }
517
+ function supportBusinessAssertionPassed(value) {
518
+ return /^(pass|passed|accepted|business_assertion_passed)$/i.test(cleanText(value, 80));
519
+ }
520
+ function buildSupportClarificationQuestion(gate, blockers) {
521
+ if ((gate === null || gate === void 0 ? void 0 : gate.issue_case.reproduction_status) === 'blocked' && gate.issue_case.reproduction_blocker) {
522
+ return "Can you provide the missing detail needed to reproduce this issue: ".concat(gate.issue_case.reproduction_blocker, "?");
523
+ }
524
+ if (blockers.some(function (blocker) { return /expected_result/.test(blocker); })) {
525
+ return 'What result did you expect to see in this workflow?';
526
+ }
527
+ if (blockers.some(function (blocker) { return /observed_result/.test(blocker); })) {
528
+ return 'What exact result are you seeing instead, including the affected record or screen if possible?';
529
+ }
530
+ if (blockers.some(function (blocker) { return /account_customer_context/.test(blocker); })) {
531
+ return 'Which customer/account/user context should we use to reproduce this issue?';
532
+ }
533
+ return 'Can you send one concrete example record, screen, or action path where this issue still occurs?';
534
+ }
535
+ function decideResolveIOSupportCustomerReplyPolicy(input) {
536
+ var _a, _b, _c;
537
+ if (input === void 0) { input = {}; }
538
+ var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.diagnosisGate);
539
+ var gate = diagnosisValidation.normalized;
540
+ var confidenceLevel = normalizeSupportConfidenceLevel(input.confidence);
541
+ var shouldBlockConfidence = ((_a = input.confidence) === null || _a === void 0 ? void 0 : _a.shouldBlockPr) === true
542
+ || ((_b = input.confidence) === null || _b === void 0 ? void 0 : _b.should_block_pr) === true
543
+ || ((_c = input.confidence) === null || _c === void 0 ? void 0 : _c.blocked) === true;
544
+ var outcomeLabel = cleanText(input.outcomeLabel, 120).toLowerCase();
545
+ var businessPassed = supportBusinessAssertionPassed(input.businessAssertionStatus)
546
+ || outcomeLabel === 'accepted';
547
+ var artifactCount = cleanList(input.businessProofArtifacts, 20, 500).length;
548
+ var unresolvedBlockers = cleanList(input.unresolvedBlockers, 20, 500);
549
+ var releaseBlocked = supportReleaseLooksBlocked(input.releaseStatus);
550
+ var requiredEvidence = [
551
+ 'valid SupportDiagnosisGate',
552
+ 'high confidence with shouldBlockPr=false',
553
+ 'accepted outcome or passed business assertion',
554
+ 'business proof contract and artifact evidence',
555
+ 'no unresolved blocker or release blocker'
556
+ ];
557
+ if (!diagnosisValidation.valid) {
558
+ var canAskCustomer = (gate === null || gate === void 0 ? void 0 : gate.issue_case.reproduction_status) === 'blocked'
559
+ || diagnosisValidation.blockers.some(function (blocker) { return /expected_result|observed_result|account_customer_context/.test(blocker); });
560
+ if (canAskCustomer) {
561
+ return {
562
+ action: 'ask_clarification',
563
+ canDraftCustomerReply: true,
564
+ canSendCustomerReply: false,
565
+ confidenceLevel: confidenceLevel,
566
+ safety: 'needs_clarification',
567
+ reason: 'support_reply_waiting_on_customer_reproduction_detail',
568
+ requiredEvidence: requiredEvidence,
569
+ clarificationQuestion: buildSupportClarificationQuestion(gate, diagnosisValidation.blockers)
570
+ };
571
+ }
572
+ return {
573
+ action: 'hold_internal',
574
+ canDraftCustomerReply: false,
575
+ canSendCustomerReply: false,
576
+ confidenceLevel: confidenceLevel,
577
+ safety: 'internal_hold',
578
+ reason: 'support_reply_blocked_until_diagnosis_gate_validates',
579
+ requiredEvidence: requiredEvidence
580
+ };
581
+ }
582
+ if (shouldBlockConfidence || confidenceLevel !== 'high') {
583
+ return {
584
+ action: 'hold_internal',
585
+ canDraftCustomerReply: false,
586
+ canSendCustomerReply: false,
587
+ confidenceLevel: confidenceLevel,
588
+ safety: 'internal_hold',
589
+ reason: shouldBlockConfidence ? 'support_reply_blocked_by_confidence_gate' : 'support_reply_requires_high_confidence',
590
+ requiredEvidence: requiredEvidence
591
+ };
592
+ }
593
+ if (unresolvedBlockers.length) {
594
+ return {
595
+ action: 'hold_internal',
596
+ canDraftCustomerReply: false,
597
+ canSendCustomerReply: false,
598
+ confidenceLevel: confidenceLevel,
599
+ safety: 'internal_hold',
600
+ reason: 'support_reply_blocked_by_unresolved_runner_blocker',
601
+ requiredEvidence: requiredEvidence
602
+ };
603
+ }
604
+ if (releaseBlocked) {
605
+ return {
606
+ action: 'hold_internal',
607
+ canDraftCustomerReply: false,
608
+ canSendCustomerReply: false,
609
+ confidenceLevel: confidenceLevel,
610
+ safety: 'internal_hold',
611
+ reason: 'support_reply_blocked_until_release_or_hotfix_gate_finishes',
612
+ requiredEvidence: requiredEvidence
613
+ };
614
+ }
615
+ if (!businessPassed) {
616
+ return {
617
+ action: 'hold_internal',
618
+ canDraftCustomerReply: false,
619
+ canSendCustomerReply: false,
620
+ confidenceLevel: confidenceLevel,
621
+ safety: 'internal_hold',
622
+ reason: 'support_reply_requires_business_assertion_pass',
623
+ requiredEvidence: requiredEvidence
624
+ };
625
+ }
626
+ if (!(gate === null || gate === void 0 ? void 0 : gate.proof_plan.business_proof_contract) || artifactCount < 1) {
627
+ return {
628
+ action: 'hold_internal',
629
+ canDraftCustomerReply: false,
630
+ canSendCustomerReply: false,
631
+ confidenceLevel: confidenceLevel,
632
+ safety: 'internal_hold',
633
+ reason: 'support_reply_requires_business_proof_contract_artifact',
634
+ requiredEvidence: requiredEvidence
635
+ };
636
+ }
637
+ return {
638
+ action: 'draft_resolution_reply',
639
+ canDraftCustomerReply: true,
640
+ canSendCustomerReply: false,
641
+ confidenceLevel: confidenceLevel,
642
+ safety: 'safe_to_draft',
643
+ reason: 'support_reply_resolution_draft_allowed_after_business_proof',
644
+ requiredEvidence: requiredEvidence,
645
+ draftBasis: {
646
+ issueClass: gate.issue_class,
647
+ businessProof: gate.proof_plan.business_proof_contract.expected_business_state_change,
648
+ artifactCount: artifactCount
649
+ }
650
+ };
651
+ }
652
+ function buildResolveIOSupportIssueClassProbes(value) {
653
+ var _a;
654
+ var validation = validateResolveIOSupportDiagnosisGate(value);
655
+ var gate = validation.normalized || normalizeResolveIOSupportDiagnosisGate(value);
656
+ if (!gate) {
657
+ return [];
658
+ }
659
+ var route = gate.proof_plan.route || gate.issue_case.route_module;
660
+ var proofContract = gate.proof_plan.business_proof_contract;
661
+ var proof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || gate.proof_plan.business_assertion;
662
+ var assertion = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion) || gate.proof_plan.data_assertion || gate.proof_plan.after;
663
+ var artifacts = ((_a = proofContract === null || proofContract === void 0 ? void 0 : proofContract.proof_artifacts) === null || _a === void 0 ? void 0 : _a.length)
664
+ ? " Required artifacts: ".concat(proofContract.proof_artifacts.join(', '), ".")
665
+ : '';
666
+ var common = {
667
+ issue_class: gate.issue_class,
668
+ probe_type: 'issue_class_probe',
669
+ route: route,
670
+ blocks_acceptance_without_business_assertion: true
671
+ };
672
+ var map = {
673
+ no_op_submit: {
674
+ action: "Submit the customer action on ".concat(route || 'the affected screen', " and assert a persisted state change or explicit validation message."),
675
+ expected: proof || 'Before/action/after proof shows the submit is no longer a no-op.'
676
+ },
677
+ missing_wrong_data: {
678
+ action: "Load the named record/list on ".concat(route || 'the affected route', " and compare visible data to the expected persisted source."),
679
+ expected: proof || 'Visible data and persisted data match the customer expectation.'
680
+ },
681
+ filter_query_mismatch: {
682
+ action: 'Apply the reported filter/query inputs and assert the returned rows/counts match the expected dataset.',
683
+ expected: proof || 'Filter/query output contains the correct included rows and excludes the wrong rows.'
684
+ },
685
+ invoice_pdf_export: {
686
+ action: 'Generate the invoice/PDF/export from the affected route and inspect the downloaded/generated artifact.',
687
+ expected: proof || 'Generated artifact contains the expected customer-visible rows, totals, or fields.'
688
+ },
689
+ upload_import: {
690
+ action: 'Run the upload/import workflow with a representative file and assert parsed plus persisted results.',
691
+ expected: proof || 'Import shows a success result and persisted rows/counts changed as expected.'
692
+ },
693
+ route_auth_hydration: {
694
+ action: 'Open the route as the affected user and assert authenticated hydration reaches the functional screen, not a shell.',
695
+ expected: proof || 'Route hydrates with the required controls/data for the affected account.'
696
+ },
697
+ slow_query_performance: {
698
+ action: 'Run the reported query/workflow with timing/log evidence before and after the fix.',
699
+ expected: proof || 'Performance evidence shows the slow path improved without changing results.'
700
+ }
701
+ };
702
+ var selected = map[gate.issue_class];
703
+ return [__assign(__assign({}, common), { objective: "Issue-class probe for ".concat(gate.issue_class, ": ").concat(gate.issue_case.customer_complaint), action: proofContract
704
+ ? "".concat(proofContract.action_under_test, " ").concat(selected.action)
705
+ : selected.action, expected_evidence: "".concat(selected.expected).concat(assertion ? " Assertion: ".concat(assertion, ".") : '').concat(artifacts).trim() })];
706
+ }
707
+ function hashResolveIOSupportV5Evidence(value) {
708
+ var raw = typeof value === 'string' ? value : JSON.stringify(value || {});
709
+ var normalized = cleanText(raw, 8000)
710
+ .toLowerCase()
711
+ .replace(/[a-f0-9]{16,}/g, '<id>')
712
+ .replace(/\b\d{2,}\b/g, '<n>');
713
+ var hash = 0;
714
+ for (var index = 0; index < normalized.length; index += 1) {
715
+ hash = ((hash << 5) - hash + normalized.charCodeAt(index)) | 0;
716
+ }
717
+ return "ev-".concat(Math.abs(hash).toString(36) || '0');
718
+ }
719
+ function decideResolveIOSupportV5RepeatedFailureStop(input) {
720
+ var failureClass = cleanText(input.failureClass || 'unknown', 80).toLowerCase();
721
+ var blockerFingerprint = fingerprintResolveIOSupportV5Blocker(input.blocker || '');
722
+ var evidenceHash = cleanText(input.evidenceHash, 80) || hashResolveIOSupportV5Evidence(input.evidence || input.blocker || '');
723
+ var limit = Math.max(1, Number(input.limit || 2) || 2);
724
+ if (input.ignoreInfra !== false && /^(infra|compile)$/.test(failureClass)) {
725
+ return {
726
+ shouldStop: false,
727
+ repeatedCount: 0,
728
+ failureClass: failureClass,
729
+ blockerFingerprint: blockerFingerprint,
730
+ evidenceHash: evidenceHash,
731
+ reason: 'support_v5_infra_failures_do_not_count_as_product_repair_loops'
732
+ };
733
+ }
734
+ var latestRecord = (input.history || [])[(input.history || []).length - 1];
735
+ var managerDecision = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerPolicy)({
736
+ history: (input.history || []).map(function (entry) { return ({
737
+ outcome: entry.outcome,
738
+ lane: entry.lane,
739
+ stepType: entry.stepType,
740
+ failureClass: entry.failureClass,
741
+ blocker: entry.blocker || entry.summary,
742
+ blockerFingerprint: entry.blockerFingerprint,
743
+ evidenceHash: entry.evidenceHash,
744
+ changedFiles: entry.changedFiles,
745
+ artifactPaths: entry.artifactPaths,
746
+ summary: entry.summary,
747
+ recordedAt: entry.recordedAt
748
+ }); }),
749
+ current: {
750
+ outcome: 'needs_repair',
751
+ lane: latestRecord === null || latestRecord === void 0 ? void 0 : latestRecord.lane,
752
+ stepType: latestRecord === null || latestRecord === void 0 ? void 0 : latestRecord.stepType,
753
+ failureClass: failureClass,
754
+ blocker: input.blocker,
755
+ blockerFingerprint: blockerFingerprint,
756
+ evidenceHash: evidenceHash
757
+ },
758
+ maxSameFailureRepeats: limit,
759
+ maxPingPongTransitions: 3,
760
+ infraFailureClasses: input.ignoreInfra !== false ? ['infra', 'compile'] : []
761
+ });
762
+ if (managerDecision.action === 'retry_infra') {
763
+ return {
764
+ shouldStop: false,
765
+ repeatedCount: 0,
766
+ failureClass: failureClass,
767
+ blockerFingerprint: blockerFingerprint,
768
+ evidenceHash: evidenceHash,
769
+ reason: 'support_v5_infra_failures_do_not_count_as_product_repair_loops'
770
+ };
771
+ }
772
+ if (managerDecision.action === 'park_ping_pong') {
773
+ return {
774
+ shouldStop: true,
775
+ repeatedCount: managerDecision.pingPongCount,
776
+ failureClass: failureClass,
777
+ blockerFingerprint: blockerFingerprint,
778
+ evidenceHash: evidenceHash,
779
+ reason: 'support_v5_ping_pong_failure_loop'
780
+ };
781
+ }
782
+ if (managerDecision.action === 'park_repeated_failure' && managerDecision.newEvidence) {
783
+ return {
784
+ shouldStop: false,
785
+ repeatedCount: managerDecision.sameFailureCount,
786
+ failureClass: failureClass,
787
+ blockerFingerprint: blockerFingerprint,
788
+ evidenceHash: evidenceHash,
789
+ reason: 'support_v5_retry_allowed_changed_evidence_hash'
790
+ };
791
+ }
792
+ if (managerDecision.action === 'park_repeated_failure') {
793
+ return {
794
+ shouldStop: true,
795
+ repeatedCount: managerDecision.sameFailureCount,
796
+ failureClass: failureClass,
797
+ blockerFingerprint: blockerFingerprint,
798
+ evidenceHash: evidenceHash,
799
+ reason: 'support_v5_same_failure_class_without_new_evidence'
800
+ };
801
+ }
802
+ var repeatedCount = 0;
803
+ for (var index = (input.history || []).length - 1; index >= 0; index -= 1) {
804
+ var item = input.history[index];
805
+ if (item.outcome === 'pass' || item.outcome === 'ready_for_merge') {
806
+ break;
807
+ }
808
+ var itemFailureClass = cleanText(item.failureClass || 'unknown', 80).toLowerCase();
809
+ var itemBlockerFingerprint = cleanText(item.blockerFingerprint, 80)
810
+ || fingerprintResolveIOSupportV5Blocker(item.blocker || item.summary || '');
811
+ var itemEvidenceHash = cleanText(item.evidenceHash, 80)
812
+ || hashResolveIOSupportV5Evidence(item.artifactPaths || item.blocker || item.summary || '');
813
+ if (itemFailureClass !== failureClass || itemBlockerFingerprint !== blockerFingerprint || itemEvidenceHash !== evidenceHash) {
814
+ break;
815
+ }
816
+ repeatedCount += 1;
817
+ }
818
+ return {
819
+ shouldStop: repeatedCount >= limit,
820
+ repeatedCount: repeatedCount,
821
+ failureClass: failureClass,
822
+ blockerFingerprint: blockerFingerprint,
823
+ evidenceHash: evidenceHash,
824
+ reason: repeatedCount >= limit
825
+ ? 'support_v5_same_failure_class_without_new_evidence'
826
+ : 'support_v5_retry_allowed_new_or_below_repeat_limit'
827
+ };
828
+ }
829
+ function changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(diagnosisGate, changedFiles, options) {
830
+ if (options === void 0) { options = {}; }
831
+ var validation = validateResolveIOSupportDiagnosisGate(diagnosisGate);
832
+ if (!validation.valid || !validation.normalized) {
833
+ return cleanList(changedFiles, 80, 500);
834
+ }
835
+ var owners = new Set(validation.normalized.owner_files.map(normalizeOwnerFilePath));
836
+ return cleanList(changedFiles, 120, 500)
837
+ .map(normalizeOwnerFilePath)
838
+ .filter(function (filePath) {
839
+ if (!filePath) {
840
+ return false;
841
+ }
842
+ if (owners.has(filePath)) {
843
+ return false;
844
+ }
845
+ if (options.allowTests && /(^|\/)(tests?|spec|__tests__)(\/|$)|\.(?:spec|test)\.[jt]sx?$/i.test(filePath)) {
846
+ return false;
847
+ }
848
+ return true;
849
+ });
850
+ }
851
+ function decideResolveIOSupportV5RepairGate(input) {
852
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
853
+ var activeStepType = cleanText(input.activeStepType, 80);
854
+ var failureClass = cleanText(input.failureClass, 80).toLowerCase();
855
+ var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.diagnosisGate, {
856
+ maxOwnerFiles: input.maxOwnerFiles
857
+ });
858
+ var ownerFiles = ((_a = diagnosisValidation.normalized) === null || _a === void 0 ? void 0 : _a.owner_files) || [];
859
+ var outsideOwnerFiles = changedFilesOutsideResolveIOSupportDiagnosisOwnerFiles(diagnosisValidation.normalized || input.diagnosisGate, input.changedFiles, { allowTests: input.allowTestsOutsideOwnerFiles === true });
860
+ var repeatedFailure = ((_b = input.history) === null || _b === void 0 ? void 0 : _b.length) ? decideResolveIOSupportV5RepeatedFailureStop({
861
+ history: input.history,
862
+ failureClass: failureClass,
863
+ blocker: input.blocker,
864
+ evidence: input.evidence,
865
+ evidenceHash: input.evidenceHash,
866
+ limit: Math.max(1, Number(input.maxRepeatedNoProgress || 2) || 2),
867
+ ignoreInfra: true
868
+ }) : undefined;
869
+ var recoveryPlanFor = function (action, reason, recoveryFailureClass, productRepairFailure) {
870
+ if (recoveryFailureClass === void 0) { recoveryFailureClass = failureClass || 'unknown'; }
871
+ if (productRepairFailure === void 0) { productRepairFailure = false; }
872
+ return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryPlan)({
873
+ action: action,
874
+ reason: reason,
875
+ failureClass: recoveryFailureClass,
876
+ lane: 'build',
877
+ stepType: activeStepType || 'build_repair',
878
+ blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
879
+ changedFiles: cleanList(input.changedFiles, 40, 500),
880
+ maxSameFailureRepeats: Math.max(1, Number(input.maxRepeatedNoProgress || 2) || 2),
881
+ productRepairFailure: productRepairFailure
882
+ });
883
+ };
884
+ var recoveryCheckpointFor = function (recoveryPlan) { return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryCheckpoint)({
885
+ plan: recoveryPlan,
886
+ current: {
887
+ lane: 'build',
888
+ stepType: activeStepType || 'build_repair',
889
+ failureClass: failureClass || 'unknown',
890
+ blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
891
+ evidenceHash: input.evidenceHash,
892
+ changedFiles: cleanList(input.changedFiles, 40, 500),
893
+ summary: input.blocker
894
+ }
895
+ }); };
896
+ var recoveryFieldsFor = function (recoveryPlan) {
897
+ var recoveryCheckpoint = recoveryCheckpointFor(recoveryPlan);
898
+ var recoveryEvidenceProbe = (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryEvidenceProbe)({
899
+ checkpoint: recoveryCheckpoint,
900
+ current: {
901
+ lane: 'build',
902
+ stepType: activeStepType || 'build_repair',
903
+ failureClass: failureClass || 'unknown',
904
+ blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
905
+ evidenceHash: input.evidenceHash,
906
+ changedFiles: cleanList(input.changedFiles, 40, 500),
907
+ summary: input.blocker
908
+ }
909
+ });
910
+ var current = {
911
+ lane: 'build',
912
+ stepType: activeStepType || 'build_repair',
913
+ failureClass: failureClass || 'unknown',
914
+ blocker: input.blocker || (diagnosisValidation.blockers || []).join(' | '),
915
+ evidenceHash: input.evidenceHash,
916
+ changedFiles: cleanList(input.changedFiles, 40, 500),
917
+ summary: input.blocker
918
+ };
919
+ return {
920
+ recoveryPlan: recoveryPlan,
921
+ recoveryCheckpoint: recoveryCheckpoint,
922
+ recoveryEvidenceProbe: recoveryEvidenceProbe,
923
+ recoveryAction: (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryActionPacket)({
924
+ plan: recoveryPlan,
925
+ checkpoint: recoveryCheckpoint,
926
+ probe: recoveryEvidenceProbe,
927
+ current: current
928
+ })
929
+ };
930
+ };
931
+ if (repeatedFailure === null || repeatedFailure === void 0 ? void 0 : repeatedFailure.shouldStop) {
932
+ var recoveryPlan_1 = recoveryPlanFor('park_repeated_failure', repeatedFailure.reason, repeatedFailure.failureClass, true);
933
+ return __assign({ action: 'park_repeated_failure', canEditProductCode: false, blockers: [repeatedFailure.reason], ownerFiles: ownerFiles, issueClass: (_c = diagnosisValidation.normalized) === null || _c === void 0 ? void 0 : _c.issue_class, proofPlan: (_d = diagnosisValidation.normalized) === null || _d === void 0 ? void 0 : _d.proof_plan, outsideOwnerFiles: outsideOwnerFiles, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_1));
934
+ }
935
+ if (failureClass === 'infra' || failureClass === 'compile') {
936
+ var recoveryPlan_2 = recoveryPlanFor('retry_infra', 'support_v5_infra_or_compile_repair_required', failureClass, false);
937
+ return __assign({ action: 'infra_repair_only', canEditProductCode: false, blockers: ['Infra/compile/Puppeteer/startup failures must be repaired in the harness lane before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_e = diagnosisValidation.normalized) === null || _e === void 0 ? void 0 : _e.issue_class, proofPlan: (_f = diagnosisValidation.normalized) === null || _f === void 0 ? void 0 : _f.proof_plan, outsideOwnerFiles: outsideOwnerFiles, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_2));
938
+ }
939
+ if (activeStepType === 'diagnosis_gate' || !diagnosisValidation.valid) {
940
+ var recoveryPlan_3 = recoveryPlanFor('continue', 'support_v5_diagnosis_gate_required', 'diagnosis', false);
941
+ return __assign({ action: 'diagnose_only', canEditProductCode: false, blockers: diagnosisValidation.blockers.length
942
+ ? diagnosisValidation.blockers
943
+ : ['SupportDiagnosisGate is required before product-code repair.'], ownerFiles: ownerFiles, issueClass: (_g = diagnosisValidation.normalized) === null || _g === void 0 ? void 0 : _g.issue_class, proofPlan: (_h = diagnosisValidation.normalized) === null || _h === void 0 ? void 0 : _h.proof_plan, outsideOwnerFiles: outsideOwnerFiles, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_3));
944
+ }
945
+ if (outsideOwnerFiles.length) {
946
+ var recoveryPlan_4 = recoveryPlanFor('continue', 'support_v5_out_of_scope_requires_diagnosis_revision', 'owner_scope', false);
947
+ return __assign({ action: 'reject_out_of_scope', canEditProductCode: false, blockers: ["Changed files outside diagnosis owner_files; revise diagnosis with new evidence before broadening edits: ".concat(outsideOwnerFiles.join(', '))], ownerFiles: ownerFiles, issueClass: (_j = diagnosisValidation.normalized) === null || _j === void 0 ? void 0 : _j.issue_class, proofPlan: (_k = diagnosisValidation.normalized) === null || _k === void 0 ? void 0 : _k.proof_plan, outsideOwnerFiles: outsideOwnerFiles, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan_4));
948
+ }
949
+ var recoveryPlan = recoveryPlanFor('continue', 'support_v5_product_repair_allowed_after_diagnosis', failureClass || 'product_code', true);
950
+ return __assign({ action: 'allow_product_repair', canEditProductCode: true, blockers: [], ownerFiles: ownerFiles, issueClass: (_l = diagnosisValidation.normalized) === null || _l === void 0 ? void 0 : _l.issue_class, proofPlan: (_m = diagnosisValidation.normalized) === null || _m === void 0 ? void 0 : _m.proof_plan, outsideOwnerFiles: outsideOwnerFiles, repeatedFailure: repeatedFailure, diagnosisValidation: diagnosisValidation }, recoveryFieldsFor(recoveryPlan));
951
+ }
952
+ function applyResolveIOSupportDiagnosisGateToMicrotasks(bundle, diagnosisGate) {
953
+ var _a;
954
+ var validation = validateResolveIOSupportDiagnosisGate(diagnosisGate);
955
+ var gate = validation.normalized;
956
+ if (!gate) {
957
+ return bundle;
958
+ }
959
+ var ownerFiles = gate.owner_files;
960
+ var probes = buildResolveIOSupportIssueClassProbes(gate);
961
+ var proofContract = gate.proof_plan.business_proof_contract;
962
+ var businessProof = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.expected_business_state_change) || gate.proof_plan.business_assertion;
963
+ var businessAssertion = (proofContract === null || proofContract === void 0 ? void 0 : proofContract.data_or_dom_assertion) || gate.proof_plan.data_assertion || gate.proof_plan.after;
964
+ var now = isoNow();
965
+ var diagnosisMicrotaskId = ((_a = (bundle.supportV5MicrotaskLedger || [])
966
+ .find(function (task) { return task.type === 'diagnosis_gate'; })) === null || _a === void 0 ? void 0 : _a.microtaskId)
967
+ || stableIdFromText('diagnosis', "Root-cause-first diagnosis gate for: ".concat(cleanText(bundle.supportV5ScopeDigest || gate.issue_case.customer_complaint, 360) || 'support ticket'));
968
+ var ledger = (bundle.supportV5MicrotaskLedger || []).map(function (task) {
969
+ var _a;
970
+ if (task.type === 'diagnosis_gate') {
971
+ return __assign(__assign({}, task), { status: validation.valid ? 'pass' : 'needs_repair', blocker: validation.valid ? '' : validation.blockers.join(' | '), updatedAt: now });
972
+ }
973
+ if (task.lane === 'build' && /repair|product_repair|build_repair/i.test(String(task.type || ''))) {
974
+ return __assign(__assign({}, task), { targetFiles: ownerFiles, contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'owner_files'], false))), selfGate: "Repair only the diagnosed owner files unless you revise the diagnosis with new evidence. Owner files: ".concat(ownerFiles.join(', '), "."), acceptanceProof: businessProof, dependsOn: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.dependsOn || [])), false), [diagnosisMicrotaskId], false))), updatedAt: now });
975
+ }
976
+ if (task.lane === 'qa' && task.type === 'qa_row') {
977
+ return __assign(__assign({}, task), { contextRefs: Array.from(new Set(__spreadArray(__spreadArray([], __read((task.contextRefs || [])), false), ['supportV5DiagnosisGate', 'proof_plan'], false))), selfGate: ((_a = probes[0]) === null || _a === void 0 ? void 0 : _a.action) || task.selfGate, acceptanceProof: businessProof || task.acceptanceProof, targetFiles: ownerFiles, updatedAt: now });
978
+ }
979
+ return task;
980
+ });
981
+ var nextActive = selectResolveIOSupportV5ActiveMicrotask(ledger, bundle.supportV5ActiveMicrotaskId);
982
+ return __assign(__assign({}, bundle), { supportV5DiagnosisGate: gate, supportV5MicrotaskLedger: ledger, supportV5ActiveMicrotaskId: nextActive === null || nextActive === void 0 ? void 0 : nextActive.microtaskId, supportV5LaneMemory: __assign(__assign({}, bundle.supportV5LaneMemory), { build: __assign(__assign({}, bundle.supportV5LaneMemory.build), { changedFiles: ownerFiles, scopeSummary: [
983
+ bundle.supportV5LaneMemory.build.scopeSummary,
984
+ "Diagnosis issue class: ".concat(gate.issue_class),
985
+ "Accepted hypothesis: ".concat(gate.accepted_hypothesis.statement),
986
+ "Owner files: ".concat(ownerFiles.join(', '))
987
+ ].filter(Boolean).join(' | '), updatedAt: now }), qa: __assign(__assign({}, bundle.supportV5LaneMemory.qa), { activeQaRow: {
988
+ workflow: (proofContract === null || proofContract === void 0 ? void 0 : proofContract.action_under_test) || gate.proof_plan.action,
989
+ route: gate.proof_plan.route || gate.issue_case.route_module,
990
+ assertion: businessAssertion,
991
+ status: 'pending'
992
+ }, updatedAt: now }) }) });
993
+ }
994
+ function stableIdFromText(prefix, value) {
995
+ var text = cleanText(value, 2000).toLowerCase();
996
+ var hash = 0;
997
+ for (var index = 0; index < text.length; index += 1) {
998
+ hash = ((hash << 5) - hash + text.charCodeAt(index)) | 0;
999
+ }
1000
+ return "".concat(prefix, "-").concat(Math.abs(hash).toString(36) || '0');
1001
+ }
1002
+ function estimateTextTokens(value) {
1003
+ var text = String(value || '');
1004
+ if (!text) {
1005
+ return 0;
1006
+ }
1007
+ return Math.max(1, Math.ceil(text.length / 4));
1008
+ }
1009
+ function fingerprintResolveIOSupportV5Blocker(value) {
1010
+ var text = cleanText(value, 4000)
1011
+ .toLowerCase()
1012
+ .replace(/[a-f0-9]{16,}/g, '<id>')
1013
+ .replace(/\b\d{2,}\b/g, '<n>')
1014
+ .replace(/\bline\s+<n>\b/g, 'line <n>');
1015
+ var hash = 0;
1016
+ for (var index = 0; index < text.length; index += 1) {
1017
+ hash = ((hash << 5) - hash + text.charCodeAt(index)) | 0;
1018
+ }
1019
+ return "v5-".concat(Math.abs(hash).toString(36));
1020
+ }
1021
+ function buildResolveIOSupportV5Budget(existing) {
1022
+ return {
1023
+ maxPromptTokensPerNonInitialStep: Number((existing === null || existing === void 0 ? void 0 : existing.maxPromptTokensPerNonInitialStep) || 1800),
1024
+ maxLoopsPerTicket: Number((existing === null || existing === void 0 ? void 0 : existing.maxLoopsPerTicket) || 24),
1025
+ maxRepeatedNoProgress: Number((existing === null || existing === void 0 ? void 0 : existing.maxRepeatedNoProgress) || 2),
1026
+ maxRuntimeMinutesPerLoop: Number((existing === null || existing === void 0 ? void 0 : existing.maxRuntimeMinutesPerLoop) || 15),
1027
+ totalPromptTokenEstimate: Number((existing === null || existing === void 0 ? void 0 : existing.totalPromptTokenEstimate) || 0),
1028
+ totalRuntimeMs: Number((existing === null || existing === void 0 ? void 0 : existing.totalRuntimeMs) || 0),
1029
+ loopCount: Number((existing === null || existing === void 0 ? void 0 : existing.loopCount) || 0)
1030
+ };
1031
+ }
1032
+ function buildResolveIOSupportV5PromptBudget(existing) {
1033
+ return {
1034
+ initialPlannerCap: Number((existing === null || existing === void 0 ? void 0 : existing.initialPlannerCap) || 6000),
1035
+ buildMicrotaskCap: Number((existing === null || existing === void 0 ? void 0 : existing.buildMicrotaskCap) || 1800),
1036
+ buildMicrotaskHardCap: Number((existing === null || existing === void 0 ? void 0 : existing.buildMicrotaskHardCap) || 2500),
1037
+ qaMicrotaskCap: Number((existing === null || existing === void 0 ? void 0 : existing.qaMicrotaskCap) || 1500),
1038
+ qaMicrotaskHardCap: Number((existing === null || existing === void 0 ? void 0 : existing.qaMicrotaskHardCap) || 2200),
1039
+ repairMicrotaskCap: Number((existing === null || existing === void 0 ? void 0 : existing.repairMicrotaskCap) || 1200),
1040
+ repairMicrotaskHardCap: Number((existing === null || existing === void 0 ? void 0 : existing.repairMicrotaskHardCap) || 1800)
1041
+ };
1042
+ }
1043
+ function buildResolveIOSupportV5ScopeDigest(input) {
1044
+ var scope = Array.isArray(input.approvedScope)
1045
+ ? cleanList(input.approvedScope, 30, 220).join(' | ')
1046
+ : cleanText(input.approvedScope, 4000);
1047
+ var raw = [
1048
+ input.goal ? "Goal: ".concat(cleanText(input.goal, 300)) : '',
1049
+ scope ? "Approved scope: ".concat(scope) : '',
1050
+ input.prBranch ? "PR branch: ".concat(cleanText(input.prBranch, 160)) : ''
1051
+ ].filter(Boolean).join('\n');
1052
+ var maxChars = Math.max(400, Math.floor(Number(input.maxTokens || 1000) * 4));
1053
+ return raw.slice(0, maxChars);
1054
+ }
1055
+ function buildResolveIOSupportV5MicrotaskLedger(input) {
1056
+ var e_4, _a;
1057
+ var existing = Array.isArray(input.existing) ? input.existing : [];
1058
+ var completedByObjective = new Map();
1059
+ try {
1060
+ for (var existing_1 = __values(existing), existing_1_1 = existing_1.next(); !existing_1_1.done; existing_1_1 = existing_1.next()) {
1061
+ var task = existing_1_1.value;
1062
+ if (task && (task.status === 'pass' || task.status === 'parked')) {
1063
+ completedByObjective.set(cleanText(task.objective, 500).toLowerCase(), task);
1064
+ }
1065
+ }
1066
+ }
1067
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1068
+ finally {
1069
+ try {
1070
+ if (existing_1_1 && !existing_1_1.done && (_a = existing_1.return)) _a.call(existing_1);
1071
+ }
1072
+ finally { if (e_4) throw e_4.error; }
1073
+ }
1074
+ var now = isoNow(input.now);
1075
+ var requirements = cleanList(input.requirements, 30, 240);
1076
+ var sourceRequirements = requirements.length
1077
+ ? requirements
1078
+ : cleanText(input.scopeDigest, 1000).split(/\s+\|\s+|\r?\n/g).map(function (line) { return line.trim(); }).filter(Boolean).slice(0, 12);
1079
+ var ledger = [];
1080
+ var diagnosisObjective = "Root-cause-first diagnosis gate for: ".concat(cleanText(input.scopeDigest, 360) || 'support ticket');
1081
+ var diagnosisId = stableIdFromText('diagnosis', diagnosisObjective);
1082
+ var existingDiagnosis = existing.find(function (task) { return (task === null || task === void 0 ? void 0 : task.type) === 'diagnosis_gate' || (task === null || task === void 0 ? void 0 : task.microtaskId) === diagnosisId; });
1083
+ ledger.push(existingDiagnosis && (existingDiagnosis.status === 'pass' || existingDiagnosis.status === 'parked') ? existingDiagnosis : {
1084
+ microtaskId: diagnosisId,
1085
+ lane: 'build',
1086
+ type: 'diagnosis_gate',
1087
+ status: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.status) || 'pending',
1088
+ objective: diagnosisObjective,
1089
+ targetFiles: [],
1090
+ contextRefs: ['scope_digest', 'support_context', 'similar_tickets', 'similar_commits'],
1091
+ selfGate: 'Read-only diagnosis only: reproduce or explicitly classify the issue, accept one falsifiable root-cause hypothesis, reject alternatives, identify the failing path, cap owner_files, and define before/action/after business proof.',
1092
+ acceptanceProof: 'Valid ResolveIOSupportDiagnosisGate JSON with issue_case, issue_class, accepted_hypothesis, rejected_alternatives, failing_path, owner_files, proof_plan, evidence, and status=passed.',
1093
+ threadKey: input.buildThreadKey,
1094
+ promptTokenEstimate: existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.promptTokenEstimate,
1095
+ attempts: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.attempts) || 0,
1096
+ dependsOn: [],
1097
+ parentScopeId: stableIdFromText('scope', diagnosisObjective),
1098
+ blocker: existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.blocker,
1099
+ createdAt: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.createdAt) || now,
1100
+ updatedAt: (existingDiagnosis === null || existingDiagnosis === void 0 ? void 0 : existingDiagnosis.updatedAt) || now
1101
+ });
1102
+ sourceRequirements.forEach(function (requirement, index) {
1103
+ var objective = cleanText(requirement, 240);
1104
+ if (!objective) {
1105
+ return;
1106
+ }
1107
+ var existingCompleted = completedByObjective.get(objective.toLowerCase());
1108
+ var buildId = stableIdFromText("build-".concat(index + 1), objective);
1109
+ var qaId = stableIdFromText("qa-".concat(index + 1), objective);
1110
+ ledger.push(existingCompleted && existingCompleted.lane === 'build' ? existingCompleted : {
1111
+ microtaskId: buildId,
1112
+ lane: 'build',
1113
+ type: 'build_repair',
1114
+ status: 'pending',
1115
+ objective: objective,
1116
+ targetFiles: [],
1117
+ contextRefs: ['scope_digest'],
1118
+ selfGate: 'Run the smallest compile/type/unit check that proves this one behavior.',
1119
+ acceptanceProof: 'Concrete code/data proof for this behavior, with changed files listed.',
1120
+ threadKey: input.buildThreadKey,
1121
+ attempts: 0,
1122
+ dependsOn: [diagnosisId],
1123
+ parentScopeId: stableIdFromText('scope', objective),
1124
+ createdAt: now,
1125
+ updatedAt: now
1126
+ });
1127
+ ledger.push({
1128
+ microtaskId: qaId,
1129
+ lane: 'qa',
1130
+ type: 'qa_row',
1131
+ status: 'pending',
1132
+ objective: "QA proof for: ".concat(objective),
1133
+ targetFiles: [],
1134
+ contextRefs: ['scope_digest', buildId],
1135
+ selfGate: 'Drive this one customer-facing workflow row in browser/localhost and capture one captioned proof artifact.',
1136
+ acceptanceProof: 'QA matrix row pass with route/data assertion, screenshot/caption artifact, and persisted before/after row/count/value proof for data-changing workflows.',
1137
+ threadKey: input.qaThreadKey,
1138
+ attempts: 0,
1139
+ dependsOn: [diagnosisId, buildId],
1140
+ parentScopeId: stableIdFromText('scope', objective),
1141
+ createdAt: now,
1142
+ updatedAt: now
1143
+ });
1144
+ });
1145
+ return ledger.length ? ledger : existing.slice(-80);
1146
+ }
1147
+ function selectResolveIOSupportV5ActiveMicrotask(ledger, preferredId) {
1148
+ if (ledger === void 0) { ledger = []; }
1149
+ var byPreferred = preferredId ? ledger.find(function (task) { return task.microtaskId === preferredId && !['pass', 'parked'].includes(task.status); }) : undefined;
1150
+ if (byPreferred) {
1151
+ return byPreferred;
1152
+ }
1153
+ return ledger.find(function (task) { return task.status === 'needs_repair'; })
1154
+ || ledger.find(function (task) { return task.status === 'in_progress'; })
1155
+ || ledger.find(function (task) { return task.type === 'diagnosis_gate' && task.status === 'pending'; })
1156
+ || ledger.find(function (task) { return task.lane === 'build' && /repair/i.test(String(task.type || '')) && task.status === 'pending'; })
1157
+ || ledger.find(function (task) { return task.status === 'pending'; })
1158
+ || ledger.find(function (task) { return task.status === 'blocked'; });
1159
+ }
1160
+ function initializeResolveIOSupportV5State(input) {
1161
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
1162
+ var now = isoNow(input.now);
1163
+ var existing = input.existing || {};
1164
+ var existingSupervisor = existing.supportV5SupervisorState;
1165
+ var existingLaneMemory = existing.supportV5LaneMemory || {};
1166
+ var scope = cleanList(input.approvedScopeRequirements, 24, 240).join(' | ')
1167
+ || cleanText(input.description, 1000)
1168
+ || cleanText(input.title, 300);
1169
+ var ticketLabel = cleanText(input.ticketNumber || input.ticketId || input.jobId, 120);
1170
+ var buildThreadKey = cleanText(input.buildThreadKey || ((_a = existingLaneMemory.build) === null || _a === void 0 ? void 0 : _a.threadKey) || "support:".concat(input.ticketId || input.jobId, ":job:").concat(input.jobId, ":build"), 240);
1171
+ var qaThreadKey = cleanText(input.qaThreadKey || ((_b = existingLaneMemory.qa) === null || _b === void 0 ? void 0 : _b.threadKey) || "support:".concat(input.ticketId || input.jobId, ":job:").concat(input.jobId, ":qa"), 240);
1172
+ var budget = buildResolveIOSupportV5Budget(existing.supportV5Budget);
1173
+ var existingDiagnosisGate = normalizeResolveIOSupportDiagnosisGate(existing.supportV5DiagnosisGate);
1174
+ var diagnosisValidation = validateResolveIOSupportDiagnosisGate(existingDiagnosisGate);
1175
+ var scopeDigest = cleanText(existing.supportV5ScopeDigest, 4000) || buildResolveIOSupportV5ScopeDigest({
1176
+ goal: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.currentGoal) || "Resolve support ticket ".concat(ticketLabel),
1177
+ approvedScope: scope,
1178
+ prBranch: input.prBranch || (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.prBranch) || ''
1179
+ });
1180
+ var ledger = buildResolveIOSupportV5MicrotaskLedger({
1181
+ scopeDigest: scopeDigest,
1182
+ requirements: cleanList(input.approvedScopeRequirements, 30, 240),
1183
+ buildThreadKey: buildThreadKey,
1184
+ qaThreadKey: qaThreadKey,
1185
+ now: now,
1186
+ existing: existing.supportV5MicrotaskLedger
1187
+ });
1188
+ var activeMicrotask = selectResolveIOSupportV5ActiveMicrotask(ledger, existing.supportV5ActiveMicrotaskId);
1189
+ var initialized = {
1190
+ supportWorkflowVersion: 'v5',
1191
+ supportV5SupervisorState: {
1192
+ version: 'v5',
1193
+ status: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.status) || 'active',
1194
+ currentGoal: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.currentGoal) || "Resolve support ticket ".concat(ticketLabel),
1195
+ approvedScope: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.approvedScope) || scope,
1196
+ prBranch: cleanText(input.prBranch || (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.prBranch) || '', 240),
1197
+ activeStep: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.activeStep) || (diagnosisValidation.valid ? 'compile_check' : 'diagnosis_gate'),
1198
+ activeBlocker: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.activeBlocker) || (diagnosisValidation.valid ? '' : 'SupportDiagnosisGate required before product-code repair.'),
1199
+ lastGoodCheckpoint: (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.lastGoodCheckpoint) || 'v5_initialized',
1200
+ currentQaRow: existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.currentQaRow,
1201
+ processLease: input.processLease || (existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.processLease),
1202
+ artifactLinks: cleanList(existingSupervisor === null || existingSupervisor === void 0 ? void 0 : existingSupervisor.artifactLinks, 40, 500),
1203
+ noEmailUnlessApproved: true,
1204
+ updatedAt: now
1205
+ },
1206
+ supportV5DiagnosisGate: diagnosisValidation.valid ? diagnosisValidation.normalized : existingDiagnosisGate,
1207
+ supportV5LaneMemory: {
1208
+ build: {
1209
+ lane: 'build',
1210
+ model: ((_c = existingLaneMemory.build) === null || _c === void 0 ? void 0 : _c.model) || 'gpt-5.3-codex',
1211
+ threadKey: buildThreadKey,
1212
+ scopeSummary: ((_d = existingLaneMemory.build) === null || _d === void 0 ? void 0 : _d.scopeSummary) || scope,
1213
+ activeBlocker: ((_e = existingLaneMemory.build) === null || _e === void 0 ? void 0 : _e.activeBlocker) || '',
1214
+ activeQaRow: (_f = existingLaneMemory.build) === null || _f === void 0 ? void 0 : _f.activeQaRow,
1215
+ changedFiles: cleanList((_g = existingLaneMemory.build) === null || _g === void 0 ? void 0 : _g.changedFiles, 80, 500),
1216
+ artifactPaths: cleanList((_h = existingLaneMemory.build) === null || _h === void 0 ? void 0 : _h.artifactPaths, 80, 500),
1217
+ latestPromptTokenEstimate: Number(((_j = existingLaneMemory.build) === null || _j === void 0 ? void 0 : _j.latestPromptTokenEstimate) || 0) || undefined,
1218
+ updatedAt: ((_k = existingLaneMemory.build) === null || _k === void 0 ? void 0 : _k.updatedAt) || now
1219
+ },
1220
+ qa: {
1221
+ lane: 'qa',
1222
+ model: ((_l = existingLaneMemory.qa) === null || _l === void 0 ? void 0 : _l.model) || 'gpt-5.4-mini',
1223
+ threadKey: qaThreadKey,
1224
+ scopeSummary: ((_m = existingLaneMemory.qa) === null || _m === void 0 ? void 0 : _m.scopeSummary) || scope,
1225
+ activeBlocker: ((_o = existingLaneMemory.qa) === null || _o === void 0 ? void 0 : _o.activeBlocker) || '',
1226
+ activeQaRow: (_p = existingLaneMemory.qa) === null || _p === void 0 ? void 0 : _p.activeQaRow,
1227
+ changedFiles: cleanList((_q = existingLaneMemory.qa) === null || _q === void 0 ? void 0 : _q.changedFiles, 80, 500),
1228
+ artifactPaths: cleanList((_r = existingLaneMemory.qa) === null || _r === void 0 ? void 0 : _r.artifactPaths, 80, 500),
1229
+ latestPromptTokenEstimate: Number(((_s = existingLaneMemory.qa) === null || _s === void 0 ? void 0 : _s.latestPromptTokenEstimate) || 0) || undefined,
1230
+ updatedAt: ((_t = existingLaneMemory.qa) === null || _t === void 0 ? void 0 : _t.updatedAt) || now
1231
+ }
1232
+ },
1233
+ supportV5StepHistory: Array.isArray(existing.supportV5StepHistory)
1234
+ ? existing.supportV5StepHistory.slice(-80)
1235
+ : [],
1236
+ supportV5Budget: budget,
1237
+ supportV5RunnerIncidents: Array.isArray(existing.supportV5RunnerIncidents)
1238
+ ? existing.supportV5RunnerIncidents.slice(-80)
1239
+ : [],
1240
+ supportV5MicrotaskLedger: ledger,
1241
+ supportV5ActiveMicrotaskId: diagnosisValidation.valid
1242
+ ? activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId
1243
+ : ((_u = ledger.find(function (task) { return task.type === 'diagnosis_gate' && !['pass', 'parked'].includes(task.status); })) === null || _u === void 0 ? void 0 : _u.microtaskId) || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.microtaskId),
1244
+ supportV5ScopeDigest: scopeDigest,
1245
+ supportV5MicrotaskUsageHistory: Array.isArray(existing.supportV5MicrotaskUsageHistory)
1246
+ ? existing.supportV5MicrotaskUsageHistory.slice(-200)
1247
+ : [],
1248
+ supportV5FailureFingerprints: Array.isArray(existing.supportV5FailureFingerprints)
1249
+ ? existing.supportV5FailureFingerprints.slice(-200)
1250
+ : [],
1251
+ supportV5RecoveryPlan: existing.supportV5RecoveryPlan,
1252
+ supportV5RecoveryCheckpoint: existing.supportV5RecoveryCheckpoint,
1253
+ supportV5RecoveryEvidenceProbe: existing.supportV5RecoveryEvidenceProbe,
1254
+ supportV5RecoveryAction: existing.supportV5RecoveryAction,
1255
+ supportV5RecoveryDispatchHistory: Array.isArray(existing.supportV5RecoveryDispatchHistory)
1256
+ ? existing.supportV5RecoveryDispatchHistory.slice(-50)
1257
+ : [],
1258
+ supportV5RecoveryDirective: existing.supportV5RecoveryDirective
1259
+ };
1260
+ return diagnosisValidation.valid && diagnosisValidation.normalized
1261
+ ? applyResolveIOSupportDiagnosisGateToMicrotasks(initialized, diagnosisValidation.normalized)
1262
+ : initialized;
1263
+ }
1264
+ function recordResolveIOSupportV5Step(bundle, step) {
1265
+ var _a, _b, _c, _d;
1266
+ var now = isoNow(step.now);
1267
+ var promptTokens = Math.max(0, Number(step.promptTokenEstimate || 0) || 0);
1268
+ var runtimeMs = Math.max(0, Number(step.runtimeMs || 0) || 0);
1269
+ var microtaskId = cleanText(step.microtaskId || bundle.supportV5ActiveMicrotaskId, 160);
1270
+ var normalizedDiagnosisGate = step.diagnosisGate
1271
+ ? normalizeResolveIOSupportDiagnosisGate(step.diagnosisGate, now)
1272
+ : undefined;
1273
+ var blockerFingerprint = step.blocker || step.summary
1274
+ ? fingerprintResolveIOSupportV5Blocker(step.blocker || step.summary || '')
1275
+ : undefined;
1276
+ var evidenceHash = cleanText(step.evidenceHash, 80)
1277
+ || (((_a = step.artifactPaths) === null || _a === void 0 ? void 0 : _a.length) || step.blocker || step.summary
1278
+ ? hashResolveIOSupportV5Evidence(((_b = step.artifactPaths) === null || _b === void 0 ? void 0 : _b.length) ? step.artifactPaths : "".concat(step.blocker || '', "\n").concat(step.summary || ''))
1279
+ : (0, ai_runner_manager_policy_1.hashResolveIOAIManagerEvidence)({
1280
+ failureClass: step.failureClass,
1281
+ blocker: step.blocker,
1282
+ summary: step.summary,
1283
+ changedFiles: step.changedFiles,
1284
+ artifactPaths: step.artifactPaths
1285
+ }));
1286
+ var record = __assign(__assign({}, (microtaskId ? { microtaskId: microtaskId } : {})), { stepType: step.stepType, outcome: step.outcome, lane: step.lane, model: cleanText(step.model, 80), threadKey: cleanText(step.threadKey, 240), promptTokenEstimate: promptTokens || undefined, runtimeMs: runtimeMs || undefined, summary: cleanText(step.summary || step.blocker || step.outcome, 1200), blocker: cleanText(step.blocker, 1200), changedFiles: cleanList(step.changedFiles, 80, 500), artifactPaths: cleanList(step.artifactPaths, 80, 500), diagnosisGate: normalizedDiagnosisGate, failureClass: cleanText(step.failureClass, 80) || undefined, blockerFingerprint: blockerFingerprint, evidenceHash: evidenceHash, recordedAt: now });
1287
+ var diagnosisGate = normalizedDiagnosisGate || bundle.supportV5DiagnosisGate;
1288
+ var laneMemory = __assign({}, bundle.supportV5LaneMemory);
1289
+ if (step.lane === 'build' || step.lane === 'qa') {
1290
+ var previous = laneMemory[step.lane];
1291
+ laneMemory[step.lane] = __assign(__assign({}, previous), { activeBlocker: record.blocker || previous.activeBlocker || '', activeQaRow: step.activeQaRow || previous.activeQaRow, changedFiles: ((_c = record.changedFiles) === null || _c === void 0 ? void 0 : _c.length) ? record.changedFiles : previous.changedFiles, artifactPaths: ((_d = record.artifactPaths) === null || _d === void 0 ? void 0 : _d.length) ? record.artifactPaths : previous.artifactPaths, latestPromptTokenEstimate: promptTokens || previous.latestPromptTokenEstimate, updatedAt: now });
1292
+ }
1293
+ var supervisor = __assign(__assign({}, bundle.supportV5SupervisorState), { status: step.outcome === 'ready_for_merge' ? 'complete' : (step.outcome === 'park_manual' || step.outcome === 'budget_stop' ? 'parked' : 'active'), activeStep: step.stepType, activeBlocker: record.blocker || '', currentQaRow: step.activeQaRow || bundle.supportV5SupervisorState.currentQaRow, lastGoodCheckpoint: step.outcome === 'pass' || step.outcome === 'ready_for_merge'
1294
+ ? step.stepType
1295
+ : bundle.supportV5SupervisorState.lastGoodCheckpoint, artifactLinks: Array.from(new Set(__spreadArray(__spreadArray([], __read(bundle.supportV5SupervisorState.artifactLinks), false), __read((record.artifactPaths || [])), false))).slice(-80), updatedAt: now });
1296
+ var ledger = (bundle.supportV5MicrotaskLedger || []).map(function (task) {
1297
+ if (task.microtaskId !== bundle.supportV5ActiveMicrotaskId) {
1298
+ return task;
1299
+ }
1300
+ var status = step.outcome === 'pass' || step.outcome === 'ready_for_merge'
1301
+ ? 'pass'
1302
+ : step.outcome === 'park_manual' || step.outcome === 'budget_stop'
1303
+ ? 'parked'
1304
+ : step.outcome === 'needs_repair' || step.outcome === 'retry_same_step'
1305
+ ? 'needs_repair'
1306
+ : 'in_progress';
1307
+ return __assign(__assign({}, task), { status: status, blocker: record.blocker || task.blocker, promptTokenEstimate: promptTokens || task.promptTokenEstimate, attempts: task.attempts + (step.outcome === 'pass' || step.outcome === 'ready_for_merge' ? 0 : 1), updatedAt: now });
1308
+ });
1309
+ var failureFingerprint = record.failureClass && record.blockerFingerprint && record.evidenceHash
1310
+ ? {
1311
+ stepType: record.stepType,
1312
+ failureClass: cleanText(record.failureClass, 80),
1313
+ blockerFingerprint: record.blockerFingerprint,
1314
+ evidenceHash: record.evidenceHash,
1315
+ recordedAt: now
1316
+ }
1317
+ : undefined;
1318
+ var managerDecision = (0, ai_runner_manager_policy_1.decideResolveIOAIManagerPolicy)({
1319
+ history: __spreadArray(__spreadArray([], __read(bundle.supportV5StepHistory), false), [record], false),
1320
+ current: record,
1321
+ maxSameFailureRepeats: buildResolveIOSupportV5Budget(bundle.supportV5Budget).maxRepeatedNoProgress,
1322
+ maxPingPongTransitions: 3,
1323
+ infraFailureClasses: ['infra', 'compile']
1324
+ });
1325
+ var previousRecord = bundle.supportV5StepHistory[bundle.supportV5StepHistory.length - 1];
1326
+ var nextLoopCount = managerDecision.loopBudgetShouldReset
1327
+ || (previousRecord === null || previousRecord === void 0 ? void 0 : previousRecord.failureClass) !== record.failureClass
1328
+ || (previousRecord === null || previousRecord === void 0 ? void 0 : previousRecord.blockerFingerprint) !== record.blockerFingerprint
1329
+ || (previousRecord === null || previousRecord === void 0 ? void 0 : previousRecord.evidenceHash) !== record.evidenceHash
1330
+ ? 1
1331
+ : bundle.supportV5Budget.loopCount + 1;
1332
+ var nextMicrotask = selectResolveIOSupportV5ActiveMicrotask(ledger, bundle.supportV5ActiveMicrotaskId);
1333
+ var nextBundle = __assign(__assign({}, bundle), { supportV5SupervisorState: supervisor, supportV5DiagnosisGate: diagnosisGate, supportV5LaneMemory: laneMemory, supportV5StepHistory: __spreadArray(__spreadArray([], __read(bundle.supportV5StepHistory), false), [record], false).slice(-100), supportV5Budget: __assign(__assign({}, bundle.supportV5Budget), { totalPromptTokenEstimate: bundle.supportV5Budget.totalPromptTokenEstimate + promptTokens, totalRuntimeMs: bundle.supportV5Budget.totalRuntimeMs + runtimeMs, loopCount: nextLoopCount }), supportV5MicrotaskLedger: ledger, supportV5ActiveMicrotaskId: nextMicrotask === null || nextMicrotask === void 0 ? void 0 : nextMicrotask.microtaskId, supportV5MicrotaskUsageHistory: bundle.supportV5MicrotaskUsageHistory || [], supportV5FailureFingerprints: failureFingerprint
1334
+ ? __spreadArray(__spreadArray([], __read((bundle.supportV5FailureFingerprints || [])), false), [failureFingerprint], false).slice(-200)
1335
+ : (bundle.supportV5FailureFingerprints || []), supportV5RecoveryPlan: managerDecision.recoveryPlan, supportV5RecoveryCheckpoint: managerDecision.recoveryCheckpoint, supportV5RecoveryEvidenceProbe: managerDecision.recoveryEvidenceProbe, supportV5RecoveryAction: managerDecision.recoveryAction });
1336
+ if (normalizedDiagnosisGate && validateResolveIOSupportDiagnosisGate(normalizedDiagnosisGate).valid) {
1337
+ return applyResolveIOSupportDiagnosisGateToMicrotasks(nextBundle, normalizedDiagnosisGate);
1338
+ }
1339
+ return nextBundle;
1340
+ }
1341
+ function recordResolveIOSupportV5MicrotaskUsage(bundle, usage) {
1342
+ var record = __assign(__assign({}, usage), { microtaskId: cleanText(usage.microtaskId, 160), threadKey: cleanText(usage.threadKey, 240), model: cleanText(usage.model, 80), promptTokenEstimate: Math.max(0, Number(usage.promptTokenEstimate || 0) || 0), promptSections: Array.isArray(usage.promptSections)
1343
+ ? usage.promptSections.map(function (section) { return ({
1344
+ name: cleanText(section.name, 120),
1345
+ tokenEstimate: Math.max(0, Number(section.tokenEstimate || 0) || 0)
1346
+ }); }).filter(function (section) { return section.name; })
1347
+ : [], recordedAt: isoNow() });
1348
+ var ledger = (bundle.supportV5MicrotaskLedger || []).map(function (task) { return task.microtaskId === record.microtaskId
1349
+ ? __assign(__assign({}, task), { promptTokenEstimate: record.promptTokenEstimate, updatedAt: record.recordedAt }) : task; });
1350
+ return __assign(__assign({}, bundle), { supportV5MicrotaskLedger: ledger, supportV5MicrotaskUsageHistory: __spreadArray(__spreadArray([], __read((bundle.supportV5MicrotaskUsageHistory || [])), false), [
1351
+ record
1352
+ ], false).slice(-200) });
1353
+ }
1354
+ function decideResolveIOSupportV5Continuation(bundle) {
1355
+ var history = bundle.supportV5StepHistory || [];
1356
+ var budget = buildResolveIOSupportV5Budget(bundle.supportV5Budget);
1357
+ var last = history[history.length - 1];
1358
+ var activeMicrotaskId = cleanText(bundle.supportV5ActiveMicrotaskId, 160);
1359
+ var blockerFingerprint = fingerprintResolveIOSupportV5Blocker((last === null || last === void 0 ? void 0 : last.blocker) || (last === null || last === void 0 ? void 0 : last.summary) || '');
1360
+ var repeatedNoProgressCount = 0;
1361
+ for (var index = history.length - 1; index >= 0; index -= 1) {
1362
+ var item = history[index];
1363
+ if (activeMicrotaskId && cleanText(item.microtaskId, 160) !== activeMicrotaskId) {
1364
+ continue;
1365
+ }
1366
+ if (item.outcome === 'pass' || item.outcome === 'ready_for_merge') {
1367
+ break;
1368
+ }
1369
+ if (item.stepType !== (last === null || last === void 0 ? void 0 : last.stepType)) {
1370
+ break;
1371
+ }
1372
+ if (fingerprintResolveIOSupportV5Blocker(item.blocker || item.summary || '') === blockerFingerprint) {
1373
+ repeatedNoProgressCount += 1;
1374
+ }
1375
+ }
1376
+ var budgetExceeded = budget.loopCount >= budget.maxLoopsPerTicket
1377
+ || ((last === null || last === void 0 ? void 0 : last.promptTokenEstimate) || 0) > budget.maxPromptTokensPerNonInitialStep;
1378
+ var repeatedFailure = last ? decideResolveIOSupportV5RepeatedFailureStop({
1379
+ history: history,
1380
+ failureClass: last.failureClass,
1381
+ blocker: last.blocker || last.summary,
1382
+ evidenceHash: last.evidenceHash,
1383
+ limit: budget.maxRepeatedNoProgress,
1384
+ ignoreInfra: true
1385
+ }) : null;
1386
+ var recoveryPlanFor = function (action, reason, extra) {
1387
+ if (extra === void 0) { extra = {}; }
1388
+ return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryPlan)(__assign({ action: action, reason: reason, failureClass: last === null || last === void 0 ? void 0 : last.failureClass, lane: (last === null || last === void 0 ? void 0 : last.lane) || 'supervisor', stepType: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.supportV5SupervisorState.activeStep, blocker: (last === null || last === void 0 ? void 0 : last.blocker) || (last === null || last === void 0 ? void 0 : last.summary), changedFiles: last === null || last === void 0 ? void 0 : last.changedFiles, artifactPaths: last === null || last === void 0 ? void 0 : last.artifactPaths, maxSameFailureRepeats: budget.maxRepeatedNoProgress }, extra));
1389
+ };
1390
+ var recoveryCheckpointFor = function (recoveryPlan) { return (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryCheckpoint)({
1391
+ plan: recoveryPlan,
1392
+ current: last
1393
+ }); };
1394
+ var recoveryFieldsFor = function (recoveryPlan) {
1395
+ var recoveryCheckpoint = recoveryCheckpointFor(recoveryPlan);
1396
+ var recoveryEvidenceProbe = (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryEvidenceProbe)({
1397
+ checkpoint: recoveryCheckpoint,
1398
+ current: last
1399
+ });
1400
+ return {
1401
+ recoveryPlan: recoveryPlan,
1402
+ recoveryCheckpoint: recoveryCheckpoint,
1403
+ recoveryEvidenceProbe: recoveryEvidenceProbe,
1404
+ recoveryAction: (0, ai_runner_manager_policy_1.buildResolveIOAIManagerRecoveryActionPacket)({
1405
+ plan: recoveryPlan,
1406
+ checkpoint: recoveryCheckpoint,
1407
+ probe: recoveryEvidenceProbe,
1408
+ current: last
1409
+ })
1410
+ };
1411
+ };
1412
+ if (budgetExceeded) {
1413
+ var recoveryPlan_5 = recoveryPlanFor('manual_handoff', 'support_v5_budget_guard', {
1414
+ productRepairFailure: false
1415
+ });
1416
+ return __assign({ action: 'park', reason: 'support_v5_budget_guard', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'cleanup', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_5));
1417
+ }
1418
+ var lastFailureClass = cleanText(last === null || last === void 0 ? void 0 : last.failureClass, 80).toLowerCase();
1419
+ if (repeatedNoProgressCount > budget.maxRepeatedNoProgress && /^(infra|compile)$/.test(lastFailureClass)) {
1420
+ var recoveryPlan_6 = recoveryPlanFor('retry_infra', 'support_v5_infra_or_compile_repair_required', {
1421
+ failureClass: lastFailureClass,
1422
+ productRepairFailure: false
1423
+ });
1424
+ return __assign({ action: 'continue', reason: 'support_v5_infra_or_compile_repair_required', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'compile_check', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_6));
1425
+ }
1426
+ if (repeatedNoProgressCount > budget.maxRepeatedNoProgress) {
1427
+ var recoveryPlan_7 = recoveryPlanFor('park_repeated_failure', 'support_v5_repeated_no_progress', {
1428
+ productRepairFailure: true
1429
+ });
1430
+ return __assign({ action: 'park', reason: 'support_v5_repeated_no_progress', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'cleanup', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_7));
1431
+ }
1432
+ if (repeatedFailure === null || repeatedFailure === void 0 ? void 0 : repeatedFailure.shouldStop) {
1433
+ var recoveryPlan_8 = recoveryPlanFor(repeatedFailure.reason === 'support_v5_ping_pong_failure_loop' ? 'park_ping_pong' : 'park_repeated_failure', repeatedFailure.reason, {
1434
+ failureClass: repeatedFailure.failureClass,
1435
+ productRepairFailure: true
1436
+ });
1437
+ return __assign({ action: 'park', reason: repeatedFailure.reason, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || 'cleanup', repeatedNoProgressCount: repeatedFailure.repeatedCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_8));
1438
+ }
1439
+ var recoveryPlan = recoveryPlanFor('continue', 'support_v5_continue');
1440
+ return __assign({ action: 'continue', reason: 'support_v5_continue', nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.supportV5SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan));
1441
+ }
1442
+ function buildResolveIOSupportV5DiagnoseFirstPrompt(lines) {
1443
+ var _a, _b;
1444
+ return [
1445
+ 'Support Runner V5 contract: act like a guarded autonomous engineer, not a gate checklist.',
1446
+ 'Start with Diagnose First: observed evidence, likely cause, smallest next action, and expected proof.',
1447
+ 'Use compact lane memory and current artifacts before asking for broad ticket context.',
1448
+ 'Do not send customer email. Do not write production data. Do not spawn duplicate build, QA, server, client, Mongo, browser, or Codex processes.',
1449
+ 'If repairing, inspect logs/artifacts/source/diff first; make the smallest code or localhost-data change, then run the smallest finite self-gate.',
1450
+ 'For build repairs, prefer `npm run build-prod -- --watch=false`, a targeted `tsc --noEmit`, or a focused unit test. `npm run build-dev` is forbidden for support microtasks because it is slow/watch-oriented and can leave heavy esbuild work. If no finite gate exists, return a blocked self-gate with the exact reason instead of running build-dev.',
1451
+ 'If QA fails, retest the failed row before advancing; if the same blocker repeats without new proof, park with the exact blocker.',
1452
+ lines.goal ? "Goal: ".concat(cleanText(lines.goal, 500)) : '',
1453
+ cleanList(lines.approvedScope, 12, 240).length ? "Approved scope: ".concat(cleanList(lines.approvedScope, 12, 240).join(' | ')) : '',
1454
+ lines.activeStep ? "Active step: ".concat(lines.activeStep) : '',
1455
+ lines.lane ? "Lane: ".concat(lines.lane) : '',
1456
+ lines.laneSummary ? "Lane memory: ".concat(cleanText(lines.laneSummary, 700)) : '',
1457
+ lines.activeBlocker ? "Active blocker: ".concat(cleanText(lines.activeBlocker, 800)) : '',
1458
+ ((_a = lines.currentQaRow) === null || _a === void 0 ? void 0 : _a.workflow) ? "Current QA row: ".concat(cleanText(lines.currentQaRow.workflow, 300)) : '',
1459
+ ((_b = lines.currentQaRow) === null || _b === void 0 ? void 0 : _b.route) ? "Current QA route: ".concat(cleanText(lines.currentQaRow.route, 300)) : '',
1460
+ cleanList(lines.changedFiles, 12, 200).length ? "Changed files: ".concat(cleanList(lines.changedFiles, 12, 200).join(', ')) : '',
1461
+ cleanList(lines.artifactPaths, 12, 240).length ? "Artifacts: ".concat(cleanList(lines.artifactPaths, 12, 240).join(', ')) : ''
1462
+ ].filter(Boolean);
1463
+ }
1464
+ function buildResolveIOSupportV5MicrotaskPrompt(input) {
1465
+ var _a, _b, _c, _d, _e, _f;
1466
+ var activeMicrotask = selectResolveIOSupportV5ActiveMicrotask(input.bundle.supportV5MicrotaskLedger || [], input.bundle.supportV5ActiveMicrotaskId);
1467
+ var diagnosisValidation = validateResolveIOSupportDiagnosisGate(input.bundle.supportV5DiagnosisGate);
1468
+ var diagnosisGate = diagnosisValidation.normalized || input.bundle.supportV5DiagnosisGate;
1469
+ var diagnosisActive = (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) === 'diagnosis_gate';
1470
+ var budget = buildResolveIOSupportV5PromptBudget();
1471
+ var repairLike = Boolean(input.failureText || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.status) === 'needs_repair' || /repair/i.test(String(input.stage || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.type) || '')));
1472
+ var cap = repairLike
1473
+ ? budget.repairMicrotaskCap
1474
+ : input.lane === 'qa'
1475
+ ? budget.qaMicrotaskCap
1476
+ : budget.buildMicrotaskCap;
1477
+ var hardCap = repairLike
1478
+ ? budget.repairMicrotaskHardCap
1479
+ : input.lane === 'qa'
1480
+ ? budget.qaMicrotaskHardCap
1481
+ : budget.buildMicrotaskHardCap;
1482
+ var laneMemory = input.bundle.supportV5LaneMemory[input.lane];
1483
+ var taskThreadKey = (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.threadKey) || laneMemory.threadKey;
1484
+ var changedFiles = cleanList(((_a = input.changedFiles) === null || _a === void 0 ? void 0 : _a.length) ? input.changedFiles : laneMemory.changedFiles, 8, 160);
1485
+ var artifactPaths = cleanList(((_b = input.artifactPaths) === null || _b === void 0 ? void 0 : _b.length) ? input.artifactPaths : laneMemory.artifactPaths, 8, 200);
1486
+ var targetFiles = cleanList(((_c = input.targetFiles) === null || _c === void 0 ? void 0 : _c.length) ? input.targetFiles : activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.targetFiles, 5, 160);
1487
+ var contextSnippets = cleanList(input.contextSnippets, 5, 360);
1488
+ var qaRow = input.activeQaRow || (activeMicrotask === null || activeMicrotask === void 0 ? void 0 : activeMicrotask.lane) === 'qa'
1489
+ ? input.activeQaRow || laneMemory.activeQaRow || input.bundle.supportV5SupervisorState.currentQaRow
1490
+ : undefined;
1491
+ var sections = [
1492
+ {
1493
+ name: 'microtask_contract',
1494
+ text: [
1495
+ 'Support Runner V5 Microtask Contract.',
1496
+ 'Use the existing persistent lane thread. Do not start a fresh thread.',
1497
+ 'Do exactly one microtask and one proof gate. Do not replay ticket triage, prior plans, attachments, broad QA checklist, or unrelated scope.',
1498
+ 'If context is insufficient, request the smallest missing file/log/artifact by path and park this microtask; do not broaden the prompt.',
1499
+ 'Do not send customer email. Do not deploy. Do not spawn duplicate server/client/Mongo/browser/Codex processes.',
1500
+ diagnosisActive
1501
+ ? 'Diagnosis gate hard boundary: read-only investigation only. Do not edit source, generated files, package files, tests, fixtures, QA artifacts, or local data. Return the diagnosis JSON contract only.'
1502
+ : input.lane === 'qa'
1503
+ ? 'QA lane hard boundary: the platform preflight owns compile, dependency install, Mongo/server/client startup, and Angular startup. This lane owns only browser/data proof and QA artifacts unless the prompt explicitly says preflight was skipped.'
1504
+ : 'Build lane hard boundary: do not run `npm run build-dev`, `ng build`, `npm run server`, `npm run client`, `ng serve`, `run-local-qa.sh`, browser automation, or any watch/long-lived command. If a broad compile gate is needed, run only `npm run build-prod -- --watch=false`; otherwise use a targeted finite check or return the precise blocker.'
1505
+ ].join('\n')
1506
+ },
1507
+ diagnosisActive ? {
1508
+ name: 'root_cause_first_diagnosis_contract',
1509
+ text: [
1510
+ 'Before any product-code repair, produce strict JSON only:',
1511
+ '{"support_diagnosis_gate":{"issue_case":{"customer_complaint":"","expected_result":"","observed_result":"","route_module":"","account_customer_context":"","reproduction_status":"reproduced|blocked|classified","reproduction_blocker":""},"issue_class":"no_op_submit|missing_wrong_data|filter_query_mismatch|invoice_pdf_export|upload_import|route_auth_hydration|slow_query_performance","accepted_hypothesis":{"statement":"","falsifiable_test":"","evidence":[""]},"rejected_alternatives":[""],"failing_path":{"frontend":"","backend":"","shared_library":"","data_query":"","description":""},"owner_files":["small/exact/file.ts"],"proof_plan":{"before":"","before_state_unavailable_reason":"","action":"","after":"","business_assertion":"","route":"","data_assertion":"","artifact_expectation":"","business_proof_contract":{"issue_class":"same as diagnosis issue_class","setup_state":"","action_under_test":"","expected_business_state_change":"","prohibited_false_pass":"Route load, screenshot, scorecard, or model claim alone is not acceptance.","proof_artifacts":["browser trace/screenshot/json/mongo delta"],"data_or_dom_assertion":""}},"similar_tickets":[],"similar_commits":[],"evidence":[{"type":"ticket|browser|mongo|log|code|commit|qa|other","summary":"","artifactPath":""}],"status":"passed"}}',
1512
+ 'Owner files must be a small exact editable set, not directories, globs, generated wrappers, or broad repo areas.',
1513
+ 'The accepted hypothesis must be falsifiable and backed by evidence; prior similar tickets or commits are hints only and cannot bypass fresh diagnosis.',
1514
+ 'The proof plan must be before/action/after business proof plus business_proof_contract. If before-state proof is impossible, explain exactly why in before_state_unavailable_reason.',
1515
+ 'The business_proof_contract must name the setup state, action under test, expected business state change, prohibited false pass, required artifacts, and DOM/data assertion.'
1516
+ ].join('\n')
1517
+ } : {
1518
+ name: 'diagnosis_gate_context',
1519
+ text: diagnosisValidation.valid && diagnosisGate ? [
1520
+ "Diagnosis issue class: ".concat(diagnosisGate.issue_class),
1521
+ "Accepted hypothesis: ".concat(diagnosisGate.accepted_hypothesis.statement),
1522
+ "Failing path: ".concat(diagnosisGate.failing_path.description || diagnosisGate.failing_path.frontend || diagnosisGate.failing_path.backend || ''),
1523
+ "Owner files: ".concat(diagnosisGate.owner_files.join(', ')),
1524
+ "Business proof required: ".concat(diagnosisGate.proof_plan.business_assertion),
1525
+ diagnosisGate.proof_plan.business_proof_contract
1526
+ ? "Business proof contract: ".concat((_d = diagnosisGate.proof_plan.business_proof_contract) === null || _d === void 0 ? void 0 : _d.action_under_test, " -> ").concat((_e = diagnosisGate.proof_plan.business_proof_contract) === null || _e === void 0 ? void 0 : _e.expected_business_state_change, "; assertion ").concat((_f = diagnosisGate.proof_plan.business_proof_contract) === null || _f === void 0 ? void 0 : _f.data_or_dom_assertion)
1527
+ : '',
1528
+ "Before/action/after: ".concat(diagnosisGate.proof_plan.before || diagnosisGate.proof_plan.before_state_unavailable_reason, " -> ").concat(diagnosisGate.proof_plan.action, " -> ").concat(diagnosisGate.proof_plan.after)
1529
+ ].filter(Boolean).join('\n') : 'SupportDiagnosisGate is not valid. Park instead of editing product code.'
1530
+ },
1531
+ {
1532
+ name: 'scope_digest',
1533
+ text: cleanText(input.bundle.supportV5ScopeDigest || input.bundle.supportV5SupervisorState.approvedScope, 900)
1534
+ },
1535
+ {
1536
+ name: 'active_microtask',
1537
+ text: activeMicrotask ? [
1538
+ "Microtask id: ".concat(activeMicrotask.microtaskId),
1539
+ "Lane: ".concat(input.lane),
1540
+ "Type: ".concat(activeMicrotask.type),
1541
+ "Status: ".concat(activeMicrotask.status),
1542
+ "Objective: ".concat(cleanText(activeMicrotask.objective, 360)),
1543
+ "Self-gate: ".concat(cleanText(activeMicrotask.selfGate, 260)),
1544
+ "Acceptance proof: ".concat(cleanText(activeMicrotask.acceptanceProof, 260)),
1545
+ "Attempts on this microtask: ".concat(activeMicrotask.attempts),
1546
+ "Thread key: ".concat(taskThreadKey)
1547
+ ].join('\n') : 'No active microtask found. Park and report support_v5_microtask_missing.'
1548
+ },
1549
+ {
1550
+ name: 'failure_delta',
1551
+ text: input.failureText ? "Latest blocker/failure delta: ".concat(cleanText(input.failureText, 700)) : ''
1552
+ },
1553
+ {
1554
+ name: 'target_context',
1555
+ text: [
1556
+ targetFiles.length ? "Target files: ".concat(targetFiles.join(', ')) : '',
1557
+ changedFiles.length ? "Changed files: ".concat(changedFiles.join(', ')) : '',
1558
+ artifactPaths.length ? "Artifacts: ".concat(artifactPaths.join(', ')) : '',
1559
+ (qaRow === null || qaRow === void 0 ? void 0 : qaRow.workflow) ? "QA row workflow: ".concat(cleanText(qaRow.workflow, 220)) : '',
1560
+ (qaRow === null || qaRow === void 0 ? void 0 : qaRow.route) ? "QA row route: ".concat(cleanText(qaRow.route, 220)) : '',
1561
+ (qaRow === null || qaRow === void 0 ? void 0 : qaRow.assertion) ? "QA row assertion: ".concat(cleanText(qaRow.assertion, 260)) : '',
1562
+ contextSnippets.length ? "Relevant snippets:\n".concat(contextSnippets.join('\n---\n')) : ''
1563
+ ].filter(Boolean).join('\n')
1564
+ },
1565
+ input.lane === 'qa' ? {
1566
+ name: 'qa_browser_evidence_contract',
1567
+ text: [
1568
+ 'QA lane first action after preflight: collect fresh browser evidence for the active row, not a proof review of existing route/auth artifacts.',
1569
+ 'Use the already-running localhost harness and staged env. Before any shell command, run `source .resolveio-support-tools/env.sh 2>/dev/null || source ../.resolveio-support-tools/env.sh 2>/dev/null || true`; then use `$RESOLVEIO_SUPPORT_QA_CLIENT_URL`, `$RESOLVEIO_SUPPORT_QA_SERVER_URL`, `$PUPPETEER_EXECUTABLE_PATH`, and `$CHROME_BIN`.',
1570
+ 'Required auth replay helper inside every Puppeteer row script: `const storage=JSON.parse(fs.readFileSync("qa-artifacts/auth-bootstrap-storage-state.json","utf8")); const entries=[...(Array.isArray(storage.localStorageEntries)?storage.localStorageEntries:[]), ...(Array.isArray(storage.localStorage)?storage.localStorage:Object.entries(storage.localStorage||{}).map(([key,value])=>({key,value}))), ...((storage.origins||[]).flatMap(o=>o.localStorage||[]))].map(e=>({key:e.key||e.name,value:e.value})).filter(e=>e.key); const clientUrl=process.env.RESOLVEIO_SUPPORT_QA_CLIENT_URL||process.env.RESOLVEIO_RUNNER_QA_CLIENT_URL; const rowRoute="<ACTIVE_QA_ROUTE>"; await page.goto(clientUrl,{waitUntil:"domcontentloaded"}); await page.evaluate(items=>{localStorage.clear(); for(const item of items)localStorage.setItem(item.key,item.value);}, entries); await page.goto(new URL(rowRoute, clientUrl).href,{waitUntil:"domcontentloaded"});` Replace `<ACTIVE_QA_ROUTE>` with the active row route before running. A screenshot of `/home`, the login screen, or a shell route after this helper means the QA script navigated to the wrong route or storage is stale; rerun the same row with the active route before returning an app blocker.',
1571
+ 'Allowed first command shape: one bounded `node`/Puppeteer row script that reads `qa-artifacts/auth-bootstrap-storage-state.json`, opens `$RESOLVEIO_SUPPORT_QA_CLIENT_URL`, seeds localStorage, navigates to the active QA route with `new URL(activeRoute, clientUrl).href`, drives the visible workflow, captures screenshot/caption, and updates the active matrix row. A `/home` proof is invalid for a locked non-home route.',
1572
+ 'Forbidden in QA lane after preflight: `npm run build`, `npm run build-dev`, `npm run build-prod`, `ng build`, `npm install`, `npm ci`, `npm run server`, `npm run client`, `ng serve`, `gulp`, `mongod`, `run-local-qa.sh`, and broad source discovery. If a build/startup/dependency problem is suspected, return `blocked` or `needs-fix` with the existing qa-artifacts log paths instead of launching those commands.',
1573
+ 'Launch Puppeteer from `PUPPETEER_EXECUTABLE_PATH || CHROME_BIN`, seed localStorage from `qa-artifacts/auth-bootstrap-storage-state.json`, then navigate to the active QA route.',
1574
+ 'Before passing, confirm `qa-artifacts/auth-bootstrap-result.json` used the ticket reporter or named affected user when available. If it used generic admin/dev while `qa-live-data-seed-result.json.selected.qa_user_context` names a reporter/affected user, rerun auth as that user or return needs-fix.',
1575
+ 'Drive the visible customer workflow for this one row. Capture a new customer-facing screenshot/caption and update `qa-artifacts/qa-coverage-matrix.json` with workflow, route, data id/name, assertion, screenshot path, caption, and pass/failed/blocked status.',
1576
+ 'After selecting any From/To, source/target, dropdown, combobox, rio-select, filter, item, customer, yard, chemical, or treatment-plan value, read the visible control text back from the DOM. If it still contains placeholder text such as Select Chemical, Select Yard, Select Customer, Select Treatment Plan Type, Loading..., empty, null, or undefined, do not click the action button and do not mark pass. Capture the selected-state blocker screenshot/DOM text and return needs-fix.',
1577
+ 'If the row needs persisted data proof, create that proof yourself in the same bounded QA command by querying localhost QA Mongo through process.env.MONGO_URL after the visible UI action. Write the result under qa-artifacts/ as JSON and reference that path in the matrix. Do not ask for a missing post-action DB artifact while the local QA stack is running; either write it or return needs-fix with the exact query/script error. For update-interchangeables rows, the JSON must include concrete non-placeholder fromText and toText, before/after counts or sample documents for treatment plans and tank/interchangeable records, and must fail if either selected value is only an arrow/placeholder or if the persisted collections are empty.',
1578
+ 'If the row names multiple concrete entities such as assets, units, BOLs, invoices, chemicals, customers, yards, or numbered records, prove every named entity. Do not pass by proving only one representative record.',
1579
+ 'For customer-reported data bugs, use production-seeded localhost records from `qa-live-data-seed-result.json`. If the exact named record is missing from the seed, fail the row as a seed/query blocker instead of testing a substitute record.',
1580
+ 'Route-ready, auth-bootstrap, shell, header-only, and empty-list screenshots do not satisfy this microtask. If the row cannot be proven, capture the blocker screenshot/DOM state and return needs-fix with that exact blocker.',
1581
+ 'Do not run compile/startup/npm install, do not spawn another server/client/Mongo, and do not inspect broad source trees before the first browser evidence command.'
1582
+ ].join('\n')
1583
+ } : {
1584
+ name: 'non_qa_noop',
1585
+ text: ''
1586
+ },
1587
+ {
1588
+ name: 'return_contract',
1589
+ text: diagnosisActive
1590
+ ? 'Return strict JSON only with support_diagnosis_gate. Do not include Markdown and do not edit files.'
1591
+ : input.lane === 'qa'
1592
+ ? 'Return strict JSON only: {"status":"pass"|"needs-fix"|"blocked","microtaskId":"","summary":"","evidence":[""],"artifacts":[""],"next_actions":[""]}.'
1593
+ : 'Return concise Markdown with: Microtask Result, Root Cause, Changes, Self-Gate, Acceptance Proof, Residual Risk.'
1594
+ }
1595
+ ].filter(function (section) { return cleanText(section.text, 20); });
1596
+ var promptSections = sections.map(function (section) { return ({
1597
+ name: section.name,
1598
+ tokenEstimate: estimateTextTokens(section.text)
1599
+ }); });
1600
+ var prompt = sections.map(function (section) { return section.text; }).join('\n\n');
1601
+ var promptTokenEstimate = estimateTextTokens(prompt);
1602
+ return {
1603
+ prompt: prompt,
1604
+ promptTokenEstimate: promptTokenEstimate,
1605
+ promptSections: promptSections,
1606
+ activeMicrotask: activeMicrotask,
1607
+ withinCap: promptTokenEstimate <= cap,
1608
+ withinHardCap: promptTokenEstimate <= hardCap,
1609
+ cap: cap,
1610
+ hardCap: hardCap,
1611
+ reason: promptTokenEstimate > hardCap
1612
+ ? 'support_v5_microtask_prompt_hard_cap'
1613
+ : promptTokenEstimate > cap
1614
+ ? 'support_v5_microtask_prompt_soft_cap'
1615
+ : undefined
1616
+ };
1617
+ }
1618
+ function summarizeResolveIOSupportV5MicrotaskUsage(bundle) {
1619
+ var e_5, _a, e_6, _b;
1620
+ var byMicrotask = new Map();
1621
+ var bySection = new Map();
1622
+ var totalPromptTokenEstimate = 0;
1623
+ var broadPromptViolations = [];
1624
+ var promptBudget = buildResolveIOSupportV5PromptBudget();
1625
+ try {
1626
+ for (var _c = __values(bundle.supportV5MicrotaskUsageHistory || []), _d = _c.next(); !_d.done; _d = _c.next()) {
1627
+ var usage = _d.value;
1628
+ totalPromptTokenEstimate += usage.promptTokenEstimate || 0;
1629
+ var existing = byMicrotask.get(usage.microtaskId) || { microtaskId: usage.microtaskId, promptTokenEstimate: 0, calls: 0 };
1630
+ existing.promptTokenEstimate += usage.promptTokenEstimate || 0;
1631
+ existing.calls += 1;
1632
+ byMicrotask.set(usage.microtaskId, existing);
1633
+ try {
1634
+ for (var _e = (e_6 = void 0, __values(usage.promptSections || [])), _f = _e.next(); !_f.done; _f = _e.next()) {
1635
+ var section = _f.value;
1636
+ bySection.set(section.name, (bySection.get(section.name) || 0) + section.tokenEstimate);
1637
+ }
1638
+ }
1639
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1640
+ finally {
1641
+ try {
1642
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
1643
+ }
1644
+ finally { if (e_6) throw e_6.error; }
1645
+ }
1646
+ var hardCap = usage.lane === 'qa' ? promptBudget.qaMicrotaskHardCap : promptBudget.buildMicrotaskHardCap;
1647
+ if ((usage.promptTokenEstimate || 0) > hardCap) {
1648
+ broadPromptViolations.push(usage);
1649
+ }
1650
+ }
1651
+ }
1652
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1653
+ finally {
1654
+ try {
1655
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1656
+ }
1657
+ finally { if (e_5) throw e_5.error; }
1658
+ }
1659
+ return {
1660
+ totalPromptTokenEstimate: totalPromptTokenEstimate,
1661
+ byMicrotask: Array.from(byMicrotask.values()),
1662
+ bySection: Array.from(bySection.entries()).map(function (_a) {
1663
+ var _b = __read(_a, 2), name = _b[0], tokenEstimate = _b[1];
1664
+ return ({ name: name, tokenEstimate: tokenEstimate });
1665
+ }),
1666
+ broadPromptViolations: broadPromptViolations
1667
+ };
1668
+ }
1669
+ function buildResolveIOSupportV5Incident(input) {
1670
+ return {
1671
+ incidentClass: cleanText(input.incidentClass, 120) || 'support_v5_runner_incident',
1672
+ summary: cleanText(input.summary, 1200),
1673
+ stepType: input.stepType,
1674
+ blockerFingerprint: input.blocker ? fingerprintResolveIOSupportV5Blocker(input.blocker) : undefined,
1675
+ artifactPaths: cleanList(input.artifactPaths, 40, 500),
1676
+ recordedAt: isoNow(input.now)
1677
+ };
1678
+ }
1679
+
1680
+ //# sourceMappingURL=support-runner-v5.js.map