@gracker/smartperfetto 1.0.13

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 (2287) hide show
  1. package/.env.example +586 -0
  2. package/LICENSE +685 -0
  3. package/data/perfettoSqlDocs.json +33478 -0
  4. package/data/perfettoSqlIndex.json +9458 -0
  5. package/data/perfettoSqlIndex.light.json +13129 -0
  6. package/data/perfettoStdlibSymbols.json +677 -0
  7. package/dist/agent/agents/base/baseAgent.d.ts +378 -0
  8. package/dist/agent/agents/base/baseAgent.d.ts.map +1 -0
  9. package/dist/agent/agents/base/baseAgent.js +1484 -0
  10. package/dist/agent/agents/base/baseAgent.js.map +1 -0
  11. package/dist/agent/agents/base/baseSubAgent.d.ts +135 -0
  12. package/dist/agent/agents/base/baseSubAgent.d.ts.map +1 -0
  13. package/dist/agent/agents/base/baseSubAgent.js +483 -0
  14. package/dist/agent/agents/base/baseSubAgent.js.map +1 -0
  15. package/dist/agent/agents/baseExpertAgent.d.ts +37 -0
  16. package/dist/agent/agents/baseExpertAgent.d.ts.map +1 -0
  17. package/dist/agent/agents/baseExpertAgent.js +322 -0
  18. package/dist/agent/agents/baseExpertAgent.js.map +1 -0
  19. package/dist/agent/agents/domain/additionalAgents.d.ts +54 -0
  20. package/dist/agent/agents/domain/additionalAgents.d.ts.map +1 -0
  21. package/dist/agent/agents/domain/additionalAgents.js +292 -0
  22. package/dist/agent/agents/domain/additionalAgents.js.map +1 -0
  23. package/dist/agent/agents/domain/binderAgent.d.ts +27 -0
  24. package/dist/agent/agents/domain/binderAgent.d.ts.map +1 -0
  25. package/dist/agent/agents/domain/binderAgent.js +100 -0
  26. package/dist/agent/agents/domain/binderAgent.js.map +1 -0
  27. package/dist/agent/agents/domain/cpuAgent.d.ts +35 -0
  28. package/dist/agent/agents/domain/cpuAgent.d.ts.map +1 -0
  29. package/dist/agent/agents/domain/cpuAgent.js +163 -0
  30. package/dist/agent/agents/domain/cpuAgent.js.map +1 -0
  31. package/dist/agent/agents/domain/frameAgent.d.ts +59 -0
  32. package/dist/agent/agents/domain/frameAgent.d.ts.map +1 -0
  33. package/dist/agent/agents/domain/frameAgent.js +511 -0
  34. package/dist/agent/agents/domain/frameAgent.js.map +1 -0
  35. package/dist/agent/agents/domain/index.d.ts +92 -0
  36. package/dist/agent/agents/domain/index.d.ts.map +1 -0
  37. package/dist/agent/agents/domain/index.js +250 -0
  38. package/dist/agent/agents/domain/index.js.map +1 -0
  39. package/dist/agent/agents/domain/memoryAgent.d.ts +26 -0
  40. package/dist/agent/agents/domain/memoryAgent.d.ts.map +1 -0
  41. package/dist/agent/agents/domain/memoryAgent.js +94 -0
  42. package/dist/agent/agents/domain/memoryAgent.js.map +1 -0
  43. package/dist/agent/agents/domain/skillCatalog.d.ts +10 -0
  44. package/dist/agent/agents/domain/skillCatalog.d.ts.map +1 -0
  45. package/dist/agent/agents/domain/skillCatalog.js +66 -0
  46. package/dist/agent/agents/domain/skillCatalog.js.map +1 -0
  47. package/dist/agent/agents/evaluatorAgent.d.ts +76 -0
  48. package/dist/agent/agents/evaluatorAgent.d.ts.map +1 -0
  49. package/dist/agent/agents/evaluatorAgent.js +517 -0
  50. package/dist/agent/agents/evaluatorAgent.js.map +1 -0
  51. package/dist/agent/agents/index.d.ts +13 -0
  52. package/dist/agent/agents/index.d.ts.map +1 -0
  53. package/dist/agent/agents/index.js +25 -0
  54. package/dist/agent/agents/index.js.map +1 -0
  55. package/dist/agent/agents/iterationStrategyPlanner.d.ts +140 -0
  56. package/dist/agent/agents/iterationStrategyPlanner.d.ts.map +1 -0
  57. package/dist/agent/agents/iterationStrategyPlanner.js +359 -0
  58. package/dist/agent/agents/iterationStrategyPlanner.js.map +1 -0
  59. package/dist/agent/agents/plannerAgent.d.ts +56 -0
  60. package/dist/agent/agents/plannerAgent.d.ts.map +1 -0
  61. package/dist/agent/agents/plannerAgent.js +379 -0
  62. package/dist/agent/agents/plannerAgent.js.map +1 -0
  63. package/dist/agent/agents/scrollingExpertAgent.d.ts +11 -0
  64. package/dist/agent/agents/scrollingExpertAgent.d.ts.map +1 -0
  65. package/dist/agent/agents/scrollingExpertAgent.js +132 -0
  66. package/dist/agent/agents/scrollingExpertAgent.js.map +1 -0
  67. package/dist/agent/agents/tools/adbTools.d.ts +5 -0
  68. package/dist/agent/agents/tools/adbTools.d.ts.map +1 -0
  69. package/dist/agent/agents/tools/adbTools.js +326 -0
  70. package/dist/agent/agents/tools/adbTools.js.map +1 -0
  71. package/dist/agent/communication/agentMessageBus.d.ts +138 -0
  72. package/dist/agent/communication/agentMessageBus.d.ts.map +1 -0
  73. package/dist/agent/communication/agentMessageBus.js +542 -0
  74. package/dist/agent/communication/agentMessageBus.js.map +1 -0
  75. package/dist/agent/communication/index.d.ts +7 -0
  76. package/dist/agent/communication/index.d.ts.map +1 -0
  77. package/dist/agent/communication/index.js +15 -0
  78. package/dist/agent/communication/index.js.map +1 -0
  79. package/dist/agent/compaction/compactionTypes.d.ts +163 -0
  80. package/dist/agent/compaction/compactionTypes.d.ts.map +1 -0
  81. package/dist/agent/compaction/compactionTypes.js +32 -0
  82. package/dist/agent/compaction/compactionTypes.js.map +1 -0
  83. package/dist/agent/compaction/contextCompactor.d.ts +109 -0
  84. package/dist/agent/compaction/contextCompactor.d.ts.map +1 -0
  85. package/dist/agent/compaction/contextCompactor.js +225 -0
  86. package/dist/agent/compaction/contextCompactor.js.map +1 -0
  87. package/dist/agent/compaction/index.d.ts +10 -0
  88. package/dist/agent/compaction/index.d.ts.map +1 -0
  89. package/dist/agent/compaction/index.js +43 -0
  90. package/dist/agent/compaction/index.js.map +1 -0
  91. package/dist/agent/compaction/strategies/index.d.ts +5 -0
  92. package/dist/agent/compaction/strategies/index.d.ts.map +1 -0
  93. package/dist/agent/compaction/strategies/index.js +13 -0
  94. package/dist/agent/compaction/strategies/index.js.map +1 -0
  95. package/dist/agent/compaction/strategies/slidingWindowStrategy.d.ts +53 -0
  96. package/dist/agent/compaction/strategies/slidingWindowStrategy.d.ts.map +1 -0
  97. package/dist/agent/compaction/strategies/slidingWindowStrategy.js +237 -0
  98. package/dist/agent/compaction/strategies/slidingWindowStrategy.js.map +1 -0
  99. package/dist/agent/compaction/tokenEstimator.d.ts +78 -0
  100. package/dist/agent/compaction/tokenEstimator.d.ts.map +1 -0
  101. package/dist/agent/compaction/tokenEstimator.js +203 -0
  102. package/dist/agent/compaction/tokenEstimator.js.map +1 -0
  103. package/dist/agent/config/decisionThresholdManifest.d.ts +72 -0
  104. package/dist/agent/config/decisionThresholdManifest.d.ts.map +1 -0
  105. package/dist/agent/config/decisionThresholdManifest.js +77 -0
  106. package/dist/agent/config/decisionThresholdManifest.js.map +1 -0
  107. package/dist/agent/config/domainManifest.d.ts +77 -0
  108. package/dist/agent/config/domainManifest.d.ts.map +1 -0
  109. package/dist/agent/config/domainManifest.js +269 -0
  110. package/dist/agent/config/domainManifest.js.map +1 -0
  111. package/dist/agent/config/drillDownRegistry.d.ts +19 -0
  112. package/dist/agent/config/drillDownRegistry.d.ts.map +1 -0
  113. package/dist/agent/config/drillDownRegistry.js +118 -0
  114. package/dist/agent/config/drillDownRegistry.js.map +1 -0
  115. package/dist/agent/context/contextBuilder.d.ts +79 -0
  116. package/dist/agent/context/contextBuilder.d.ts.map +1 -0
  117. package/dist/agent/context/contextBuilder.js +273 -0
  118. package/dist/agent/context/contextBuilder.js.map +1 -0
  119. package/dist/agent/context/contextTypes.d.ts +121 -0
  120. package/dist/agent/context/contextTypes.d.ts.map +1 -0
  121. package/dist/agent/context/contextTypes.js +14 -0
  122. package/dist/agent/context/contextTypes.js.map +1 -0
  123. package/dist/agent/context/enhancedSessionContext.d.ts +283 -0
  124. package/dist/agent/context/enhancedSessionContext.d.ts.map +1 -0
  125. package/dist/agent/context/enhancedSessionContext.js +1636 -0
  126. package/dist/agent/context/enhancedSessionContext.js.map +1 -0
  127. package/dist/agent/context/entityStore.d.ts +374 -0
  128. package/dist/agent/context/entityStore.d.ts.map +1 -0
  129. package/dist/agent/context/entityStore.js +621 -0
  130. package/dist/agent/context/entityStore.js.map +1 -0
  131. package/dist/agent/context/focusStore.d.ts +229 -0
  132. package/dist/agent/context/focusStore.d.ts.map +1 -0
  133. package/dist/agent/context/focusStore.js +528 -0
  134. package/dist/agent/context/focusStore.js.map +1 -0
  135. package/dist/agent/context/index.d.ts +10 -0
  136. package/dist/agent/context/index.d.ts.map +1 -0
  137. package/dist/agent/context/index.js +42 -0
  138. package/dist/agent/context/index.js.map +1 -0
  139. package/dist/agent/context/policies/evaluatorPolicy.d.ts +22 -0
  140. package/dist/agent/context/policies/evaluatorPolicy.d.ts.map +1 -0
  141. package/dist/agent/context/policies/evaluatorPolicy.js +82 -0
  142. package/dist/agent/context/policies/evaluatorPolicy.js.map +1 -0
  143. package/dist/agent/context/policies/index.d.ts +7 -0
  144. package/dist/agent/context/policies/index.d.ts.map +1 -0
  145. package/dist/agent/context/policies/index.js +18 -0
  146. package/dist/agent/context/policies/index.js.map +1 -0
  147. package/dist/agent/context/policies/plannerPolicy.d.ts +27 -0
  148. package/dist/agent/context/policies/plannerPolicy.d.ts.map +1 -0
  149. package/dist/agent/context/policies/plannerPolicy.js +67 -0
  150. package/dist/agent/context/policies/plannerPolicy.js.map +1 -0
  151. package/dist/agent/context/policies/workerPolicy.d.ts +29 -0
  152. package/dist/agent/context/policies/workerPolicy.d.ts.map +1 -0
  153. package/dist/agent/context/policies/workerPolicy.js +99 -0
  154. package/dist/agent/context/policies/workerPolicy.js.map +1 -0
  155. package/dist/agent/core/circuitBreaker.d.ts +150 -0
  156. package/dist/agent/core/circuitBreaker.d.ts.map +1 -0
  157. package/dist/agent/core/circuitBreaker.js +500 -0
  158. package/dist/agent/core/circuitBreaker.js.map +1 -0
  159. package/dist/agent/core/conclusionContract.d.ts +61 -0
  160. package/dist/agent/core/conclusionContract.d.ts.map +1 -0
  161. package/dist/agent/core/conclusionContract.js +6 -0
  162. package/dist/agent/core/conclusionContract.js.map +1 -0
  163. package/dist/agent/core/conclusionGenerator.d.ts +42 -0
  164. package/dist/agent/core/conclusionGenerator.d.ts.map +1 -0
  165. package/dist/agent/core/conclusionGenerator.js +4109 -0
  166. package/dist/agent/core/conclusionGenerator.js.map +1 -0
  167. package/dist/agent/core/conclusionSceneTemplates.d.ts +8 -0
  168. package/dist/agent/core/conclusionSceneTemplates.d.ts.map +1 -0
  169. package/dist/agent/core/conclusionSceneTemplates.js +31 -0
  170. package/dist/agent/core/conclusionSceneTemplates.js.map +1 -0
  171. package/dist/agent/core/drillDownResolver.d.ts +67 -0
  172. package/dist/agent/core/drillDownResolver.d.ts.map +1 -0
  173. package/dist/agent/core/drillDownResolver.js +583 -0
  174. package/dist/agent/core/drillDownResolver.js.map +1 -0
  175. package/dist/agent/core/emittedEnvelopeRegistry.d.ts +75 -0
  176. package/dist/agent/core/emittedEnvelopeRegistry.d.ts.map +1 -0
  177. package/dist/agent/core/emittedEnvelopeRegistry.js +164 -0
  178. package/dist/agent/core/emittedEnvelopeRegistry.js.map +1 -0
  179. package/dist/agent/core/entityCapture.d.ts +53 -0
  180. package/dist/agent/core/entityCapture.d.ts.map +1 -0
  181. package/dist/agent/core/entityCapture.js +522 -0
  182. package/dist/agent/core/entityCapture.js.map +1 -0
  183. package/dist/agent/core/entityRegistry.d.ts +19 -0
  184. package/dist/agent/core/entityRegistry.d.ts.map +1 -0
  185. package/dist/agent/core/entityRegistry.js +102 -0
  186. package/dist/agent/core/entityRegistry.js.map +1 -0
  187. package/dist/agent/core/executors/analysisExecutor.d.ts +21 -0
  188. package/dist/agent/core/executors/analysisExecutor.d.ts.map +1 -0
  189. package/dist/agent/core/executors/analysisExecutor.js +6 -0
  190. package/dist/agent/core/executors/analysisExecutor.js.map +1 -0
  191. package/dist/agent/core/executors/clarifyExecutor.d.ts +42 -0
  192. package/dist/agent/core/executors/clarifyExecutor.d.ts.map +1 -0
  193. package/dist/agent/core/executors/clarifyExecutor.js +316 -0
  194. package/dist/agent/core/executors/clarifyExecutor.js.map +1 -0
  195. package/dist/agent/core/executors/comparisonExecutor.d.ts +39 -0
  196. package/dist/agent/core/executors/comparisonExecutor.d.ts.map +1 -0
  197. package/dist/agent/core/executors/comparisonExecutor.js +404 -0
  198. package/dist/agent/core/executors/comparisonExecutor.js.map +1 -0
  199. package/dist/agent/core/executors/directDrillDownExecutor.d.ts +56 -0
  200. package/dist/agent/core/executors/directDrillDownExecutor.d.ts.map +1 -0
  201. package/dist/agent/core/executors/directDrillDownExecutor.js +665 -0
  202. package/dist/agent/core/executors/directDrillDownExecutor.js.map +1 -0
  203. package/dist/agent/core/executors/directSkillExecutor.d.ts +106 -0
  204. package/dist/agent/core/executors/directSkillExecutor.d.ts.map +1 -0
  205. package/dist/agent/core/executors/directSkillExecutor.js +633 -0
  206. package/dist/agent/core/executors/directSkillExecutor.js.map +1 -0
  207. package/dist/agent/core/executors/extendExecutor.d.ts +50 -0
  208. package/dist/agent/core/executors/extendExecutor.d.ts.map +1 -0
  209. package/dist/agent/core/executors/extendExecutor.js +402 -0
  210. package/dist/agent/core/executors/extendExecutor.js.map +1 -0
  211. package/dist/agent/core/executors/hypothesisExecutor.d.ts +52 -0
  212. package/dist/agent/core/executors/hypothesisExecutor.d.ts.map +1 -0
  213. package/dist/agent/core/executors/hypothesisExecutor.js +564 -0
  214. package/dist/agent/core/executors/hypothesisExecutor.js.map +1 -0
  215. package/dist/agent/core/executors/index.d.ts +9 -0
  216. package/dist/agent/core/executors/index.d.ts.map +1 -0
  217. package/dist/agent/core/executors/index.js +15 -0
  218. package/dist/agent/core/executors/index.js.map +1 -0
  219. package/dist/agent/core/executors/strategy/strategyFrameEnvelopeCoordinator.d.ts +12 -0
  220. package/dist/agent/core/executors/strategy/strategyFrameEnvelopeCoordinator.d.ts.map +1 -0
  221. package/dist/agent/core/executors/strategy/strategyFrameEnvelopeCoordinator.js +186 -0
  222. package/dist/agent/core/executors/strategy/strategyFrameEnvelopeCoordinator.js.map +1 -0
  223. package/dist/agent/core/executors/strategy/strategyFrameMechanismCollector.d.ts +9 -0
  224. package/dist/agent/core/executors/strategy/strategyFrameMechanismCollector.d.ts.map +1 -0
  225. package/dist/agent/core/executors/strategy/strategyFrameMechanismCollector.js +123 -0
  226. package/dist/agent/core/executors/strategy/strategyFrameMechanismCollector.js.map +1 -0
  227. package/dist/agent/core/executors/strategy/strategyStagePlanner.d.ts +18 -0
  228. package/dist/agent/core/executors/strategy/strategyStagePlanner.d.ts.map +1 -0
  229. package/dist/agent/core/executors/strategy/strategyStagePlanner.js +69 -0
  230. package/dist/agent/core/executors/strategy/strategyStagePlanner.js.map +1 -0
  231. package/dist/agent/core/executors/strategy/strategyStageTaskBuilder.d.ts +14 -0
  232. package/dist/agent/core/executors/strategy/strategyStageTaskBuilder.d.ts.map +1 -0
  233. package/dist/agent/core/executors/strategy/strategyStageTaskBuilder.js +129 -0
  234. package/dist/agent/core/executors/strategy/strategyStageTaskBuilder.js.map +1 -0
  235. package/dist/agent/core/executors/strategyExecutor.d.ts +16 -0
  236. package/dist/agent/core/executors/strategyExecutor.d.ts.map +1 -0
  237. package/dist/agent/core/executors/strategyExecutor.js +377 -0
  238. package/dist/agent/core/executors/strategyExecutor.js.map +1 -0
  239. package/dist/agent/core/executors/traceConfigDetector.d.ts +28 -0
  240. package/dist/agent/core/executors/traceConfigDetector.d.ts.map +1 -0
  241. package/dist/agent/core/executors/traceConfigDetector.js +156 -0
  242. package/dist/agent/core/executors/traceConfigDetector.js.map +1 -0
  243. package/dist/agent/core/feedbackSynthesizer.d.ts +28 -0
  244. package/dist/agent/core/feedbackSynthesizer.d.ts.map +1 -0
  245. package/dist/agent/core/feedbackSynthesizer.js +841 -0
  246. package/dist/agent/core/feedbackSynthesizer.js.map +1 -0
  247. package/dist/agent/core/followUpHandler.d.ts +36 -0
  248. package/dist/agent/core/followUpHandler.d.ts.map +1 -0
  249. package/dist/agent/core/followUpHandler.js +413 -0
  250. package/dist/agent/core/followUpHandler.js.map +1 -0
  251. package/dist/agent/core/hypothesisGenerator.d.ts +45 -0
  252. package/dist/agent/core/hypothesisGenerator.d.ts.map +1 -0
  253. package/dist/agent/core/hypothesisGenerator.js +257 -0
  254. package/dist/agent/core/hypothesisGenerator.js.map +1 -0
  255. package/dist/agent/core/incrementalAnalyzer.d.ts +164 -0
  256. package/dist/agent/core/incrementalAnalyzer.d.ts.map +1 -0
  257. package/dist/agent/core/incrementalAnalyzer.js +382 -0
  258. package/dist/agent/core/incrementalAnalyzer.js.map +1 -0
  259. package/dist/agent/core/index.d.ts +25 -0
  260. package/dist/agent/core/index.d.ts.map +1 -0
  261. package/dist/agent/core/index.js +61 -0
  262. package/dist/agent/core/index.js.map +1 -0
  263. package/dist/agent/core/intentUnderstanding.d.ts +28 -0
  264. package/dist/agent/core/intentUnderstanding.d.ts.map +1 -0
  265. package/dist/agent/core/intentUnderstanding.js +451 -0
  266. package/dist/agent/core/intentUnderstanding.js.map +1 -0
  267. package/dist/agent/core/interventionController.d.ts +211 -0
  268. package/dist/agent/core/interventionController.d.ts.map +1 -0
  269. package/dist/agent/core/interventionController.js +477 -0
  270. package/dist/agent/core/interventionController.js.map +1 -0
  271. package/dist/agent/core/jankCauseSummarizer.d.ts +87 -0
  272. package/dist/agent/core/jankCauseSummarizer.d.ts.map +1 -0
  273. package/dist/agent/core/jankCauseSummarizer.js +432 -0
  274. package/dist/agent/core/jankCauseSummarizer.js.map +1 -0
  275. package/dist/agent/core/modelRouter.d.ts +164 -0
  276. package/dist/agent/core/modelRouter.d.ts.map +1 -0
  277. package/dist/agent/core/modelRouter.js +1169 -0
  278. package/dist/agent/core/modelRouter.js.map +1 -0
  279. package/dist/agent/core/modelRouterSingleton.d.ts +4 -0
  280. package/dist/agent/core/modelRouterSingleton.d.ts.map +1 -0
  281. package/dist/agent/core/modelRouterSingleton.js +20 -0
  282. package/dist/agent/core/modelRouterSingleton.js.map +1 -0
  283. package/dist/agent/core/orchestratorTypes.d.ts +506 -0
  284. package/dist/agent/core/orchestratorTypes.d.ts.map +1 -0
  285. package/dist/agent/core/orchestratorTypes.js +91 -0
  286. package/dist/agent/core/orchestratorTypes.js.map +1 -0
  287. package/dist/agent/core/pipelineExecutor.d.ts +154 -0
  288. package/dist/agent/core/pipelineExecutor.d.ts.map +1 -0
  289. package/dist/agent/core/pipelineExecutor.js +677 -0
  290. package/dist/agent/core/pipelineExecutor.js.map +1 -0
  291. package/dist/agent/core/scenePolicy.d.ts +3 -0
  292. package/dist/agent/core/scenePolicy.d.ts.map +1 -0
  293. package/dist/agent/core/scenePolicy.js +49 -0
  294. package/dist/agent/core/scenePolicy.js.map +1 -0
  295. package/dist/agent/core/sceneRouter.d.ts +8 -0
  296. package/dist/agent/core/sceneRouter.d.ts.map +1 -0
  297. package/dist/agent/core/sceneRouter.js +122 -0
  298. package/dist/agent/core/sceneRouter.js.map +1 -0
  299. package/dist/agent/core/sceneTaxonomy.d.ts +6 -0
  300. package/dist/agent/core/sceneTaxonomy.d.ts.map +1 -0
  301. package/dist/agent/core/sceneTaxonomy.js +83 -0
  302. package/dist/agent/core/sceneTaxonomy.js.map +1 -0
  303. package/dist/agent/core/sceneTemplateStore.d.ts +10 -0
  304. package/dist/agent/core/sceneTemplateStore.d.ts.map +1 -0
  305. package/dist/agent/core/sceneTemplateStore.js +244 -0
  306. package/dist/agent/core/sceneTemplateStore.js.map +1 -0
  307. package/dist/agent/core/sceneTemplateValidator.d.ts +22 -0
  308. package/dist/agent/core/sceneTemplateValidator.d.ts.map +1 -0
  309. package/dist/agent/core/sceneTemplateValidator.js +226 -0
  310. package/dist/agent/core/sceneTemplateValidator.js.map +1 -0
  311. package/dist/agent/core/sceneTypes.d.ts +53 -0
  312. package/dist/agent/core/sceneTypes.d.ts.map +1 -0
  313. package/dist/agent/core/sceneTypes.js +6 -0
  314. package/dist/agent/core/sceneTypes.js.map +1 -0
  315. package/dist/agent/core/stateMachine.d.ts +135 -0
  316. package/dist/agent/core/stateMachine.d.ts.map +1 -0
  317. package/dist/agent/core/stateMachine.js +516 -0
  318. package/dist/agent/core/stateMachine.js.map +1 -0
  319. package/dist/agent/core/strategySelector.d.ts +121 -0
  320. package/dist/agent/core/strategySelector.d.ts.map +1 -0
  321. package/dist/agent/core/strategySelector.js +344 -0
  322. package/dist/agent/core/strategySelector.js.map +1 -0
  323. package/dist/agent/core/taskGraphExecutor.d.ts +30 -0
  324. package/dist/agent/core/taskGraphExecutor.d.ts.map +1 -0
  325. package/dist/agent/core/taskGraphExecutor.js +142 -0
  326. package/dist/agent/core/taskGraphExecutor.js.map +1 -0
  327. package/dist/agent/core/taskGraphPlanner.d.ts +33 -0
  328. package/dist/agent/core/taskGraphPlanner.d.ts.map +1 -0
  329. package/dist/agent/core/taskGraphPlanner.js +312 -0
  330. package/dist/agent/core/taskGraphPlanner.js.map +1 -0
  331. package/dist/agent/decision/decisionTreeExecutor.d.ts +55 -0
  332. package/dist/agent/decision/decisionTreeExecutor.d.ts.map +1 -0
  333. package/dist/agent/decision/decisionTreeExecutor.js +250 -0
  334. package/dist/agent/decision/decisionTreeExecutor.js.map +1 -0
  335. package/dist/agent/decision/decisionTreeStageExecutor.d.ts +65 -0
  336. package/dist/agent/decision/decisionTreeStageExecutor.d.ts.map +1 -0
  337. package/dist/agent/decision/decisionTreeStageExecutor.js +286 -0
  338. package/dist/agent/decision/decisionTreeStageExecutor.js.map +1 -0
  339. package/dist/agent/decision/index.d.ts +27 -0
  340. package/dist/agent/decision/index.d.ts.map +1 -0
  341. package/dist/agent/decision/index.js +70 -0
  342. package/dist/agent/decision/index.js.map +1 -0
  343. package/dist/agent/decision/skillExecutorAdapter.d.ts +89 -0
  344. package/dist/agent/decision/skillExecutorAdapter.d.ts.map +1 -0
  345. package/dist/agent/decision/skillExecutorAdapter.js +447 -0
  346. package/dist/agent/decision/skillExecutorAdapter.js.map +1 -0
  347. package/dist/agent/decision/trees/index.d.ts +8 -0
  348. package/dist/agent/decision/trees/index.d.ts.map +1 -0
  349. package/dist/agent/decision/trees/index.js +16 -0
  350. package/dist/agent/decision/trees/index.js.map +1 -0
  351. package/dist/agent/decision/trees/launchDecisionTree.d.ts +7 -0
  352. package/dist/agent/decision/trees/launchDecisionTree.d.ts.map +1 -0
  353. package/dist/agent/decision/trees/launchDecisionTree.js +670 -0
  354. package/dist/agent/decision/trees/launchDecisionTree.js.map +1 -0
  355. package/dist/agent/decision/trees/scrollingDecisionTree.d.ts +7 -0
  356. package/dist/agent/decision/trees/scrollingDecisionTree.d.ts.map +1 -0
  357. package/dist/agent/decision/trees/scrollingDecisionTree.js +698 -0
  358. package/dist/agent/decision/trees/scrollingDecisionTree.js.map +1 -0
  359. package/dist/agent/decision/types.d.ts +191 -0
  360. package/dist/agent/decision/types.d.ts.map +1 -0
  361. package/dist/agent/decision/types.js +6 -0
  362. package/dist/agent/decision/types.js.map +1 -0
  363. package/dist/agent/detectors/architectureDetector.d.ts +31 -0
  364. package/dist/agent/detectors/architectureDetector.d.ts.map +1 -0
  365. package/dist/agent/detectors/architectureDetector.js +190 -0
  366. package/dist/agent/detectors/architectureDetector.js.map +1 -0
  367. package/dist/agent/detectors/index.d.ts +11 -0
  368. package/dist/agent/detectors/index.d.ts.map +1 -0
  369. package/dist/agent/detectors/index.js +36 -0
  370. package/dist/agent/detectors/index.js.map +1 -0
  371. package/dist/agent/detectors/types.d.ts +113 -0
  372. package/dist/agent/detectors/types.d.ts.map +1 -0
  373. package/dist/agent/detectors/types.js +6 -0
  374. package/dist/agent/detectors/types.js.map +1 -0
  375. package/dist/agent/evalSystem.d.ts +61 -0
  376. package/dist/agent/evalSystem.d.ts.map +1 -0
  377. package/dist/agent/evalSystem.js +210 -0
  378. package/dist/agent/evalSystem.js.map +1 -0
  379. package/dist/agent/experts/base/baseExpert.d.ts +108 -0
  380. package/dist/agent/experts/base/baseExpert.d.ts.map +1 -0
  381. package/dist/agent/experts/base/baseExpert.js +359 -0
  382. package/dist/agent/experts/base/baseExpert.js.map +1 -0
  383. package/dist/agent/experts/base/index.d.ts +9 -0
  384. package/dist/agent/experts/base/index.d.ts.map +1 -0
  385. package/dist/agent/experts/base/index.js +15 -0
  386. package/dist/agent/experts/base/index.js.map +1 -0
  387. package/dist/agent/experts/base/types.d.ts +202 -0
  388. package/dist/agent/experts/base/types.d.ts.map +1 -0
  389. package/dist/agent/experts/base/types.js +6 -0
  390. package/dist/agent/experts/base/types.js.map +1 -0
  391. package/dist/agent/experts/crossDomain/baseCrossDomainExpert.d.ts +113 -0
  392. package/dist/agent/experts/crossDomain/baseCrossDomainExpert.d.ts.map +1 -0
  393. package/dist/agent/experts/crossDomain/baseCrossDomainExpert.js +412 -0
  394. package/dist/agent/experts/crossDomain/baseCrossDomainExpert.js.map +1 -0
  395. package/dist/agent/experts/crossDomain/dialogueProtocol.d.ts +164 -0
  396. package/dist/agent/experts/crossDomain/dialogueProtocol.d.ts.map +1 -0
  397. package/dist/agent/experts/crossDomain/dialogueProtocol.js +390 -0
  398. package/dist/agent/experts/crossDomain/dialogueProtocol.js.map +1 -0
  399. package/dist/agent/experts/crossDomain/experts/performanceExpert.d.ts +119 -0
  400. package/dist/agent/experts/crossDomain/experts/performanceExpert.d.ts.map +1 -0
  401. package/dist/agent/experts/crossDomain/experts/performanceExpert.js +736 -0
  402. package/dist/agent/experts/crossDomain/experts/performanceExpert.js.map +1 -0
  403. package/dist/agent/experts/crossDomain/hypothesisManager.d.ts +105 -0
  404. package/dist/agent/experts/crossDomain/hypothesisManager.d.ts.map +1 -0
  405. package/dist/agent/experts/crossDomain/hypothesisManager.js +283 -0
  406. package/dist/agent/experts/crossDomain/hypothesisManager.js.map +1 -0
  407. package/dist/agent/experts/crossDomain/index.d.ts +18 -0
  408. package/dist/agent/experts/crossDomain/index.d.ts.map +1 -0
  409. package/dist/agent/experts/crossDomain/index.js +28 -0
  410. package/dist/agent/experts/crossDomain/index.js.map +1 -0
  411. package/dist/agent/experts/crossDomain/moduleCatalog.d.ts +97 -0
  412. package/dist/agent/experts/crossDomain/moduleCatalog.d.ts.map +1 -0
  413. package/dist/agent/experts/crossDomain/moduleCatalog.js +453 -0
  414. package/dist/agent/experts/crossDomain/moduleCatalog.js.map +1 -0
  415. package/dist/agent/experts/crossDomain/moduleExpertInvoker.d.ts +149 -0
  416. package/dist/agent/experts/crossDomain/moduleExpertInvoker.d.ts.map +1 -0
  417. package/dist/agent/experts/crossDomain/moduleExpertInvoker.js +582 -0
  418. package/dist/agent/experts/crossDomain/moduleExpertInvoker.js.map +1 -0
  419. package/dist/agent/experts/crossDomain/types.d.ts +369 -0
  420. package/dist/agent/experts/crossDomain/types.d.ts.map +1 -0
  421. package/dist/agent/experts/crossDomain/types.js +6 -0
  422. package/dist/agent/experts/crossDomain/types.js.map +1 -0
  423. package/dist/agent/experts/index.d.ts +81 -0
  424. package/dist/agent/experts/index.d.ts.map +1 -0
  425. package/dist/agent/experts/index.js +222 -0
  426. package/dist/agent/experts/index.js.map +1 -0
  427. package/dist/agent/experts/interactionExpert.d.ts +66 -0
  428. package/dist/agent/experts/interactionExpert.d.ts.map +1 -0
  429. package/dist/agent/experts/interactionExpert.js +280 -0
  430. package/dist/agent/experts/interactionExpert.js.map +1 -0
  431. package/dist/agent/experts/launchExpert.d.ts +73 -0
  432. package/dist/agent/experts/launchExpert.d.ts.map +1 -0
  433. package/dist/agent/experts/launchExpert.js +411 -0
  434. package/dist/agent/experts/launchExpert.js.map +1 -0
  435. package/dist/agent/experts/systemExpert.d.ts +81 -0
  436. package/dist/agent/experts/systemExpert.d.ts.map +1 -0
  437. package/dist/agent/experts/systemExpert.js +507 -0
  438. package/dist/agent/experts/systemExpert.js.map +1 -0
  439. package/dist/agent/fork/forkManager.d.ts +161 -0
  440. package/dist/agent/fork/forkManager.d.ts.map +1 -0
  441. package/dist/agent/fork/forkManager.js +721 -0
  442. package/dist/agent/fork/forkManager.js.map +1 -0
  443. package/dist/agent/fork/forkTypes.d.ts +274 -0
  444. package/dist/agent/fork/forkTypes.d.ts.map +1 -0
  445. package/dist/agent/fork/forkTypes.js +18 -0
  446. package/dist/agent/fork/forkTypes.js.map +1 -0
  447. package/dist/agent/fork/index.d.ts +10 -0
  448. package/dist/agent/fork/index.d.ts.map +1 -0
  449. package/dist/agent/fork/index.js +47 -0
  450. package/dist/agent/fork/index.js.map +1 -0
  451. package/dist/agent/fork/mergeStrategies.d.ts +115 -0
  452. package/dist/agent/fork/mergeStrategies.d.ts.map +1 -0
  453. package/dist/agent/fork/mergeStrategies.js +404 -0
  454. package/dist/agent/fork/mergeStrategies.js.map +1 -0
  455. package/dist/agent/fork/sessionTree.d.ts +141 -0
  456. package/dist/agent/fork/sessionTree.d.ts.map +1 -0
  457. package/dist/agent/fork/sessionTree.js +443 -0
  458. package/dist/agent/fork/sessionTree.js.map +1 -0
  459. package/dist/agent/hooks/hookContext.d.ts +19 -0
  460. package/dist/agent/hooks/hookContext.d.ts.map +1 -0
  461. package/dist/agent/hooks/hookContext.js +67 -0
  462. package/dist/agent/hooks/hookContext.js.map +1 -0
  463. package/dist/agent/hooks/hookRegistry.d.ts +73 -0
  464. package/dist/agent/hooks/hookRegistry.d.ts.map +1 -0
  465. package/dist/agent/hooks/hookRegistry.js +271 -0
  466. package/dist/agent/hooks/hookRegistry.js.map +1 -0
  467. package/dist/agent/hooks/hookTypes.d.ts +186 -0
  468. package/dist/agent/hooks/hookTypes.d.ts.map +1 -0
  469. package/dist/agent/hooks/hookTypes.js +24 -0
  470. package/dist/agent/hooks/hookTypes.js.map +1 -0
  471. package/dist/agent/hooks/index.d.ts +10 -0
  472. package/dist/agent/hooks/index.d.ts.map +1 -0
  473. package/dist/agent/hooks/index.js +41 -0
  474. package/dist/agent/hooks/index.js.map +1 -0
  475. package/dist/agent/hooks/middleware/index.d.ts +6 -0
  476. package/dist/agent/hooks/middleware/index.d.ts.map +1 -0
  477. package/dist/agent/hooks/middleware/index.js +17 -0
  478. package/dist/agent/hooks/middleware/index.js.map +1 -0
  479. package/dist/agent/hooks/middleware/loggingMiddleware.d.ts +27 -0
  480. package/dist/agent/hooks/middleware/loggingMiddleware.d.ts.map +1 -0
  481. package/dist/agent/hooks/middleware/loggingMiddleware.js +104 -0
  482. package/dist/agent/hooks/middleware/loggingMiddleware.js.map +1 -0
  483. package/dist/agent/hooks/middleware/timingMiddleware.d.ts +56 -0
  484. package/dist/agent/hooks/middleware/timingMiddleware.d.ts.map +1 -0
  485. package/dist/agent/hooks/middleware/timingMiddleware.js +171 -0
  486. package/dist/agent/hooks/middleware/timingMiddleware.js.map +1 -0
  487. package/dist/agent/index.d.ts +15 -0
  488. package/dist/agent/index.d.ts.map +1 -0
  489. package/dist/agent/index.js +88 -0
  490. package/dist/agent/index.js.map +1 -0
  491. package/dist/agent/llmAdapter.d.ts +33 -0
  492. package/dist/agent/llmAdapter.d.ts.map +1 -0
  493. package/dist/agent/llmAdapter.js +257 -0
  494. package/dist/agent/llmAdapter.js.map +1 -0
  495. package/dist/agent/scene/sceneAnalysisJobRunner.d.ts +106 -0
  496. package/dist/agent/scene/sceneAnalysisJobRunner.d.ts.map +1 -0
  497. package/dist/agent/scene/sceneAnalysisJobRunner.js +201 -0
  498. package/dist/agent/scene/sceneAnalysisJobRunner.js.map +1 -0
  499. package/dist/agent/scene/sceneCostEstimator.d.ts +33 -0
  500. package/dist/agent/scene/sceneCostEstimator.d.ts.map +1 -0
  501. package/dist/agent/scene/sceneCostEstimator.js +42 -0
  502. package/dist/agent/scene/sceneCostEstimator.js.map +1 -0
  503. package/dist/agent/scene/sceneIntervalBuilder.d.ts +37 -0
  504. package/dist/agent/scene/sceneIntervalBuilder.d.ts.map +1 -0
  505. package/dist/agent/scene/sceneIntervalBuilder.js +748 -0
  506. package/dist/agent/scene/sceneIntervalBuilder.js.map +1 -0
  507. package/dist/agent/scene/sceneStage1Runner.d.ts +47 -0
  508. package/dist/agent/scene/sceneStage1Runner.d.ts.map +1 -0
  509. package/dist/agent/scene/sceneStage1Runner.js +49 -0
  510. package/dist/agent/scene/sceneStage1Runner.js.map +1 -0
  511. package/dist/agent/scene/sceneStage3Summarizer.d.ts +11 -0
  512. package/dist/agent/scene/sceneStage3Summarizer.d.ts.map +1 -0
  513. package/dist/agent/scene/sceneStage3Summarizer.js +155 -0
  514. package/dist/agent/scene/sceneStage3Summarizer.js.map +1 -0
  515. package/dist/agent/scene/sceneStoryService.d.ts +168 -0
  516. package/dist/agent/scene/sceneStoryService.d.ts.map +1 -0
  517. package/dist/agent/scene/sceneStoryService.js +623 -0
  518. package/dist/agent/scene/sceneStoryService.js.map +1 -0
  519. package/dist/agent/scene/sceneTraceDurationProbe.d.ts +16 -0
  520. package/dist/agent/scene/sceneTraceDurationProbe.d.ts.map +1 -0
  521. package/dist/agent/scene/sceneTraceDurationProbe.js +22 -0
  522. package/dist/agent/scene/sceneTraceDurationProbe.js.map +1 -0
  523. package/dist/agent/scene/traceHash.d.ts +23 -0
  524. package/dist/agent/scene/traceHash.d.ts.map +1 -0
  525. package/dist/agent/scene/traceHash.js +65 -0
  526. package/dist/agent/scene/traceHash.js.map +1 -0
  527. package/dist/agent/scene/types.d.ts +199 -0
  528. package/dist/agent/scene/types.d.ts.map +1 -0
  529. package/dist/agent/scene/types.js +6 -0
  530. package/dist/agent/scene/types.js.map +1 -0
  531. package/dist/agent/state/checkpointManager.d.ts +85 -0
  532. package/dist/agent/state/checkpointManager.d.ts.map +1 -0
  533. package/dist/agent/state/checkpointManager.js +339 -0
  534. package/dist/agent/state/checkpointManager.js.map +1 -0
  535. package/dist/agent/state/index.d.ts +11 -0
  536. package/dist/agent/state/index.d.ts.map +1 -0
  537. package/dist/agent/state/index.js +21 -0
  538. package/dist/agent/state/index.js.map +1 -0
  539. package/dist/agent/state/sessionStore.d.ts +126 -0
  540. package/dist/agent/state/sessionStore.d.ts.map +1 -0
  541. package/dist/agent/state/sessionStore.js +440 -0
  542. package/dist/agent/state/sessionStore.js.map +1 -0
  543. package/dist/agent/state/traceAgentState.d.ts +125 -0
  544. package/dist/agent/state/traceAgentState.d.ts.map +1 -0
  545. package/dist/agent/state/traceAgentState.js +173 -0
  546. package/dist/agent/state/traceAgentState.js.map +1 -0
  547. package/dist/agent/strategies/helpers.d.ts +44 -0
  548. package/dist/agent/strategies/helpers.d.ts.map +1 -0
  549. package/dist/agent/strategies/helpers.js +138 -0
  550. package/dist/agent/strategies/helpers.js.map +1 -0
  551. package/dist/agent/strategies/index.d.ts +15 -0
  552. package/dist/agent/strategies/index.d.ts.map +1 -0
  553. package/dist/agent/strategies/index.js +23 -0
  554. package/dist/agent/strategies/index.js.map +1 -0
  555. package/dist/agent/strategies/interactionStrategy.d.ts +3 -0
  556. package/dist/agent/strategies/interactionStrategy.d.ts.map +1 -0
  557. package/dist/agent/strategies/interactionStrategy.js +242 -0
  558. package/dist/agent/strategies/interactionStrategy.js.map +1 -0
  559. package/dist/agent/strategies/registry.d.ts +110 -0
  560. package/dist/agent/strategies/registry.d.ts.map +1 -0
  561. package/dist/agent/strategies/registry.js +264 -0
  562. package/dist/agent/strategies/registry.js.map +1 -0
  563. package/dist/agent/strategies/sceneReconstructionStrategy.d.ts +4 -0
  564. package/dist/agent/strategies/sceneReconstructionStrategy.d.ts.map +1 -0
  565. package/dist/agent/strategies/sceneReconstructionStrategy.js +593 -0
  566. package/dist/agent/strategies/sceneReconstructionStrategy.js.map +1 -0
  567. package/dist/agent/strategies/scrollingStrategy.d.ts +3 -0
  568. package/dist/agent/strategies/scrollingStrategy.d.ts.map +1 -0
  569. package/dist/agent/strategies/scrollingStrategy.js +414 -0
  570. package/dist/agent/strategies/scrollingStrategy.js.map +1 -0
  571. package/dist/agent/strategies/startupStrategy.d.ts +3 -0
  572. package/dist/agent/strategies/startupStrategy.d.ts.map +1 -0
  573. package/dist/agent/strategies/startupStrategy.js +495 -0
  574. package/dist/agent/strategies/startupStrategy.js.map +1 -0
  575. package/dist/agent/strategies/types.d.ts +156 -0
  576. package/dist/agent/strategies/types.d.ts.map +1 -0
  577. package/dist/agent/strategies/types.js +6 -0
  578. package/dist/agent/strategies/types.js.map +1 -0
  579. package/dist/agent/toolRegistry.d.ts +4 -0
  580. package/dist/agent/toolRegistry.d.ts.map +1 -0
  581. package/dist/agent/toolRegistry.js +45 -0
  582. package/dist/agent/toolRegistry.js.map +1 -0
  583. package/dist/agent/tools/dataStats.d.ts +23 -0
  584. package/dist/agent/tools/dataStats.d.ts.map +1 -0
  585. package/dist/agent/tools/dataStats.js +123 -0
  586. package/dist/agent/tools/dataStats.js.map +1 -0
  587. package/dist/agent/tools/frameAnalyzer.d.ts +45 -0
  588. package/dist/agent/tools/frameAnalyzer.d.ts.map +1 -0
  589. package/dist/agent/tools/frameAnalyzer.js +338 -0
  590. package/dist/agent/tools/frameAnalyzer.js.map +1 -0
  591. package/dist/agent/tools/index.d.ts +6 -0
  592. package/dist/agent/tools/index.d.ts.map +1 -0
  593. package/dist/agent/tools/index.js +31 -0
  594. package/dist/agent/tools/index.js.map +1 -0
  595. package/dist/agent/tools/skillInvoker.d.ts +50 -0
  596. package/dist/agent/tools/skillInvoker.d.ts.map +1 -0
  597. package/dist/agent/tools/skillInvoker.js +279 -0
  598. package/dist/agent/tools/skillInvoker.js.map +1 -0
  599. package/dist/agent/tools/sqlExecutor.d.ts +12 -0
  600. package/dist/agent/tools/sqlExecutor.d.ts.map +1 -0
  601. package/dist/agent/tools/sqlExecutor.js +193 -0
  602. package/dist/agent/tools/sqlExecutor.js.map +1 -0
  603. package/dist/agent/tools/sqlGenerator.d.ts +154 -0
  604. package/dist/agent/tools/sqlGenerator.d.ts.map +1 -0
  605. package/dist/agent/tools/sqlGenerator.js +449 -0
  606. package/dist/agent/tools/sqlGenerator.js.map +1 -0
  607. package/dist/agent/tools/sqlValidator.d.ts +149 -0
  608. package/dist/agent/tools/sqlValidator.d.ts.map +1 -0
  609. package/dist/agent/tools/sqlValidator.js +376 -0
  610. package/dist/agent/tools/sqlValidator.js.map +1 -0
  611. package/dist/agent/traceRecorder.d.ts +42 -0
  612. package/dist/agent/traceRecorder.d.ts.map +1 -0
  613. package/dist/agent/traceRecorder.js +122 -0
  614. package/dist/agent/traceRecorder.js.map +1 -0
  615. package/dist/agent/types/agentProtocol.d.ts +377 -0
  616. package/dist/agent/types/agentProtocol.d.ts.map +1 -0
  617. package/dist/agent/types/agentProtocol.js +102 -0
  618. package/dist/agent/types/agentProtocol.js.map +1 -0
  619. package/dist/agent/types/jankCause.d.ts +47 -0
  620. package/dist/agent/types/jankCause.d.ts.map +1 -0
  621. package/dist/agent/types/jankCause.js +6 -0
  622. package/dist/agent/types/jankCause.js.map +1 -0
  623. package/dist/agent/types.d.ts +725 -0
  624. package/dist/agent/types.d.ts.map +1 -0
  625. package/dist/agent/types.js +63 -0
  626. package/dist/agent/types.js.map +1 -0
  627. package/dist/agentOpenAI/index.d.ts +4 -0
  628. package/dist/agentOpenAI/index.d.ts.map +1 -0
  629. package/dist/agentOpenAI/index.js +17 -0
  630. package/dist/agentOpenAI/index.js.map +1 -0
  631. package/dist/agentOpenAI/mimoReasoningCompat.d.ts +9 -0
  632. package/dist/agentOpenAI/mimoReasoningCompat.d.ts.map +1 -0
  633. package/dist/agentOpenAI/mimoReasoningCompat.js +367 -0
  634. package/dist/agentOpenAI/mimoReasoningCompat.js.map +1 -0
  635. package/dist/agentOpenAI/openAiComplexityClassifier.d.ts +18 -0
  636. package/dist/agentOpenAI/openAiComplexityClassifier.d.ts.map +1 -0
  637. package/dist/agentOpenAI/openAiComplexityClassifier.js +102 -0
  638. package/dist/agentOpenAI/openAiComplexityClassifier.js.map +1 -0
  639. package/dist/agentOpenAI/openAiConfig.d.ts +38 -0
  640. package/dist/agentOpenAI/openAiConfig.d.ts.map +1 -0
  641. package/dist/agentOpenAI/openAiConfig.js +104 -0
  642. package/dist/agentOpenAI/openAiConfig.js.map +1 -0
  643. package/dist/agentOpenAI/openAiRuntime.d.ts +99 -0
  644. package/dist/agentOpenAI/openAiRuntime.d.ts.map +1 -0
  645. package/dist/agentOpenAI/openAiRuntime.js +1440 -0
  646. package/dist/agentOpenAI/openAiRuntime.js.map +1 -0
  647. package/dist/agentOpenAI/openAiToolAdapter.d.ts +9 -0
  648. package/dist/agentOpenAI/openAiToolAdapter.d.ts.map +1 -0
  649. package/dist/agentOpenAI/openAiToolAdapter.js +111 -0
  650. package/dist/agentOpenAI/openAiToolAdapter.js.map +1 -0
  651. package/dist/agentRuntime/envCredentialSources.d.ts +6 -0
  652. package/dist/agentRuntime/envCredentialSources.d.ts.map +1 -0
  653. package/dist/agentRuntime/envCredentialSources.js +104 -0
  654. package/dist/agentRuntime/envCredentialSources.js.map +1 -0
  655. package/dist/agentRuntime/index.d.ts +2 -0
  656. package/dist/agentRuntime/index.d.ts.map +1 -0
  657. package/dist/agentRuntime/index.js +10 -0
  658. package/dist/agentRuntime/index.js.map +1 -0
  659. package/dist/agentRuntime/runtimeHealth.d.ts +65 -0
  660. package/dist/agentRuntime/runtimeHealth.d.ts.map +1 -0
  661. package/dist/agentRuntime/runtimeHealth.js +58 -0
  662. package/dist/agentRuntime/runtimeHealth.js.map +1 -0
  663. package/dist/agentRuntime/runtimeSelection.d.ts +25 -0
  664. package/dist/agentRuntime/runtimeSelection.d.ts.map +1 -0
  665. package/dist/agentRuntime/runtimeSelection.js +66 -0
  666. package/dist/agentRuntime/runtimeSelection.js.map +1 -0
  667. package/dist/agentv3/__mocks__/claude-agent-sdk.d.ts +25 -0
  668. package/dist/agentv3/__mocks__/claude-agent-sdk.d.ts.map +1 -0
  669. package/dist/agentv3/__mocks__/claude-agent-sdk.js +48 -0
  670. package/dist/agentv3/__mocks__/claude-agent-sdk.js.map +1 -0
  671. package/dist/agentv3/activePhaseReminder.d.ts +12 -0
  672. package/dist/agentv3/activePhaseReminder.d.ts.map +1 -0
  673. package/dist/agentv3/activePhaseReminder.js +73 -0
  674. package/dist/agentv3/activePhaseReminder.js.map +1 -0
  675. package/dist/agentv3/agentMetrics.d.ts +114 -0
  676. package/dist/agentv3/agentMetrics.d.ts.map +1 -0
  677. package/dist/agentv3/agentMetrics.js +262 -0
  678. package/dist/agentv3/agentMetrics.js.map +1 -0
  679. package/dist/agentv3/analysisPatternMemory.d.ts +146 -0
  680. package/dist/agentv3/analysisPatternMemory.d.ts.map +1 -0
  681. package/dist/agentv3/analysisPatternMemory.js +860 -0
  682. package/dist/agentv3/analysisPatternMemory.js.map +1 -0
  683. package/dist/agentv3/analysisTermination.d.ts +21 -0
  684. package/dist/agentv3/analysisTermination.d.ts.map +1 -0
  685. package/dist/agentv3/analysisTermination.js +97 -0
  686. package/dist/agentv3/analysisTermination.js.map +1 -0
  687. package/dist/agentv3/artifactStore.d.ts +131 -0
  688. package/dist/agentv3/artifactStore.d.ts.map +1 -0
  689. package/dist/agentv3/artifactStore.js +208 -0
  690. package/dist/agentv3/artifactStore.js.map +1 -0
  691. package/dist/agentv3/claudeAgentDefinitions.d.ts +44 -0
  692. package/dist/agentv3/claudeAgentDefinitions.d.ts.map +1 -0
  693. package/dist/agentv3/claudeAgentDefinitions.js +209 -0
  694. package/dist/agentv3/claudeAgentDefinitions.js.map +1 -0
  695. package/dist/agentv3/claudeConfig.d.ts +156 -0
  696. package/dist/agentv3/claudeConfig.d.ts.map +1 -0
  697. package/dist/agentv3/claudeConfig.js +553 -0
  698. package/dist/agentv3/claudeConfig.js.map +1 -0
  699. package/dist/agentv3/claudeFindingExtractor.d.ts +15 -0
  700. package/dist/agentv3/claudeFindingExtractor.d.ts.map +1 -0
  701. package/dist/agentv3/claudeFindingExtractor.js +150 -0
  702. package/dist/agentv3/claudeFindingExtractor.js.map +1 -0
  703. package/dist/agentv3/claudeMcpServer.d.ts +89 -0
  704. package/dist/agentv3/claudeMcpServer.d.ts.map +1 -0
  705. package/dist/agentv3/claudeMcpServer.js +3785 -0
  706. package/dist/agentv3/claudeMcpServer.js.map +1 -0
  707. package/dist/agentv3/claudeRuntime.d.ts +137 -0
  708. package/dist/agentv3/claudeRuntime.d.ts.map +1 -0
  709. package/dist/agentv3/claudeRuntime.js +2541 -0
  710. package/dist/agentv3/claudeRuntime.js.map +1 -0
  711. package/dist/agentv3/claudeSseBridge.d.ts +23 -0
  712. package/dist/agentv3/claudeSseBridge.d.ts.map +1 -0
  713. package/dist/agentv3/claudeSseBridge.js +385 -0
  714. package/dist/agentv3/claudeSseBridge.js.map +1 -0
  715. package/dist/agentv3/claudeSystemPrompt.d.ts +65 -0
  716. package/dist/agentv3/claudeSystemPrompt.d.ts.map +1 -0
  717. package/dist/agentv3/claudeSystemPrompt.js +486 -0
  718. package/dist/agentv3/claudeSystemPrompt.js.map +1 -0
  719. package/dist/agentv3/claudeVerifier.d.ts +82 -0
  720. package/dist/agentv3/claudeVerifier.d.ts.map +1 -0
  721. package/dist/agentv3/claudeVerifier.js +1047 -0
  722. package/dist/agentv3/claudeVerifier.js.map +1 -0
  723. package/dist/agentv3/contextTokenMeter.d.ts +78 -0
  724. package/dist/agentv3/contextTokenMeter.d.ts.map +1 -0
  725. package/dist/agentv3/contextTokenMeter.js +88 -0
  726. package/dist/agentv3/contextTokenMeter.js.map +1 -0
  727. package/dist/agentv3/focusAppDetector.d.ts +22 -0
  728. package/dist/agentv3/focusAppDetector.d.ts.map +1 -0
  729. package/dist/agentv3/focusAppDetector.js +208 -0
  730. package/dist/agentv3/focusAppDetector.js.map +1 -0
  731. package/dist/agentv3/index.d.ts +6 -0
  732. package/dist/agentv3/index.d.ts.map +1 -0
  733. package/dist/agentv3/index.js +16 -0
  734. package/dist/agentv3/index.js.map +1 -0
  735. package/dist/agentv3/mcpToolRegistry.d.ts +90 -0
  736. package/dist/agentv3/mcpToolRegistry.d.ts.map +1 -0
  737. package/dist/agentv3/mcpToolRegistry.js +152 -0
  738. package/dist/agentv3/mcpToolRegistry.js.map +1 -0
  739. package/dist/agentv3/outputLanguage.d.ts +6 -0
  740. package/dist/agentv3/outputLanguage.d.ts.map +1 -0
  741. package/dist/agentv3/outputLanguage.js +37 -0
  742. package/dist/agentv3/outputLanguage.js.map +1 -0
  743. package/dist/agentv3/phaseHintMatcher.d.ts +36 -0
  744. package/dist/agentv3/phaseHintMatcher.d.ts.map +1 -0
  745. package/dist/agentv3/phaseHintMatcher.js +48 -0
  746. package/dist/agentv3/phaseHintMatcher.js.map +1 -0
  747. package/dist/agentv3/projectMemory.d.ts +80 -0
  748. package/dist/agentv3/projectMemory.d.ts.map +1 -0
  749. package/dist/agentv3/projectMemory.js +334 -0
  750. package/dist/agentv3/projectMemory.js.map +1 -0
  751. package/dist/agentv3/queryComplexityClassifier.d.ts +21 -0
  752. package/dist/agentv3/queryComplexityClassifier.d.ts.map +1 -0
  753. package/dist/agentv3/queryComplexityClassifier.js +196 -0
  754. package/dist/agentv3/queryComplexityClassifier.js.map +1 -0
  755. package/dist/agentv3/rawSqlNormalizer.d.ts +11 -0
  756. package/dist/agentv3/rawSqlNormalizer.d.ts.map +1 -0
  757. package/dist/agentv3/rawSqlNormalizer.js +649 -0
  758. package/dist/agentv3/rawSqlNormalizer.js.map +1 -0
  759. package/dist/agentv3/recoveryNoteBuilder.d.ts +51 -0
  760. package/dist/agentv3/recoveryNoteBuilder.d.ts.map +1 -0
  761. package/dist/agentv3/recoveryNoteBuilder.js +84 -0
  762. package/dist/agentv3/recoveryNoteBuilder.js.map +1 -0
  763. package/dist/agentv3/sceneClassifier.d.ts +11 -0
  764. package/dist/agentv3/sceneClassifier.d.ts.map +1 -0
  765. package/dist/agentv3/sceneClassifier.js +46 -0
  766. package/dist/agentv3/sceneClassifier.js.map +1 -0
  767. package/dist/agentv3/scenePlanTemplates.d.ts +80 -0
  768. package/dist/agentv3/scenePlanTemplates.d.ts.map +1 -0
  769. package/dist/agentv3/scenePlanTemplates.js +164 -0
  770. package/dist/agentv3/scenePlanTemplates.js.map +1 -0
  771. package/dist/agentv3/selfImprove/contentScanner.d.ts +44 -0
  772. package/dist/agentv3/selfImprove/contentScanner.d.ts.map +1 -0
  773. package/dist/agentv3/selfImprove/contentScanner.js +112 -0
  774. package/dist/agentv3/selfImprove/contentScanner.js.map +1 -0
  775. package/dist/agentv3/selfImprove/failureTaxonomy.d.ts +38 -0
  776. package/dist/agentv3/selfImprove/failureTaxonomy.d.ts.map +1 -0
  777. package/dist/agentv3/selfImprove/failureTaxonomy.js +102 -0
  778. package/dist/agentv3/selfImprove/failureTaxonomy.js.map +1 -0
  779. package/dist/agentv3/selfImprove/feedbackEnricher.d.ts +69 -0
  780. package/dist/agentv3/selfImprove/feedbackEnricher.d.ts.map +1 -0
  781. package/dist/agentv3/selfImprove/feedbackEnricher.js +135 -0
  782. package/dist/agentv3/selfImprove/feedbackEnricher.js.map +1 -0
  783. package/dist/agentv3/selfImprove/feedbackPipeline.d.ts +63 -0
  784. package/dist/agentv3/selfImprove/feedbackPipeline.d.ts.map +1 -0
  785. package/dist/agentv3/selfImprove/feedbackPipeline.js +239 -0
  786. package/dist/agentv3/selfImprove/feedbackPipeline.js.map +1 -0
  787. package/dist/agentv3/selfImprove/hintFingerprint.d.ts +14 -0
  788. package/dist/agentv3/selfImprove/hintFingerprint.d.ts.map +1 -0
  789. package/dist/agentv3/selfImprove/hintFingerprint.js +47 -0
  790. package/dist/agentv3/selfImprove/hintFingerprint.js.map +1 -0
  791. package/dist/agentv3/selfImprove/metricsAggregator.d.ts +46 -0
  792. package/dist/agentv3/selfImprove/metricsAggregator.d.ts.map +1 -0
  793. package/dist/agentv3/selfImprove/metricsAggregator.js +195 -0
  794. package/dist/agentv3/selfImprove/metricsAggregator.js.map +1 -0
  795. package/dist/agentv3/selfImprove/migrateFailureModeHash.d.ts +31 -0
  796. package/dist/agentv3/selfImprove/migrateFailureModeHash.d.ts.map +1 -0
  797. package/dist/agentv3/selfImprove/migrateFailureModeHash.js +220 -0
  798. package/dist/agentv3/selfImprove/migrateFailureModeHash.js.map +1 -0
  799. package/dist/agentv3/selfImprove/phaseHintsRenderer.d.ts +56 -0
  800. package/dist/agentv3/selfImprove/phaseHintsRenderer.d.ts.map +1 -0
  801. package/dist/agentv3/selfImprove/phaseHintsRenderer.js +202 -0
  802. package/dist/agentv3/selfImprove/phaseHintsRenderer.js.map +1 -0
  803. package/dist/agentv3/selfImprove/promoteSkillNote.d.ts +17 -0
  804. package/dist/agentv3/selfImprove/promoteSkillNote.d.ts.map +1 -0
  805. package/dist/agentv3/selfImprove/promoteSkillNote.js +146 -0
  806. package/dist/agentv3/selfImprove/promoteSkillNote.js.map +1 -0
  807. package/dist/agentv3/selfImprove/proposeStrategyPatch.d.ts +40 -0
  808. package/dist/agentv3/selfImprove/proposeStrategyPatch.d.ts.map +1 -0
  809. package/dist/agentv3/selfImprove/proposeStrategyPatch.js +115 -0
  810. package/dist/agentv3/selfImprove/proposeStrategyPatch.js.map +1 -0
  811. package/dist/agentv3/selfImprove/reviewAgentSdk.d.ts +32 -0
  812. package/dist/agentv3/selfImprove/reviewAgentSdk.d.ts.map +1 -0
  813. package/dist/agentv3/selfImprove/reviewAgentSdk.js +173 -0
  814. package/dist/agentv3/selfImprove/reviewAgentSdk.js.map +1 -0
  815. package/dist/agentv3/selfImprove/reviewOutbox.d.ts +128 -0
  816. package/dist/agentv3/selfImprove/reviewOutbox.d.ts.map +1 -0
  817. package/dist/agentv3/selfImprove/reviewOutbox.js +313 -0
  818. package/dist/agentv3/selfImprove/reviewOutbox.js.map +1 -0
  819. package/dist/agentv3/selfImprove/reviewWorker.d.ts +95 -0
  820. package/dist/agentv3/selfImprove/reviewWorker.d.ts.map +1 -0
  821. package/dist/agentv3/selfImprove/reviewWorker.js +172 -0
  822. package/dist/agentv3/selfImprove/reviewWorker.js.map +1 -0
  823. package/dist/agentv3/selfImprove/skillNotesInjector.d.ts +71 -0
  824. package/dist/agentv3/selfImprove/skillNotesInjector.d.ts.map +1 -0
  825. package/dist/agentv3/selfImprove/skillNotesInjector.js +214 -0
  826. package/dist/agentv3/selfImprove/skillNotesInjector.js.map +1 -0
  827. package/dist/agentv3/selfImprove/skillNotesWriter.d.ts +89 -0
  828. package/dist/agentv3/selfImprove/skillNotesWriter.d.ts.map +1 -0
  829. package/dist/agentv3/selfImprove/skillNotesWriter.js +274 -0
  830. package/dist/agentv3/selfImprove/skillNotesWriter.js.map +1 -0
  831. package/dist/agentv3/selfImprove/strategyFingerprint.d.ts +85 -0
  832. package/dist/agentv3/selfImprove/strategyFingerprint.d.ts.map +1 -0
  833. package/dist/agentv3/selfImprove/strategyFingerprint.js +189 -0
  834. package/dist/agentv3/selfImprove/strategyFingerprint.js.map +1 -0
  835. package/dist/agentv3/selfImprove/strategyPatchApplier.d.ts +15 -0
  836. package/dist/agentv3/selfImprove/strategyPatchApplier.d.ts.map +1 -0
  837. package/dist/agentv3/selfImprove/strategyPatchApplier.js +138 -0
  838. package/dist/agentv3/selfImprove/strategyPatchApplier.js.map +1 -0
  839. package/dist/agentv3/selfImprove/supersedeStore.d.ts +136 -0
  840. package/dist/agentv3/selfImprove/supersedeStore.d.ts.map +1 -0
  841. package/dist/agentv3/selfImprove/supersedeStore.js +386 -0
  842. package/dist/agentv3/selfImprove/supersedeStore.js.map +1 -0
  843. package/dist/agentv3/selfImprove/worktreeRunner.d.ts +49 -0
  844. package/dist/agentv3/selfImprove/worktreeRunner.d.ts.map +1 -0
  845. package/dist/agentv3/selfImprove/worktreeRunner.js +153 -0
  846. package/dist/agentv3/selfImprove/worktreeRunner.js.map +1 -0
  847. package/dist/agentv3/sessionStateSnapshot.d.ts +166 -0
  848. package/dist/agentv3/sessionStateSnapshot.d.ts.map +1 -0
  849. package/dist/agentv3/sessionStateSnapshot.js +6 -0
  850. package/dist/agentv3/sessionStateSnapshot.js.map +1 -0
  851. package/dist/agentv3/sqlIncludeInjector.d.ts +24 -0
  852. package/dist/agentv3/sqlIncludeInjector.d.ts.map +1 -0
  853. package/dist/agentv3/sqlIncludeInjector.js +78 -0
  854. package/dist/agentv3/sqlIncludeInjector.js.map +1 -0
  855. package/dist/agentv3/sqlSummarizer.d.ts +38 -0
  856. package/dist/agentv3/sqlSummarizer.d.ts.map +1 -0
  857. package/dist/agentv3/sqlSummarizer.js +101 -0
  858. package/dist/agentv3/sqlSummarizer.js.map +1 -0
  859. package/dist/agentv3/standaloneMcpServer.d.ts +96 -0
  860. package/dist/agentv3/standaloneMcpServer.d.ts.map +1 -0
  861. package/dist/agentv3/standaloneMcpServer.js +244 -0
  862. package/dist/agentv3/standaloneMcpServer.js.map +1 -0
  863. package/dist/agentv3/strategyLoader.d.ts +96 -0
  864. package/dist/agentv3/strategyLoader.d.ts.map +1 -0
  865. package/dist/agentv3/strategyLoader.js +204 -0
  866. package/dist/agentv3/strategyLoader.js.map +1 -0
  867. package/dist/agentv3/toolCallSummary.d.ts +15 -0
  868. package/dist/agentv3/toolCallSummary.d.ts.map +1 -0
  869. package/dist/agentv3/toolCallSummary.js +66 -0
  870. package/dist/agentv3/toolCallSummary.js.map +1 -0
  871. package/dist/agentv3/toolNarration.d.ts +4 -0
  872. package/dist/agentv3/toolNarration.d.ts.map +1 -0
  873. package/dist/agentv3/toolNarration.js +371 -0
  874. package/dist/agentv3/toolNarration.js.map +1 -0
  875. package/dist/agentv3/traceCompletenessProber.d.ts +56 -0
  876. package/dist/agentv3/traceCompletenessProber.d.ts.map +1 -0
  877. package/dist/agentv3/traceCompletenessProber.js +337 -0
  878. package/dist/agentv3/traceCompletenessProber.js.map +1 -0
  879. package/dist/agentv3/types.d.ts +443 -0
  880. package/dist/agentv3/types.d.ts.map +1 -0
  881. package/dist/agentv3/types.js +37 -0
  882. package/dist/agentv3/types.js.map +1 -0
  883. package/dist/assistant/application/agentAnalyzeSessionService.d.ts +130 -0
  884. package/dist/assistant/application/agentAnalyzeSessionService.d.ts.map +1 -0
  885. package/dist/assistant/application/agentAnalyzeSessionService.js +433 -0
  886. package/dist/assistant/application/agentAnalyzeSessionService.js.map +1 -0
  887. package/dist/assistant/application/assistantApplicationService.d.ts +39 -0
  888. package/dist/assistant/application/assistantApplicationService.d.ts.map +1 -0
  889. package/dist/assistant/application/assistantApplicationService.js +88 -0
  890. package/dist/assistant/application/assistantApplicationService.js.map +1 -0
  891. package/dist/assistant/contracts/assistantResultContract.d.ts +41 -0
  892. package/dist/assistant/contracts/assistantResultContract.d.ts.map +1 -0
  893. package/dist/assistant/contracts/assistantResultContract.js +145 -0
  894. package/dist/assistant/contracts/assistantResultContract.js.map +1 -0
  895. package/dist/assistant/stream/sessionSseReplay.d.ts +10 -0
  896. package/dist/assistant/stream/sessionSseReplay.d.ts.map +1 -0
  897. package/dist/assistant/stream/sessionSseReplay.js +42 -0
  898. package/dist/assistant/stream/sessionSseReplay.js.map +1 -0
  899. package/dist/assistant/stream/streamProjector.d.ts +53 -0
  900. package/dist/assistant/stream/streamProjector.d.ts.map +1 -0
  901. package/dist/assistant/stream/streamProjector.js +150 -0
  902. package/dist/assistant/stream/streamProjector.js.map +1 -0
  903. package/dist/cli/commands/coverage.d.ts +12 -0
  904. package/dist/cli/commands/coverage.d.ts.map +1 -0
  905. package/dist/cli/commands/coverage.js +106 -0
  906. package/dist/cli/commands/coverage.js.map +1 -0
  907. package/dist/cli/commands/list.d.ts +11 -0
  908. package/dist/cli/commands/list.d.ts.map +1 -0
  909. package/dist/cli/commands/list.js +169 -0
  910. package/dist/cli/commands/list.js.map +1 -0
  911. package/dist/cli/commands/smoke.d.ts +11 -0
  912. package/dist/cli/commands/smoke.d.ts.map +1 -0
  913. package/dist/cli/commands/smoke.js +215 -0
  914. package/dist/cli/commands/smoke.js.map +1 -0
  915. package/dist/cli/commands/test.d.ts +11 -0
  916. package/dist/cli/commands/test.d.ts.map +1 -0
  917. package/dist/cli/commands/test.js +183 -0
  918. package/dist/cli/commands/test.js.map +1 -0
  919. package/dist/cli/commands/validate.d.ts +26 -0
  920. package/dist/cli/commands/validate.d.ts.map +1 -0
  921. package/dist/cli/commands/validate.js +918 -0
  922. package/dist/cli/commands/validate.js.map +1 -0
  923. package/dist/cli/index.d.ts +3 -0
  924. package/dist/cli/index.d.ts.map +1 -0
  925. package/dist/cli/index.js +29 -0
  926. package/dist/cli/index.js.map +1 -0
  927. package/dist/cli-user/bin.d.ts +3 -0
  928. package/dist/cli-user/bin.d.ts.map +1 -0
  929. package/dist/cli-user/bin.js +490 -0
  930. package/dist/cli-user/bin.js.map +1 -0
  931. package/dist/cli-user/bootstrap.d.ts +12 -0
  932. package/dist/cli-user/bootstrap.d.ts.map +1 -0
  933. package/dist/cli-user/bootstrap.js +165 -0
  934. package/dist/cli-user/bootstrap.js.map +1 -0
  935. package/dist/cli-user/commands/analyze.d.ts +12 -0
  936. package/dist/cli-user/commands/analyze.d.ts.map +1 -0
  937. package/dist/cli-user/commands/analyze.js +83 -0
  938. package/dist/cli-user/commands/analyze.js.map +1 -0
  939. package/dist/cli-user/commands/capture.d.ts +12 -0
  940. package/dist/cli-user/commands/capture.d.ts.map +1 -0
  941. package/dist/cli-user/commands/capture.js +155 -0
  942. package/dist/cli-user/commands/capture.js.map +1 -0
  943. package/dist/cli-user/commands/compare.d.ts +13 -0
  944. package/dist/cli-user/commands/compare.d.ts.map +1 -0
  945. package/dist/cli-user/commands/compare.js +74 -0
  946. package/dist/cli-user/commands/compare.js.map +1 -0
  947. package/dist/cli-user/commands/config.d.ts +9 -0
  948. package/dist/cli-user/commands/config.d.ts.map +1 -0
  949. package/dist/cli-user/commands/config.js +109 -0
  950. package/dist/cli-user/commands/config.js.map +1 -0
  951. package/dist/cli-user/commands/doctor.d.ts +8 -0
  952. package/dist/cli-user/commands/doctor.d.ts.map +1 -0
  953. package/dist/cli-user/commands/doctor.js +37 -0
  954. package/dist/cli-user/commands/doctor.js.map +1 -0
  955. package/dist/cli-user/commands/list.d.ts +10 -0
  956. package/dist/cli-user/commands/list.d.ts.map +1 -0
  957. package/dist/cli-user/commands/list.js +79 -0
  958. package/dist/cli-user/commands/list.js.map +1 -0
  959. package/dist/cli-user/commands/provider.d.ts +12 -0
  960. package/dist/cli-user/commands/provider.d.ts.map +1 -0
  961. package/dist/cli-user/commands/provider.js +121 -0
  962. package/dist/cli-user/commands/provider.js.map +1 -0
  963. package/dist/cli-user/commands/query.d.ts +10 -0
  964. package/dist/cli-user/commands/query.d.ts.map +1 -0
  965. package/dist/cli-user/commands/query.js +128 -0
  966. package/dist/cli-user/commands/query.js.map +1 -0
  967. package/dist/cli-user/commands/report.d.ts +18 -0
  968. package/dist/cli-user/commands/report.d.ts.map +1 -0
  969. package/dist/cli-user/commands/report.js +225 -0
  970. package/dist/cli-user/commands/report.js.map +1 -0
  971. package/dist/cli-user/commands/resume.d.ts +12 -0
  972. package/dist/cli-user/commands/resume.d.ts.map +1 -0
  973. package/dist/cli-user/commands/resume.js +48 -0
  974. package/dist/cli-user/commands/resume.js.map +1 -0
  975. package/dist/cli-user/commands/rm.d.ts +8 -0
  976. package/dist/cli-user/commands/rm.d.ts.map +1 -0
  977. package/dist/cli-user/commands/rm.js +91 -0
  978. package/dist/cli-user/commands/rm.js.map +1 -0
  979. package/dist/cli-user/commands/show.d.ts +8 -0
  980. package/dist/cli-user/commands/show.d.ts.map +1 -0
  981. package/dist/cli-user/commands/show.js +84 -0
  982. package/dist/cli-user/commands/show.js.map +1 -0
  983. package/dist/cli-user/commands/skill.d.ts +11 -0
  984. package/dist/cli-user/commands/skill.d.ts.map +1 -0
  985. package/dist/cli-user/commands/skill.js +118 -0
  986. package/dist/cli-user/commands/skill.js.map +1 -0
  987. package/dist/cli-user/constants.d.ts +10 -0
  988. package/dist/cli-user/constants.d.ts.map +1 -0
  989. package/dist/cli-user/constants.js +16 -0
  990. package/dist/cli-user/constants.js.map +1 -0
  991. package/dist/cli-user/io/indexJson.d.ts +11 -0
  992. package/dist/cli-user/io/indexJson.d.ts.map +1 -0
  993. package/dist/cli-user/io/indexJson.js +79 -0
  994. package/dist/cli-user/io/indexJson.js.map +1 -0
  995. package/dist/cli-user/io/openFile.d.ts +8 -0
  996. package/dist/cli-user/io/openFile.d.ts.map +1 -0
  997. package/dist/cli-user/io/openFile.js +34 -0
  998. package/dist/cli-user/io/openFile.js.map +1 -0
  999. package/dist/cli-user/io/paths.d.ts +33 -0
  1000. package/dist/cli-user/io/paths.d.ts.map +1 -0
  1001. package/dist/cli-user/io/paths.js +149 -0
  1002. package/dist/cli-user/io/paths.js.map +1 -0
  1003. package/dist/cli-user/io/sessionStore.d.ts +17 -0
  1004. package/dist/cli-user/io/sessionStore.d.ts.map +1 -0
  1005. package/dist/cli-user/io/sessionStore.js +101 -0
  1006. package/dist/cli-user/io/sessionStore.js.map +1 -0
  1007. package/dist/cli-user/io/stdio.d.ts +8 -0
  1008. package/dist/cli-user/io/stdio.d.ts.map +1 -0
  1009. package/dist/cli-user/io/stdio.js +25 -0
  1010. package/dist/cli-user/io/stdio.js.map +1 -0
  1011. package/dist/cli-user/io/transcriptWriter.d.ts +5 -0
  1012. package/dist/cli-user/io/transcriptWriter.d.ts.map +1 -0
  1013. package/dist/cli-user/io/transcriptWriter.js +60 -0
  1014. package/dist/cli-user/io/transcriptWriter.js.map +1 -0
  1015. package/dist/cli-user/repl/index.d.ts +14 -0
  1016. package/dist/cli-user/repl/index.d.ts.map +1 -0
  1017. package/dist/cli-user/repl/index.js +301 -0
  1018. package/dist/cli-user/repl/index.js.map +1 -0
  1019. package/dist/cli-user/repl/renderer.d.ts +43 -0
  1020. package/dist/cli-user/repl/renderer.d.ts.map +1 -0
  1021. package/dist/cli-user/repl/renderer.js +210 -0
  1022. package/dist/cli-user/repl/renderer.js.map +1 -0
  1023. package/dist/cli-user/repl/slashCommands.d.ts +49 -0
  1024. package/dist/cli-user/repl/slashCommands.d.ts.map +1 -0
  1025. package/dist/cli-user/repl/slashCommands.js +65 -0
  1026. package/dist/cli-user/repl/slashCommands.js.map +1 -0
  1027. package/dist/cli-user/services/cliAnalyzeService.d.ts +73 -0
  1028. package/dist/cli-user/services/cliAnalyzeService.d.ts.map +1 -0
  1029. package/dist/cli-user/services/cliAnalyzeService.js +393 -0
  1030. package/dist/cli-user/services/cliAnalyzeService.js.map +1 -0
  1031. package/dist/cli-user/services/runtimeGuard.d.ts +46 -0
  1032. package/dist/cli-user/services/runtimeGuard.d.ts.map +1 -0
  1033. package/dist/cli-user/services/runtimeGuard.js +188 -0
  1034. package/dist/cli-user/services/runtimeGuard.js.map +1 -0
  1035. package/dist/cli-user/services/traceProcessorInstaller.d.ts +2 -0
  1036. package/dist/cli-user/services/traceProcessorInstaller.d.ts.map +1 -0
  1037. package/dist/cli-user/services/traceProcessorInstaller.js +241 -0
  1038. package/dist/cli-user/services/traceProcessorInstaller.js.map +1 -0
  1039. package/dist/cli-user/services/turnPersistence.d.ts +41 -0
  1040. package/dist/cli-user/services/turnPersistence.d.ts.map +1 -0
  1041. package/dist/cli-user/services/turnPersistence.js +55 -0
  1042. package/dist/cli-user/services/turnPersistence.js.map +1 -0
  1043. package/dist/cli-user/services/turnRunner.d.ts +49 -0
  1044. package/dist/cli-user/services/turnRunner.d.ts.map +1 -0
  1045. package/dist/cli-user/services/turnRunner.js +436 -0
  1046. package/dist/cli-user/services/turnRunner.js.map +1 -0
  1047. package/dist/cli-user/types.d.ts +62 -0
  1048. package/dist/cli-user/types.d.ts.map +1 -0
  1049. package/dist/cli-user/types.js +6 -0
  1050. package/dist/cli-user/types.js.map +1 -0
  1051. package/dist/config/index.d.ts +393 -0
  1052. package/dist/config/index.d.ts.map +1 -0
  1053. package/dist/config/index.js +334 -0
  1054. package/dist/config/index.js.map +1 -0
  1055. package/dist/config/prompts.d.ts +20 -0
  1056. package/dist/config/prompts.d.ts.map +1 -0
  1057. package/dist/config/prompts.js +74 -0
  1058. package/dist/config/prompts.js.map +1 -0
  1059. package/dist/config/teaching.config.d.ts +253 -0
  1060. package/dist/config/teaching.config.d.ts.map +1 -0
  1061. package/dist/config/teaching.config.js +203 -0
  1062. package/dist/config/teaching.config.js.map +1 -0
  1063. package/dist/config/thresholds.d.ts +300 -0
  1064. package/dist/config/thresholds.d.ts.map +1 -0
  1065. package/dist/config/thresholds.js +338 -0
  1066. package/dist/config/thresholds.js.map +1 -0
  1067. package/dist/controllers/skillAdminController.d.ts +62 -0
  1068. package/dist/controllers/skillAdminController.d.ts.map +1 -0
  1069. package/dist/controllers/skillAdminController.js +482 -0
  1070. package/dist/controllers/skillAdminController.js.map +1 -0
  1071. package/dist/controllers/skillController.d.ts +49 -0
  1072. package/dist/controllers/skillController.d.ts.map +1 -0
  1073. package/dist/controllers/skillController.js +246 -0
  1074. package/dist/controllers/skillController.js.map +1 -0
  1075. package/dist/controllers/sqlController.d.ts +9 -0
  1076. package/dist/controllers/sqlController.d.ts.map +1 -0
  1077. package/dist/controllers/sqlController.js +125 -0
  1078. package/dist/controllers/sqlController.js.map +1 -0
  1079. package/dist/controllers/traceController.d.ts +13 -0
  1080. package/dist/controllers/traceController.d.ts.map +1 -0
  1081. package/dist/controllers/traceController.js +209 -0
  1082. package/dist/controllers/traceController.js.map +1 -0
  1083. package/dist/controllers/traceProcessorController.d.ts +14 -0
  1084. package/dist/controllers/traceProcessorController.d.ts.map +1 -0
  1085. package/dist/controllers/traceProcessorController.js +222 -0
  1086. package/dist/controllers/traceProcessorController.js.map +1 -0
  1087. package/dist/data/perfettoSchema.d.ts +9 -0
  1088. package/dist/data/perfettoSchema.d.ts.map +1 -0
  1089. package/dist/data/perfettoSchema.js +286 -0
  1090. package/dist/data/perfettoSchema.js.map +1 -0
  1091. package/dist/index.d.ts +2 -0
  1092. package/dist/index.d.ts.map +1 -0
  1093. package/dist/index.js +251 -0
  1094. package/dist/index.js.map +1 -0
  1095. package/dist/middleware/auth.d.ts +37 -0
  1096. package/dist/middleware/auth.d.ts.map +1 -0
  1097. package/dist/middleware/auth.js +307 -0
  1098. package/dist/middleware/auth.js.map +1 -0
  1099. package/dist/middleware/legacyAgentApi.d.ts +8 -0
  1100. package/dist/middleware/legacyAgentApi.d.ts.map +1 -0
  1101. package/dist/middleware/legacyAgentApi.js +64 -0
  1102. package/dist/middleware/legacyAgentApi.js.map +1 -0
  1103. package/dist/middleware/workspaceRouteContext.d.ts +4 -0
  1104. package/dist/middleware/workspaceRouteContext.d.ts.map +1 -0
  1105. package/dist/middleware/workspaceRouteContext.js +44 -0
  1106. package/dist/middleware/workspaceRouteContext.js.map +1 -0
  1107. package/dist/models/sessionSchema.d.ts +106 -0
  1108. package/dist/models/sessionSchema.d.ts.map +1 -0
  1109. package/dist/models/sessionSchema.js +6 -0
  1110. package/dist/models/sessionSchema.js.map +1 -0
  1111. package/dist/routes/agentLogsRoutes.d.ts +3 -0
  1112. package/dist/routes/agentLogsRoutes.d.ts.map +1 -0
  1113. package/dist/routes/agentLogsRoutes.js +283 -0
  1114. package/dist/routes/agentLogsRoutes.js.map +1 -0
  1115. package/dist/routes/agentQuickSceneRoutes.d.ts +9 -0
  1116. package/dist/routes/agentQuickSceneRoutes.d.ts.map +1 -0
  1117. package/dist/routes/agentQuickSceneRoutes.js +51 -0
  1118. package/dist/routes/agentQuickSceneRoutes.js.map +1 -0
  1119. package/dist/routes/agentReportRoutes.d.ts +11 -0
  1120. package/dist/routes/agentReportRoutes.d.ts.map +1 -0
  1121. package/dist/routes/agentReportRoutes.js +100 -0
  1122. package/dist/routes/agentReportRoutes.js.map +1 -0
  1123. package/dist/routes/agentResumeRoutes.d.ts +14 -0
  1124. package/dist/routes/agentResumeRoutes.d.ts.map +1 -0
  1125. package/dist/routes/agentResumeRoutes.js +263 -0
  1126. package/dist/routes/agentResumeRoutes.js.map +1 -0
  1127. package/dist/routes/agentRoutes.d.ts +3 -0
  1128. package/dist/routes/agentRoutes.d.ts.map +1 -0
  1129. package/dist/routes/agentRoutes.js +4349 -0
  1130. package/dist/routes/agentRoutes.js.map +1 -0
  1131. package/dist/routes/agentSceneReconstructRoutes.d.ts +68 -0
  1132. package/dist/routes/agentSceneReconstructRoutes.d.ts.map +1 -0
  1133. package/dist/routes/agentSceneReconstructRoutes.js +448 -0
  1134. package/dist/routes/agentSceneReconstructRoutes.js.map +1 -0
  1135. package/dist/routes/agentSessionCatalogRoutes.d.ts +20 -0
  1136. package/dist/routes/agentSessionCatalogRoutes.d.ts.map +1 -0
  1137. package/dist/routes/agentSessionCatalogRoutes.js +90 -0
  1138. package/dist/routes/agentSessionCatalogRoutes.js.map +1 -0
  1139. package/dist/routes/agentTeachingRoutes.d.ts +3 -0
  1140. package/dist/routes/agentTeachingRoutes.d.ts.map +1 -0
  1141. package/dist/routes/agentTeachingRoutes.js +62 -0
  1142. package/dist/routes/agentTeachingRoutes.js.map +1 -0
  1143. package/dist/routes/analysisResultRoutes.d.ts +3 -0
  1144. package/dist/routes/analysisResultRoutes.d.ts.map +1 -0
  1145. package/dist/routes/analysisResultRoutes.js +216 -0
  1146. package/dist/routes/analysisResultRoutes.js.map +1 -0
  1147. package/dist/routes/baselineRoutes.d.ts +29 -0
  1148. package/dist/routes/baselineRoutes.d.ts.map +1 -0
  1149. package/dist/routes/baselineRoutes.js +123 -0
  1150. package/dist/routes/baselineRoutes.js.map +1 -0
  1151. package/dist/routes/caseRoutes.d.ts +29 -0
  1152. package/dist/routes/caseRoutes.d.ts.map +1 -0
  1153. package/dist/routes/caseRoutes.js +194 -0
  1154. package/dist/routes/caseRoutes.js.map +1 -0
  1155. package/dist/routes/ciGateRoutes.d.ts +11 -0
  1156. package/dist/routes/ciGateRoutes.d.ts.map +1 -0
  1157. package/dist/routes/ciGateRoutes.js +363 -0
  1158. package/dist/routes/ciGateRoutes.js.map +1 -0
  1159. package/dist/routes/comparisonRoutes.d.ts +3 -0
  1160. package/dist/routes/comparisonRoutes.d.ts.map +1 -0
  1161. package/dist/routes/comparisonRoutes.js +536 -0
  1162. package/dist/routes/comparisonRoutes.js.map +1 -0
  1163. package/dist/routes/criticalPathRoutes.d.ts +3 -0
  1164. package/dist/routes/criticalPathRoutes.d.ts.map +1 -0
  1165. package/dist/routes/criticalPathRoutes.js +88 -0
  1166. package/dist/routes/criticalPathRoutes.js.map +1 -0
  1167. package/dist/routes/enterpriseApiKeyRoutes.d.ts +9 -0
  1168. package/dist/routes/enterpriseApiKeyRoutes.d.ts.map +1 -0
  1169. package/dist/routes/enterpriseApiKeyRoutes.js +126 -0
  1170. package/dist/routes/enterpriseApiKeyRoutes.js.map +1 -0
  1171. package/dist/routes/enterpriseAuthRoutes.d.ts +18 -0
  1172. package/dist/routes/enterpriseAuthRoutes.d.ts.map +1 -0
  1173. package/dist/routes/enterpriseAuthRoutes.js +160 -0
  1174. package/dist/routes/enterpriseAuthRoutes.js.map +1 -0
  1175. package/dist/routes/enterpriseRuntimeDashboardRoutes.d.ts +6 -0
  1176. package/dist/routes/enterpriseRuntimeDashboardRoutes.d.ts.map +1 -0
  1177. package/dist/routes/enterpriseRuntimeDashboardRoutes.js +32 -0
  1178. package/dist/routes/enterpriseRuntimeDashboardRoutes.js.map +1 -0
  1179. package/dist/routes/enterpriseTenantRoutes.d.ts +4 -0
  1180. package/dist/routes/enterpriseTenantRoutes.d.ts.map +1 -0
  1181. package/dist/routes/enterpriseTenantRoutes.js +313 -0
  1182. package/dist/routes/enterpriseTenantRoutes.js.map +1 -0
  1183. package/dist/routes/exportRoutes.d.ts +3 -0
  1184. package/dist/routes/exportRoutes.d.ts.map +1 -0
  1185. package/dist/routes/exportRoutes.js +196 -0
  1186. package/dist/routes/exportRoutes.js.map +1 -0
  1187. package/dist/routes/flamegraphRoutes.d.ts +3 -0
  1188. package/dist/routes/flamegraphRoutes.d.ts.map +1 -0
  1189. package/dist/routes/flamegraphRoutes.js +99 -0
  1190. package/dist/routes/flamegraphRoutes.js.map +1 -0
  1191. package/dist/routes/memoryRoutes.d.ts +31 -0
  1192. package/dist/routes/memoryRoutes.d.ts.map +1 -0
  1193. package/dist/routes/memoryRoutes.js +150 -0
  1194. package/dist/routes/memoryRoutes.js.map +1 -0
  1195. package/dist/routes/narrativeSanitizer.d.ts +2 -0
  1196. package/dist/routes/narrativeSanitizer.d.ts.map +1 -0
  1197. package/dist/routes/narrativeSanitizer.js +167 -0
  1198. package/dist/routes/narrativeSanitizer.js.map +1 -0
  1199. package/dist/routes/perfettoLocalRoutes.d.ts +3 -0
  1200. package/dist/routes/perfettoLocalRoutes.d.ts.map +1 -0
  1201. package/dist/routes/perfettoLocalRoutes.js +222 -0
  1202. package/dist/routes/perfettoLocalRoutes.js.map +1 -0
  1203. package/dist/routes/perfettoSqlRoutes.d.ts +7 -0
  1204. package/dist/routes/perfettoSqlRoutes.d.ts.map +1 -0
  1205. package/dist/routes/perfettoSqlRoutes.js +738 -0
  1206. package/dist/routes/perfettoSqlRoutes.js.map +1 -0
  1207. package/dist/routes/providerRoutes.d.ts +3 -0
  1208. package/dist/routes/providerRoutes.d.ts.map +1 -0
  1209. package/dist/routes/providerRoutes.js +219 -0
  1210. package/dist/routes/providerRoutes.js.map +1 -0
  1211. package/dist/routes/ragAdminRoutes.d.ts +30 -0
  1212. package/dist/routes/ragAdminRoutes.d.ts.map +1 -0
  1213. package/dist/routes/ragAdminRoutes.js +93 -0
  1214. package/dist/routes/ragAdminRoutes.js.map +1 -0
  1215. package/dist/routes/reportRoutes.d.ts +17 -0
  1216. package/dist/routes/reportRoutes.d.ts.map +1 -0
  1217. package/dist/routes/reportRoutes.js +579 -0
  1218. package/dist/routes/reportRoutes.js.map +1 -0
  1219. package/dist/routes/sessionRoutes.d.ts +3 -0
  1220. package/dist/routes/sessionRoutes.d.ts.map +1 -0
  1221. package/dist/routes/sessionRoutes.js +144 -0
  1222. package/dist/routes/sessionRoutes.js.map +1 -0
  1223. package/dist/routes/simpleTraceRoutes.d.ts +3 -0
  1224. package/dist/routes/simpleTraceRoutes.d.ts.map +1 -0
  1225. package/dist/routes/simpleTraceRoutes.js +1131 -0
  1226. package/dist/routes/simpleTraceRoutes.js.map +1 -0
  1227. package/dist/routes/skillAdminRoutes.d.ts +3 -0
  1228. package/dist/routes/skillAdminRoutes.d.ts.map +1 -0
  1229. package/dist/routes/skillAdminRoutes.js +100 -0
  1230. package/dist/routes/skillAdminRoutes.js.map +1 -0
  1231. package/dist/routes/skillRoutes.d.ts +3 -0
  1232. package/dist/routes/skillRoutes.d.ts.map +1 -0
  1233. package/dist/routes/skillRoutes.js +88 -0
  1234. package/dist/routes/skillRoutes.js.map +1 -0
  1235. package/dist/routes/sql.d.ts +3 -0
  1236. package/dist/routes/sql.d.ts.map +1 -0
  1237. package/dist/routes/sql.js +19 -0
  1238. package/dist/routes/sql.js.map +1 -0
  1239. package/dist/routes/strategyAdminRoutes.d.ts +3 -0
  1240. package/dist/routes/strategyAdminRoutes.d.ts.map +1 -0
  1241. package/dist/routes/strategyAdminRoutes.js +65 -0
  1242. package/dist/routes/strategyAdminRoutes.js.map +1 -0
  1243. package/dist/routes/templateAnalysisRoutes.d.ts +3 -0
  1244. package/dist/routes/templateAnalysisRoutes.d.ts.map +1 -0
  1245. package/dist/routes/templateAnalysisRoutes.js +173 -0
  1246. package/dist/routes/templateAnalysisRoutes.js.map +1 -0
  1247. package/dist/routes/trace.d.ts +3 -0
  1248. package/dist/routes/trace.d.ts.map +1 -0
  1249. package/dist/routes/trace.js +48 -0
  1250. package/dist/routes/trace.js.map +1 -0
  1251. package/dist/routes/traceProcessorProxyRoutes.d.ts +6 -0
  1252. package/dist/routes/traceProcessorProxyRoutes.d.ts.map +1 -0
  1253. package/dist/routes/traceProcessorProxyRoutes.js +607 -0
  1254. package/dist/routes/traceProcessorProxyRoutes.js.map +1 -0
  1255. package/dist/routes/traceProcessorRoutes.d.ts +3 -0
  1256. package/dist/routes/traceProcessorRoutes.d.ts.map +1 -0
  1257. package/dist/routes/traceProcessorRoutes.js +40 -0
  1258. package/dist/routes/traceProcessorRoutes.js.map +1 -0
  1259. package/dist/routes/workspaceWindowRoutes.d.ts +3 -0
  1260. package/dist/routes/workspaceWindowRoutes.d.ts.map +1 -0
  1261. package/dist/routes/workspaceWindowRoutes.js +146 -0
  1262. package/dist/routes/workspaceWindowRoutes.js.map +1 -0
  1263. package/dist/runtimePaths.d.ts +3 -0
  1264. package/dist/runtimePaths.d.ts.map +1 -0
  1265. package/dist/runtimePaths.js +20 -0
  1266. package/dist/runtimePaths.js.map +1 -0
  1267. package/dist/scripts/analyzeComprehensiveTrace.d.ts +2 -0
  1268. package/dist/scripts/analyzeComprehensiveTrace.d.ts.map +1 -0
  1269. package/dist/scripts/analyzeComprehensiveTrace.js +210 -0
  1270. package/dist/scripts/analyzeComprehensiveTrace.js.map +1 -0
  1271. package/dist/scripts/analyzeUserTrace.d.ts +2 -0
  1272. package/dist/scripts/analyzeUserTrace.d.ts.map +1 -0
  1273. package/dist/scripts/analyzeUserTrace.js +170 -0
  1274. package/dist/scripts/analyzeUserTrace.js.map +1 -0
  1275. package/dist/scripts/auditTraceProcessorRssMatrix.d.ts +49 -0
  1276. package/dist/scripts/auditTraceProcessorRssMatrix.d.ts.map +1 -0
  1277. package/dist/scripts/auditTraceProcessorRssMatrix.js +390 -0
  1278. package/dist/scripts/auditTraceProcessorRssMatrix.js.map +1 -0
  1279. package/dist/scripts/benchmarkTraceProcessorRss.d.ts +96 -0
  1280. package/dist/scripts/benchmarkTraceProcessorRss.d.ts.map +1 -0
  1281. package/dist/scripts/benchmarkTraceProcessorRss.js +569 -0
  1282. package/dist/scripts/benchmarkTraceProcessorRss.js.map +1 -0
  1283. package/dist/scripts/captureContextEngineeringBaseline.d.ts +2 -0
  1284. package/dist/scripts/captureContextEngineeringBaseline.d.ts.map +1 -0
  1285. package/dist/scripts/captureContextEngineeringBaseline.js +271 -0
  1286. package/dist/scripts/captureContextEngineeringBaseline.js.map +1 -0
  1287. package/dist/scripts/checkTables.d.ts +2 -0
  1288. package/dist/scripts/checkTables.d.ts.map +1 -0
  1289. package/dist/scripts/checkTables.js +22 -0
  1290. package/dist/scripts/checkTables.js.map +1 -0
  1291. package/dist/scripts/diagnoseJankDetection.d.ts +2 -0
  1292. package/dist/scripts/diagnoseJankDetection.d.ts.map +1 -0
  1293. package/dist/scripts/diagnoseJankDetection.js +314 -0
  1294. package/dist/scripts/diagnoseJankDetection.js.map +1 -0
  1295. package/dist/scripts/diagnoseTrace.d.ts +2 -0
  1296. package/dist/scripts/diagnoseTrace.d.ts.map +1 -0
  1297. package/dist/scripts/diagnoseTrace.js +74 -0
  1298. package/dist/scripts/diagnoseTrace.js.map +1 -0
  1299. package/dist/scripts/enterpriseAcceptanceLoadTest.d.ts +193 -0
  1300. package/dist/scripts/enterpriseAcceptanceLoadTest.d.ts.map +1 -0
  1301. package/dist/scripts/enterpriseAcceptanceLoadTest.js +912 -0
  1302. package/dist/scripts/enterpriseAcceptanceLoadTest.js.map +1 -0
  1303. package/dist/scripts/enterpriseMigrationSnapshot.d.ts +3 -0
  1304. package/dist/scripts/enterpriseMigrationSnapshot.d.ts.map +1 -0
  1305. package/dist/scripts/enterpriseMigrationSnapshot.js +57 -0
  1306. package/dist/scripts/enterpriseMigrationSnapshot.js.map +1 -0
  1307. package/dist/scripts/enterpriseReadinessAudit.d.ts +30 -0
  1308. package/dist/scripts/enterpriseReadinessAudit.d.ts.map +1 -0
  1309. package/dist/scripts/enterpriseReadinessAudit.js +743 -0
  1310. package/dist/scripts/enterpriseReadinessAudit.js.map +1 -0
  1311. package/dist/scripts/enterpriseRssBenchmarkMatrix.d.ts +6 -0
  1312. package/dist/scripts/enterpriseRssBenchmarkMatrix.d.ts.map +1 -0
  1313. package/dist/scripts/enterpriseRssBenchmarkMatrix.js +20 -0
  1314. package/dist/scripts/enterpriseRssBenchmarkMatrix.js.map +1 -0
  1315. package/dist/scripts/enterpriseRuntimeIsolationChecklist.d.ts +22 -0
  1316. package/dist/scripts/enterpriseRuntimeIsolationChecklist.d.ts.map +1 -0
  1317. package/dist/scripts/enterpriseRuntimeIsolationChecklist.js +374 -0
  1318. package/dist/scripts/enterpriseRuntimeIsolationChecklist.js.map +1 -0
  1319. package/dist/scripts/enterpriseSecurityAuditChecklist.d.ts +20 -0
  1320. package/dist/scripts/enterpriseSecurityAuditChecklist.d.ts.map +1 -0
  1321. package/dist/scripts/enterpriseSecurityAuditChecklist.js +113 -0
  1322. package/dist/scripts/enterpriseSecurityAuditChecklist.js.map +1 -0
  1323. package/dist/scripts/probeStdlibSchema.d.ts +2 -0
  1324. package/dist/scripts/probeStdlibSchema.d.ts.map +1 -0
  1325. package/dist/scripts/probeStdlibSchema.js +209 -0
  1326. package/dist/scripts/probeStdlibSchema.js.map +1 -0
  1327. package/dist/scripts/runAgentTest.d.ts +2 -0
  1328. package/dist/scripts/runAgentTest.d.ts.map +1 -0
  1329. package/dist/scripts/runAgentTest.js +149 -0
  1330. package/dist/scripts/runAgentTest.js.map +1 -0
  1331. package/dist/scripts/runScrollingTest.d.ts +2 -0
  1332. package/dist/scripts/runScrollingTest.d.ts.map +1 -0
  1333. package/dist/scripts/runScrollingTest.js +199 -0
  1334. package/dist/scripts/runScrollingTest.js.map +1 -0
  1335. package/dist/scripts/runScrollingTestRealData.d.ts +2 -0
  1336. package/dist/scripts/runScrollingTestRealData.d.ts.map +1 -0
  1337. package/dist/scripts/runScrollingTestRealData.js +121 -0
  1338. package/dist/scripts/runScrollingTestRealData.js.map +1 -0
  1339. package/dist/scripts/testAndroidTrace.d.ts +2 -0
  1340. package/dist/scripts/testAndroidTrace.d.ts.map +1 -0
  1341. package/dist/scripts/testAndroidTrace.js +21 -0
  1342. package/dist/scripts/testAndroidTrace.js.map +1 -0
  1343. package/dist/scripts/testCrossDomainExpert.d.ts +2 -0
  1344. package/dist/scripts/testCrossDomainExpert.d.ts.map +1 -0
  1345. package/dist/scripts/testCrossDomainExpert.js +288 -0
  1346. package/dist/scripts/testCrossDomainExpert.js.map +1 -0
  1347. package/dist/scripts/testCrossDomainIntegration.d.ts +2 -0
  1348. package/dist/scripts/testCrossDomainIntegration.d.ts.map +1 -0
  1349. package/dist/scripts/testCrossDomainIntegration.js +282 -0
  1350. package/dist/scripts/testCrossDomainIntegration.js.map +1 -0
  1351. package/dist/scripts/testDeepLayerFix.d.ts +2 -0
  1352. package/dist/scripts/testDeepLayerFix.d.ts.map +1 -0
  1353. package/dist/scripts/testDeepLayerFix.js +137 -0
  1354. package/dist/scripts/testDeepLayerFix.js.map +1 -0
  1355. package/dist/scripts/testHtmlReportGen.d.ts +2 -0
  1356. package/dist/scripts/testHtmlReportGen.d.ts.map +1 -0
  1357. package/dist/scripts/testHtmlReportGen.js +148 -0
  1358. package/dist/scripts/testHtmlReportGen.js.map +1 -0
  1359. package/dist/scripts/verifyAgentSseScrolling.d.ts +2 -0
  1360. package/dist/scripts/verifyAgentSseScrolling.d.ts.map +1 -0
  1361. package/dist/scripts/verifyAgentSseScrolling.js +558 -0
  1362. package/dist/scripts/verifyAgentSseScrolling.js.map +1 -0
  1363. package/dist/scripts/verifyCriticalPathE2E.d.ts +2 -0
  1364. package/dist/scripts/verifyCriticalPathE2E.d.ts.map +1 -0
  1365. package/dist/scripts/verifyCriticalPathE2E.js +171 -0
  1366. package/dist/scripts/verifyCriticalPathE2E.js.map +1 -0
  1367. package/dist/scripts/verifyEnterpriseMultiTenantWindows.d.ts +24 -0
  1368. package/dist/scripts/verifyEnterpriseMultiTenantWindows.d.ts.map +1 -0
  1369. package/dist/scripts/verifyEnterpriseMultiTenantWindows.js +1363 -0
  1370. package/dist/scripts/verifyEnterpriseMultiTenantWindows.js.map +1 -0
  1371. package/dist/services/adb/adbContextDetector.d.ts +3 -0
  1372. package/dist/services/adb/adbContextDetector.d.ts.map +1 -0
  1373. package/dist/services/adb/adbContextDetector.js +151 -0
  1374. package/dist/services/adb/adbContextDetector.js.map +1 -0
  1375. package/dist/services/adb/adbService.d.ts +28 -0
  1376. package/dist/services/adb/adbService.d.ts.map +1 -0
  1377. package/dist/services/adb/adbService.js +238 -0
  1378. package/dist/services/adb/adbService.js.map +1 -0
  1379. package/dist/services/adb/index.d.ts +5 -0
  1380. package/dist/services/adb/index.d.ts.map +1 -0
  1381. package/dist/services/adb/index.js +24 -0
  1382. package/dist/services/adb/index.js.map +1 -0
  1383. package/dist/services/adb/traceDeviceMatcher.d.ts +12 -0
  1384. package/dist/services/adb/traceDeviceMatcher.d.ts.map +1 -0
  1385. package/dist/services/adb/traceDeviceMatcher.js +149 -0
  1386. package/dist/services/adb/traceDeviceMatcher.js.map +1 -0
  1387. package/dist/services/adb/types.d.ts +69 -0
  1388. package/dist/services/adb/types.d.ts.map +1 -0
  1389. package/dist/services/adb/types.js +6 -0
  1390. package/dist/services/adb/types.js.map +1 -0
  1391. package/dist/services/agentEventStore.d.ts +17 -0
  1392. package/dist/services/agentEventStore.d.ts.map +1 -0
  1393. package/dist/services/agentEventStore.js +139 -0
  1394. package/dist/services/agentEventStore.js.map +1 -0
  1395. package/dist/services/agentReportData.d.ts +42 -0
  1396. package/dist/services/agentReportData.d.ts.map +1 -0
  1397. package/dist/services/agentReportData.js +81 -0
  1398. package/dist/services/agentReportData.js.map +1 -0
  1399. package/dist/services/agentResultNormalizer.d.ts +33 -0
  1400. package/dist/services/agentResultNormalizer.d.ts.map +1 -0
  1401. package/dist/services/agentResultNormalizer.js +92 -0
  1402. package/dist/services/agentResultNormalizer.js.map +1 -0
  1403. package/dist/services/analysisResultSnapshotPipeline.d.ts +24 -0
  1404. package/dist/services/analysisResultSnapshotPipeline.d.ts.map +1 -0
  1405. package/dist/services/analysisResultSnapshotPipeline.js +466 -0
  1406. package/dist/services/analysisResultSnapshotPipeline.js.map +1 -0
  1407. package/dist/services/analysisResultSnapshotStore.d.ts +29 -0
  1408. package/dist/services/analysisResultSnapshotStore.d.ts.map +1 -0
  1409. package/dist/services/analysisResultSnapshotStore.js +457 -0
  1410. package/dist/services/analysisResultSnapshotStore.js.map +1 -0
  1411. package/dist/services/analysisResultWindowStateStore.d.ts +37 -0
  1412. package/dist/services/analysisResultWindowStateStore.d.ts.map +1 -0
  1413. package/dist/services/analysisResultWindowStateStore.js +190 -0
  1414. package/dist/services/analysisResultWindowStateStore.js.map +1 -0
  1415. package/dist/services/analysisRunStore.d.ts +38 -0
  1416. package/dist/services/analysisRunStore.d.ts.map +1 -0
  1417. package/dist/services/analysisRunStore.js +195 -0
  1418. package/dist/services/analysisRunStore.js.map +1 -0
  1419. package/dist/services/analysisTemplates/cpuCoreAnalysis.d.ts +70 -0
  1420. package/dist/services/analysisTemplates/cpuCoreAnalysis.d.ts.map +1 -0
  1421. package/dist/services/analysisTemplates/cpuCoreAnalysis.js +277 -0
  1422. package/dist/services/analysisTemplates/cpuCoreAnalysis.js.map +1 -0
  1423. package/dist/services/analysisTemplates/fourQuadrantAnalysis.d.ts +64 -0
  1424. package/dist/services/analysisTemplates/fourQuadrantAnalysis.d.ts.map +1 -0
  1425. package/dist/services/analysisTemplates/fourQuadrantAnalysis.js +288 -0
  1426. package/dist/services/analysisTemplates/fourQuadrantAnalysis.js.map +1 -0
  1427. package/dist/services/analysisTemplates/frameStatsAnalysis.d.ts +77 -0
  1428. package/dist/services/analysisTemplates/frameStatsAnalysis.d.ts.map +1 -0
  1429. package/dist/services/analysisTemplates/frameStatsAnalysis.js +232 -0
  1430. package/dist/services/analysisTemplates/frameStatsAnalysis.js.map +1 -0
  1431. package/dist/services/analysisTemplates/templateManager.d.ts +70 -0
  1432. package/dist/services/analysisTemplates/templateManager.d.ts.map +1 -0
  1433. package/dist/services/analysisTemplates/templateManager.js +293 -0
  1434. package/dist/services/analysisTemplates/templateManager.js.map +1 -0
  1435. package/dist/services/anonymizer.d.ts +61 -0
  1436. package/dist/services/anonymizer.d.ts.map +1 -0
  1437. package/dist/services/anonymizer.js +232 -0
  1438. package/dist/services/anonymizer.js.map +1 -0
  1439. package/dist/services/aospKnowledgeIngester.d.ts +67 -0
  1440. package/dist/services/aospKnowledgeIngester.d.ts.map +1 -0
  1441. package/dist/services/aospKnowledgeIngester.js +171 -0
  1442. package/dist/services/aospKnowledgeIngester.js.map +1 -0
  1443. package/dist/services/artifactCompression.d.ts +52 -0
  1444. package/dist/services/artifactCompression.d.ts.map +1 -0
  1445. package/dist/services/artifactCompression.js +215 -0
  1446. package/dist/services/artifactCompression.js.map +1 -0
  1447. package/dist/services/baselineDiffer.d.ts +85 -0
  1448. package/dist/services/baselineDiffer.d.ts.map +1 -0
  1449. package/dist/services/baselineDiffer.js +287 -0
  1450. package/dist/services/baselineDiffer.js.map +1 -0
  1451. package/dist/services/baselineStore.d.ts +52 -0
  1452. package/dist/services/baselineStore.d.ts.map +1 -0
  1453. package/dist/services/baselineStore.js +224 -0
  1454. package/dist/services/baselineStore.js.map +1 -0
  1455. package/dist/services/binderRootCauseChain.d.ts +38 -0
  1456. package/dist/services/binderRootCauseChain.d.ts.map +1 -0
  1457. package/dist/services/binderRootCauseChain.js +74 -0
  1458. package/dist/services/binderRootCauseChain.js.map +1 -0
  1459. package/dist/services/blogKnowledgeIngester.d.ts +89 -0
  1460. package/dist/services/blogKnowledgeIngester.d.ts.map +1 -0
  1461. package/dist/services/blogKnowledgeIngester.js +192 -0
  1462. package/dist/services/blogKnowledgeIngester.js.map +1 -0
  1463. package/dist/services/caseGraph.d.ts +55 -0
  1464. package/dist/services/caseGraph.d.ts.map +1 -0
  1465. package/dist/services/caseGraph.js +260 -0
  1466. package/dist/services/caseGraph.js.map +1 -0
  1467. package/dist/services/caseLibrary.d.ts +61 -0
  1468. package/dist/services/caseLibrary.d.ts.map +1 -0
  1469. package/dist/services/caseLibrary.js +269 -0
  1470. package/dist/services/caseLibrary.js.map +1 -0
  1471. package/dist/services/ciGateRunStore.d.ts +39 -0
  1472. package/dist/services/ciGateRunStore.d.ts.map +1 -0
  1473. package/dist/services/ciGateRunStore.js +208 -0
  1474. package/dist/services/ciGateRunStore.js.map +1 -0
  1475. package/dist/services/comparisonAiConclusionService.d.ts +23 -0
  1476. package/dist/services/comparisonAiConclusionService.d.ts.map +1 -0
  1477. package/dist/services/comparisonAiConclusionService.js +207 -0
  1478. package/dist/services/comparisonAiConclusionService.js.map +1 -0
  1479. package/dist/services/comparisonAppendixService.d.ts +50 -0
  1480. package/dist/services/comparisonAppendixService.d.ts.map +1 -0
  1481. package/dist/services/comparisonAppendixService.js +276 -0
  1482. package/dist/services/comparisonAppendixService.js.map +1 -0
  1483. package/dist/services/comparisonHtmlReportService.d.ts +20 -0
  1484. package/dist/services/comparisonHtmlReportService.d.ts.map +1 -0
  1485. package/dist/services/comparisonHtmlReportService.js +214 -0
  1486. package/dist/services/comparisonHtmlReportService.js.map +1 -0
  1487. package/dist/services/comparisonMatrixService.d.ts +7 -0
  1488. package/dist/services/comparisonMatrixService.d.ts.map +1 -0
  1489. package/dist/services/comparisonMatrixService.js +211 -0
  1490. package/dist/services/comparisonMatrixService.js.map +1 -0
  1491. package/dist/services/comparisonResultService.d.ts +13 -0
  1492. package/dist/services/comparisonResultService.d.ts.map +1 -0
  1493. package/dist/services/comparisonResultService.js +99 -0
  1494. package/dist/services/comparisonResultService.js.map +1 -0
  1495. package/dist/services/comparisonSignificance.d.ts +3 -0
  1496. package/dist/services/comparisonSignificance.d.ts.map +1 -0
  1497. package/dist/services/comparisonSignificance.js +42 -0
  1498. package/dist/services/comparisonSignificance.js.map +1 -0
  1499. package/dist/services/cpuThermalPmu.d.ts +38 -0
  1500. package/dist/services/cpuThermalPmu.d.ts.map +1 -0
  1501. package/dist/services/cpuThermalPmu.js +141 -0
  1502. package/dist/services/cpuThermalPmu.js.map +1 -0
  1503. package/dist/services/criticalPathAiSummary.d.ts +29 -0
  1504. package/dist/services/criticalPathAiSummary.d.ts.map +1 -0
  1505. package/dist/services/criticalPathAiSummary.js +310 -0
  1506. package/dist/services/criticalPathAiSummary.js.map +1 -0
  1507. package/dist/services/criticalPathAnalyzer.d.ts +108 -0
  1508. package/dist/services/criticalPathAnalyzer.d.ts.map +1 -0
  1509. package/dist/services/criticalPathAnalyzer.js +880 -0
  1510. package/dist/services/criticalPathAnalyzer.js.map +1 -0
  1511. package/dist/services/criticalPathQuantify.d.ts +70 -0
  1512. package/dist/services/criticalPathQuantify.d.ts.map +1 -0
  1513. package/dist/services/criticalPathQuantify.js +214 -0
  1514. package/dist/services/criticalPathQuantify.js.map +1 -0
  1515. package/dist/services/criticalPathSemantics.d.ts +95 -0
  1516. package/dist/services/criticalPathSemantics.d.ts.map +1 -0
  1517. package/dist/services/criticalPathSemantics.js +453 -0
  1518. package/dist/services/criticalPathSemantics.js.map +1 -0
  1519. package/dist/services/criticalPathWakerChain.d.ts +38 -0
  1520. package/dist/services/criticalPathWakerChain.d.ts.map +1 -0
  1521. package/dist/services/criticalPathWakerChain.js +144 -0
  1522. package/dist/services/criticalPathWakerChain.js.map +1 -0
  1523. package/dist/services/domainSkillEvalHarness.d.ts +51 -0
  1524. package/dist/services/domainSkillEvalHarness.d.ts.map +1 -0
  1525. package/dist/services/domainSkillEvalHarness.js +141 -0
  1526. package/dist/services/domainSkillEvalHarness.js.map +1 -0
  1527. package/dist/services/enhancedAIService.d.ts +81 -0
  1528. package/dist/services/enhancedAIService.d.ts.map +1 -0
  1529. package/dist/services/enhancedAIService.js +277 -0
  1530. package/dist/services/enhancedAIService.js.map +1 -0
  1531. package/dist/services/enterpriseAdminControlPlaneService.d.ts +124 -0
  1532. package/dist/services/enterpriseAdminControlPlaneService.d.ts.map +1 -0
  1533. package/dist/services/enterpriseAdminControlPlaneService.js +323 -0
  1534. package/dist/services/enterpriseAdminControlPlaneService.js.map +1 -0
  1535. package/dist/services/enterpriseApiKeyService.d.ts +56 -0
  1536. package/dist/services/enterpriseApiKeyService.d.ts.map +1 -0
  1537. package/dist/services/enterpriseApiKeyService.js +260 -0
  1538. package/dist/services/enterpriseApiKeyService.js.map +1 -0
  1539. package/dist/services/enterpriseAuditService.d.ts +30 -0
  1540. package/dist/services/enterpriseAuditService.d.ts.map +1 -0
  1541. package/dist/services/enterpriseAuditService.js +73 -0
  1542. package/dist/services/enterpriseAuditService.js.map +1 -0
  1543. package/dist/services/enterpriseDb.d.ts +5 -0
  1544. package/dist/services/enterpriseDb.d.ts.map +1 -0
  1545. package/dist/services/enterpriseDb.js +33 -0
  1546. package/dist/services/enterpriseDb.js.map +1 -0
  1547. package/dist/services/enterpriseMigration.d.ts +89 -0
  1548. package/dist/services/enterpriseMigration.d.ts.map +1 -0
  1549. package/dist/services/enterpriseMigration.js +506 -0
  1550. package/dist/services/enterpriseMigration.js.map +1 -0
  1551. package/dist/services/enterpriseOidcClient.d.ts +36 -0
  1552. package/dist/services/enterpriseOidcClient.d.ts.map +1 -0
  1553. package/dist/services/enterpriseOidcClient.js +124 -0
  1554. package/dist/services/enterpriseOidcClient.js.map +1 -0
  1555. package/dist/services/enterpriseQuotaPolicyService.d.ts +37 -0
  1556. package/dist/services/enterpriseQuotaPolicyService.d.ts.map +1 -0
  1557. package/dist/services/enterpriseQuotaPolicyService.js +198 -0
  1558. package/dist/services/enterpriseQuotaPolicyService.js.map +1 -0
  1559. package/dist/services/enterpriseRepository.d.ts +36 -0
  1560. package/dist/services/enterpriseRepository.d.ts.map +1 -0
  1561. package/dist/services/enterpriseRepository.js +208 -0
  1562. package/dist/services/enterpriseRepository.js.map +1 -0
  1563. package/dist/services/enterpriseRuntimeDashboardService.d.ts +114 -0
  1564. package/dist/services/enterpriseRuntimeDashboardService.d.ts.map +1 -0
  1565. package/dist/services/enterpriseRuntimeDashboardService.js +205 -0
  1566. package/dist/services/enterpriseRuntimeDashboardService.js.map +1 -0
  1567. package/dist/services/enterpriseSchema.d.ts +7 -0
  1568. package/dist/services/enterpriseSchema.d.ts.map +1 -0
  1569. package/dist/services/enterpriseSchema.js +688 -0
  1570. package/dist/services/enterpriseSchema.js.map +1 -0
  1571. package/dist/services/enterpriseSsoService.d.ts +99 -0
  1572. package/dist/services/enterpriseSsoService.d.ts.map +1 -0
  1573. package/dist/services/enterpriseSsoService.js +538 -0
  1574. package/dist/services/enterpriseSsoService.js.map +1 -0
  1575. package/dist/services/enterpriseTenantExportService.d.ts +58 -0
  1576. package/dist/services/enterpriseTenantExportService.d.ts.map +1 -0
  1577. package/dist/services/enterpriseTenantExportService.js +339 -0
  1578. package/dist/services/enterpriseTenantExportService.js.map +1 -0
  1579. package/dist/services/enterpriseTenantLifecycleService.d.ts +52 -0
  1580. package/dist/services/enterpriseTenantLifecycleService.d.ts.map +1 -0
  1581. package/dist/services/enterpriseTenantLifecycleService.js +323 -0
  1582. package/dist/services/enterpriseTenantLifecycleService.js.map +1 -0
  1583. package/dist/services/flamegraphAiSummary.d.ts +4 -0
  1584. package/dist/services/flamegraphAiSummary.d.ts.map +1 -0
  1585. package/dist/services/flamegraphAiSummary.js +172 -0
  1586. package/dist/services/flamegraphAiSummary.js.map +1 -0
  1587. package/dist/services/flamegraphAnalyzer.d.ts +14 -0
  1588. package/dist/services/flamegraphAnalyzer.d.ts.map +1 -0
  1589. package/dist/services/flamegraphAnalyzer.js +607 -0
  1590. package/dist/services/flamegraphAnalyzer.js.map +1 -0
  1591. package/dist/services/flamegraphTypes.d.ts +106 -0
  1592. package/dist/services/flamegraphTypes.d.ts.map +1 -0
  1593. package/dist/services/flamegraphTypes.js +6 -0
  1594. package/dist/services/flamegraphTypes.js.map +1 -0
  1595. package/dist/services/gpuSurfaceFlinger.d.ts +27 -0
  1596. package/dist/services/gpuSurfaceFlinger.d.ts.map +1 -0
  1597. package/dist/services/gpuSurfaceFlinger.js +68 -0
  1598. package/dist/services/gpuSurfaceFlinger.js.map +1 -0
  1599. package/dist/services/htmlReportGenerator.d.ts +425 -0
  1600. package/dist/services/htmlReportGenerator.d.ts.map +1 -0
  1601. package/dist/services/htmlReportGenerator.js +5110 -0
  1602. package/dist/services/htmlReportGenerator.js.map +1 -0
  1603. package/dist/services/ioNetworkWakeup.d.ts +27 -0
  1604. package/dist/services/ioNetworkWakeup.d.ts.map +1 -0
  1605. package/dist/services/ioNetworkWakeup.js +68 -0
  1606. package/dist/services/ioNetworkWakeup.js.map +1 -0
  1607. package/dist/services/jankDecisionTree.d.ts +39 -0
  1608. package/dist/services/jankDecisionTree.d.ts.map +1 -0
  1609. package/dist/services/jankDecisionTree.js +230 -0
  1610. package/dist/services/jankDecisionTree.js.map +1 -0
  1611. package/dist/services/legacyApiTelemetry.d.ts +28 -0
  1612. package/dist/services/legacyApiTelemetry.d.ts.map +1 -0
  1613. package/dist/services/legacyApiTelemetry.js +157 -0
  1614. package/dist/services/legacyApiTelemetry.js.map +1 -0
  1615. package/dist/services/memoryRootCause.d.ts +24 -0
  1616. package/dist/services/memoryRootCause.d.ts.map +1 -0
  1617. package/dist/services/memoryRootCause.js +70 -0
  1618. package/dist/services/memoryRootCause.js.map +1 -0
  1619. package/dist/services/multiTraceComparisonStore.d.ts +28 -0
  1620. package/dist/services/multiTraceComparisonStore.d.ts.map +1 -0
  1621. package/dist/services/multiTraceComparisonStore.js +220 -0
  1622. package/dist/services/multiTraceComparisonStore.js.map +1 -0
  1623. package/dist/services/oemSdkKnowledgeIngester.d.ts +62 -0
  1624. package/dist/services/oemSdkKnowledgeIngester.d.ts.map +1 -0
  1625. package/dist/services/oemSdkKnowledgeIngester.js +154 -0
  1626. package/dist/services/oemSdkKnowledgeIngester.js.map +1 -0
  1627. package/dist/services/perfettoLocalService.d.ts +25 -0
  1628. package/dist/services/perfettoLocalService.d.ts.map +1 -0
  1629. package/dist/services/perfettoLocalService.js +213 -0
  1630. package/dist/services/perfettoLocalService.js.map +1 -0
  1631. package/dist/services/perfettoService.d.ts +39 -0
  1632. package/dist/services/perfettoService.d.ts.map +1 -0
  1633. package/dist/services/perfettoService.js +330 -0
  1634. package/dist/services/perfettoService.js.map +1 -0
  1635. package/dist/services/perfettoSqlDocs.d.ts +94 -0
  1636. package/dist/services/perfettoSqlDocs.d.ts.map +1 -0
  1637. package/dist/services/perfettoSqlDocs.js +222 -0
  1638. package/dist/services/perfettoSqlDocs.js.map +1 -0
  1639. package/dist/services/perfettoSqlSkill.d.ts +263 -0
  1640. package/dist/services/perfettoSqlSkill.d.ts.map +1 -0
  1641. package/dist/services/perfettoSqlSkill.js +3731 -0
  1642. package/dist/services/perfettoSqlSkill.js.map +1 -0
  1643. package/dist/services/perfettoStdlibScanner.d.ts +66 -0
  1644. package/dist/services/perfettoStdlibScanner.d.ts.map +1 -0
  1645. package/dist/services/perfettoStdlibScanner.js +345 -0
  1646. package/dist/services/perfettoStdlibScanner.js.map +1 -0
  1647. package/dist/services/persistAgentSession.d.ts +43 -0
  1648. package/dist/services/persistAgentSession.d.ts.map +1 -0
  1649. package/dist/services/persistAgentSession.js +146 -0
  1650. package/dist/services/persistAgentSession.js.map +1 -0
  1651. package/dist/services/pipelineDocService.d.ts +83 -0
  1652. package/dist/services/pipelineDocService.d.ts.map +1 -0
  1653. package/dist/services/pipelineDocService.js +417 -0
  1654. package/dist/services/pipelineDocService.js.map +1 -0
  1655. package/dist/services/pipelineSkillLoader.d.ts +173 -0
  1656. package/dist/services/pipelineSkillLoader.d.ts.map +1 -0
  1657. package/dist/services/pipelineSkillLoader.js +301 -0
  1658. package/dist/services/pipelineSkillLoader.js.map +1 -0
  1659. package/dist/services/portPool.d.ts +85 -0
  1660. package/dist/services/portPool.d.ts.map +1 -0
  1661. package/dist/services/portPool.js +221 -0
  1662. package/dist/services/portPool.js.map +1 -0
  1663. package/dist/services/processIdentity/identityGate.d.ts +27 -0
  1664. package/dist/services/processIdentity/identityGate.d.ts.map +1 -0
  1665. package/dist/services/processIdentity/identityGate.js +284 -0
  1666. package/dist/services/processIdentity/identityGate.js.map +1 -0
  1667. package/dist/services/processIdentity/types.d.ts +49 -0
  1668. package/dist/services/processIdentity/types.d.ts.map +1 -0
  1669. package/dist/services/processIdentity/types.js +16 -0
  1670. package/dist/services/processIdentity/types.js.map +1 -0
  1671. package/dist/services/processRss.d.ts +10 -0
  1672. package/dist/services/processRss.d.ts.map +1 -0
  1673. package/dist/services/processRss.js +78 -0
  1674. package/dist/services/processRss.js.map +1 -0
  1675. package/dist/services/promptTemplateService.d.ts +68 -0
  1676. package/dist/services/promptTemplateService.d.ts.map +1 -0
  1677. package/dist/services/promptTemplateService.js +196 -0
  1678. package/dist/services/promptTemplateService.js.map +1 -0
  1679. package/dist/services/providerManager/connectionTester.d.ts +3 -0
  1680. package/dist/services/providerManager/connectionTester.d.ts.map +1 -0
  1681. package/dist/services/providerManager/connectionTester.js +479 -0
  1682. package/dist/services/providerManager/connectionTester.js.map +1 -0
  1683. package/dist/services/providerManager/envIsolation.d.ts +3 -0
  1684. package/dist/services/providerManager/envIsolation.d.ts.map +1 -0
  1685. package/dist/services/providerManager/envIsolation.js +31 -0
  1686. package/dist/services/providerManager/envIsolation.js.map +1 -0
  1687. package/dist/services/providerManager/index.d.ts +9 -0
  1688. package/dist/services/providerManager/index.d.ts.map +1 -0
  1689. package/dist/services/providerManager/index.js +40 -0
  1690. package/dist/services/providerManager/index.js.map +1 -0
  1691. package/dist/services/providerManager/localSecretStore.d.ts +32 -0
  1692. package/dist/services/providerManager/localSecretStore.d.ts.map +1 -0
  1693. package/dist/services/providerManager/localSecretStore.js +338 -0
  1694. package/dist/services/providerManager/localSecretStore.js.map +1 -0
  1695. package/dist/services/providerManager/providerService.d.ts +31 -0
  1696. package/dist/services/providerManager/providerService.d.ts.map +1 -0
  1697. package/dist/services/providerManager/providerService.js +460 -0
  1698. package/dist/services/providerManager/providerService.js.map +1 -0
  1699. package/dist/services/providerManager/providerSnapshot.d.ts +30 -0
  1700. package/dist/services/providerManager/providerSnapshot.d.ts.map +1 -0
  1701. package/dist/services/providerManager/providerSnapshot.js +224 -0
  1702. package/dist/services/providerManager/providerSnapshot.js.map +1 -0
  1703. package/dist/services/providerManager/providerStore.d.ts +31 -0
  1704. package/dist/services/providerManager/providerStore.d.ts.map +1 -0
  1705. package/dist/services/providerManager/providerStore.js +553 -0
  1706. package/dist/services/providerManager/providerStore.js.map +1 -0
  1707. package/dist/services/providerManager/templates.d.ts +3 -0
  1708. package/dist/services/providerManager/templates.d.ts.map +1 -0
  1709. package/dist/services/providerManager/templates.js +328 -0
  1710. package/dist/services/providerManager/templates.js.map +1 -0
  1711. package/dist/services/providerManager/types.d.ts +119 -0
  1712. package/dist/services/providerManager/types.d.ts.map +1 -0
  1713. package/dist/services/providerManager/types.js +5 -0
  1714. package/dist/services/providerManager/types.js.map +1 -0
  1715. package/dist/services/ragStore.d.ts +60 -0
  1716. package/dist/services/ragStore.d.ts.map +1 -0
  1717. package/dist/services/ragStore.js +297 -0
  1718. package/dist/services/ragStore.js.map +1 -0
  1719. package/dist/services/rbac.d.ts +19 -0
  1720. package/dist/services/rbac.d.ts.map +1 -0
  1721. package/dist/services/rbac.js +153 -0
  1722. package/dist/services/rbac.js.map +1 -0
  1723. package/dist/services/renderingPipelineDetectionSkillGenerator.d.ts +3 -0
  1724. package/dist/services/renderingPipelineDetectionSkillGenerator.d.ts.map +1 -0
  1725. package/dist/services/renderingPipelineDetectionSkillGenerator.js +1120 -0
  1726. package/dist/services/renderingPipelineDetectionSkillGenerator.js.map +1 -0
  1727. package/dist/services/renderingPipelineTeachingService.d.ts +33 -0
  1728. package/dist/services/renderingPipelineTeachingService.d.ts.map +1 -0
  1729. package/dist/services/renderingPipelineTeachingService.js +1312 -0
  1730. package/dist/services/renderingPipelineTeachingService.js.map +1 -0
  1731. package/dist/services/reportCausalMapAssets.d.ts +3 -0
  1732. package/dist/services/reportCausalMapAssets.d.ts.map +1 -0
  1733. package/dist/services/reportCausalMapAssets.js +898 -0
  1734. package/dist/services/reportCausalMapAssets.js.map +1 -0
  1735. package/dist/services/reportGenerator.d.ts +54 -0
  1736. package/dist/services/reportGenerator.d.ts.map +1 -0
  1737. package/dist/services/reportGenerator.js +241 -0
  1738. package/dist/services/reportGenerator.js.map +1 -0
  1739. package/dist/services/resourceOwnership.d.ts +21 -0
  1740. package/dist/services/resourceOwnership.d.ts.map +1 -0
  1741. package/dist/services/resourceOwnership.js +50 -0
  1742. package/dist/services/resourceOwnership.js.map +1 -0
  1743. package/dist/services/resultExportService.d.ts +66 -0
  1744. package/dist/services/resultExportService.d.ts.map +1 -0
  1745. package/dist/services/resultExportService.js +170 -0
  1746. package/dist/services/resultExportService.js.map +1 -0
  1747. package/dist/services/runtimeSnapshotStore.d.ts +19 -0
  1748. package/dist/services/runtimeSnapshotStore.d.ts.map +1 -0
  1749. package/dist/services/runtimeSnapshotStore.js +222 -0
  1750. package/dist/services/runtimeSnapshotStore.js.map +1 -0
  1751. package/dist/services/sceneReport/sceneReportMemoryCache.d.ts +38 -0
  1752. package/dist/services/sceneReport/sceneReportMemoryCache.d.ts.map +1 -0
  1753. package/dist/services/sceneReport/sceneReportMemoryCache.js +55 -0
  1754. package/dist/services/sceneReport/sceneReportMemoryCache.js.map +1 -0
  1755. package/dist/services/sceneReport/sceneReportStore.d.ts +41 -0
  1756. package/dist/services/sceneReport/sceneReportStore.d.ts.map +1 -0
  1757. package/dist/services/sceneReport/sceneReportStore.js +248 -0
  1758. package/dist/services/sceneReport/sceneReportStore.js.map +1 -0
  1759. package/dist/services/scopedKnowledgeStore.d.ts +45 -0
  1760. package/dist/services/scopedKnowledgeStore.d.ts.map +1 -0
  1761. package/dist/services/scopedKnowledgeStore.js +225 -0
  1762. package/dist/services/scopedKnowledgeStore.js.map +1 -0
  1763. package/dist/services/sessionLogger.d.ts +142 -0
  1764. package/dist/services/sessionLogger.d.ts.map +1 -0
  1765. package/dist/services/sessionLogger.js +566 -0
  1766. package/dist/services/sessionLogger.js.map +1 -0
  1767. package/dist/services/sessionPersistenceService.d.ts +190 -0
  1768. package/dist/services/sessionPersistenceService.d.ts.map +1 -0
  1769. package/dist/services/sessionPersistenceService.js +737 -0
  1770. package/dist/services/sessionPersistenceService.js.map +1 -0
  1771. package/dist/services/skillEngine/answerGenerator.d.ts +102 -0
  1772. package/dist/services/skillEngine/answerGenerator.d.ts.map +1 -0
  1773. package/dist/services/skillEngine/answerGenerator.js +508 -0
  1774. package/dist/services/skillEngine/answerGenerator.js.map +1 -0
  1775. package/dist/services/skillEngine/displayContractValidator.d.ts +26 -0
  1776. package/dist/services/skillEngine/displayContractValidator.d.ts.map +1 -0
  1777. package/dist/services/skillEngine/displayContractValidator.js +232 -0
  1778. package/dist/services/skillEngine/displayContractValidator.js.map +1 -0
  1779. package/dist/services/skillEngine/eventCollector.d.ts +96 -0
  1780. package/dist/services/skillEngine/eventCollector.d.ts.map +1 -0
  1781. package/dist/services/skillEngine/eventCollector.js +226 -0
  1782. package/dist/services/skillEngine/eventCollector.js.map +1 -0
  1783. package/dist/services/skillEngine/expressionUtils.d.ts +25 -0
  1784. package/dist/services/skillEngine/expressionUtils.d.ts.map +1 -0
  1785. package/dist/services/skillEngine/expressionUtils.js +66 -0
  1786. package/dist/services/skillEngine/expressionUtils.js.map +1 -0
  1787. package/dist/services/skillEngine/index.d.ts +25 -0
  1788. package/dist/services/skillEngine/index.d.ts.map +1 -0
  1789. package/dist/services/skillEngine/index.js +98 -0
  1790. package/dist/services/skillEngine/index.js.map +1 -0
  1791. package/dist/services/skillEngine/skillAnalysisAdapter.d.ts +149 -0
  1792. package/dist/services/skillEngine/skillAnalysisAdapter.d.ts.map +1 -0
  1793. package/dist/services/skillEngine/skillAnalysisAdapter.js +752 -0
  1794. package/dist/services/skillEngine/skillAnalysisAdapter.js.map +1 -0
  1795. package/dist/services/skillEngine/skillExecutor.d.ts +371 -0
  1796. package/dist/services/skillEngine/skillExecutor.d.ts.map +1 -0
  1797. package/dist/services/skillEngine/skillExecutor.js +4129 -0
  1798. package/dist/services/skillEngine/skillExecutor.js.map +1 -0
  1799. package/dist/services/skillEngine/skillLoader.d.ts +163 -0
  1800. package/dist/services/skillEngine/skillLoader.d.ts.map +1 -0
  1801. package/dist/services/skillEngine/skillLoader.js +840 -0
  1802. package/dist/services/skillEngine/skillLoader.js.map +1 -0
  1803. package/dist/services/skillEngine/skillValidator.d.ts +53 -0
  1804. package/dist/services/skillEngine/skillValidator.d.ts.map +1 -0
  1805. package/dist/services/skillEngine/skillValidator.js +274 -0
  1806. package/dist/services/skillEngine/skillValidator.js.map +1 -0
  1807. package/dist/services/skillEngine/smartSummaryGenerator.d.ts +70 -0
  1808. package/dist/services/skillEngine/smartSummaryGenerator.d.ts.map +1 -0
  1809. package/dist/services/skillEngine/smartSummaryGenerator.js +324 -0
  1810. package/dist/services/skillEngine/smartSummaryGenerator.js.map +1 -0
  1811. package/dist/services/skillEngine/types.d.ts +584 -0
  1812. package/dist/services/skillEngine/types.d.ts.map +1 -0
  1813. package/dist/services/skillEngine/types.js +6 -0
  1814. package/dist/services/skillEngine/types.js.map +1 -0
  1815. package/dist/services/smartperfettoSqlPackage.d.ts +11 -0
  1816. package/dist/services/smartperfettoSqlPackage.d.ts.map +1 -0
  1817. package/dist/services/smartperfettoSqlPackage.js +168 -0
  1818. package/dist/services/smartperfettoSqlPackage.js.map +1 -0
  1819. package/dist/services/sqlGuardrailAnalyzer.d.ts +24 -0
  1820. package/dist/services/sqlGuardrailAnalyzer.d.ts.map +1 -0
  1821. package/dist/services/sqlGuardrailAnalyzer.js +362 -0
  1822. package/dist/services/sqlGuardrailAnalyzer.js.map +1 -0
  1823. package/dist/services/sqlKnowledgeBase.d.ts +236 -0
  1824. package/dist/services/sqlKnowledgeBase.d.ts.map +1 -0
  1825. package/dist/services/sqlKnowledgeBase.js +1109 -0
  1826. package/dist/services/sqlKnowledgeBase.js.map +1 -0
  1827. package/dist/services/sqlStdlibDependencyAnalyzer.d.ts +26 -0
  1828. package/dist/services/sqlStdlibDependencyAnalyzer.d.ts.map +1 -0
  1829. package/dist/services/sqlStdlibDependencyAnalyzer.js +486 -0
  1830. package/dist/services/sqlStdlibDependencyAnalyzer.js.map +1 -0
  1831. package/dist/services/sqlTemplateEngine.d.ts +134 -0
  1832. package/dist/services/sqlTemplateEngine.d.ts.map +1 -0
  1833. package/dist/services/sqlTemplateEngine.js +430 -0
  1834. package/dist/services/sqlTemplateEngine.js.map +1 -0
  1835. package/dist/services/sqlValidator.d.ts +21 -0
  1836. package/dist/services/sqlValidator.d.ts.map +1 -0
  1837. package/dist/services/sqlValidator.js +175 -0
  1838. package/dist/services/sqlValidator.js.map +1 -0
  1839. package/dist/services/standardMetricBackfillService.d.ts +23 -0
  1840. package/dist/services/standardMetricBackfillService.d.ts.map +1 -0
  1841. package/dist/services/standardMetricBackfillService.js +196 -0
  1842. package/dist/services/standardMetricBackfillService.js.map +1 -0
  1843. package/dist/services/startupAnrMethodGraph.d.ts +20 -0
  1844. package/dist/services/startupAnrMethodGraph.d.ts.map +1 -0
  1845. package/dist/services/startupAnrMethodGraph.js +70 -0
  1846. package/dist/services/startupAnrMethodGraph.js.map +1 -0
  1847. package/dist/services/stdlibSkillCoverage.d.ts +23 -0
  1848. package/dist/services/stdlibSkillCoverage.d.ts.map +1 -0
  1849. package/dist/services/stdlibSkillCoverage.js +289 -0
  1850. package/dist/services/stdlibSkillCoverage.js.map +1 -0
  1851. package/dist/services/threadSchedContext.d.ts +49 -0
  1852. package/dist/services/threadSchedContext.d.ts.map +1 -0
  1853. package/dist/services/threadSchedContext.js +84 -0
  1854. package/dist/services/threadSchedContext.js.map +1 -0
  1855. package/dist/services/timelineBinning.d.ts +44 -0
  1856. package/dist/services/timelineBinning.d.ts.map +1 -0
  1857. package/dist/services/timelineBinning.js +150 -0
  1858. package/dist/services/timelineBinning.js.map +1 -0
  1859. package/dist/services/traceConfigGenerator.d.ts +36 -0
  1860. package/dist/services/traceConfigGenerator.d.ts.map +1 -0
  1861. package/dist/services/traceConfigGenerator.js +110 -0
  1862. package/dist/services/traceConfigGenerator.js.map +1 -0
  1863. package/dist/services/traceFormatDetector.d.ts +39 -0
  1864. package/dist/services/traceFormatDetector.d.ts.map +1 -0
  1865. package/dist/services/traceFormatDetector.js +287 -0
  1866. package/dist/services/traceFormatDetector.js.map +1 -0
  1867. package/dist/services/traceMetadataStore.d.ts +32 -0
  1868. package/dist/services/traceMetadataStore.d.ts.map +1 -0
  1869. package/dist/services/traceMetadataStore.js +375 -0
  1870. package/dist/services/traceMetadataStore.js.map +1 -0
  1871. package/dist/services/traceProcessorConnectionModel.d.ts +32 -0
  1872. package/dist/services/traceProcessorConnectionModel.d.ts.map +1 -0
  1873. package/dist/services/traceProcessorConnectionModel.js +38 -0
  1874. package/dist/services/traceProcessorConnectionModel.js.map +1 -0
  1875. package/dist/services/traceProcessorHttpRpcClient.d.ts +22 -0
  1876. package/dist/services/traceProcessorHttpRpcClient.d.ts.map +1 -0
  1877. package/dist/services/traceProcessorHttpRpcClient.js +89 -0
  1878. package/dist/services/traceProcessorHttpRpcClient.js.map +1 -0
  1879. package/dist/services/traceProcessorLeaseModeDecision.d.ts +52 -0
  1880. package/dist/services/traceProcessorLeaseModeDecision.d.ts.map +1 -0
  1881. package/dist/services/traceProcessorLeaseModeDecision.js +150 -0
  1882. package/dist/services/traceProcessorLeaseModeDecision.js.map +1 -0
  1883. package/dist/services/traceProcessorLeaseStore.d.ts +88 -0
  1884. package/dist/services/traceProcessorLeaseStore.d.ts.map +1 -0
  1885. package/dist/services/traceProcessorLeaseStore.js +463 -0
  1886. package/dist/services/traceProcessorLeaseStore.js.map +1 -0
  1887. package/dist/services/traceProcessorProtobuf.d.ts +56 -0
  1888. package/dist/services/traceProcessorProtobuf.d.ts.map +1 -0
  1889. package/dist/services/traceProcessorProtobuf.js +442 -0
  1890. package/dist/services/traceProcessorProtobuf.js.map +1 -0
  1891. package/dist/services/traceProcessorRamBudget.d.ts +55 -0
  1892. package/dist/services/traceProcessorRamBudget.d.ts.map +1 -0
  1893. package/dist/services/traceProcessorRamBudget.js +140 -0
  1894. package/dist/services/traceProcessorRamBudget.js.map +1 -0
  1895. package/dist/services/traceProcessorService.d.ts +223 -0
  1896. package/dist/services/traceProcessorService.d.ts.map +1 -0
  1897. package/dist/services/traceProcessorService.js +838 -0
  1898. package/dist/services/traceProcessorService.js.map +1 -0
  1899. package/dist/services/traceProcessorSqlWorker.d.ts +49 -0
  1900. package/dist/services/traceProcessorSqlWorker.d.ts.map +1 -0
  1901. package/dist/services/traceProcessorSqlWorker.js +218 -0
  1902. package/dist/services/traceProcessorSqlWorker.js.map +1 -0
  1903. package/dist/services/traceProcessorSqlWorkerThread.d.ts +2 -0
  1904. package/dist/services/traceProcessorSqlWorkerThread.d.ts.map +1 -0
  1905. package/dist/services/traceProcessorSqlWorkerThread.js +35 -0
  1906. package/dist/services/traceProcessorSqlWorkerThread.js.map +1 -0
  1907. package/dist/services/traceSummaryV2.d.ts +47 -0
  1908. package/dist/services/traceSummaryV2.d.ts.map +1 -0
  1909. package/dist/services/traceSummaryV2.js +241 -0
  1910. package/dist/services/traceSummaryV2.js.map +1 -0
  1911. package/dist/services/traceUploadLimit.d.ts +3 -0
  1912. package/dist/services/traceUploadLimit.d.ts.map +1 -0
  1913. package/dist/services/traceUploadLimit.js +24 -0
  1914. package/dist/services/traceUploadLimit.js.map +1 -0
  1915. package/dist/services/workingTraceProcessor.d.ts +226 -0
  1916. package/dist/services/workingTraceProcessor.d.ts.map +1 -0
  1917. package/dist/services/workingTraceProcessor.js +1093 -0
  1918. package/dist/services/workingTraceProcessor.js.map +1 -0
  1919. package/dist/trace-processor-pin.env +39 -0
  1920. package/dist/types/analysis.d.ts +511 -0
  1921. package/dist/types/analysis.d.ts.map +1 -0
  1922. package/dist/types/analysis.js +112 -0
  1923. package/dist/types/analysis.js.map +1 -0
  1924. package/dist/types/ciGateContracts.d.ts +63 -0
  1925. package/dist/types/ciGateContracts.d.ts.map +1 -0
  1926. package/dist/types/ciGateContracts.js +6 -0
  1927. package/dist/types/ciGateContracts.js.map +1 -0
  1928. package/dist/types/dataContract.d.ts +624 -0
  1929. package/dist/types/dataContract.d.ts.map +1 -0
  1930. package/dist/types/dataContract.js +775 -0
  1931. package/dist/types/dataContract.js.map +1 -0
  1932. package/dist/types/index.d.ts +40 -0
  1933. package/dist/types/index.d.ts.map +1 -0
  1934. package/dist/types/index.js +21 -0
  1935. package/dist/types/index.js.map +1 -0
  1936. package/dist/types/multiTraceComparison.d.ts +215 -0
  1937. package/dist/types/multiTraceComparison.d.ts.map +1 -0
  1938. package/dist/types/multiTraceComparison.js +33 -0
  1939. package/dist/types/multiTraceComparison.js.map +1 -0
  1940. package/dist/types/perfettoSql.d.ts +596 -0
  1941. package/dist/types/perfettoSql.d.ts.map +1 -0
  1942. package/dist/types/perfettoSql.js +28 -0
  1943. package/dist/types/perfettoSql.js.map +1 -0
  1944. package/dist/types/sparkContracts.d.ts +1642 -0
  1945. package/dist/types/sparkContracts.d.ts.map +1 -0
  1946. package/dist/types/sparkContracts.js +25 -0
  1947. package/dist/types/sparkContracts.js.map +1 -0
  1948. package/dist/types/teaching.types.d.ts +395 -0
  1949. package/dist/types/teaching.types.d.ts.map +1 -0
  1950. package/dist/types/teaching.types.js +300 -0
  1951. package/dist/types/teaching.types.js.map +1 -0
  1952. package/dist/utils/analysisNarrative.d.ts +24 -0
  1953. package/dist/utils/analysisNarrative.d.ts.map +1 -0
  1954. package/dist/utils/analysisNarrative.js +101 -0
  1955. package/dist/utils/analysisNarrative.js.map +1 -0
  1956. package/dist/utils/atomicFileWriter.d.ts +5 -0
  1957. package/dist/utils/atomicFileWriter.d.ts.map +1 -0
  1958. package/dist/utils/atomicFileWriter.js +90 -0
  1959. package/dist/utils/atomicFileWriter.js.map +1 -0
  1960. package/dist/utils/epipeGuard.d.ts +10 -0
  1961. package/dist/utils/epipeGuard.d.ts.map +1 -0
  1962. package/dist/utils/epipeGuard.js +40 -0
  1963. package/dist/utils/epipeGuard.js.map +1 -0
  1964. package/dist/utils/httpValue.d.ts +2 -0
  1965. package/dist/utils/httpValue.d.ts.map +1 -0
  1966. package/dist/utils/httpValue.js +24 -0
  1967. package/dist/utils/httpValue.js.map +1 -0
  1968. package/dist/utils/llmJson.d.ts +33 -0
  1969. package/dist/utils/llmJson.d.ts.map +1 -0
  1970. package/dist/utils/llmJson.js +148 -0
  1971. package/dist/utils/llmJson.js.map +1 -0
  1972. package/dist/utils/llmPrivacy.d.ts +15 -0
  1973. package/dist/utils/llmPrivacy.d.ts.map +1 -0
  1974. package/dist/utils/llmPrivacy.js +126 -0
  1975. package/dist/utils/llmPrivacy.js.map +1 -0
  1976. package/dist/utils/logger.d.ts +24 -0
  1977. package/dist/utils/logger.d.ts.map +1 -0
  1978. package/dist/utils/logger.js +68 -0
  1979. package/dist/utils/logger.js.map +1 -0
  1980. package/dist/utils/traceProcessorRowUtils.d.ts +11 -0
  1981. package/dist/utils/traceProcessorRowUtils.d.ts.map +1 -0
  1982. package/dist/utils/traceProcessorRowUtils.js +64 -0
  1983. package/dist/utils/traceProcessorRowUtils.js.map +1 -0
  1984. package/dist/utils/uuid.d.ts +3 -0
  1985. package/dist/utils/uuid.d.ts.map +1 -0
  1986. package/dist/utils/uuid.js +7 -0
  1987. package/dist/utils/uuid.js.map +1 -0
  1988. package/dist/version.d.ts +2 -0
  1989. package/dist/version.d.ts.map +1 -0
  1990. package/dist/version.js +53 -0
  1991. package/dist/version.js.map +1 -0
  1992. package/package.json +128 -0
  1993. package/prebuilts/trace_processor/README.md +20 -0
  1994. package/prebuilts/trace_processor/darwin-arm64/trace_processor_shell +0 -0
  1995. package/prebuilts/trace_processor/linux-x64/trace_processor_shell +0 -0
  1996. package/prebuilts/trace_processor/win32-x64/trace_processor_shell.exe +0 -0
  1997. package/skills/README.md +686 -0
  1998. package/skills/_template/README.md +43 -0
  1999. package/skills/_template/atomic_A_template.skill.yaml +79 -0
  2000. package/skills/_template/atomic_B_template.skill.yaml +61 -0
  2001. package/skills/_template/atomic_S_template.skill.yaml +92 -0
  2002. package/skills/_template/composite_S_template.skill.yaml +198 -0
  2003. package/skills/_template/vendor_override_template.yaml +72 -0
  2004. package/skills/atomic/android_bitmap_memory_per_process.skill.yaml +203 -0
  2005. package/skills/atomic/android_dvfs_counter_stats.skill.yaml +60 -0
  2006. package/skills/atomic/android_gpu_work_period_track.skill.yaml +55 -0
  2007. package/skills/atomic/android_heap_graph_summary.skill.yaml +232 -0
  2008. package/skills/atomic/android_job_scheduler_events.skill.yaml +58 -0
  2009. package/skills/atomic/android_kernel_wakelock_summary.skill.yaml +57 -0
  2010. package/skills/atomic/anr_context_in_range.skill.yaml +99 -0
  2011. package/skills/atomic/anr_main_thread_blocking.skill.yaml +513 -0
  2012. package/skills/atomic/app_frame_production.skill.yaml +147 -0
  2013. package/skills/atomic/app_lifecycle_in_range.skill.yaml +142 -0
  2014. package/skills/atomic/app_process_starts_summary.skill.yaml +75 -0
  2015. package/skills/atomic/battery_charge_timeline.skill.yaml +72 -0
  2016. package/skills/atomic/battery_doze_state_timeline.skill.yaml +83 -0
  2017. package/skills/atomic/binder_blocking_in_range.skill.yaml +99 -0
  2018. package/skills/atomic/binder_in_range.skill.yaml +86 -0
  2019. package/skills/atomic/binder_root_cause.skill.yaml +191 -0
  2020. package/skills/atomic/binder_storm_detection.skill.yaml +394 -0
  2021. package/skills/atomic/blocking_chain_analysis.skill.yaml +316 -0
  2022. package/skills/atomic/buffer_transaction_lifecycle.skill.yaml +256 -0
  2023. package/skills/atomic/cache_miss_impact.skill.yaml +115 -0
  2024. package/skills/atomic/chrome_scroll_jank_frame_timeline.skill.yaml +337 -0
  2025. package/skills/atomic/compose_recomposition_hotspot.skill.yaml +403 -0
  2026. package/skills/atomic/consumer_jank_detection.skill.yaml +556 -0
  2027. package/skills/atomic/cpu_cluster_load_in_range.skill.yaml +138 -0
  2028. package/skills/atomic/cpu_cluster_mapping_view.skill.yaml +47 -0
  2029. package/skills/atomic/cpu_freq_timeline.skill.yaml +143 -0
  2030. package/skills/atomic/cpu_idle_analysis.skill.yaml +101 -0
  2031. package/skills/atomic/cpu_idle_state_residency.skill.yaml +54 -0
  2032. package/skills/atomic/cpu_load_in_range.skill.yaml +145 -0
  2033. package/skills/atomic/cpu_process_utilization_period.skill.yaml +51 -0
  2034. package/skills/atomic/cpu_slice_analysis.skill.yaml +118 -0
  2035. package/skills/atomic/cpu_thread_utilization_period.skill.yaml +68 -0
  2036. package/skills/atomic/cpu_throttling_in_range.skill.yaml +131 -0
  2037. package/skills/atomic/cpu_time_per_frame.skill.yaml +59 -0
  2038. package/skills/atomic/cpu_topology_detection.skill.yaml +233 -0
  2039. package/skills/atomic/cpu_topology_view.skill.yaml +272 -0
  2040. package/skills/atomic/cpu_utilization_per_period.skill.yaml +55 -0
  2041. package/skills/atomic/device_state_snapshot.skill.yaml +171 -0
  2042. package/skills/atomic/device_state_timeline.skill.yaml +308 -0
  2043. package/skills/atomic/fence_wait_decomposition.skill.yaml +314 -0
  2044. package/skills/atomic/fpsgo_analysis.skill.yaml +80 -0
  2045. package/skills/atomic/frame_blocking_calls.skill.yaml +215 -0
  2046. package/skills/atomic/frame_overrun_summary.skill.yaml +68 -0
  2047. package/skills/atomic/frame_pipeline_variance.skill.yaml +124 -0
  2048. package/skills/atomic/frame_production_gap.skill.yaml +337 -0
  2049. package/skills/atomic/frame_ui_time_breakdown.skill.yaml +58 -0
  2050. package/skills/atomic/futex_wait_distribution.skill.yaml +117 -0
  2051. package/skills/atomic/game_fps_analysis.skill.yaml +385 -0
  2052. package/skills/atomic/game_main_loop_jank.skill.yaml +309 -0
  2053. package/skills/atomic/gc_events_in_range.skill.yaml +118 -0
  2054. package/skills/atomic/gl_standalone_swap_jank.skill.yaml +259 -0
  2055. package/skills/atomic/gpu_freq_in_range.skill.yaml +99 -0
  2056. package/skills/atomic/gpu_frequency_analysis.skill.yaml +94 -0
  2057. package/skills/atomic/gpu_metrics.skill.yaml +411 -0
  2058. package/skills/atomic/gpu_power_state_analysis.skill.yaml +117 -0
  2059. package/skills/atomic/gpu_render_in_range.skill.yaml +104 -0
  2060. package/skills/atomic/input_events_in_range.skill.yaml +130 -0
  2061. package/skills/atomic/input_to_frame_latency.skill.yaml +436 -0
  2062. package/skills/atomic/linux_irq_summary.skill.yaml +66 -0
  2063. package/skills/atomic/linux_perf_counter_hotspots.skill.yaml +108 -0
  2064. package/skills/atomic/linux_process_rss_swap_timeline.skill.yaml +96 -0
  2065. package/skills/atomic/linux_runqueue_depth_timeline.skill.yaml +132 -0
  2066. package/skills/atomic/linux_sched_latency_distribution.skill.yaml +130 -0
  2067. package/skills/atomic/lmk_kill_attribution.skill.yaml +72 -0
  2068. package/skills/atomic/lock_contention_in_range.skill.yaml +402 -0
  2069. package/skills/atomic/logcat_analysis.skill.yaml +85 -0
  2070. package/skills/atomic/main_thread_file_io_in_range.skill.yaml +116 -0
  2071. package/skills/atomic/main_thread_sched_latency_in_range.skill.yaml +91 -0
  2072. package/skills/atomic/main_thread_slices_in_range.skill.yaml +129 -0
  2073. package/skills/atomic/main_thread_states_in_range.skill.yaml +105 -0
  2074. package/skills/atomic/mali_gpu_power_state.skill.yaml +54 -0
  2075. package/skills/atomic/media_codec_activity.skill.yaml +236 -0
  2076. package/skills/atomic/memory_growth_detector.skill.yaml +146 -0
  2077. package/skills/atomic/memory_pressure_in_range.skill.yaml +382 -0
  2078. package/skills/atomic/memory_rss_high_watermark.skill.yaml +62 -0
  2079. package/skills/atomic/native_heap_breakdown.skill.yaml +80 -0
  2080. package/skills/atomic/oom_adjuster_score_timeline.skill.yaml +77 -0
  2081. package/skills/atomic/page_fault_in_range.skill.yaml +113 -0
  2082. package/skills/atomic/pipeline_4feature_scoring.skill.yaml +299 -0
  2083. package/skills/atomic/pipeline_key_slices_overlay.skill.yaml +108 -0
  2084. package/skills/atomic/present_fence_timing.skill.yaml +156 -0
  2085. package/skills/atomic/process_identity_resolver.skill.yaml +503 -0
  2086. package/skills/atomic/render_pipeline_latency.skill.yaml +120 -0
  2087. package/skills/atomic/render_thread_slices.skill.yaml +107 -0
  2088. package/skills/atomic/rendering_pipeline_detection.skill.yaml +770 -0
  2089. package/skills/atomic/rn_bridge_to_frame_jank.skill.yaml +209 -0
  2090. package/skills/atomic/rn_fabric_render_jank.skill.yaml +213 -0
  2091. package/skills/atomic/sched_latency_in_range.skill.yaml +94 -0
  2092. package/skills/atomic/scheduling_analysis.skill.yaml +103 -0
  2093. package/skills/atomic/scroll_response_latency.skill.yaml +131 -0
  2094. package/skills/atomic/sf_composition_in_range.skill.yaml +99 -0
  2095. package/skills/atomic/sf_frame_consumption.skill.yaml +133 -0
  2096. package/skills/atomic/sf_layer_count_in_range.skill.yaml +155 -0
  2097. package/skills/atomic/startup_binder_in_range.skill.yaml +106 -0
  2098. package/skills/atomic/startup_binder_pool_analysis.skill.yaml +115 -0
  2099. package/skills/atomic/startup_breakdown_in_range.skill.yaml +115 -0
  2100. package/skills/atomic/startup_class_loading_in_range.skill.yaml +93 -0
  2101. package/skills/atomic/startup_cpu_placement_timeline.skill.yaml +135 -0
  2102. package/skills/atomic/startup_critical_tasks.skill.yaml +247 -0
  2103. package/skills/atomic/startup_events_in_range.skill.yaml +251 -0
  2104. package/skills/atomic/startup_freq_rampup.skill.yaml +110 -0
  2105. package/skills/atomic/startup_gc_in_range.skill.yaml +97 -0
  2106. package/skills/atomic/startup_hot_slice_states.skill.yaml +116 -0
  2107. package/skills/atomic/startup_jit_analysis.skill.yaml +158 -0
  2108. package/skills/atomic/startup_main_thread_binder_blocking_in_range.skill.yaml +114 -0
  2109. package/skills/atomic/startup_main_thread_file_io_in_range.skill.yaml +117 -0
  2110. package/skills/atomic/startup_main_thread_slices_in_range.skill.yaml +138 -0
  2111. package/skills/atomic/startup_main_thread_states_in_range.skill.yaml +100 -0
  2112. package/skills/atomic/startup_main_thread_sync_binder_in_range.skill.yaml +103 -0
  2113. package/skills/atomic/startup_sched_latency_in_range.skill.yaml +93 -0
  2114. package/skills/atomic/startup_slow_reasons.skill.yaml +625 -0
  2115. package/skills/atomic/startup_thread_blocking_graph.skill.yaml +181 -0
  2116. package/skills/atomic/system_load_in_range.skill.yaml +95 -0
  2117. package/skills/atomic/task_migration_in_range.skill.yaml +115 -0
  2118. package/skills/atomic/textureview_producer_frame_timing.skill.yaml +302 -0
  2119. package/skills/atomic/thermal_predictor.skill.yaml +182 -0
  2120. package/skills/atomic/thread_affinity_violation.skill.yaml +139 -0
  2121. package/skills/atomic/touch_to_display_latency.skill.yaml +130 -0
  2122. package/skills/atomic/util_tracking_analysis.skill.yaml +89 -0
  2123. package/skills/atomic/vrr_detection.skill.yaml +301 -0
  2124. package/skills/atomic/vsync_alignment_in_range.skill.yaml +116 -0
  2125. package/skills/atomic/vsync_config.skill.yaml +147 -0
  2126. package/skills/atomic/vsync_period_detection.skill.yaml +178 -0
  2127. package/skills/atomic/vsync_phase_alignment.skill.yaml +255 -0
  2128. package/skills/atomic/wakelock_tracking.skill.yaml +276 -0
  2129. package/skills/atomic/wattson_app_startup_power.skill.yaml +66 -0
  2130. package/skills/atomic/wattson_rails_power_breakdown.skill.yaml +70 -0
  2131. package/skills/atomic/wattson_thread_power_attribution.skill.yaml +74 -0
  2132. package/skills/atomic/webview_v8_analysis.skill.yaml +297 -0
  2133. package/skills/comparison/multi_trace_result_comparison.skill.yaml +60 -0
  2134. package/skills/composite/anr_analysis.skill.yaml +889 -0
  2135. package/skills/composite/anr_detail.skill.yaml +796 -0
  2136. package/skills/composite/battery_drain_attribution.skill.yaml +134 -0
  2137. package/skills/composite/binder_analysis.skill.yaml +742 -0
  2138. package/skills/composite/binder_detail.skill.yaml +388 -0
  2139. package/skills/composite/block_io_analysis.skill.yaml +559 -0
  2140. package/skills/composite/click_response_analysis.skill.yaml +915 -0
  2141. package/skills/composite/click_response_detail.skill.yaml +800 -0
  2142. package/skills/composite/cpu_analysis.skill.yaml +960 -0
  2143. package/skills/composite/dmabuf_analysis.skill.yaml +622 -0
  2144. package/skills/composite/flutter_scrolling_analysis.skill.yaml +443 -0
  2145. package/skills/composite/gc_analysis.skill.yaml +744 -0
  2146. package/skills/composite/global_trace_sanity_check.skill.yaml +716 -0
  2147. package/skills/composite/gpu_analysis.skill.yaml +700 -0
  2148. package/skills/composite/io_pressure.skill.yaml +654 -0
  2149. package/skills/composite/irq_analysis.skill.yaml +696 -0
  2150. package/skills/composite/jank_frame_detail.skill.yaml +2065 -0
  2151. package/skills/composite/lmk_analysis.skill.yaml +626 -0
  2152. package/skills/composite/lock_binder_wait.skill.yaml +95 -0
  2153. package/skills/composite/lock_contention_analysis.skill.yaml +878 -0
  2154. package/skills/composite/memory_analysis.skill.yaml +718 -0
  2155. package/skills/composite/navigation_analysis.skill.yaml +901 -0
  2156. package/skills/composite/network_analysis.skill.yaml +760 -0
  2157. package/skills/composite/power_consumption_overview.skill.yaml +143 -0
  2158. package/skills/composite/scene_reconstruction.skill.yaml +2788 -0
  2159. package/skills/composite/scroll_session_analysis.skill.yaml +496 -0
  2160. package/skills/composite/scrolling_analysis.skill.yaml +3295 -0
  2161. package/skills/composite/startup_analysis.skill.yaml +1172 -0
  2162. package/skills/composite/startup_detail.skill.yaml +1339 -0
  2163. package/skills/composite/state_timeline.skill.yaml +1021 -0
  2164. package/skills/composite/surfaceflinger_analysis.skill.yaml +808 -0
  2165. package/skills/composite/suspend_wakeup_analysis.skill.yaml +698 -0
  2166. package/skills/composite/thermal_throttling.skill.yaml +964 -0
  2167. package/skills/composite/thermal_throttling_chain.skill.yaml +147 -0
  2168. package/skills/composite/webview_drawfunctor_jank_chain.skill.yaml +343 -0
  2169. package/skills/config/conclusion_scene_templates.base.yaml +181 -0
  2170. package/skills/config/conclusion_scene_templates.yaml +17 -0
  2171. package/skills/deep/callstack_analysis.skill.yaml +436 -0
  2172. package/skills/deep/cpu_profiling.skill.yaml +617 -0
  2173. package/skills/docs/scrolling.sop.md +312 -0
  2174. package/skills/docs/startup.sop.md +382 -0
  2175. package/skills/docs/upstream-perfetto-ai-skill-translation.sop.md +50 -0
  2176. package/skills/fragments/target_threads.sql +34 -0
  2177. package/skills/fragments/thread_states_quadrant.sql +26 -0
  2178. package/skills/fragments/vsync_config.sql +32 -0
  2179. package/skills/modules/app/launcher_module.skill.yaml +473 -0
  2180. package/skills/modules/app/systemui_module.skill.yaml +565 -0
  2181. package/skills/modules/app/third_party_module.skill.yaml +275 -0
  2182. package/skills/modules/framework/ams_module.skill.yaml +239 -0
  2183. package/skills/modules/framework/art_module.skill.yaml +266 -0
  2184. package/skills/modules/framework/choreographer_module.skill.yaml +419 -0
  2185. package/skills/modules/framework/input_module.skill.yaml +219 -0
  2186. package/skills/modules/framework/surfaceflinger_module.skill.yaml +343 -0
  2187. package/skills/modules/framework/wms_module.skill.yaml +356 -0
  2188. package/skills/modules/hardware/cpu_module.skill.yaml +300 -0
  2189. package/skills/modules/hardware/gpu_module.skill.yaml +229 -0
  2190. package/skills/modules/hardware/memory_module.skill.yaml +443 -0
  2191. package/skills/modules/hardware/power_module.skill.yaml +377 -0
  2192. package/skills/modules/hardware/thermal_module.skill.yaml +410 -0
  2193. package/skills/modules/kernel/binder_module.skill.yaml +223 -0
  2194. package/skills/modules/kernel/filesystem_module.skill.yaml +423 -0
  2195. package/skills/modules/kernel/lock_contention_module.skill.yaml +424 -0
  2196. package/skills/modules/kernel/scheduler_module.skill.yaml +247 -0
  2197. package/skills/pipelines/_base.skill.yaml +103 -0
  2198. package/skills/pipelines/android_pip_freeform.skill.yaml +224 -0
  2199. package/skills/pipelines/android_view_mixed.skill.yaml +305 -0
  2200. package/skills/pipelines/android_view_multi_window.skill.yaml +271 -0
  2201. package/skills/pipelines/android_view_software.skill.yaml +172 -0
  2202. package/skills/pipelines/android_view_standard_blast.skill.yaml +357 -0
  2203. package/skills/pipelines/android_view_standard_legacy.skill.yaml +233 -0
  2204. package/skills/pipelines/angle_gles_vulkan.skill.yaml +178 -0
  2205. package/skills/pipelines/camera_pipeline.skill.yaml +215 -0
  2206. package/skills/pipelines/chrome_browser_viz.skill.yaml +288 -0
  2207. package/skills/pipelines/compose_standard.skill.yaml +250 -0
  2208. package/skills/pipelines/flutter_surfaceview_impeller.skill.yaml +233 -0
  2209. package/skills/pipelines/flutter_surfaceview_skia.skill.yaml +194 -0
  2210. package/skills/pipelines/flutter_textureview.skill.yaml +219 -0
  2211. package/skills/pipelines/game_engine.skill.yaml +311 -0
  2212. package/skills/pipelines/hardware_buffer_renderer.skill.yaml +205 -0
  2213. package/skills/pipelines/imagereader_pipeline.skill.yaml +237 -0
  2214. package/skills/pipelines/index.yaml +122 -0
  2215. package/skills/pipelines/opengl_es.skill.yaml +185 -0
  2216. package/skills/pipelines/rn_new_arch.skill.yaml +126 -0
  2217. package/skills/pipelines/rn_old_arch.skill.yaml +137 -0
  2218. package/skills/pipelines/rn_skia.skill.yaml +115 -0
  2219. package/skills/pipelines/software_compositing.skill.yaml +203 -0
  2220. package/skills/pipelines/surface_control_api.skill.yaml +208 -0
  2221. package/skills/pipelines/surfaceview_blast.skill.yaml +210 -0
  2222. package/skills/pipelines/textureview_standard.skill.yaml +301 -0
  2223. package/skills/pipelines/variable_refresh_rate.skill.yaml +264 -0
  2224. package/skills/pipelines/video_overlay_hwc.skill.yaml +193 -0
  2225. package/skills/pipelines/vulkan_native.skill.yaml +215 -0
  2226. package/skills/pipelines/webview_gl_functor.skill.yaml +232 -0
  2227. package/skills/pipelines/webview_surface_control.skill.yaml +187 -0
  2228. package/skills/pipelines/webview_surfaceview_wrapper.skill.yaml +196 -0
  2229. package/skills/pipelines/webview_textureview_custom.skill.yaml +201 -0
  2230. package/skills/vendors/honor/startup.override.yaml +117 -0
  2231. package/skills/vendors/mtk/startup.override.yaml +133 -0
  2232. package/skills/vendors/oppo/startup.override.yaml +188 -0
  2233. package/skills/vendors/pixel/startup.override.yaml +163 -0
  2234. package/skills/vendors/qualcomm/startup.override.yaml +175 -0
  2235. package/skills/vendors/samsung/startup.override.yaml +161 -0
  2236. package/skills/vendors/vivo/startup.override.yaml +144 -0
  2237. package/skills/vendors/xiaomi/startup.override.yaml +120 -0
  2238. package/sql/smartperfetto/PACKAGE.json +24 -0
  2239. package/sql/smartperfetto/binder/victim_to_server.sql +36 -0
  2240. package/sql/smartperfetto/scrolling/jank_frames.sql +55 -0
  2241. package/strategies/anr.strategy.md +200 -0
  2242. package/strategies/arch-compose.template.md +10 -0
  2243. package/strategies/arch-flutter.template.md +17 -0
  2244. package/strategies/arch-standard.template.md +31 -0
  2245. package/strategies/arch-webview.template.md +9 -0
  2246. package/strategies/comparison-conclusion.template.md +36 -0
  2247. package/strategies/comparison-methodology.template.md +41 -0
  2248. package/strategies/comparison-result-methodology.template.md +35 -0
  2249. package/strategies/game.strategy.md +121 -0
  2250. package/strategies/general.strategy.md +48 -0
  2251. package/strategies/interaction.strategy.md +149 -0
  2252. package/strategies/knowledge-binder-ipc.template.md +59 -0
  2253. package/strategies/knowledge-cpu-scheduler.template.md +67 -0
  2254. package/strategies/knowledge-data-sources.template.md +738 -0
  2255. package/strategies/knowledge-gc-dynamics.template.md +65 -0
  2256. package/strategies/knowledge-harmonyos-rendering.template.md +54 -0
  2257. package/strategies/knowledge-harmonyos-tools.template.md +73 -0
  2258. package/strategies/knowledge-lock-contention.template.md +61 -0
  2259. package/strategies/knowledge-pipeline-anchors.template.md +136 -0
  2260. package/strategies/knowledge-pipeline-fences.template.md +158 -0
  2261. package/strategies/knowledge-rendering-pipeline.template.md +170 -0
  2262. package/strategies/knowledge-startup-root-causes.template.md +951 -0
  2263. package/strategies/knowledge-thermal-throttling.template.md +53 -0
  2264. package/strategies/linux.strategy.md +86 -0
  2265. package/strategies/media.strategy.md +75 -0
  2266. package/strategies/memory.strategy.md +94 -0
  2267. package/strategies/multi-trace-result-comparison.strategy.md +96 -0
  2268. package/strategies/network.strategy.md +80 -0
  2269. package/strategies/overview.strategy.md +139 -0
  2270. package/strategies/phase_hint_templates/misdiagnosis_vsync_vrr.template.yaml +37 -0
  2271. package/strategies/pipeline.strategy.md +208 -0
  2272. package/strategies/power.strategy.md +165 -0
  2273. package/strategies/prompt-complexity-classifier.template.md +26 -0
  2274. package/strategies/prompt-language-en.template.md +9 -0
  2275. package/strategies/prompt-language-zh.template.md +8 -0
  2276. package/strategies/prompt-methodology.template.md +183 -0
  2277. package/strategies/prompt-output-format.template.md +115 -0
  2278. package/strategies/prompt-quick.template.md +44 -0
  2279. package/strategies/prompt-role.template.md +13 -0
  2280. package/strategies/runtime-correctness.strategy.md +73 -0
  2281. package/strategies/scroll-response.strategy.md +236 -0
  2282. package/strategies/scrolling.strategy.md +467 -0
  2283. package/strategies/selection-area.template.md +46 -0
  2284. package/strategies/selection-slice.template.md +126 -0
  2285. package/strategies/startup.strategy.md +694 -0
  2286. package/strategies/teaching.strategy.md +176 -0
  2287. package/strategies/touch-tracking.strategy.md +213 -0
@@ -0,0 +1,4109 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: AGPL-3.0-or-later
3
+ // Copyright (C) 2024-2026 Gracker (Chris)
4
+ // This file is part of SmartPerfetto. See LICENSE for details.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deriveConclusionContract = deriveConclusionContract;
7
+ exports.renderConclusionContractMarkdown = renderConclusionContractMarkdown;
8
+ exports.generateConclusion = generateConclusion;
9
+ exports.generateSimpleConclusion = generateSimpleConclusion;
10
+ exports.shouldNormalizeConclusionOutput = shouldNormalizeConclusionOutput;
11
+ exports.normalizeConclusionOutput = normalizeConclusionOutput;
12
+ const jankCauseSummarizer_1 = require("./jankCauseSummarizer");
13
+ const analysisNarrative_1 = require("../../utils/analysisNarrative");
14
+ const conclusionSceneTemplates_1 = require("./conclusionSceneTemplates");
15
+ const DISABLED_FLAG_VALUES = new Set(['0', 'false', 'off', 'no']);
16
+ const ENABLED_FLAG_VALUES = new Set(['1', 'true', 'on', 'yes']);
17
+ const PROMPT_FINDING_LIMIT = 8;
18
+ const PROMPT_FINDING_OTHER_FIELDS_LIMIT = 8;
19
+ const PROMPT_FINDING_OTHER_FIELD_MAX_CHARS = 90;
20
+ const PROMPT_FINDING_PRIORITY_FIELD_MAX_CHARS = 140;
21
+ const PROMPT_FINDING_EVIDENCE_ITEMS_LIMIT = 4;
22
+ const PROMPT_FINDING_EVIDENCE_MAX_CHARS = 120;
23
+ const STARTUP_WRAPPER_SLICE_RE = /\b(clientTransactionExecuted|activityStart|bindApplication|performCreate:)/i;
24
+ const STARTUP_ACTIONABLE_HINT_RE = /\b(LoadSimulator_|ChaosTask|SimulateInflation|RealInflation|AppInit|ActivityInit)\b/i;
25
+ const DEFAULT_TOP_CLUSTER_FRAME_RENDER_LIMIT = 5;
26
+ const DEFAULT_FULL_CLUSTER_FRAME_RENDER_LIMIT = 120;
27
+ const STRUCTURED_ACTION_ITEM_RE = /(?=.*(?:owner|责任人)\s*[::=])(?=.*(?:priority|优先级)\s*[::=])(?=.*(?:verification|验证)\s*[::=])/i;
28
+ const SYSTEM_CONTEXT_SKILL_HINTS = {
29
+ io_pressure: {
30
+ owner: '存储/内核团队',
31
+ verification: '复跑同时间窗 trace,确认 total_io_wait_ms 与长 IO 事件数下降,且关键卡顿帧无回归',
32
+ },
33
+ network_analysis: {
34
+ owner: '网络/接入团队',
35
+ verification: '复跑同时间窗 trace,确认 total_mb 与 active_periods 下降,并验证关键交互帧无新增掉帧',
36
+ },
37
+ thermal_throttling: {
38
+ owner: '热管理/性能团队',
39
+ verification: '复跑同时间窗 trace,确认峰值温度与降频占比下降,并验证 jank_rate 改善',
40
+ },
41
+ };
42
+ function isJankSceneId(sceneId) {
43
+ return String(sceneId || '').trim().toLowerCase() === 'jank';
44
+ }
45
+ function resolveClusterSectionHeading(sceneId) {
46
+ return isJankSceneId(sceneId)
47
+ ? '## 掉帧聚类(先看大头)'
48
+ : '## 聚类(先看大头)';
49
+ }
50
+ function normalizeFindingTitleKey(title) {
51
+ return String(title || '')
52
+ .trim()
53
+ .replace(/\s+/g, ' ')
54
+ .toLowerCase();
55
+ }
56
+ function dedupeFindingsForConclusion(findings) {
57
+ const merged = new Map();
58
+ for (const finding of findings) {
59
+ const key = normalizeFindingTitleKey(finding.title || '');
60
+ if (!key)
61
+ continue;
62
+ if (!merged.has(key)) {
63
+ merged.set(key, finding);
64
+ continue;
65
+ }
66
+ const existing = merged.get(key);
67
+ const existingScore = Number(existing.confidence || 0.5);
68
+ const candidateScore = Number(finding.confidence || 0.5);
69
+ if (candidateScore > existingScore) {
70
+ merged.set(key, finding);
71
+ }
72
+ }
73
+ return Array.from(merged.values());
74
+ }
75
+ function isStartupDetailFinding(finding) {
76
+ const src = String(finding.source || '').toLowerCase();
77
+ if (src.includes('startup_detail'))
78
+ return true;
79
+ const title = String(finding.title || '');
80
+ return title.includes('启动') || title.includes('温启动') || title.includes('冷启动') || title.includes('热启动');
81
+ }
82
+ function isStartupFrameworkWrapperFinding(finding) {
83
+ if (!isStartupDetailFinding(finding))
84
+ return false;
85
+ const text = `${String(finding.title || '')}\n${String(finding.description || '')}`;
86
+ return STARTUP_WRAPPER_SLICE_RE.test(text);
87
+ }
88
+ function hasStartupActionableFinding(findings) {
89
+ return findings.some((finding) => {
90
+ if (!isStartupDetailFinding(finding))
91
+ return false;
92
+ const text = `${String(finding.title || '')}\n${String(finding.description || '')}`;
93
+ if (text.includes('主线程可操作热点'))
94
+ return true;
95
+ return STARTUP_ACTIONABLE_HINT_RE.test(text);
96
+ });
97
+ }
98
+ function sanitizeFindingsForConclusion(allFindings) {
99
+ const deduped = dedupeFindingsForConclusion(allFindings);
100
+ if (deduped.length === 0)
101
+ return deduped;
102
+ const actionableStartupExists = hasStartupActionableFinding(deduped);
103
+ if (!actionableStartupExists)
104
+ return deduped;
105
+ return deduped.filter((finding) => !isStartupFrameworkWrapperFinding(finding));
106
+ }
107
+ function toEvidenceArray(evidence) {
108
+ if (Array.isArray(evidence)) {
109
+ return evidence;
110
+ }
111
+ return evidence ? [evidence] : [];
112
+ }
113
+ function asEvidenceObject(value) {
114
+ if (!value || typeof value !== 'object') {
115
+ return null;
116
+ }
117
+ return value;
118
+ }
119
+ function stringifyValue(value, maxLength) {
120
+ if (value && typeof value === 'object') {
121
+ return JSON.stringify(value).slice(0, maxLength);
122
+ }
123
+ return String(value);
124
+ }
125
+ function normalizeOptionalFlagValue(value) {
126
+ if (value === undefined || value === null) {
127
+ return null;
128
+ }
129
+ const normalized = String(value).trim().toLowerCase();
130
+ return normalized.length > 0 ? normalized : null;
131
+ }
132
+ function isFollowUpConclusionTurn(turnCount, intent) {
133
+ return turnCount >= 1 || Boolean(intent.followUpType && intent.followUpType !== 'initial');
134
+ }
135
+ function collectEntityIds(intent, entityType) {
136
+ const ids = new Set();
137
+ const params = intent.extractedParams || {};
138
+ if (entityType === 'frame') {
139
+ const frameId = params.frame_id ?? params.frameId;
140
+ if (frameId !== undefined && frameId !== null)
141
+ ids.add(String(frameId));
142
+ }
143
+ else {
144
+ const sessionId = params.session_id ?? params.sessionId;
145
+ if (sessionId !== undefined && sessionId !== null)
146
+ ids.add(String(sessionId));
147
+ }
148
+ for (const entity of intent.referencedEntities || []) {
149
+ if (entity.type !== entityType)
150
+ continue;
151
+ const raw = entity.value !== undefined ? entity.value : entity.id;
152
+ if (raw !== undefined && raw !== null)
153
+ ids.add(String(raw));
154
+ }
155
+ return Array.from(ids).map(id => id.trim()).filter(id => id.length > 0);
156
+ }
157
+ function isSingleFrameDrillDown(intent) {
158
+ if (intent.followUpType !== 'drill_down')
159
+ return false;
160
+ const frameIds = collectEntityIds(intent, 'frame');
161
+ return frameIds.length === 1;
162
+ }
163
+ function isInsightConclusionEnabled() {
164
+ // Default ON (per user request). Allow disabling for rollback.
165
+ const override = process.env.SMARTPERFETTO_CONCLUSION_V2 ??
166
+ process.env.SMARTPERFETTO_INSIGHT_CONCLUSION;
167
+ const normalized = normalizeOptionalFlagValue(override);
168
+ if (!normalized) {
169
+ return true;
170
+ }
171
+ if (DISABLED_FLAG_VALUES.has(normalized))
172
+ return false;
173
+ if (ENABLED_FLAG_VALUES.has(normalized))
174
+ return true;
175
+ return true;
176
+ }
177
+ function selectConclusionOutputMode(params) {
178
+ const { turnCount, intent, findingsCount, confirmedHypothesesCount, hasJankSummary, } = params;
179
+ const isFollowUp = isFollowUpConclusionTurn(turnCount, intent);
180
+ const hasAnyEvidence = findingsCount > 0 || confirmedHypothesesCount > 0 || hasJankSummary;
181
+ if (!hasAnyEvidence) {
182
+ return 'need_input';
183
+ }
184
+ if (!isFollowUp) {
185
+ return 'initial_report';
186
+ }
187
+ return 'focused_answer';
188
+ }
189
+ function resolveConclusionOutputMode(params) {
190
+ const { insightEnabled, turnCount, intent, findingsCount, confirmedHypothesesCount, hasJankSummary, } = params;
191
+ if (!insightEnabled) {
192
+ return isFollowUpConclusionTurn(turnCount, intent) ? 'focused_answer' : 'initial_report';
193
+ }
194
+ return selectConclusionOutputMode({
195
+ turnCount,
196
+ intent,
197
+ findingsCount,
198
+ confirmedHypothesesCount,
199
+ hasJankSummary,
200
+ });
201
+ }
202
+ /**
203
+ * Format a finding with its evidence data for LLM consumption.
204
+ * Includes title, description, and key data entries from details.
205
+ *
206
+ * Key design decisions:
207
+ * - Priority fields (root_cause, primary_cause, cause_type) are preserved fully
208
+ * - Other details are truncated to manage token usage
209
+ * - Evidence is preserved with reasonable limits
210
+ */
211
+ function formatFindingWithEvidence(f) {
212
+ let result = `- [${f.severity}] ${f.title}`;
213
+ if (f.description) {
214
+ result += `\n 描述: ${f.description}`;
215
+ }
216
+ if (f.details && typeof f.details === 'object' && Object.keys(f.details).length > 0) {
217
+ // Priority fields that should be preserved in full
218
+ const priorityFields = [
219
+ 'root_cause',
220
+ 'primary_cause',
221
+ 'deep_reason',
222
+ 'reason_code',
223
+ 'optimization_hint',
224
+ 'cause_type',
225
+ 'supply_constraint',
226
+ 'trigger_layer',
227
+ 'amplification_path',
228
+ 'owner',
229
+ 'priority',
230
+ 'action',
231
+ 'verification',
232
+ 'system_context',
233
+ 'systemContext',
234
+ 'confidence',
235
+ 'jank_type',
236
+ ];
237
+ const details = f.details;
238
+ // First, output priority fields without truncation
239
+ const priorityEntries = [];
240
+ for (const field of priorityFields) {
241
+ if (details[field] !== undefined) {
242
+ const val = stringifyValue(details[field], PROMPT_FINDING_PRIORITY_FIELD_MAX_CHARS);
243
+ priorityEntries.push(`${field}: ${val}`);
244
+ }
245
+ }
246
+ // Then, output other fields with truncation
247
+ const otherEntries = Object.entries(details)
248
+ .filter(([k]) => !priorityFields.includes(k))
249
+ .slice(0, PROMPT_FINDING_OTHER_FIELDS_LIMIT)
250
+ .map(([k, v]) => `${k}: ${stringifyValue(v, PROMPT_FINDING_OTHER_FIELD_MAX_CHARS)}`);
251
+ const allEntries = [...priorityEntries, ...otherEntries];
252
+ if (allEntries.length > 0) {
253
+ result += `\n 数据: { ${allEntries.join(', ')} }`;
254
+ }
255
+ }
256
+ // Preserve evidence with compact limits to avoid prompt bloat on large traces
257
+ if (f.evidence && Array.isArray(f.evidence) && f.evidence.length > 0) {
258
+ const evidenceStr = f.evidence
259
+ .slice(0, PROMPT_FINDING_EVIDENCE_ITEMS_LIMIT)
260
+ .map(e => stringifyValue(e, PROMPT_FINDING_EVIDENCE_MAX_CHARS))
261
+ .join('; ');
262
+ result += `\n 证据: ${evidenceStr}`;
263
+ }
264
+ return result;
265
+ }
266
+ const APP_LIKE_CAUSE_TYPES = new Set([
267
+ 'slice',
268
+ 'blocking',
269
+ 'io_blocking',
270
+ 'cpu_contention',
271
+ 'cpu_overload',
272
+ 'sched_latency',
273
+ 'small_core',
274
+ 'freq_limit',
275
+ ]);
276
+ const SF_LIKE_CAUSE_TYPES = new Set([
277
+ 'gpu_fence',
278
+ 'render_wait',
279
+ ]);
280
+ const TRIGGER_CAUSE_TYPES = new Set([
281
+ 'slice',
282
+ 'blocking',
283
+ 'io_blocking',
284
+ ]);
285
+ const SUPPLY_CAUSE_TYPES = new Set([
286
+ 'cpu_overload',
287
+ 'freq_limit',
288
+ 'sched_latency',
289
+ 'small_core',
290
+ 'cpu_contention',
291
+ ]);
292
+ const AMPLIFICATION_CAUSE_TYPES = new Set([
293
+ 'gpu_fence',
294
+ 'render_wait',
295
+ ]);
296
+ function toFiniteNumber(v) {
297
+ const n = Number(v);
298
+ return Number.isFinite(n) ? n : 0;
299
+ }
300
+ function collectFindingTextSources(finding) {
301
+ const textParts = [
302
+ String(finding.title || ''),
303
+ String(finding.description || ''),
304
+ ];
305
+ const evidence = finding.evidence;
306
+ const evidenceItems = Array.isArray(evidence) ? evidence : (evidence ? [evidence] : []);
307
+ for (const item of evidenceItems) {
308
+ if (typeof item === 'string') {
309
+ textParts.push(item);
310
+ continue;
311
+ }
312
+ if (item && typeof item === 'object') {
313
+ textParts.push(JSON.stringify(item).slice(0, 500));
314
+ }
315
+ }
316
+ return textParts.join('\n');
317
+ }
318
+ function extractResponsibilityDistributionFromFindings(findings) {
319
+ let sfCount = 0;
320
+ let sfPct = 0;
321
+ let appCount = 0;
322
+ let appPct = 0;
323
+ const pairRe = /(SF|APP)\s+(\d+)\s*\((\d+(?:\.\d+)?)%\)/ig;
324
+ for (const f of findings) {
325
+ const text = collectFindingTextSources(f);
326
+ for (const m of text.matchAll(pairRe)) {
327
+ const side = String(m[1] || '').toUpperCase();
328
+ const count = toFiniteNumber(m[2]);
329
+ const pct = toFiniteNumber(m[3]);
330
+ if (side === 'SF') {
331
+ if (count > sfCount || (count === sfCount && pct > sfPct)) {
332
+ sfCount = count;
333
+ sfPct = pct;
334
+ }
335
+ }
336
+ else if (side === 'APP') {
337
+ if (count > appCount || (count === appCount && pct > appPct)) {
338
+ appCount = count;
339
+ appPct = pct;
340
+ }
341
+ }
342
+ }
343
+ }
344
+ return { sfCount, sfPct, appCount, appPct };
345
+ }
346
+ function extractConsumerStatsFromFindings(findings) {
347
+ let frames = 0;
348
+ let rate = 0;
349
+ const textRe = /消费端\s*[::]\s*(\d+)\s*帧\s*\((\d+(?:\.\d+)?)%\)/ig;
350
+ for (const f of findings) {
351
+ const details = (f.details && typeof f.details === 'object') ? f.details : {};
352
+ const allSources = (details.allSources && typeof details.allSources === 'object')
353
+ ? details.allSources
354
+ : {};
355
+ const consumer = allSources.consumer && typeof allSources.consumer === 'object'
356
+ ? allSources.consumer
357
+ : {};
358
+ if (consumer.count !== undefined || consumer.rate !== undefined) {
359
+ const c = toFiniteNumber(consumer.count);
360
+ const r = toFiniteNumber(consumer.rate);
361
+ if (c > frames || (c === frames && r > rate)) {
362
+ frames = c;
363
+ rate = r;
364
+ }
365
+ }
366
+ const text = collectFindingTextSources(f);
367
+ for (const m of text.matchAll(textRe)) {
368
+ const c = toFiniteNumber(m[1]);
369
+ const r = toFiniteNumber(m[2]);
370
+ if (c > frames || (c === frames && r > rate)) {
371
+ frames = c;
372
+ rate = r;
373
+ }
374
+ }
375
+ }
376
+ return { frames, rate };
377
+ }
378
+ function deriveAttributionAssessment(findings, jankSummary) {
379
+ const rationale = [];
380
+ const frameSample = toFiniteNumber(jankSummary?.totalJankFrames);
381
+ const allCauses = Array.isArray(jankSummary?.allCauses) ? jankSummary.allCauses : [];
382
+ let appLikePct = 0;
383
+ let sfLikePct = 0;
384
+ for (const c of allCauses) {
385
+ const ct = String(c.causeType || '').toLowerCase();
386
+ const pct = toFiniteNumber(c.percentage);
387
+ if (APP_LIKE_CAUSE_TYPES.has(ct))
388
+ appLikePct += pct;
389
+ if (SF_LIKE_CAUSE_TYPES.has(ct))
390
+ sfLikePct += pct;
391
+ }
392
+ const resp = extractResponsibilityDistributionFromFindings(findings);
393
+ const consumer = extractConsumerStatsFromFindings(findings);
394
+ let appScore = 0;
395
+ let sfScore = 0;
396
+ if (frameSample >= 3) {
397
+ if (appLikePct >= 70) {
398
+ appScore += 4;
399
+ rationale.push(`逐帧根因中 APP/主线程侧占比 ${appLikePct.toFixed(1)}%`);
400
+ }
401
+ else if (appLikePct >= 50) {
402
+ appScore += 3;
403
+ rationale.push(`逐帧根因中 APP/主线程侧占比 ${appLikePct.toFixed(1)}%`);
404
+ }
405
+ else if (appLikePct > 0) {
406
+ appScore += 1;
407
+ }
408
+ if (sfLikePct >= 70) {
409
+ sfScore += 4;
410
+ rationale.push(`逐帧根因中 SF/GPU 侧占比 ${sfLikePct.toFixed(1)}%`);
411
+ }
412
+ else if (sfLikePct >= 50) {
413
+ sfScore += 3;
414
+ rationale.push(`逐帧根因中 SF/GPU 侧占比 ${sfLikePct.toFixed(1)}%`);
415
+ }
416
+ else if (sfLikePct > 0) {
417
+ sfScore += 1;
418
+ }
419
+ if (frameSample >= 10) {
420
+ appScore += 1;
421
+ sfScore += 1;
422
+ }
423
+ else {
424
+ rationale.push(`逐帧样本量偏小(${frameSample} 帧)`);
425
+ }
426
+ }
427
+ else if (frameSample > 0) {
428
+ rationale.push(`逐帧样本不足(${frameSample} 帧)`);
429
+ }
430
+ if (resp.sfCount >= 20 && resp.sfPct >= 80) {
431
+ sfScore += 2;
432
+ rationale.push(`责任分布显示 SF ${resp.sfCount} 帧 (${resp.sfPct.toFixed(1)}%)`);
433
+ }
434
+ else if (resp.sfCount > 0) {
435
+ rationale.push(`责任分布样本较小(SF ${resp.sfCount} 帧)`);
436
+ }
437
+ if (resp.appCount >= 5 && resp.appPct >= 30) {
438
+ appScore += 1;
439
+ }
440
+ if (consumer.frames >= 100 && consumer.rate >= 50) {
441
+ sfScore += 1;
442
+ rationale.push(`全局消费端掉帧 ${consumer.frames} 帧 (${consumer.rate.toFixed(1)}%)`);
443
+ }
444
+ else if (consumer.frames > 0) {
445
+ rationale.push(`消费端统计样本 ${consumer.frames} 帧 (${consumer.rate.toFixed(1)}%)`);
446
+ }
447
+ let verdict = 'INSUFFICIENT';
448
+ if (frameSample === 0 && resp.sfCount === 0 && consumer.frames === 0) {
449
+ verdict = 'INSUFFICIENT';
450
+ }
451
+ else if (frameSample >= 3 &&
452
+ appLikePct >= 60 &&
453
+ (resp.sfPct >= 70 || consumer.rate >= 50)) {
454
+ verdict = 'MIXED';
455
+ }
456
+ else if (appScore >= sfScore + 2) {
457
+ verdict = 'APP_TRIGGER';
458
+ }
459
+ else if (sfScore >= appScore + 2) {
460
+ verdict = 'SF_CONSUMER';
461
+ }
462
+ else if (appScore > 0 && sfScore > 0) {
463
+ verdict = 'MIXED';
464
+ }
465
+ else {
466
+ verdict = 'INSUFFICIENT';
467
+ }
468
+ let confidence = 0.35;
469
+ if (verdict !== 'INSUFFICIENT') {
470
+ const sampleBoost = frameSample >= 10 ? 0.15 : frameSample >= 3 ? 0.08 : 0;
471
+ const respBoost = resp.sfCount >= 20 ? 0.08 : 0;
472
+ const consumerBoost = consumer.frames >= 100 ? 0.05 : 0;
473
+ const scoreGapBoost = Math.min(0.15, Math.abs(appScore - sfScore) * 0.03);
474
+ confidence = Math.min(0.9, 0.5 + sampleBoost + respBoost + consumerBoost + scoreGapBoost);
475
+ }
476
+ return {
477
+ verdict,
478
+ confidence,
479
+ frameSample,
480
+ appLikePct,
481
+ sfLikePct,
482
+ sfRespSample: resp.sfCount,
483
+ sfRespPct: resp.sfPct,
484
+ appRespSample: resp.appCount,
485
+ appRespPct: resp.appPct,
486
+ consumerFrames: consumer.frames,
487
+ consumerRate: consumer.rate,
488
+ rationale,
489
+ };
490
+ }
491
+ function getAllCauses(jankSummary) {
492
+ if (!jankSummary || !Array.isArray(jankSummary.allCauses)) {
493
+ return [];
494
+ }
495
+ return jankSummary.allCauses.map(c => ({
496
+ causeType: String(c.causeType || '').toLowerCase(),
497
+ label: String(c.label || c.causeType || 'unknown'),
498
+ percentage: toFiniteNumber(c.percentage),
499
+ frameCount: toFiniteNumber(c.frameCount),
500
+ }));
501
+ }
502
+ function getCausePercentage(allCauses, causeType) {
503
+ const row = allCauses.find(c => c.causeType === causeType);
504
+ return row ? row.percentage : 0;
505
+ }
506
+ function getTopCauseByGroup(allCauses, group) {
507
+ const candidates = allCauses.filter(c => group.has(c.causeType));
508
+ if (candidates.length === 0)
509
+ return null;
510
+ candidates.sort((a, b) => b.percentage - a.percentage);
511
+ return candidates[0];
512
+ }
513
+ function getTopClusterHints(jankSummary) {
514
+ const clusters = jankSummary?.clusters;
515
+ if (!Array.isArray(clusters) || clusters.length === 0) {
516
+ return [];
517
+ }
518
+ return clusters.slice(0, 3).map((cluster) => {
519
+ const id = String(cluster.clusterId || 'K?');
520
+ const trigger = String(cluster.triggerFactor || 'unknown');
521
+ const supply = String(cluster.supplyConstraint || 'unknown');
522
+ const amp = String(cluster.amplificationPath || 'unknown');
523
+ const count = toFiniteNumber(cluster.frameCount);
524
+ const pct = toFiniteNumber(cluster.percentage).toFixed(1);
525
+ return `${id}: ${trigger} / ${supply} / ${amp}(${count}帧, ${pct}%)`;
526
+ });
527
+ }
528
+ function getWorkloadDominantCluster(jankSummary) {
529
+ const clusters = jankSummary?.clusters;
530
+ if (!Array.isArray(clusters) || clusters.length === 0) {
531
+ return null;
532
+ }
533
+ const dominant = clusters.find((cluster) => {
534
+ const supply = String(cluster?.supplyConstraint || '').trim();
535
+ return supply === analysisNarrative_1.SUPPLY_WORKLOAD_WEAK_TEXT;
536
+ });
537
+ if (!dominant) {
538
+ return null;
539
+ }
540
+ return {
541
+ clusterId: String(dominant.clusterId || 'K?'),
542
+ frameCount: toFiniteNumber(dominant.frameCount),
543
+ percentage: toFiniteNumber(dominant.percentage),
544
+ frameIds: readClusterFrameIds(dominant),
545
+ samplePrimaryCauses: Array.isArray(dominant.samplePrimaryCauses)
546
+ ? dominant.samplePrimaryCauses.map((v) => String(v)).filter(Boolean).slice(0, 2)
547
+ : [],
548
+ };
549
+ }
550
+ function readClusterFrameIds(cluster) {
551
+ const rawFrameIds = Array.isArray(cluster.frameIds)
552
+ ? cluster.frameIds
553
+ : (Array.isArray(cluster.representativeFrames) ? cluster.representativeFrames : []);
554
+ return Array.from(new Set(rawFrameIds.map((v) => String(v)).filter(Boolean)));
555
+ }
556
+ function resolveClusterFrameLimit(mode, maxFramesPerCluster) {
557
+ if (mode === 'none')
558
+ return 0;
559
+ if (Number.isFinite(maxFramesPerCluster) && (maxFramesPerCluster || 0) > 0) {
560
+ return Math.round(maxFramesPerCluster);
561
+ }
562
+ return mode === 'top'
563
+ ? DEFAULT_TOP_CLUSTER_FRAME_RENDER_LIMIT
564
+ : DEFAULT_FULL_CLUSTER_FRAME_RENDER_LIMIT;
565
+ }
566
+ function applyClusterFrameListMode(frameIds, mode, maxFramesPerCluster) {
567
+ if (mode === 'none')
568
+ return { frameIds: [], omittedCount: 0 };
569
+ const limit = resolveClusterFrameLimit(mode, maxFramesPerCluster);
570
+ const selected = frameIds.slice(0, limit);
571
+ return {
572
+ frameIds: selected,
573
+ omittedCount: Math.max(0, frameIds.length - selected.length),
574
+ };
575
+ }
576
+ function buildClusterFrameAggregationLines(jankSummary, frameListMode, maxFramesPerCluster) {
577
+ if (frameListMode === 'none') {
578
+ return [];
579
+ }
580
+ const clusters = jankSummary?.clusters;
581
+ if (!Array.isArray(clusters) || clusters.length === 0) {
582
+ return [];
583
+ }
584
+ const totalFrames = toFiniteNumber(jankSummary?.totalJankFrames);
585
+ const lines = [];
586
+ const modeLabel = frameListMode === 'full' ? '全量帧' : 'Top帧';
587
+ lines.push(`- 聚类帧聚合(${modeLabel},覆盖 ${totalFrames} 帧)`);
588
+ for (const cluster of clusters) {
589
+ const clusterId = String(cluster.clusterId || 'K?');
590
+ const clusterFrameCount = toFiniteNumber(cluster.frameCount);
591
+ const selection = applyClusterFrameListMode(readClusterFrameIds(cluster), frameListMode, maxFramesPerCluster);
592
+ const frameList = selection.frameIds.length > 0 ? selection.frameIds.join(' / ') : '无可用帧ID';
593
+ const omissionHint = selection.omittedCount > 0
594
+ ? `(其余 ${selection.omittedCount} 帧省略)`
595
+ : '';
596
+ lines.push(`- ${clusterId}(${clusterFrameCount}帧): ${frameList}${omissionHint}`);
597
+ }
598
+ return lines;
599
+ }
600
+ function injectAllJankFrameAggregation(markdown, jankSummary, frameListMode, maxFramesPerCluster) {
601
+ if (/聚类帧聚合(/.test(markdown)) {
602
+ return markdown;
603
+ }
604
+ const aggregationLines = buildClusterFrameAggregationLines(jankSummary, frameListMode, maxFramesPerCluster);
605
+ if (aggregationLines.length === 0) {
606
+ return markdown;
607
+ }
608
+ const clusterSection = findMarkdownSection(String(markdown || ''), /^##\s*(?:掉帧聚类(先看大头)|掉帧聚类|聚类(先看大头)|聚类)\s*$/m);
609
+ if (!clusterSection) {
610
+ return markdown;
611
+ }
612
+ const originalBody = clusterSection.body;
613
+ const trimmedBody = originalBody.trimStart();
614
+ const nextBody = `${aggregationLines.join('\n')}\n${trimmedBody}`;
615
+ return `${markdown.slice(0, clusterSection.bodyStart)}${nextBody}${markdown.slice(clusterSection.bodyEnd)}`;
616
+ }
617
+ function injectWorkloadDominantClusterMarker(markdown, jankSummary) {
618
+ const cluster = getWorkloadDominantCluster(jankSummary);
619
+ if (!cluster) {
620
+ return markdown;
621
+ }
622
+ if (/负载主导簇:/.test(markdown)) {
623
+ return markdown;
624
+ }
625
+ const repFramesText = cluster.frameIds.length > 0
626
+ ? `;聚合帧: ${cluster.frameIds.join(' / ')}`
627
+ : '';
628
+ const sampleCauseText = cluster.samplePrimaryCauses.length > 0
629
+ ? `;关键切片: ${cluster.samplePrimaryCauses.join(';')}`
630
+ : '';
631
+ const marker = `- 负载主导簇: ${cluster.clusterId}(${cluster.frameCount}帧, ${cluster.percentage.toFixed(1)}%),该簇以 APP 侧工作负载触发为主,资源问题信号较弱${repFramesText}${sampleCauseText}。`;
632
+ const lines = String(markdown || '').split('\n');
633
+ const headingPatterns = [
634
+ /^##\s*结论(按可能性排序)\s*$/,
635
+ /^##\s*结论\s*$/,
636
+ /^结论\s*[::]\s*$/,
637
+ /^\*\*conclusion:\*\*\s*$/i,
638
+ /^conclusion\s*:\s*$/i,
639
+ ];
640
+ for (let i = 0; i < lines.length; i += 1) {
641
+ if (headingPatterns.some(re => re.test(lines[i] || ''))) {
642
+ let insertAt = i + 1;
643
+ while (insertAt < lines.length && (lines[insertAt] || '').trim() === '') {
644
+ insertAt += 1;
645
+ }
646
+ lines.splice(insertAt, 0, marker);
647
+ return lines.join('\n');
648
+ }
649
+ }
650
+ return markdown;
651
+ }
652
+ function summarizeSupplyConstraintsFromRecords(frameMechanismRecords) {
653
+ if (!Array.isArray(frameMechanismRecords) || frameMechanismRecords.length === 0) {
654
+ return {
655
+ breakdown: [],
656
+ totalFrames: 0,
657
+ constrainedFrames: 0,
658
+ };
659
+ }
660
+ const counter = new Map();
661
+ const totalFrames = frameMechanismRecords.length;
662
+ for (const record of frameMechanismRecords) {
663
+ const raw = typeof record.supplyConstraint === 'string' ? record.supplyConstraint.trim() : '';
664
+ if (!raw || raw === 'none')
665
+ continue;
666
+ counter.set(raw, (counter.get(raw) || 0) + 1);
667
+ }
668
+ const constrainedFrames = Array.from(counter.values()).reduce((sum, v) => sum + v, 0);
669
+ if (constrainedFrames === 0) {
670
+ return {
671
+ breakdown: [],
672
+ totalFrames,
673
+ constrainedFrames,
674
+ };
675
+ }
676
+ return {
677
+ breakdown: Array.from(counter.entries())
678
+ .map(([constraint, count]) => ({
679
+ constraint,
680
+ count,
681
+ percentage: Math.round((count / totalFrames) * 1000) / 10,
682
+ }))
683
+ .sort((a, b) => b.count - a.count),
684
+ totalFrames,
685
+ constrainedFrames,
686
+ };
687
+ }
688
+ function supplyConstraintLabel(constraint) {
689
+ switch (constraint) {
690
+ case 'load_high': return '负载偏高';
691
+ case 'frequency_insufficient': return '频率不足';
692
+ case 'scheduling_delay': return '调度延迟';
693
+ case 'core_placement': return '核心摆放偏小核';
694
+ case 'blocking_wait': return '阻塞等待';
695
+ default: return constraint;
696
+ }
697
+ }
698
+ function buildSupplyEvidence(params) {
699
+ const { recordSupplyParts, supplyFromRecords, supplyParts, supplyTop, frameSample, } = params;
700
+ if (recordSupplyParts.length > 0) {
701
+ return `逐帧结构化资源问题: ${recordSupplyParts.join(';')}(命中 ${supplyFromRecords.constrainedFrames}/${supplyFromRecords.totalFrames} 帧)`;
702
+ }
703
+ if (supplyFromRecords.totalFrames > 0) {
704
+ return `逐帧结构化资源问题命中较低(${supplyFromRecords.constrainedFrames}/${supplyFromRecords.totalFrames} 帧)`;
705
+ }
706
+ if (supplyParts.length > 0) {
707
+ return `资源问题信号: ${supplyParts.join(';')}`;
708
+ }
709
+ if (supplyTop) {
710
+ return `逐帧资源问题主因=${supplyTop.causeType},占比 ${supplyTop.percentage.toFixed(1)}%`;
711
+ }
712
+ return `资源问题样本不足(逐帧样本 ${frameSample})`;
713
+ }
714
+ function deriveMechanismTriad(assessment, jankSummary, frameMechanismRecords = []) {
715
+ const allCauses = getAllCauses(jankSummary);
716
+ const triggerTop = getTopCauseByGroup(allCauses, TRIGGER_CAUSE_TYPES);
717
+ const supplyTop = getTopCauseByGroup(allCauses, SUPPLY_CAUSE_TYPES);
718
+ const amplificationTop = getTopCauseByGroup(allCauses, AMPLIFICATION_CAUSE_TYPES);
719
+ const supplyFromRecords = summarizeSupplyConstraintsFromRecords(frameMechanismRecords);
720
+ const freqPct = getCausePercentage(allCauses, 'freq_limit');
721
+ const smallCorePct = getCausePercentage(allCauses, 'small_core');
722
+ const schedPct = getCausePercentage(allCauses, 'sched_latency');
723
+ const contentionPct = getCausePercentage(allCauses, 'cpu_contention');
724
+ const overloadPct = getCausePercentage(allCauses, 'cpu_overload');
725
+ let trigger = '未形成稳定触发证据';
726
+ if (triggerTop) {
727
+ trigger = `${triggerTop.label}(占比 ${triggerTop.percentage.toFixed(1)}%)`;
728
+ }
729
+ else if (assessment.appLikePct >= 30) {
730
+ trigger = `APP/主线程侧信号存在(占比 ${assessment.appLikePct.toFixed(1)}%)`;
731
+ }
732
+ const supplyParts = [];
733
+ if (overloadPct >= 10)
734
+ supplyParts.push(`负载偏高 ${overloadPct.toFixed(1)}%`);
735
+ if (freqPct >= 10)
736
+ supplyParts.push(`频率不足 ${freqPct.toFixed(1)}%`);
737
+ if (schedPct >= 10)
738
+ supplyParts.push(`调度延迟 ${schedPct.toFixed(1)}%`);
739
+ if (smallCorePct >= 10)
740
+ supplyParts.push(`核心摆放偏小核 ${smallCorePct.toFixed(1)}%`);
741
+ if (contentionPct >= 10)
742
+ supplyParts.push(`CPU 争抢 ${contentionPct.toFixed(1)}%`);
743
+ const recordSupplyParts = supplyFromRecords.breakdown.slice(0, 2)
744
+ .map(s => `${supplyConstraintLabel(s.constraint)} ${s.percentage.toFixed(1)}%`);
745
+ let supply = '暂无明显资源问题证据';
746
+ if (recordSupplyParts.length > 0) {
747
+ supply = recordSupplyParts.join(';');
748
+ if (supplyFromRecords.constrainedFrames < supplyFromRecords.totalFrames) {
749
+ supply += `(覆盖 ${supplyFromRecords.constrainedFrames}/${supplyFromRecords.totalFrames} 帧)`;
750
+ }
751
+ }
752
+ else if (supplyFromRecords.totalFrames > 0) {
753
+ supply = `资源问题不明显(命中 ${supplyFromRecords.constrainedFrames}/${supplyFromRecords.totalFrames} 帧)`;
754
+ }
755
+ else if (supplyParts.length > 0) {
756
+ supply = supplyParts.join(';');
757
+ }
758
+ else if (supplyTop) {
759
+ supply = `${supplyTop.label}(占比 ${supplyTop.percentage.toFixed(1)}%)`;
760
+ }
761
+ else if (assessment.frameSample > 0) {
762
+ supply = '资源问题信号较弱或样本不足';
763
+ }
764
+ let amplification = '未观察到稳定放大因素证据';
765
+ if (amplificationTop) {
766
+ amplification = `${amplificationTop.label}(逐帧占比 ${amplificationTop.percentage.toFixed(1)}%)`;
767
+ }
768
+ else if (assessment.sfRespPct >= 50 || assessment.consumerRate >= 30) {
769
+ amplification = `SF/消费端放大信号存在(责任分布 SF ${assessment.sfRespPct.toFixed(1)}%,消费端 ${assessment.consumerRate.toFixed(1)}%)`;
770
+ }
771
+ const triggerEvidence = triggerTop
772
+ ? `逐帧 cause_type=${triggerTop.causeType},样本占比 ${triggerTop.percentage.toFixed(1)}%`
773
+ : `逐帧 APP/主线程侧累计占比 ${assessment.appLikePct.toFixed(1)}%`;
774
+ const supplyEvidence = buildSupplyEvidence({
775
+ recordSupplyParts,
776
+ supplyFromRecords,
777
+ supplyParts,
778
+ supplyTop,
779
+ frameSample: assessment.frameSample,
780
+ });
781
+ const amplificationEvidence = amplificationTop
782
+ ? `逐帧放大因素主因=${amplificationTop.causeType},占比 ${amplificationTop.percentage.toFixed(1)}%`
783
+ : `责任分布 SF ${assessment.sfRespSample} 帧 (${assessment.sfRespPct.toFixed(1)}%),消费端 ${assessment.consumerFrames} 帧 (${assessment.consumerRate.toFixed(1)}%)`;
784
+ return {
785
+ trigger,
786
+ supply,
787
+ amplification,
788
+ triggerEvidence,
789
+ supplyEvidence,
790
+ amplificationEvidence,
791
+ };
792
+ }
793
+ function buildMechanismTriadPromptSection(assessment, jankSummary, frameMechanismRecords = []) {
794
+ const triad = deriveMechanismTriad(assessment, jankSummary, frameMechanismRecords);
795
+ const clusterHints = getTopClusterHints(jankSummary);
796
+ const lines = [];
797
+ lines.push(`## ${analysisNarrative_1.TRIAD_HEADING}`);
798
+ lines.push(`- ${analysisNarrative_1.TRIAD_LABELS.trigger}: ${triad.trigger}`);
799
+ lines.push(`- ${analysisNarrative_1.TRIAD_LABELS.supply}: ${triad.supply}`);
800
+ lines.push(`- ${analysisNarrative_1.TRIAD_LABELS.amplification}: ${triad.amplification}`);
801
+ if (clusterHints.length > 0) {
802
+ lines.push('- 聚类优先级(先治大头):');
803
+ for (const hint of clusterHints) {
804
+ lines.push(` - ${hint}`);
805
+ }
806
+ }
807
+ lines.push('- 回答要求: 明确区分“APP 触发层”与“SF 消费放大层”,不要只给“主线程100%”结论。');
808
+ return lines.join('\n');
809
+ }
810
+ function verdictToChinese(verdict) {
811
+ switch (verdict) {
812
+ case 'APP_TRIGGER': return 'APP/主线程触发主导';
813
+ case 'SF_CONSUMER': return 'SF/消费端主导';
814
+ case 'MIXED': return '混合型(APP 触发 + SF 放大)';
815
+ default: return '证据不足';
816
+ }
817
+ }
818
+ function buildAttributionAssessmentPromptSection(a) {
819
+ const lines = [];
820
+ lines.push('## 掉帧归因裁决(规则预判)');
821
+ lines.push(`- 预判结论: ${verdictToChinese(a.verdict)}(置信度 ${Math.round(a.confidence * 100)}%)`);
822
+ lines.push(`- 逐帧根因样本: ${a.frameSample} 帧,APP/主线程侧 ${a.appLikePct.toFixed(1)}%,SF/GPU 侧 ${a.sfLikePct.toFixed(1)}%`);
823
+ lines.push(`- 责任分布样本: SF ${a.sfRespSample} 帧 (${a.sfRespPct.toFixed(1)}%),APP ${a.appRespSample} 帧 (${a.appRespPct.toFixed(1)}%)`);
824
+ lines.push(`- 消费端统计: ${a.consumerFrames} 帧 (${a.consumerRate.toFixed(1)}%)`);
825
+ if (a.rationale.length > 0) {
826
+ for (const r of a.rationale.slice(0, 4))
827
+ lines.push(`- 依据: ${r}`);
828
+ }
829
+ lines.push('- 结论约束: 必须与预判一致;若存在冲突,优先保守表述为“混合型/证据不足”。');
830
+ return lines.join('\n');
831
+ }
832
+ function isConclusionContradictingAttributionVerdict(conclusion, assessment) {
833
+ const t = String(conclusion || '');
834
+ if (!t.trim())
835
+ return false;
836
+ const sfOverclaimPatterns = [
837
+ /主要由\s*SF.*导致.*而非\s*App主线程/i,
838
+ /主要由\s*SurfaceFlinger.*导致.*而非\s*App主线程/i,
839
+ /问题主要在\s*SurfaceFlinger.*而非\s*App/i,
840
+ /非\s*App主线程.*根因/i,
841
+ ];
842
+ const appOverclaimPatterns = [
843
+ /主要由\s*主线程.*导致/i,
844
+ /主线程.*是主要根因/i,
845
+ /APP.*主因.*占主导/i,
846
+ ];
847
+ if (assessment.verdict === 'APP_TRIGGER' || assessment.verdict === 'MIXED') {
848
+ return sfOverclaimPatterns.some(re => re.test(t));
849
+ }
850
+ if (assessment.verdict === 'SF_CONSUMER') {
851
+ return appOverclaimPatterns.some(re => re.test(t));
852
+ }
853
+ return false;
854
+ }
855
+ function generateAttributionSafeFallback(assessment, findings, contradictionReasons, stopReason, jankSummary, frameMechanismRecords = []) {
856
+ const usableFindings = findings.filter(f => !f.details?._contradicted);
857
+ const evidenceCandidates = usableFindings
858
+ .map(f => ({ finding: f, evIds: extractEvidenceIdsFromFinding(f) }))
859
+ .filter(c => c.evIds.length > 0);
860
+ const usedEv = new Set();
861
+ const takeEvidenceTag = (preferredIndex) => {
862
+ if (evidenceCandidates.length === 0)
863
+ return '';
864
+ const ordered = [
865
+ preferredIndex,
866
+ ...evidenceCandidates.map((_, i) => i).filter(i => i !== preferredIndex),
867
+ ].filter(i => i >= 0 && i < evidenceCandidates.length);
868
+ for (const idx of ordered) {
869
+ const c = evidenceCandidates[idx];
870
+ if (!c)
871
+ continue;
872
+ const fresh = c.evIds.filter(id => !usedEv.has(id)).slice(0, 2);
873
+ const finalIds = fresh.length > 0 ? fresh : c.evIds.slice(0, 1);
874
+ if (finalIds.length > 0) {
875
+ for (const id of finalIds)
876
+ usedEv.add(id);
877
+ return `(${finalIds.join('|')})`;
878
+ }
879
+ }
880
+ return '';
881
+ };
882
+ const c1EvTag = takeEvidenceTag(0);
883
+ const c2EvTag = takeEvidenceTag(1);
884
+ const c3EvTag = takeEvidenceTag(2);
885
+ const mechanismTriad = deriveMechanismTriad(assessment, jankSummary, frameMechanismRecords);
886
+ const clusterHints = getTopClusterHints(jankSummary);
887
+ const lines = [];
888
+ const topFinding = usableFindings[0] || findings[0];
889
+ const topTitle = topFinding?.title ? String(topFinding.title) : '当前证据摘要';
890
+ lines.push('## 结论(按可能性排序)');
891
+ if (assessment.verdict === 'APP_TRIGGER') {
892
+ lines.push(`1. 更可能是 APP/主线程侧触发掉帧,消费端表现为放大层(置信度: ${Math.round(assessment.confidence * 100)}%)。`);
893
+ lines.push('2. SF/消费端异常仍可能参与,但当前不是唯一主因(置信度: 55%)。');
894
+ }
895
+ else if (assessment.verdict === 'SF_CONSUMER') {
896
+ lines.push(`1. 更可能是 SF/消费端侧主导,APP 侧证据不足以证明主因(置信度: ${Math.round(assessment.confidence * 100)}%)。`);
897
+ lines.push('2. 仍需排查少量 APP 侧长耗时帧是否触发了局部异常(置信度: 45%)。');
898
+ }
899
+ else if (assessment.verdict === 'MIXED') {
900
+ lines.push(`1. 这是混合型掉帧:APP/主线程触发与 SF/消费端放大同时存在(置信度: ${Math.round(assessment.confidence * 100)}%)。`);
901
+ lines.push('2. 不能仅用“SF 主因”或“APP 主因”单侧表述覆盖全链路(置信度: 60%)。');
902
+ }
903
+ else {
904
+ lines.push('1. 当前证据不足以给出单一主因结论(置信度: 35%)。');
905
+ }
906
+ lines.push(`- ${analysisNarrative_1.TRIAD_LABELS.trigger}: ${mechanismTriad.trigger}`);
907
+ lines.push(`- ${analysisNarrative_1.TRIAD_LABELS.supply}: ${mechanismTriad.supply}`);
908
+ lines.push(`- ${analysisNarrative_1.TRIAD_LABELS.amplification}: ${mechanismTriad.amplification}`);
909
+ lines.push('');
910
+ lines.push('## 聚类(先看大头)');
911
+ if (clusterHints.length > 0) {
912
+ for (const hint of clusterHints) {
913
+ lines.push(`- ${hint}`);
914
+ }
915
+ }
916
+ else {
917
+ lines.push('- 当前缺少可用聚类结果,建议先补足逐帧样本(>=20 帧)。');
918
+ }
919
+ lines.push('');
920
+ lines.push('## 证据链(对应上述结论)');
921
+ lines.push(`- C1: ${analysisNarrative_1.TRIAD_EVIDENCE_LABELS.trigger}:${mechanismTriad.triggerEvidence}${c1EvTag ? ` ${c1EvTag}` : ''}`);
922
+ lines.push(`- C2: ${analysisNarrative_1.TRIAD_EVIDENCE_LABELS.supply}:${mechanismTriad.supplyEvidence}${c2EvTag ? ` ${c2EvTag}` : ''}`);
923
+ lines.push(`- C3: ${analysisNarrative_1.TRIAD_EVIDENCE_LABELS.amplification}:${mechanismTriad.amplificationEvidence};Finding=${topTitle}${c3EvTag ? ` ${c3EvTag}` : ''}`);
924
+ lines.push('');
925
+ lines.push('## 不确定性与反例');
926
+ if (assessment.rationale.length > 0) {
927
+ for (const r of assessment.rationale.slice(0, 3))
928
+ lines.push(`- ${r}`);
929
+ }
930
+ else {
931
+ lines.push('- 当前缺少同口径、同时间窗的补充证据。');
932
+ }
933
+ if (contradictionReasons.length > 0) {
934
+ lines.push(`- 检测到矛盾: ${contradictionReasons.slice(0, 2).join(';')}`);
935
+ }
936
+ if (stopReason) {
937
+ lines.push(`- 备注:本轮提前结束(${stopReason})。`);
938
+ }
939
+ lines.push('');
940
+ lines.push('## 下一步(最高信息增益)');
941
+ lines.push('- 在同一时间窗扩大逐帧样本(建议 >= 20 帧),重新计算 cause_type 占比。');
942
+ lines.push('- 对主线程长耗时帧与消费端 token_gap/vsync_missed 做时间重叠验证。');
943
+ return lines.join('\n');
944
+ }
945
+ function finalizeConclusionMarkdown(markdown, findings, jankSummary, options = {}) {
946
+ const withPerConclusionMapping = injectPerConclusionEvidenceMapping(markdown, findings);
947
+ const withEvidenceIndex = injectEvidenceIndexIntoEvidenceChain(withPerConclusionMapping, findings);
948
+ const withTriadAligned = options.singleFrameDrillDown
949
+ ? injectSingleFrameRootCauseTriad(withEvidenceIndex, findings)
950
+ : withEvidenceIndex;
951
+ const withEvidenceAligned = options.singleFrameDrillDown
952
+ ? injectSingleFrameRootCauseEvidenceChain(withTriadAligned, findings)
953
+ : withTriadAligned;
954
+ const withHumanReadable = options.singleFrameDrillDown
955
+ ? injectSingleFrameHumanReadableConclusion(withEvidenceAligned, findings)
956
+ : withEvidenceAligned;
957
+ const withDeepReason = injectDeepReasonIntoConclusionSection(withHumanReadable, findings);
958
+ const shouldInjectClusterAggregation = Boolean(options.scenePromptHints?.clusterPolicy.injectClusterFrameAggregation);
959
+ const withClusterAggregation = shouldInjectClusterAggregation
960
+ ? injectAllJankFrameAggregation(withDeepReason, jankSummary, options.scenePromptHints?.clusterPolicy.frameListMode || 'none', options.scenePromptHints?.clusterPolicy.maxFramesPerCluster)
961
+ : withDeepReason;
962
+ const shouldInjectWorkloadDominant = Boolean(options.scenePromptHints?.clusterPolicy.injectWorkloadDominantMarker);
963
+ const withWorkloadDominant = shouldInjectWorkloadDominant
964
+ ? injectWorkloadDominantClusterMarker(withClusterAggregation, jankSummary)
965
+ : withClusterAggregation;
966
+ return injectSystemContextActionItems(withWorkloadDominant, findings);
967
+ }
968
+ function extractDirectSkillIdFromFindingSource(source) {
969
+ const match = String(source || '').trim().match(/^direct_skill:([a-zA-Z0-9_.-]+)/i);
970
+ return match ? String(match[1]).toLowerCase() : null;
971
+ }
972
+ function severityToActionPriority(severity) {
973
+ const normalized = String(severity || '').trim().toLowerCase();
974
+ if (normalized === 'critical' || normalized === 'high')
975
+ return 'P0';
976
+ if (normalized === 'warning' || normalized === 'medium')
977
+ return 'P1';
978
+ return 'P2';
979
+ }
980
+ function normalizeActionPriority(raw, fallbackSeverity) {
981
+ if (typeof raw === 'number' && Number.isFinite(raw)) {
982
+ if (raw <= 1)
983
+ return 'P0';
984
+ if (raw <= 3)
985
+ return 'P1';
986
+ return 'P2';
987
+ }
988
+ const normalized = String(raw || '').trim().toLowerCase();
989
+ if (!normalized)
990
+ return severityToActionPriority(fallbackSeverity);
991
+ if (/p0\b|critical|urgent|highest|高优|紧急|严重/.test(normalized))
992
+ return 'P0';
993
+ if (/p1\b|warning|medium|中优|中等|警告/.test(normalized))
994
+ return 'P1';
995
+ if (/p2\b|info|low|低优|低风险/.test(normalized))
996
+ return 'P2';
997
+ const asNumber = Number(normalized);
998
+ if (Number.isFinite(asNumber)) {
999
+ if (asNumber <= 1)
1000
+ return 'P0';
1001
+ if (asNumber <= 3)
1002
+ return 'P1';
1003
+ return 'P2';
1004
+ }
1005
+ return severityToActionPriority(fallbackSeverity);
1006
+ }
1007
+ function readFirstStringFromRecord(record, keys) {
1008
+ if (!record)
1009
+ return undefined;
1010
+ for (const key of keys) {
1011
+ const value = record[key];
1012
+ if (typeof value === 'string' && value.trim()) {
1013
+ return value.trim();
1014
+ }
1015
+ }
1016
+ return undefined;
1017
+ }
1018
+ function truncateActionItemText(text, maxLength = 120) {
1019
+ const normalized = String(text || '').trim();
1020
+ if (normalized.length <= maxLength)
1021
+ return normalized;
1022
+ return `${normalized.slice(0, Math.max(0, maxLength - 1))}…`;
1023
+ }
1024
+ function normalizeActionLineForDedupe(line) {
1025
+ return String(line || '')
1026
+ .toLowerCase()
1027
+ .replace(/[\s;;::,,()()\[\]{}"'`]/g, '')
1028
+ .trim();
1029
+ }
1030
+ function isActionableSystemFinding(finding) {
1031
+ const details = (finding.details && typeof finding.details === 'object')
1032
+ ? finding.details
1033
+ : null;
1034
+ const hasExplicitSystemContext = Boolean((details && (details.system_context || details.systemContext))
1035
+ || readFirstStringFromRecord(details, ['owner', 'priority', 'verification', 'action']));
1036
+ const directSkillId = extractDirectSkillIdFromFindingSource(finding.source);
1037
+ const hasSystemSkillHint = Boolean(directSkillId && SYSTEM_CONTEXT_SKILL_HINTS[directSkillId]);
1038
+ if (!hasExplicitSystemContext && !hasSystemSkillHint)
1039
+ return false;
1040
+ const severity = String(finding.severity || '').toLowerCase();
1041
+ if (severity === 'critical' || severity === 'warning' || severity === 'high' || severity === 'medium') {
1042
+ return true;
1043
+ }
1044
+ const text = `${String(finding.title || '')}\n${String(finding.description || '')}`;
1045
+ if (/严重|偏高|风险|瓶颈|阻塞|过大|节流|异常/i.test(text)) {
1046
+ return true;
1047
+ }
1048
+ if (/正常|良好|无明显|未检测到/i.test(text)) {
1049
+ return false;
1050
+ }
1051
+ return severity !== 'info' && severity !== 'low';
1052
+ }
1053
+ function buildSystemContextActionItem(finding) {
1054
+ if (!isActionableSystemFinding(finding)) {
1055
+ return null;
1056
+ }
1057
+ const details = (finding.details && typeof finding.details === 'object')
1058
+ ? finding.details
1059
+ : null;
1060
+ const systemContextRecord = (() => {
1061
+ if (!details)
1062
+ return null;
1063
+ if (details.system_context && typeof details.system_context === 'object' && !Array.isArray(details.system_context)) {
1064
+ return details.system_context;
1065
+ }
1066
+ if (details.systemContext && typeof details.systemContext === 'object' && !Array.isArray(details.systemContext)) {
1067
+ return details.systemContext;
1068
+ }
1069
+ return null;
1070
+ })();
1071
+ const directSkillId = extractDirectSkillIdFromFindingSource(finding.source);
1072
+ const hint = directSkillId ? SYSTEM_CONTEXT_SKILL_HINTS[directSkillId] : undefined;
1073
+ const owner = readFirstStringFromRecord(systemContextRecord, ['owner', '责任人'])
1074
+ || readFirstStringFromRecord(details, ['owner', '责任人'])
1075
+ || hint?.owner
1076
+ || '性能优化负责人';
1077
+ const priorityRaw = readFirstStringFromRecord(systemContextRecord, ['priority', '优先级'])
1078
+ || readFirstStringFromRecord(details, ['priority', '优先级']);
1079
+ const priority = normalizeActionPriority(priorityRaw, finding.severity);
1080
+ const actionRaw = readFirstStringFromRecord(systemContextRecord, ['action', 'next_action', 'nextStep', '建议'])
1081
+ || readFirstStringFromRecord(details, ['action', 'next_action', 'nextStep', '建议']);
1082
+ const fallbackAction = String(finding.title || finding.description || '推进系统性能优化动作')
1083
+ .replace(/^\[[^\]]+\]\s*/, '')
1084
+ .trim();
1085
+ const action = truncateActionItemText(actionRaw || fallbackAction || '推进系统性能优化动作');
1086
+ const verification = readFirstStringFromRecord(systemContextRecord, ['verification', 'verify', '验收标准', '验证'])
1087
+ || readFirstStringFromRecord(details, ['verification', 'verify', '验收标准', '验证'])
1088
+ || hint?.verification
1089
+ || '复跑同时间窗 trace,确认对应指标改善且无回归';
1090
+ return { owner, priority, action, verification: truncateActionItemText(verification, 140) };
1091
+ }
1092
+ function buildSystemContextActionItems(findings) {
1093
+ const candidates = findings
1094
+ .map(buildSystemContextActionItem)
1095
+ .filter((item) => Boolean(item));
1096
+ if (candidates.length === 0)
1097
+ return [];
1098
+ const priorityRank = { P0: 0, P1: 1, P2: 2 };
1099
+ candidates.sort((a, b) => {
1100
+ const pa = priorityRank[a.priority];
1101
+ const pb = priorityRank[b.priority];
1102
+ if (pa !== pb)
1103
+ return pa - pb;
1104
+ return a.action.localeCompare(b.action, 'zh-CN');
1105
+ });
1106
+ const deduped = [];
1107
+ const seen = new Set();
1108
+ for (const item of candidates) {
1109
+ const line = `owner: ${item.owner}; priority: ${item.priority}; action: ${item.action}; verification: ${item.verification}`;
1110
+ const key = normalizeActionLineForDedupe(line);
1111
+ if (seen.has(key))
1112
+ continue;
1113
+ seen.add(key);
1114
+ deduped.push(line);
1115
+ }
1116
+ return deduped.slice(0, 3);
1117
+ }
1118
+ function injectSystemContextActionItems(markdown, findings) {
1119
+ const text = String(markdown || '');
1120
+ if (!text.trim())
1121
+ return text;
1122
+ const nextStepSection = findMarkdownSection(text, /^##\s*下一步[((]最高信息增益[))]\s*$/m);
1123
+ if (!nextStepSection)
1124
+ return text;
1125
+ const actionItems = buildSystemContextActionItems(findings);
1126
+ if (actionItems.length === 0)
1127
+ return text;
1128
+ const existingEntries = extractListEntriesFromSectionBody(nextStepSection.body);
1129
+ if (existingEntries.some(entry => STRUCTURED_ACTION_ITEM_RE.test(entry))) {
1130
+ return text;
1131
+ }
1132
+ const existingKeys = new Set(existingEntries.map(normalizeActionLineForDedupe));
1133
+ const injectedLines = actionItems
1134
+ .filter(item => !existingKeys.has(normalizeActionLineForDedupe(item)))
1135
+ .map(item => `- ${item}`);
1136
+ if (injectedLines.length === 0)
1137
+ return text;
1138
+ const existingBodyLines = String(nextStepSection.body || '')
1139
+ .split(/\r?\n/)
1140
+ .map(line => line.trim())
1141
+ .filter(Boolean)
1142
+ .filter(line => !/^\s*(?:-\s*)?暂无\s*$/i.test(line));
1143
+ const mergedBody = [...injectedLines, ...existingBodyLines];
1144
+ const replacement = `${mergedBody.join('\n')}\n`;
1145
+ return `${text.slice(0, nextStepSection.bodyStart)}${replacement}${text.slice(nextStepSection.bodyEnd)}`;
1146
+ }
1147
+ function normalizeHintText(text) {
1148
+ const deepReasonPrefix = new RegExp(`^(?:${analysisNarrative_1.DEEP_REASON_ALIASES.join('|')})\\s*[::]\\s*`, 'i');
1149
+ return String(text || '')
1150
+ .trim()
1151
+ .replace(new RegExp(`^${analysisNarrative_1.OPTIMIZATION_LABEL}\\s*[::]\\s*`, 'i'), '')
1152
+ .replace(deepReasonPrefix, '')
1153
+ .trim();
1154
+ }
1155
+ function extractDeepReasonHints(findings) {
1156
+ for (const finding of findings) {
1157
+ if (!finding?.details || typeof finding.details !== 'object')
1158
+ continue;
1159
+ const details = finding.details;
1160
+ const deepReasonRaw = typeof details.deep_reason === 'string'
1161
+ ? details.deep_reason
1162
+ : (typeof details.secondary_info === 'string' ? details.secondary_info : '');
1163
+ const optimizationRaw = typeof details.optimization_hint === 'string' ? details.optimization_hint : '';
1164
+ const deepReason = normalizeHintText(deepReasonRaw);
1165
+ const optimizationHint = normalizeHintText(optimizationRaw);
1166
+ if (deepReason || optimizationHint) {
1167
+ return {
1168
+ ...(deepReason ? { deepReason } : {}),
1169
+ ...(optimizationHint ? { optimizationHint } : {}),
1170
+ };
1171
+ }
1172
+ }
1173
+ return {};
1174
+ }
1175
+ function injectDeepReasonIntoConclusionSection(markdown, findings) {
1176
+ const hints = extractDeepReasonHints(findings);
1177
+ if (!hints.deepReason && !hints.optimizationHint) {
1178
+ return markdown;
1179
+ }
1180
+ const lines = String(markdown || '').split('\n');
1181
+ const headerIdx = lines.findIndex(line => /^##\s*结论(按可能性排序)\s*$/.test(line.trim()));
1182
+ if (headerIdx < 0) {
1183
+ return markdown;
1184
+ }
1185
+ let nextHeaderIdx = -1;
1186
+ for (let i = headerIdx + 1; i < lines.length; i += 1) {
1187
+ if (/^##\s+/.test(lines[i].trim())) {
1188
+ nextHeaderIdx = i;
1189
+ break;
1190
+ }
1191
+ }
1192
+ const sectionEnd = nextHeaderIdx >= 0 ? nextHeaderIdx : lines.length;
1193
+ const sectionLines = lines.slice(headerIdx + 1, sectionEnd);
1194
+ const hasDeepReasonLine = sectionLines.some(line => new RegExp(`(?:${analysisNarrative_1.DEEP_REASON_ALIASES.join('|')})\\s*[::]`).test(line));
1195
+ const hasOptimizationLine = sectionLines.some(line => new RegExp(`${analysisNarrative_1.OPTIMIZATION_LABEL}\\s*[::]`).test(line));
1196
+ const inserts = [];
1197
+ if (hints.deepReason && !hasDeepReasonLine) {
1198
+ inserts.push(`- ${analysisNarrative_1.DEEP_REASON_LABEL}: ${hints.deepReason}`);
1199
+ }
1200
+ if (hints.optimizationHint && !hasOptimizationLine) {
1201
+ inserts.push(`- ${analysisNarrative_1.OPTIMIZATION_LABEL}: ${hints.optimizationHint}`);
1202
+ }
1203
+ if (inserts.length === 0) {
1204
+ return markdown;
1205
+ }
1206
+ if (sectionEnd > 0 && lines[sectionEnd - 1].trim() !== '') {
1207
+ inserts.push('');
1208
+ }
1209
+ lines.splice(sectionEnd, 0, ...inserts);
1210
+ return lines.join('\n').replace(/\n{3,}/g, '\n\n');
1211
+ }
1212
+ function supplyConstraintToConclusionText(constraintRaw, secondaryInfoRaw) {
1213
+ const constraint = String(constraintRaw || '').trim();
1214
+ const secondaryInfo = normalizeMechanismPlainText(String(secondaryInfoRaw || '').trim());
1215
+ switch (constraint) {
1216
+ case 'blocking_wait':
1217
+ return secondaryInfo || '阻塞等待';
1218
+ case 'frequency_insufficient':
1219
+ return secondaryInfo || '频率不足';
1220
+ case 'scheduling_delay':
1221
+ return secondaryInfo || '调度延迟';
1222
+ case 'core_placement':
1223
+ return secondaryInfo || '核心摆放偏小核';
1224
+ case 'load_high':
1225
+ return secondaryInfo || 'CPU 负载偏高';
1226
+ case 'none':
1227
+ return analysisNarrative_1.SUPPLY_NONE_CURRENT_FRAME_TEXT;
1228
+ default:
1229
+ return secondaryInfo || (constraint ? constraint : analysisNarrative_1.SUPPLY_NONE_CURRENT_FRAME_TEXT);
1230
+ }
1231
+ }
1232
+ function amplificationPathToConclusionText(pathRaw) {
1233
+ const path = normalizeMechanismPlainText(String(pathRaw || '').trim());
1234
+ switch (path) {
1235
+ case 'gpu_fence_wait':
1236
+ return 'GPU Fence 等待放大';
1237
+ case 'render_pipeline_wait':
1238
+ return 'RenderThread/RenderPipeline 等待放大';
1239
+ case 'sf_consumer_backpressure':
1240
+ return 'SF 消费端背压';
1241
+ case 'app_deadline_miss':
1242
+ return 'APP 截止超时';
1243
+ case 'unknown':
1244
+ default:
1245
+ return analysisNarrative_1.AMPLIFICATION_UNKNOWN_CURRENT_FRAME_TEXT;
1246
+ }
1247
+ }
1248
+ function parseOptionalNumber(value) {
1249
+ const n = Number(value);
1250
+ return Number.isFinite(n) ? n : undefined;
1251
+ }
1252
+ function roundStr(value, digits = 2) {
1253
+ if (value === undefined)
1254
+ return '-';
1255
+ return Number(value.toFixed(digits)).toString();
1256
+ }
1257
+ function confidenceToPercent(raw) {
1258
+ if (typeof raw === 'number') {
1259
+ if (raw > 0 && raw <= 1)
1260
+ return Math.round(raw * 100);
1261
+ if (raw > 1 && raw <= 100)
1262
+ return Math.round(raw);
1263
+ }
1264
+ const text = String(raw || '').trim();
1265
+ if (!text)
1266
+ return undefined;
1267
+ if (/^高$/.test(text))
1268
+ return 85;
1269
+ if (/^中$/.test(text))
1270
+ return 70;
1271
+ if (/^低$/.test(text))
1272
+ return 55;
1273
+ const n = Number(text.replace(/[%%]/g, ''));
1274
+ if (Number.isFinite(n))
1275
+ return Math.round(n <= 1 ? n * 100 : n);
1276
+ return undefined;
1277
+ }
1278
+ function parsePrimaryCauseMetrics(primaryCauseRaw) {
1279
+ const text = String(primaryCauseRaw || '');
1280
+ const m = text.match(/主线程耗时操作\s+"([^"]+)"\s+占用\s+([0-9.]+)ms\s+\(帧预算\s+([0-9.]+)ms\)/);
1281
+ if (!m)
1282
+ return {};
1283
+ return {
1284
+ sliceName: m[1],
1285
+ sliceDurMs: parseOptionalNumber(m[2]),
1286
+ frameBudgetMs: parseOptionalNumber(m[3]),
1287
+ };
1288
+ }
1289
+ function collectSingleFrameFacts(details) {
1290
+ const parsed = parsePrimaryCauseMetrics(details.primary_cause);
1291
+ const sliceName = String(details.slice_name || parsed.sliceName || '').trim() || undefined;
1292
+ const sliceDurMs = parseOptionalNumber(details.slice_dur) ?? parsed.sliceDurMs;
1293
+ const frameBudgetMs = parseOptionalNumber(details.frame_budget_ms) ?? parsed.frameBudgetMs;
1294
+ const mainQ3Pct = parseOptionalNumber(details.main_q3_pct);
1295
+ const mainQ4Pct = parseOptionalNumber(details.main_q4_pct);
1296
+ const gpuFenceMs = parseOptionalNumber(details.gpu_fence_ms);
1297
+ const confidencePct = confidenceToPercent(details.confidence_level ?? details.confidence);
1298
+ const triggerText = normalizeMechanismPlainText(String(details.primary_cause || '').trim());
1299
+ const supplyText = supplyConstraintToConclusionText(details.supply_constraint, details.secondary_info);
1300
+ const amplificationText = amplificationPathToConclusionText(details.amplification_path);
1301
+ return {
1302
+ sliceName,
1303
+ sliceDurMs,
1304
+ frameBudgetMs,
1305
+ mainQ3Pct,
1306
+ mainQ4Pct,
1307
+ gpuFenceMs,
1308
+ confidencePct,
1309
+ supplyText,
1310
+ amplificationText,
1311
+ triggerText,
1312
+ };
1313
+ }
1314
+ function normalizeMechanismPlainText(text) {
1315
+ return (0, analysisNarrative_1.normalizeLegacyTriadTerms)((0, analysisNarrative_1.stripTriadPrefix)(String(text || '').trim()))
1316
+ .replace(/\s+/g, ' ')
1317
+ .trim();
1318
+ }
1319
+ function pickBestRootCauseDetails(findings) {
1320
+ const candidates = findings
1321
+ .filter(f => f?.details && typeof f.details === 'object' && typeof f.details.primary_cause === 'string')
1322
+ .map(f => {
1323
+ const details = f.details;
1324
+ const primary = String(details.primary_cause || '');
1325
+ const title = String(f.title || '');
1326
+ let score = 0;
1327
+ if (primary && title.includes(primary))
1328
+ score += 4;
1329
+ if (f.severity === 'critical')
1330
+ score += 2;
1331
+ if (Array.isArray(f.evidence) && f.evidence.length > 0)
1332
+ score += 1;
1333
+ return { details, score };
1334
+ })
1335
+ .sort((a, b) => b.score - a.score);
1336
+ return candidates[0]?.details || null;
1337
+ }
1338
+ function injectSingleFrameRootCauseTriad(markdown, findings) {
1339
+ const details = pickBestRootCauseDetails(findings);
1340
+ if (!details)
1341
+ return markdown;
1342
+ const trigger = normalizeMechanismPlainText(String(details.primary_cause || '').trim());
1343
+ if (!trigger)
1344
+ return markdown;
1345
+ const supply = supplyConstraintToConclusionText(details.supply_constraint, details.secondary_info);
1346
+ const amplification = amplificationPathToConclusionText(details.amplification_path);
1347
+ const triad = (0, analysisNarrative_1.buildTriadStatement)({ trigger, supply, amplification });
1348
+ const lines = String(markdown || '').split('\n');
1349
+ const headerIdx = lines.findIndex(line => /^##\s*结论(按可能性排序)\s*$/.test(line.trim()));
1350
+ if (headerIdx < 0)
1351
+ return markdown;
1352
+ let nextHeaderIdx = -1;
1353
+ for (let i = headerIdx + 1; i < lines.length; i += 1) {
1354
+ if (/^##\s+/.test(lines[i].trim())) {
1355
+ nextHeaderIdx = i;
1356
+ break;
1357
+ }
1358
+ }
1359
+ const sectionEnd = nextHeaderIdx >= 0 ? nextHeaderIdx : lines.length;
1360
+ let replaced = false;
1361
+ for (let i = headerIdx + 1; i < sectionEnd; i += 1) {
1362
+ const raw = lines[i];
1363
+ if (!(0, analysisNarrative_1.hasTriadRoleText)(raw, 'trigger') ||
1364
+ !(0, analysisNarrative_1.hasTriadRoleText)(raw, 'supply') ||
1365
+ !(0, analysisNarrative_1.hasTriadRoleText)(raw, 'amplification'))
1366
+ continue;
1367
+ const numbered = raw.match(/^(\s*\d+\.\s*)(.*)$/);
1368
+ const bullet = raw.match(/^(\s*-\s*)(.*)$/);
1369
+ const prefix = numbered?.[1] || bullet?.[1] || '';
1370
+ const content = numbered?.[2] || bullet?.[2] || raw.trim();
1371
+ const conf = content.match(/(置信度\s*[::]?\s*\d+(?:\.\d+)?%?\)/)?.[0] || '';
1372
+ lines[i] = `${prefix}${triad}${conf}`.trimEnd();
1373
+ replaced = true;
1374
+ break;
1375
+ }
1376
+ if (!replaced) {
1377
+ let insertAt = headerIdx + 1;
1378
+ for (let i = headerIdx + 1; i < sectionEnd; i += 1) {
1379
+ if (/^\s*\d+\.\s+/.test(lines[i])) {
1380
+ insertAt = i + 1;
1381
+ break;
1382
+ }
1383
+ }
1384
+ lines.splice(insertAt, 0, `- ${triad}`);
1385
+ }
1386
+ return lines.join('\n').replace(/\n{3,}/g, '\n\n');
1387
+ }
1388
+ function getSingleFrameEvidenceTag(findings) {
1389
+ const evIds = findings
1390
+ .flatMap(f => extractEvidenceIdsFromFinding(f))
1391
+ .filter(Boolean);
1392
+ const deduped = [...new Set(evIds)].slice(0, 2);
1393
+ if (deduped.length === 0) {
1394
+ return '(证据ID缺失)';
1395
+ }
1396
+ return `(${deduped.join('|')})`;
1397
+ }
1398
+ function injectSingleFrameRootCauseEvidenceChain(markdown, findings) {
1399
+ const details = pickBestRootCauseDetails(findings);
1400
+ if (!details)
1401
+ return markdown;
1402
+ const facts = collectSingleFrameFacts(details);
1403
+ if (!facts.triggerText)
1404
+ return markdown;
1405
+ const evTag = getSingleFrameEvidenceTag(findings);
1406
+ const section = findMarkdownSection(markdown, /^##\s*证据链[((]对应上述结论[))]\s*$/m);
1407
+ if (!section)
1408
+ return markdown;
1409
+ const c1 = facts.sliceName && facts.sliceDurMs !== undefined && facts.frameBudgetMs !== undefined
1410
+ ? `主线程 ${facts.sliceName} 执行 ${roundStr(facts.sliceDurMs)}ms,超过帧预算 ${roundStr(facts.frameBudgetMs)}ms ${evTag}`
1411
+ : `${facts.triggerText} ${evTag}`;
1412
+ const q3Text = facts.mainQ3Pct !== undefined ? `Q3=${roundStr(facts.mainQ3Pct, 1)}%` : '';
1413
+ const q4Text = facts.mainQ4Pct !== undefined ? `Q4=${roundStr(facts.mainQ4Pct, 1)}%` : '';
1414
+ const supplyBasis = [q3Text, q4Text].filter(Boolean).join(',');
1415
+ const c2 = supplyBasis
1416
+ ? `${supplyBasis},结论:${facts.supplyText} ${evTag}`
1417
+ : `${facts.supplyText} ${evTag}`;
1418
+ const c3 = facts.gpuFenceMs !== undefined
1419
+ ? `GPU Fence=${roundStr(facts.gpuFenceMs)}ms,结论:${facts.amplificationText} ${evTag}`
1420
+ : `${facts.amplificationText} ${evTag}`;
1421
+ const normalizedLines = [
1422
+ `- C1: ${analysisNarrative_1.TRIAD_EVIDENCE_LABELS.trigger}:${c1}`,
1423
+ `- C2: ${analysisNarrative_1.TRIAD_EVIDENCE_LABELS.supply}:${c2}`,
1424
+ `- C3: ${analysisNarrative_1.TRIAD_EVIDENCE_LABELS.amplification}:${c3}`,
1425
+ ];
1426
+ return `${markdown.slice(0, section.bodyStart)}${normalizedLines.join('\n')}\n${markdown.slice(section.bodyEnd)}`;
1427
+ }
1428
+ function injectSingleFrameHumanReadableConclusion(markdown, findings) {
1429
+ const details = pickBestRootCauseDetails(findings);
1430
+ if (!details)
1431
+ return markdown;
1432
+ const facts = collectSingleFrameFacts(details);
1433
+ if (!facts.triggerText)
1434
+ return markdown;
1435
+ const lines = String(markdown || '').split('\n');
1436
+ const headerIdx = lines.findIndex(line => /^##\s*结论(按可能性排序)\s*$/.test(line.trim()));
1437
+ if (headerIdx < 0)
1438
+ return markdown;
1439
+ let nextHeaderIdx = -1;
1440
+ for (let i = headerIdx + 1; i < lines.length; i += 1) {
1441
+ if (/^##\s+/.test(lines[i].trim())) {
1442
+ nextHeaderIdx = i;
1443
+ break;
1444
+ }
1445
+ }
1446
+ const sectionEnd = nextHeaderIdx >= 0 ? nextHeaderIdx : lines.length;
1447
+ const summary = facts.sliceName && facts.sliceDurMs !== undefined && facts.frameBudgetMs !== undefined
1448
+ ? `这帧主要卡在主线程 ${facts.sliceName}:单次 ${roundStr(facts.sliceDurMs)}ms,超过帧预算 ${roundStr(facts.frameBudgetMs)}ms。`
1449
+ : `这帧主要卡在主线程长耗时:${facts.triggerText}。`;
1450
+ const confSuffix = facts.confidencePct !== undefined ? `(置信度: ${facts.confidencePct}%)` : '';
1451
+ const triggerLine = `- ${analysisNarrative_1.TRIAD_LABELS.trigger}: ${facts.triggerText}`;
1452
+ const supplyLine = facts.mainQ3Pct !== undefined || facts.mainQ4Pct !== undefined
1453
+ ? `- ${analysisNarrative_1.TRIAD_LABELS.supply}: ${facts.supplyText}(主线程 Q3=${facts.mainQ3Pct !== undefined ? `${roundStr(facts.mainQ3Pct, 1)}%` : '未知'},Q4=${facts.mainQ4Pct !== undefined ? `${roundStr(facts.mainQ4Pct, 1)}%` : '未知'})`
1454
+ : `- ${analysisNarrative_1.TRIAD_LABELS.supply}: ${facts.supplyText}`;
1455
+ const amplificationLine = facts.gpuFenceMs !== undefined
1456
+ ? `- ${analysisNarrative_1.TRIAD_LABELS.amplification}: ${facts.amplificationText}(GPU Fence=${roundStr(facts.gpuFenceMs)}ms)`
1457
+ : `- ${analysisNarrative_1.TRIAD_LABELS.amplification}: ${facts.amplificationText}`;
1458
+ let firstItemIdx = -1;
1459
+ for (let i = headerIdx + 1; i < sectionEnd; i += 1) {
1460
+ if (/^\s*1\.\s+/.test(lines[i])) {
1461
+ firstItemIdx = i;
1462
+ break;
1463
+ }
1464
+ }
1465
+ if (firstItemIdx >= 0) {
1466
+ lines[firstItemIdx] = `1. ${summary}${confSuffix}`;
1467
+ }
1468
+ const cleanedSection = lines
1469
+ .slice(headerIdx + 1, sectionEnd)
1470
+ .filter(line => {
1471
+ const t = line.trim();
1472
+ if (!t)
1473
+ return true;
1474
+ if (/^(?:-|\d+\.)\s*/.test(t)) {
1475
+ const noPrefix = t.replace(/^(?:-|\d+\.)\s*/, '');
1476
+ if ((0, analysisNarrative_1.hasTriadRoleText)(noPrefix, 'trigger'))
1477
+ return false;
1478
+ if ((0, analysisNarrative_1.hasTriadRoleText)(noPrefix, 'supply'))
1479
+ return false;
1480
+ if ((0, analysisNarrative_1.hasTriadRoleText)(noPrefix, 'amplification'))
1481
+ return false;
1482
+ }
1483
+ if (/抢不到CPU|阻塞型卡顿|渲染端放大/.test(t))
1484
+ return false;
1485
+ return true;
1486
+ });
1487
+ const rebuilt = [...cleanedSection];
1488
+ const hasTriadBullets = rebuilt.some(line => (0, analysisNarrative_1.hasTriadRoleText)(line, 'trigger') ||
1489
+ (0, analysisNarrative_1.hasTriadRoleText)(line, 'supply') ||
1490
+ (0, analysisNarrative_1.hasTriadRoleText)(line, 'amplification'));
1491
+ if (!hasTriadBullets) {
1492
+ let insertAt = firstItemIdx >= 0 ? (firstItemIdx - (headerIdx + 1) + 1) : 0;
1493
+ rebuilt.splice(insertAt, 0, triggerLine, supplyLine, amplificationLine);
1494
+ }
1495
+ return `${lines.slice(0, headerIdx + 1).join('\n')}\n${rebuilt.join('\n')}\n${lines.slice(sectionEnd).join('\n')}`
1496
+ .replace(/\n{3,}/g, '\n\n')
1497
+ .trim();
1498
+ }
1499
+ function parseNumberFromUnknown(raw) {
1500
+ const value = readNumberValue(raw);
1501
+ return Number.isFinite(value) ? value : undefined;
1502
+ }
1503
+ function clampPercent(raw) {
1504
+ if (typeof raw !== 'number' || !Number.isFinite(raw))
1505
+ return undefined;
1506
+ // Use strict < 1 so that exactly 1 is treated as "1%" not "100%".
1507
+ // LLM may output confidence on 0-1 scale (e.g. 0.85) or 0-100 scale (e.g. 85).
1508
+ if (raw > 0 && raw < 1)
1509
+ return Math.max(0, Math.min(100, raw * 100));
1510
+ return Math.max(0, Math.min(100, raw));
1511
+ }
1512
+ function normalizeConclusionId(id, fallbackRank) {
1513
+ const text = String(id || '').trim();
1514
+ if (!text)
1515
+ return `C${fallbackRank}`;
1516
+ const m = text.match(/C?\s*(\d+)/i);
1517
+ if (m)
1518
+ return `C${Math.max(1, Number(m[1]))}`;
1519
+ return `C${fallbackRank}`;
1520
+ }
1521
+ function stripJsonCodeFence(text) {
1522
+ return String(text || '')
1523
+ .trim()
1524
+ .replace(/^```(?:json)?\s*/i, '')
1525
+ .replace(/\s*```$/i, '')
1526
+ .trim();
1527
+ }
1528
+ function extractFirstJsonObject(text) {
1529
+ const source = String(text || '');
1530
+ const start = source.indexOf('{');
1531
+ if (start < 0)
1532
+ return null;
1533
+ let depth = 0;
1534
+ let inString = false;
1535
+ let escaping = false;
1536
+ for (let i = start; i < source.length; i += 1) {
1537
+ const ch = source[i];
1538
+ if (inString) {
1539
+ if (escaping) {
1540
+ escaping = false;
1541
+ }
1542
+ else if (ch === '\\') {
1543
+ escaping = true;
1544
+ }
1545
+ else if (ch === '"') {
1546
+ inString = false;
1547
+ }
1548
+ continue;
1549
+ }
1550
+ if (ch === '"') {
1551
+ inString = true;
1552
+ continue;
1553
+ }
1554
+ if (ch === '{') {
1555
+ depth += 1;
1556
+ continue;
1557
+ }
1558
+ if (ch === '}') {
1559
+ depth -= 1;
1560
+ if (depth === 0) {
1561
+ return source.slice(start, i + 1);
1562
+ }
1563
+ }
1564
+ }
1565
+ return null;
1566
+ }
1567
+ function toRecord(value) {
1568
+ if (!value || typeof value !== 'object' || Array.isArray(value))
1569
+ return null;
1570
+ return value;
1571
+ }
1572
+ function toStringArray(value) {
1573
+ if (Array.isArray(value)) {
1574
+ return value
1575
+ .map(v => stripBulletPrefix(String(v || '').trim()))
1576
+ .filter(Boolean);
1577
+ }
1578
+ if (typeof value === 'string') {
1579
+ const line = stripBulletPrefix(value.trim());
1580
+ return line ? [line] : [];
1581
+ }
1582
+ return [];
1583
+ }
1584
+ function parseConclusionItemFromRecord(record, fallbackRank) {
1585
+ const trigger = readSemanticText(record, 'trigger');
1586
+ const supply = readSemanticText(record, 'supply');
1587
+ const amplification = readSemanticText(record, 'amplification');
1588
+ const statement = readSemanticText(record, 'statement');
1589
+ const rank = Math.round(parseNumberFromUnknown(readValueFromAliases(record, ['rank', 'order', 'index', '序号', '编号'])) || fallbackRank);
1590
+ const confidencePercent = clampPercent(readSemanticNumber(record, 'confidence'));
1591
+ let resolvedStatement = statement;
1592
+ if (!resolvedStatement && (trigger || supply || amplification)) {
1593
+ resolvedStatement = (0, analysisNarrative_1.buildTriadStatement)({
1594
+ ...(trigger ? { trigger } : {}),
1595
+ ...(supply ? { supply } : {}),
1596
+ ...(amplification ? { amplification } : {}),
1597
+ });
1598
+ }
1599
+ if (!resolvedStatement)
1600
+ return null;
1601
+ return {
1602
+ rank: Number.isFinite(rank) && rank > 0 ? rank : fallbackRank,
1603
+ statement: resolvedStatement,
1604
+ confidencePercent,
1605
+ trigger: trigger || undefined,
1606
+ supply: supply || undefined,
1607
+ amplification: amplification || undefined,
1608
+ };
1609
+ }
1610
+ function parseClusterItemFromRecord(record) {
1611
+ const cluster = readSemanticText(record, 'cluster_label');
1612
+ const description = readSemanticText(record, 'cluster_description');
1613
+ const rank = readSemanticNumber(record, 'cluster_rank');
1614
+ const rankPrefix = typeof rank === 'number' && rank > 0 ? `K${Math.round(rank)}` : '';
1615
+ const frames = parseNumberFromUnknown(readSemanticNumber(record, 'cluster_frames'));
1616
+ const percentage = parseNumberFromUnknown(readSemanticNumber(record, 'cluster_percentage'));
1617
+ const frameRefs = parseClusterFrameRefs(record);
1618
+ let resolvedCluster = cluster;
1619
+ if (!resolvedCluster && rankPrefix)
1620
+ resolvedCluster = rankPrefix;
1621
+ if (!resolvedCluster && !description)
1622
+ return null;
1623
+ if (!resolvedCluster && description)
1624
+ resolvedCluster = description;
1625
+ if (resolvedCluster && rankPrefix && !new RegExp(`^${rankPrefix}\\b`, 'i').test(resolvedCluster)) {
1626
+ resolvedCluster = `${rankPrefix}: ${resolvedCluster}`;
1627
+ }
1628
+ return {
1629
+ cluster: resolvedCluster || '',
1630
+ description: description || undefined,
1631
+ frames: typeof frames === 'number' && frames > 0 ? frames : undefined,
1632
+ percentage: typeof percentage === 'number' ? percentage : undefined,
1633
+ frameRefs: frameRefs.length > 0 ? frameRefs : undefined,
1634
+ };
1635
+ }
1636
+ function parseFrameRefsFromUnknown(raw) {
1637
+ if (Array.isArray(raw)) {
1638
+ return Array.from(new Set(raw.map((v) => String(v).trim()).filter(Boolean)));
1639
+ }
1640
+ if (typeof raw !== 'string') {
1641
+ return [];
1642
+ }
1643
+ const text = raw.trim();
1644
+ if (!text)
1645
+ return [];
1646
+ const normalized = text.replace(/[((]\s*其余\s*\d+\s*帧省略\s*[))]/g, '').trim();
1647
+ const tokens = normalized.split(/[\/|,,;;\s]+/g)
1648
+ .map(t => t.trim())
1649
+ .filter(Boolean)
1650
+ .filter(t => /^\d{3,}$/.test(t));
1651
+ return Array.from(new Set(tokens));
1652
+ }
1653
+ function parseClusterFrameRefs(record) {
1654
+ const direct = readValueFromAliases(record, [
1655
+ 'frameRefs',
1656
+ 'frame_refs',
1657
+ 'frameIds',
1658
+ 'frame_ids',
1659
+ 'cluster_frame_refs',
1660
+ 'clusterFrameRefs',
1661
+ 'cluster_frames_list',
1662
+ 'clusterFramesList',
1663
+ '聚合帧',
1664
+ '帧列表',
1665
+ '帧ID列表',
1666
+ ]);
1667
+ const directRefs = parseFrameRefsFromUnknown(direct);
1668
+ if (directRefs.length > 0)
1669
+ return directRefs;
1670
+ const clusterDescription = readSemanticText(record, 'cluster_description');
1671
+ return parseFrameRefsFromUnknown(clusterDescription);
1672
+ }
1673
+ function parseEvidenceItemsFromRecord(record, fallbackRank) {
1674
+ const conclusionId = normalizeConclusionId(readSemanticText(record, 'conclusion_id'), fallbackRank);
1675
+ const evidenceTexts = extractEvidenceTextsFromJsonLikeObject(record);
1676
+ if (evidenceTexts.length === 0)
1677
+ return [];
1678
+ return evidenceTexts.map(text => ({ conclusionId, text }));
1679
+ }
1680
+ function parseClaimScalar(value) {
1681
+ if (typeof value === 'boolean')
1682
+ return value;
1683
+ if (typeof value === 'number' && Number.isFinite(value))
1684
+ return value;
1685
+ if (typeof value !== 'string')
1686
+ return undefined;
1687
+ const text = String(value).trim();
1688
+ if (!text)
1689
+ return undefined;
1690
+ if (/^(true|false)$/i.test(text))
1691
+ return /^true$/i.test(text);
1692
+ if (/^[+-]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:e[+-]?\d+)?$/i.test(text)) {
1693
+ const parsed = Number(text);
1694
+ if (Number.isFinite(parsed))
1695
+ return parsed;
1696
+ }
1697
+ return text;
1698
+ }
1699
+ function parseClaimRowSelector(value) {
1700
+ let record = toRecord(value);
1701
+ if (!record && typeof value === 'string') {
1702
+ const text = value.trim();
1703
+ if (text.startsWith('{')) {
1704
+ try {
1705
+ record = toRecord(JSON.parse(text));
1706
+ }
1707
+ catch {
1708
+ record = null;
1709
+ }
1710
+ }
1711
+ else {
1712
+ const parsed = {};
1713
+ for (const part of text.split(/[,,]/)) {
1714
+ const match = part.trim().match(/^([^=::]+)\s*(?:=|:|:)\s*(.+)$/);
1715
+ if (!match)
1716
+ continue;
1717
+ const key = match[1].trim();
1718
+ const parsedValue = parseClaimScalar(match[2].trim().replace(/^['"]|['"]$/g, ''));
1719
+ if (!key || parsedValue === undefined)
1720
+ continue;
1721
+ parsed[key] = parsedValue;
1722
+ }
1723
+ return Object.keys(parsed).length > 0 ? parsed : undefined;
1724
+ }
1725
+ }
1726
+ if (!record)
1727
+ return undefined;
1728
+ const selector = {};
1729
+ for (const [key, rawValue] of Object.entries(record)) {
1730
+ const normalizedKey = String(key || '').trim();
1731
+ const parsedValue = parseClaimScalar(rawValue);
1732
+ if (!normalizedKey || parsedValue === undefined)
1733
+ continue;
1734
+ selector[normalizedKey] = parsedValue;
1735
+ }
1736
+ return Object.keys(selector).length > 0 ? selector : undefined;
1737
+ }
1738
+ function parseClaimReferenceFromRecord(record) {
1739
+ const evidenceRefId = String(readValueFromAliases(record, [
1740
+ 'evidenceRefId', 'evidence_ref_id', 'evidenceId', 'evidence_id',
1741
+ ]) || '').trim();
1742
+ const sourceRef = String(readValueFromAliases(record, [
1743
+ 'sourceRef', 'source_ref', 'ref',
1744
+ ]) || '').trim();
1745
+ const sourceToolCallId = String(readValueFromAliases(record, [
1746
+ 'sourceToolCallId', 'source_tool_call_id', 'toolCallId', 'tool_call_id',
1747
+ ]) || '').trim();
1748
+ const rowIndexRaw = readValueFromAliases(record, ['rowIndex', 'row_index']);
1749
+ const rowIndex = parseNumberFromUnknown(rowIndexRaw);
1750
+ const rowSelector = parseClaimRowSelector(readValueFromAliases(record, ['rowSelector', 'row_selector']));
1751
+ const column = String(readValueFromAliases(record, ['column', 'col']) || '').trim();
1752
+ const value = parseClaimScalar(readValueFromAliases(record, ['value']));
1753
+ if (!evidenceRefId && !sourceRef && !sourceToolCallId)
1754
+ return null;
1755
+ return {
1756
+ evidenceRefId,
1757
+ ...(rowIndex !== undefined ? { rowIndex } : {}),
1758
+ ...(rowSelector ? { rowSelector } : {}),
1759
+ ...(column ? { column } : {}),
1760
+ ...(value !== undefined ? { value } : {}),
1761
+ ...(sourceRef ? { sourceRef } : {}),
1762
+ ...(sourceToolCallId ? { sourceToolCallId } : {}),
1763
+ };
1764
+ }
1765
+ function parseClaimItemsFromUnknown(value) {
1766
+ if (!Array.isArray(value))
1767
+ return [];
1768
+ const claims = [];
1769
+ value.forEach((item, idx) => {
1770
+ const record = toRecord(item);
1771
+ if (!record)
1772
+ return;
1773
+ const referencesSource = readValueFromAliases(record, [
1774
+ 'references', 'refs', 'evidenceRefs', 'evidence_refs',
1775
+ ]);
1776
+ const references = Array.isArray(referencesSource)
1777
+ ? referencesSource
1778
+ .map(ref => toRecord(ref))
1779
+ .filter((ref) => Boolean(ref))
1780
+ .map(ref => parseClaimReferenceFromRecord(ref))
1781
+ .filter((ref) => Boolean(ref))
1782
+ : [];
1783
+ if (references.length === 0)
1784
+ return;
1785
+ const claimId = String(readValueFromAliases(record, ['id', 'claimId', 'claim_id']) || '').trim();
1786
+ const conclusionId = normalizeConclusionId(String(readValueFromAliases(record, ['conclusionId', 'conclusion_id', 'conclusion']) || '').trim(), idx + 1);
1787
+ const text = String(readValueFromAliases(record, ['text', 'statement', 'claim']) || '').trim() || `claim ${idx + 1}`;
1788
+ claims.push({
1789
+ ...(claimId ? { id: claimId } : {}),
1790
+ conclusionId,
1791
+ text,
1792
+ references,
1793
+ });
1794
+ });
1795
+ return claims;
1796
+ }
1797
+ function formatClaimReferenceMarkdown(ref) {
1798
+ const parts = [];
1799
+ if (ref.evidenceRefId)
1800
+ parts.push(`evidence_ref_id=${ref.evidenceRefId}`);
1801
+ if (ref.sourceRef)
1802
+ parts.push(`source_ref=${ref.sourceRef}`);
1803
+ if (ref.sourceToolCallId)
1804
+ parts.push(`source_tool_call_id=${ref.sourceToolCallId}`);
1805
+ if (typeof ref.rowIndex === 'number')
1806
+ parts.push(`row_index=${ref.rowIndex}`);
1807
+ if (ref.rowSelector)
1808
+ parts.push(`row_selector=${JSON.stringify(ref.rowSelector)}`);
1809
+ if (ref.column)
1810
+ parts.push(`column=${ref.column}`);
1811
+ if (ref.value !== undefined)
1812
+ parts.push(`value=${String(ref.value)}`);
1813
+ return parts.join('; ');
1814
+ }
1815
+ function parseClaimReferenceFromMarkdownLine(line) {
1816
+ const record = {};
1817
+ for (const part of String(line || '').split(';')) {
1818
+ const match = part.trim().match(/^([a-zA-Z_]+)\s*=\s*(.*)$/);
1819
+ if (!match)
1820
+ continue;
1821
+ record[match[1]] = match[2].trim();
1822
+ }
1823
+ return parseClaimReferenceFromRecord(record);
1824
+ }
1825
+ function parseClaimItemsFromMarkdownSection(sectionBody) {
1826
+ const claims = [];
1827
+ let current = null;
1828
+ const flush = () => {
1829
+ if (current && current.references.length > 0)
1830
+ claims.push(current);
1831
+ current = null;
1832
+ };
1833
+ for (const rawLine of String(sectionBody || '').split(/\r?\n/)) {
1834
+ const line = rawLine.trim();
1835
+ if (!line)
1836
+ continue;
1837
+ const claimMatch = line.match(/^[-*]\s+([^::]+)\s*[::]\s*(.+)$/);
1838
+ if (claimMatch && !/=/.test(claimMatch[1])) {
1839
+ flush();
1840
+ const idPart = claimMatch[1].trim();
1841
+ const [claimIdRaw, conclusionIdRaw] = idPart.split('/').map(part => part.trim());
1842
+ current = {
1843
+ ...(claimIdRaw ? { id: claimIdRaw } : {}),
1844
+ ...(conclusionIdRaw ? { conclusionId: normalizeConclusionId(conclusionIdRaw, claims.length + 1) } : {}),
1845
+ text: stripBulletPrefix(claimMatch[2].trim()),
1846
+ references: [],
1847
+ };
1848
+ continue;
1849
+ }
1850
+ const refLine = line.replace(/^[-*]\s+/, '').trim();
1851
+ const ref = parseClaimReferenceFromMarkdownLine(refLine);
1852
+ if (ref) {
1853
+ if (!current) {
1854
+ current = {
1855
+ id: `Q${claims.length + 1}`,
1856
+ text: `claim ${claims.length + 1}`,
1857
+ references: [],
1858
+ };
1859
+ }
1860
+ current.references.push(ref);
1861
+ }
1862
+ }
1863
+ flush();
1864
+ return claims;
1865
+ }
1866
+ function extractListEntriesFromSectionBody(body) {
1867
+ const entries = [];
1868
+ for (const rawLine of String(body || '').split(/\r?\n/)) {
1869
+ const line = rawLine.trim();
1870
+ if (!line)
1871
+ continue;
1872
+ const bullet = line.match(/^(?:[-*]|\d+\.)\s+(.+)$/);
1873
+ if (bullet) {
1874
+ const text = stripBulletPrefix(bullet[1].trim());
1875
+ if (text)
1876
+ entries.push(text);
1877
+ continue;
1878
+ }
1879
+ entries.push(stripBulletPrefix(line));
1880
+ }
1881
+ return entries.filter(Boolean);
1882
+ }
1883
+ function parseConclusionConfidenceFromStatement(statement) {
1884
+ const raw = String(statement || '')
1885
+ .trim()
1886
+ .replace(/[·]\s*$/, '')
1887
+ .trim();
1888
+ if (!raw)
1889
+ return { statement: raw };
1890
+ const m = raw.match(/[((]\s*置信度\s*[::]?\s*(\d+(?:\.\d+)?)\s*%?\s*[))]/i);
1891
+ if (!m)
1892
+ return { statement: raw };
1893
+ const confidence = clampPercent(Number(m[1]));
1894
+ const cleaned = raw.replace(m[0], '').trim();
1895
+ return { statement: cleaned || raw, confidencePercent: confidence };
1896
+ }
1897
+ function parseConclusionItemsFromMarkdownSection(sectionBody) {
1898
+ const numberedItems = [];
1899
+ const bulletFallback = [];
1900
+ const lines = String(sectionBody || '').split(/\r?\n/);
1901
+ for (const rawLine of lines) {
1902
+ const line = rawLine.trim();
1903
+ if (!line)
1904
+ continue;
1905
+ const mNum = line.match(/^([1-3])\s*[.)、]\s*(.+)$/);
1906
+ if (mNum) {
1907
+ numberedItems.push({ index: Number(mNum[1]), text: mNum[2].trim() });
1908
+ continue;
1909
+ }
1910
+ const mC = line.match(/^C([1-3])\s*[::]\s*(.+)$/i);
1911
+ if (mC) {
1912
+ numberedItems.push({ index: Number(mC[1]), text: mC[2].trim() });
1913
+ continue;
1914
+ }
1915
+ const mBullet = line.match(/^-\s+(.+)$/);
1916
+ if (mBullet) {
1917
+ bulletFallback.push(mBullet[1].trim());
1918
+ }
1919
+ }
1920
+ const baseItems = numberedItems.length > 0
1921
+ ? numberedItems
1922
+ : bulletFallback.slice(0, 3).map((text, idx) => ({ index: idx + 1, text }));
1923
+ const triadParts = (0, analysisNarrative_1.parseTriadParts)(sectionBody || '');
1924
+ const items = baseItems.map((item, idx) => {
1925
+ const rank = item.index || idx + 1;
1926
+ const parsed = parseConclusionConfidenceFromStatement(item.text);
1927
+ return {
1928
+ rank,
1929
+ statement: parsed.statement,
1930
+ confidencePercent: parsed.confidencePercent,
1931
+ };
1932
+ });
1933
+ if (triadParts.trigger || triadParts.supply || triadParts.amplification) {
1934
+ const triadStatement = (0, analysisNarrative_1.buildTriadStatement)(triadParts);
1935
+ const alreadyCovered = items.some(item => (0, analysisNarrative_1.hasTriadRoleText)(item.statement, 'trigger') &&
1936
+ (0, analysisNarrative_1.hasTriadRoleText)(item.statement, 'supply') &&
1937
+ (0, analysisNarrative_1.hasTriadRoleText)(item.statement, 'amplification'));
1938
+ if (!alreadyCovered) {
1939
+ items.push({
1940
+ rank: items.length + 1,
1941
+ statement: triadStatement,
1942
+ confidencePercent: undefined,
1943
+ });
1944
+ }
1945
+ }
1946
+ return items;
1947
+ }
1948
+ function parseClusterItemsFromMarkdownSection(sectionBody) {
1949
+ const entries = extractListEntriesFromSectionBody(sectionBody);
1950
+ const clusters = [];
1951
+ for (const entry of entries) {
1952
+ const metricMatch = entry.match(/[((]\s*(\d+(?:\.\d+)?)\s*帧\s*,\s*(\d+(?:\.\d+)?)\s*%\s*[))]/);
1953
+ let clusterText = entry;
1954
+ let frames;
1955
+ let percentage;
1956
+ if (metricMatch) {
1957
+ clusterText = entry.replace(metricMatch[0], '').trim();
1958
+ frames = Number(metricMatch[1]);
1959
+ percentage = Number(metricMatch[2]);
1960
+ }
1961
+ if (!clusterText)
1962
+ continue;
1963
+ const m = clusterText.match(/^(K\d+)\s*[::]\s*(.+)$/i);
1964
+ const description = m ? m[2] : undefined;
1965
+ const frameRefs = parseFrameRefsFromUnknown(description);
1966
+ clusters.push({
1967
+ cluster: m ? m[1] : clusterText,
1968
+ description,
1969
+ frames: Number.isFinite(frames) ? frames : undefined,
1970
+ percentage: Number.isFinite(percentage) ? percentage : undefined,
1971
+ frameRefs: frameRefs.length > 0 ? frameRefs : undefined,
1972
+ });
1973
+ }
1974
+ return clusters;
1975
+ }
1976
+ function parseEvidenceItemsFromMarkdownSection(sectionBody) {
1977
+ const entries = extractListEntriesFromSectionBody(sectionBody);
1978
+ const evidenceItems = [];
1979
+ entries.forEach((entry, idx) => {
1980
+ const m = entry.match(/^(C\d+)\s*[::]\s*(.+)$/i);
1981
+ if (m) {
1982
+ evidenceItems.push({
1983
+ conclusionId: normalizeConclusionId(m[1], idx + 1),
1984
+ text: m[2].trim(),
1985
+ });
1986
+ }
1987
+ else {
1988
+ evidenceItems.push({
1989
+ conclusionId: normalizeConclusionId('', idx + 1),
1990
+ text: entry,
1991
+ });
1992
+ }
1993
+ });
1994
+ return evidenceItems;
1995
+ }
1996
+ function parseMetadataFromMarkdownSection(sectionBody) {
1997
+ const entries = extractListEntriesFromSectionBody(sectionBody);
1998
+ let confidencePercent;
1999
+ let rounds;
2000
+ for (const entry of entries) {
2001
+ const confidenceMatch = entry.match(/置信度\s*[::]\s*(\d+(?:\.\d+)?)\s*%?/i);
2002
+ if (confidenceMatch && confidencePercent === undefined) {
2003
+ confidencePercent = clampPercent(Number(confidenceMatch[1]));
2004
+ continue;
2005
+ }
2006
+ const roundsMatch = entry.match(/分析轮次\s*[::]\s*(\d+(?:\.\d+)?)/i);
2007
+ if (roundsMatch && rounds === undefined) {
2008
+ rounds = Number(roundsMatch[1]);
2009
+ }
2010
+ }
2011
+ if (confidencePercent === undefined && rounds === undefined)
2012
+ return undefined;
2013
+ return {
2014
+ confidencePercent,
2015
+ rounds: typeof rounds === 'number' && Number.isFinite(rounds) ? Math.max(1, Math.round(rounds)) : undefined,
2016
+ };
2017
+ }
2018
+ function normalizeSceneId(raw, fallback) {
2019
+ const direct = String(raw || '').trim().toLowerCase();
2020
+ if (direct)
2021
+ return direct;
2022
+ const fallbackText = String(fallback || '').trim().toLowerCase();
2023
+ return fallbackText || undefined;
2024
+ }
2025
+ function normalizeClusterOutputMode(raw, fallback = 'optional') {
2026
+ const text = String(raw || '').trim().toLowerCase();
2027
+ if (text === 'required' || text === 'optional' || text === 'none')
2028
+ return text;
2029
+ return fallback;
2030
+ }
2031
+ function normalizeClusterFrameListMode(raw, fallback = 'none') {
2032
+ const text = String(raw || '').trim().toLowerCase();
2033
+ if (text === 'full' || text === 'top' || text === 'none')
2034
+ return text;
2035
+ return fallback;
2036
+ }
2037
+ function normalizeClusterPolicy(raw, fallback) {
2038
+ const source = raw && typeof raw === 'object' ? raw : {};
2039
+ const outputMode = normalizeClusterOutputMode(readValueFromAliases(source, ['outputMode', 'output_mode']), fallback?.outputMode || 'optional');
2040
+ const frameListMode = normalizeClusterFrameListMode(readValueFromAliases(source, ['frameListMode', 'frame_list_mode']), fallback?.frameListMode || 'none');
2041
+ const maxFramesPerCluster = parseNumberFromUnknown(readValueFromAliases(source, ['maxFramesPerCluster', 'max_frames_per_cluster']));
2042
+ const resolvedMax = Number.isFinite(maxFramesPerCluster) && (maxFramesPerCluster || 0) > 0
2043
+ ? Math.round(maxFramesPerCluster)
2044
+ : fallback?.maxFramesPerCluster;
2045
+ const hasSignal = Boolean(raw) || Boolean(fallback);
2046
+ if (!hasSignal)
2047
+ return undefined;
2048
+ return {
2049
+ outputMode,
2050
+ frameListMode,
2051
+ maxFramesPerCluster: resolvedMax,
2052
+ };
2053
+ }
2054
+ function sanitizeConclusionContract(contract, options) {
2055
+ const sanitizeText = (text) => stripBulletPrefix(String(text || '').trim())
2056
+ .replace(/[·]\s*$/, '')
2057
+ .trim();
2058
+ const dedupe = (items) => {
2059
+ const seen = new Set();
2060
+ const out = [];
2061
+ for (const raw of items) {
2062
+ const item = sanitizeText(raw);
2063
+ if (!item || seen.has(item))
2064
+ continue;
2065
+ seen.add(item);
2066
+ out.push(item);
2067
+ }
2068
+ return out;
2069
+ };
2070
+ const conclusions = contract.conclusions
2071
+ .map((item, idx) => {
2072
+ const rank = Number.isFinite(item.rank) && item.rank > 0 ? Math.round(item.rank) : idx + 1;
2073
+ const parsed = parseConclusionConfidenceFromStatement(item.statement);
2074
+ const statement = sanitizeText(parsed.statement);
2075
+ const confidencePercent = clampPercent(item.confidencePercent ?? parsed.confidencePercent);
2076
+ return {
2077
+ rank,
2078
+ statement,
2079
+ confidencePercent,
2080
+ trigger: sanitizeText(item.trigger || ''),
2081
+ supply: sanitizeText(item.supply || ''),
2082
+ amplification: sanitizeText(item.amplification || ''),
2083
+ };
2084
+ })
2085
+ .filter(item => item.statement || item.trigger || item.supply || item.amplification)
2086
+ .sort((a, b) => a.rank - b.rank)
2087
+ .slice(0, 3)
2088
+ .map((item, idx) => {
2089
+ let statement = item.statement;
2090
+ if (!statement) {
2091
+ statement = (0, analysisNarrative_1.buildTriadStatement)({
2092
+ ...(item.trigger ? { trigger: item.trigger } : {}),
2093
+ ...(item.supply ? { supply: item.supply } : {}),
2094
+ ...(item.amplification ? { amplification: item.amplification } : {}),
2095
+ });
2096
+ }
2097
+ return {
2098
+ rank: idx + 1,
2099
+ statement: statement || '结论信息缺失(证据不足)',
2100
+ confidencePercent: item.confidencePercent,
2101
+ trigger: item.trigger || undefined,
2102
+ supply: item.supply || undefined,
2103
+ amplification: item.amplification || undefined,
2104
+ };
2105
+ });
2106
+ const scenePolicy = options.scenePromptHints
2107
+ ? {
2108
+ outputMode: options.scenePromptHints.clusterPolicy.outputMode,
2109
+ frameListMode: options.scenePromptHints.clusterPolicy.frameListMode,
2110
+ maxFramesPerCluster: options.scenePromptHints.clusterPolicy.maxFramesPerCluster,
2111
+ }
2112
+ : undefined;
2113
+ const clusterPolicy = normalizeClusterPolicy(contract.metadata?.clusterPolicy, scenePolicy);
2114
+ const sceneId = normalizeSceneId(contract.metadata?.sceneId, options.scenePromptHints?.sceneId);
2115
+ const clusters = options.singleFrameDrillDown
2116
+ ? []
2117
+ : contract.clusters
2118
+ .map(item => ({
2119
+ cluster: sanitizeText(item.cluster),
2120
+ description: sanitizeText(item.description || '') || undefined,
2121
+ frames: typeof item.frames === 'number' && Number.isFinite(item.frames) && item.frames > 0
2122
+ ? Math.round(item.frames)
2123
+ : undefined,
2124
+ percentage: clampPercent(item.percentage),
2125
+ frameRefs: parseFrameRefsFromUnknown(item.frameRefs),
2126
+ }))
2127
+ .filter(item => item.cluster)
2128
+ .map(item => {
2129
+ const selection = applyClusterFrameListMode(item.frameRefs, clusterPolicy?.frameListMode || 'top', clusterPolicy?.maxFramesPerCluster);
2130
+ return {
2131
+ cluster: item.cluster,
2132
+ description: item.description,
2133
+ frames: item.frames,
2134
+ percentage: item.percentage,
2135
+ frameRefs: selection.frameIds.length > 0 ? selection.frameIds : undefined,
2136
+ omittedFrameRefs: selection.omittedCount > 0 ? selection.omittedCount : undefined,
2137
+ };
2138
+ })
2139
+ .slice(0, 5);
2140
+ const evidenceChain = contract.evidenceChain
2141
+ .map((item, idx) => ({
2142
+ conclusionId: normalizeConclusionId(item.conclusionId, idx + 1),
2143
+ text: sanitizeText(item.text),
2144
+ }))
2145
+ .filter(item => item.text)
2146
+ .slice(0, 12);
2147
+ const claims = (contract.claims || [])
2148
+ .map((item, idx) => {
2149
+ const references = (item.references || [])
2150
+ .map(ref => ({
2151
+ evidenceRefId: sanitizeText(ref.evidenceRefId),
2152
+ ...(typeof ref.rowIndex === 'number' && Number.isFinite(ref.rowIndex) ? { rowIndex: ref.rowIndex } : {}),
2153
+ ...(ref.rowSelector ? { rowSelector: parseClaimRowSelector(ref.rowSelector) } : {}),
2154
+ ...(ref.column ? { column: sanitizeText(ref.column) } : {}),
2155
+ ...(ref.value !== undefined ? { value: parseClaimScalar(ref.value) } : {}),
2156
+ ...(ref.sourceRef ? { sourceRef: sanitizeText(ref.sourceRef) } : {}),
2157
+ ...(ref.sourceToolCallId ? { sourceToolCallId: sanitizeText(ref.sourceToolCallId) } : {}),
2158
+ }))
2159
+ .filter(ref => ((ref.evidenceRefId || ref.sourceRef || ref.sourceToolCallId) &&
2160
+ (ref.value === undefined || typeof ref.value === 'string' || typeof ref.value === 'number' || typeof ref.value === 'boolean')));
2161
+ return {
2162
+ ...(item.id ? { id: sanitizeText(item.id) } : {}),
2163
+ ...(item.conclusionId ? { conclusionId: normalizeConclusionId(item.conclusionId, idx + 1) } : {}),
2164
+ text: sanitizeText(item.text) || `claim ${idx + 1}`,
2165
+ references,
2166
+ };
2167
+ })
2168
+ .filter(item => item.text && item.references.length > 0)
2169
+ .slice(0, 50);
2170
+ const uncertainties = dedupe(contract.uncertainties).slice(0, 6);
2171
+ const nextSteps = dedupe(contract.nextSteps).slice(0, 6);
2172
+ const metadata = contract.metadata
2173
+ ? {
2174
+ confidencePercent: clampPercent(contract.metadata.confidencePercent),
2175
+ rounds: typeof contract.metadata.rounds === 'number' && Number.isFinite(contract.metadata.rounds)
2176
+ ? Math.max(1, Math.round(contract.metadata.rounds))
2177
+ : undefined,
2178
+ clusterPolicy,
2179
+ sceneId,
2180
+ }
2181
+ : ((clusterPolicy || sceneId) ? { ...(clusterPolicy ? { clusterPolicy } : {}), ...(sceneId ? { sceneId } : {}) } : undefined);
2182
+ return {
2183
+ schemaVersion: 'conclusion_contract_v1',
2184
+ mode: contract.mode,
2185
+ conclusions: conclusions.length > 0 ? conclusions : [{
2186
+ rank: 1,
2187
+ statement: '结论信息缺失(证据不足)',
2188
+ confidencePercent: 40,
2189
+ }],
2190
+ clusters,
2191
+ evidenceChain,
2192
+ ...(claims.length > 0 ? { claims } : {}),
2193
+ uncertainties,
2194
+ nextSteps,
2195
+ metadata: metadata && (metadata.confidencePercent !== undefined ||
2196
+ metadata.rounds !== undefined ||
2197
+ metadata.clusterPolicy !== undefined ||
2198
+ metadata.sceneId !== undefined)
2199
+ ? metadata
2200
+ : undefined,
2201
+ };
2202
+ }
2203
+ function renderConclusionContract(contract, options) {
2204
+ const lines = [];
2205
+ lines.push('## 结论(按可能性排序)');
2206
+ contract.conclusions.forEach((item, idx) => {
2207
+ const confidenceSuffix = typeof item.confidencePercent === 'number'
2208
+ ? `(置信度: ${Math.round(item.confidencePercent)}%)`
2209
+ : '';
2210
+ lines.push(`${idx + 1}. ${item.statement}${confidenceSuffix}`);
2211
+ });
2212
+ lines.push('');
2213
+ if (!options.singleFrameDrillDown) {
2214
+ const sceneId = options.scenePromptHints?.sceneId || contract.metadata?.sceneId;
2215
+ lines.push(resolveClusterSectionHeading(sceneId));
2216
+ if (contract.clusters.length === 0) {
2217
+ lines.push('- 暂无');
2218
+ }
2219
+ else {
2220
+ contract.clusters.forEach((cluster) => {
2221
+ const prefix = cluster.description
2222
+ ? `${cluster.cluster}: ${cluster.description}`
2223
+ : cluster.cluster;
2224
+ const metrics = [];
2225
+ if (typeof cluster.frames === 'number')
2226
+ metrics.push(`${Math.round(cluster.frames)}帧`);
2227
+ if (typeof cluster.percentage === 'number')
2228
+ metrics.push(`${cluster.percentage.toFixed(1)}%`);
2229
+ const frameRefs = parseFrameRefsFromUnknown(cluster.frameRefs);
2230
+ const frameRefText = frameRefs.length > 0 ? `;帧: ${frameRefs.join(' / ')}` : '';
2231
+ const omissionHint = typeof cluster.omittedFrameRefs === 'number' && cluster.omittedFrameRefs > 0
2232
+ ? `(其余 ${Math.round(cluster.omittedFrameRefs)} 帧省略)`
2233
+ : '';
2234
+ lines.push(`- ${prefix}${metrics.length > 0 ? `(${metrics.join(', ')})` : ''}${frameRefText}${omissionHint}`);
2235
+ });
2236
+ }
2237
+ lines.push('');
2238
+ }
2239
+ lines.push('## 证据链(对应上述结论)');
2240
+ if (contract.evidenceChain.length === 0) {
2241
+ lines.push('- 证据链信息缺失');
2242
+ }
2243
+ else {
2244
+ contract.evidenceChain.forEach((item) => lines.push(`- ${item.conclusionId}: ${item.text}`));
2245
+ }
2246
+ lines.push('');
2247
+ if (contract.claims && contract.claims.length > 0) {
2248
+ lines.push('## 逐句数据引用(结构化来源)');
2249
+ contract.claims.forEach((item, idx) => {
2250
+ const claimId = item.id || `Q${idx + 1}`;
2251
+ const conclusionId = item.conclusionId ? ` / ${item.conclusionId}` : '';
2252
+ lines.push(`- ${claimId}${conclusionId}: ${item.text}`);
2253
+ item.references.forEach((ref) => {
2254
+ const line = formatClaimReferenceMarkdown(ref);
2255
+ if (line)
2256
+ lines.push(` - ${line}`);
2257
+ });
2258
+ });
2259
+ lines.push('');
2260
+ }
2261
+ lines.push('## 不确定性与反例');
2262
+ if (contract.uncertainties.length === 0) {
2263
+ lines.push('- 暂无');
2264
+ }
2265
+ else {
2266
+ contract.uncertainties.forEach((item) => lines.push(`- ${item}`));
2267
+ }
2268
+ lines.push('');
2269
+ lines.push('## 下一步(最高信息增益)');
2270
+ if (contract.nextSteps.length === 0) {
2271
+ lines.push('- 暂无');
2272
+ }
2273
+ else {
2274
+ contract.nextSteps.forEach((item) => lines.push(`- ${item}`));
2275
+ }
2276
+ if (contract.metadata && (contract.metadata.confidencePercent !== undefined || contract.metadata.rounds !== undefined)) {
2277
+ lines.push('');
2278
+ lines.push('## 分析元数据');
2279
+ if (contract.metadata.confidencePercent !== undefined) {
2280
+ lines.push(`- 置信度: ${Math.round(contract.metadata.confidencePercent)}%`);
2281
+ }
2282
+ if (contract.metadata.rounds !== undefined) {
2283
+ lines.push(`- 分析轮次: ${Math.round(contract.metadata.rounds)}`);
2284
+ }
2285
+ }
2286
+ return lines.join('\n');
2287
+ }
2288
+ function parseMarkdownToConclusionContract(markdown, mode, options) {
2289
+ const text = String(markdown || '').trim();
2290
+ if (!text)
2291
+ return null;
2292
+ const conclusionSection = findMarkdownSection(text, /^##\s*结论[((]按可能性排序[))]\s*$/m) ||
2293
+ findMarkdownSection(text, /^##\s*分析结论\s*$/m);
2294
+ const clusterSection = findMarkdownSection(text, /^##\s*掉帧聚类[((]先看大头[))]\s*$/m)
2295
+ || findMarkdownSection(text, /^##\s*聚类[((]先看大头[))]\s*$/m)
2296
+ || findMarkdownSection(text, /^##\s*聚类\s*$/m);
2297
+ const evidenceSection = findMarkdownSection(text, /^##\s*证据链[((]对应上述结论[))]\s*$/m);
2298
+ const claimsSection = findMarkdownSection(text, /^##\s*逐句数据引用(?:[((](?:结构化来源|系统核对结果)[))])?\s*$/m);
2299
+ const uncertaintySection = findMarkdownSection(text, /^##\s*不确定性与反例\s*$/m);
2300
+ const nextStepSection = findMarkdownSection(text, /^##\s*下一步[((]最高信息增益[))]\s*$/m);
2301
+ const metadataSection = findMarkdownSection(text, /^##\s*分析元数据\s*$/m);
2302
+ const hasSignal = Boolean(conclusionSection || clusterSection || evidenceSection || claimsSection || uncertaintySection || nextStepSection || metadataSection);
2303
+ if (!hasSignal)
2304
+ return null;
2305
+ const clusterHeader = clusterSection
2306
+ ? text.slice(clusterSection.headerStart, clusterSection.headerEnd)
2307
+ : '';
2308
+ const inferredSceneId = /掉帧聚类/.test(clusterHeader) ? 'jank' : undefined;
2309
+ const parsedMetadata = metadataSection ? parseMetadataFromMarkdownSection(metadataSection.body) : undefined;
2310
+ const metadata = inferredSceneId
2311
+ ? { ...(parsedMetadata || {}), sceneId: inferredSceneId }
2312
+ : parsedMetadata;
2313
+ const contract = {
2314
+ schemaVersion: 'conclusion_contract_v1',
2315
+ mode,
2316
+ conclusions: conclusionSection ? parseConclusionItemsFromMarkdownSection(conclusionSection.body) : [],
2317
+ clusters: clusterSection ? parseClusterItemsFromMarkdownSection(clusterSection.body) : [],
2318
+ evidenceChain: evidenceSection ? parseEvidenceItemsFromMarkdownSection(evidenceSection.body) : [],
2319
+ claims: claimsSection ? parseClaimItemsFromMarkdownSection(claimsSection.body) : [],
2320
+ uncertainties: uncertaintySection
2321
+ ? extractListEntriesFromSectionBody(uncertaintySection.body).map(normalizeUncertaintyWording)
2322
+ : [],
2323
+ nextSteps: nextStepSection
2324
+ ? extractListEntriesFromSectionBody(nextStepSection.body).map(normalizeNextStepWording)
2325
+ : [],
2326
+ metadata,
2327
+ };
2328
+ return sanitizeConclusionContract(contract, options);
2329
+ }
2330
+ function parseJsonToConclusionContract(rawText, mode, options) {
2331
+ const cleaned = stripJsonCodeFence(rawText);
2332
+ if (!cleaned)
2333
+ return null;
2334
+ if (!cleaned.startsWith('{'))
2335
+ return null;
2336
+ let parsed = null;
2337
+ const candidate = cleaned.endsWith('}') ? cleaned : extractFirstJsonObject(cleaned);
2338
+ if (!candidate)
2339
+ return null;
2340
+ try {
2341
+ parsed = JSON.parse(candidate);
2342
+ }
2343
+ catch {
2344
+ return null;
2345
+ }
2346
+ const root = toRecord(parsed);
2347
+ if (!root)
2348
+ return null;
2349
+ const conclusionSource = readValueFromAliases(root, ['conclusion', 'conclusions', '结论']);
2350
+ const clusterSource = readValueFromAliases(root, ['clusters', 'jank_clusters', '掉帧聚类', 'cluster']);
2351
+ const evidenceSource = readValueFromAliases(root, ['evidence_chain', 'evidenceChain', '证据链']);
2352
+ const claimsSource = readValueFromAliases(root, ['claims', 'claim_refs', 'claimRefs', 'claimReferences', '逐句数据引用']);
2353
+ const uncertaintySource = readValueFromAliases(root, ['uncertainties', 'uncertainty', '不确定性与反例', '不确定性']);
2354
+ const nextStepSource = readValueFromAliases(root, ['next_steps', 'nextStep', 'next_step', '下一步']);
2355
+ const metadataSource = readValueFromAliases(root, ['metadata', 'analysis_metadata', '分析元数据']);
2356
+ const conclusions = [];
2357
+ if (Array.isArray(conclusionSource)) {
2358
+ conclusionSource.forEach((item, idx) => {
2359
+ if (typeof item === 'string') {
2360
+ const parsedItem = parseConclusionConfidenceFromStatement(item);
2361
+ conclusions.push({
2362
+ rank: idx + 1,
2363
+ statement: parsedItem.statement,
2364
+ confidencePercent: parsedItem.confidencePercent,
2365
+ });
2366
+ return;
2367
+ }
2368
+ const record = toRecord(item);
2369
+ if (!record)
2370
+ return;
2371
+ const parsedItem = parseConclusionItemFromRecord(record, idx + 1);
2372
+ if (parsedItem)
2373
+ conclusions.push(parsedItem);
2374
+ });
2375
+ }
2376
+ else if (typeof conclusionSource === 'string') {
2377
+ const parsedItem = parseConclusionConfidenceFromStatement(conclusionSource);
2378
+ if (parsedItem.statement) {
2379
+ conclusions.push({
2380
+ rank: 1,
2381
+ statement: parsedItem.statement,
2382
+ confidencePercent: parsedItem.confidencePercent,
2383
+ });
2384
+ }
2385
+ }
2386
+ else {
2387
+ const fallbackItem = parseConclusionItemFromRecord(root, 1);
2388
+ if (fallbackItem)
2389
+ conclusions.push(fallbackItem);
2390
+ }
2391
+ const clusters = [];
2392
+ if (Array.isArray(clusterSource)) {
2393
+ for (const item of clusterSource) {
2394
+ const record = toRecord(item);
2395
+ if (!record)
2396
+ continue;
2397
+ const parsedItem = parseClusterItemFromRecord(record);
2398
+ if (parsedItem)
2399
+ clusters.push(parsedItem);
2400
+ }
2401
+ }
2402
+ else {
2403
+ const record = toRecord(clusterSource);
2404
+ if (record) {
2405
+ const parsedItem = parseClusterItemFromRecord(record);
2406
+ if (parsedItem)
2407
+ clusters.push(parsedItem);
2408
+ }
2409
+ }
2410
+ const evidenceChain = [];
2411
+ if (Array.isArray(evidenceSource)) {
2412
+ evidenceSource.forEach((item, idx) => {
2413
+ if (typeof item === 'string') {
2414
+ const m = item.match(/^(C\d+)\s*[::]\s*(.+)$/i);
2415
+ evidenceChain.push({
2416
+ conclusionId: normalizeConclusionId(m?.[1] || '', idx + 1),
2417
+ text: stripBulletPrefix(m?.[2] || item),
2418
+ });
2419
+ return;
2420
+ }
2421
+ const record = toRecord(item);
2422
+ if (!record)
2423
+ return;
2424
+ evidenceChain.push(...parseEvidenceItemsFromRecord(record, idx + 1));
2425
+ });
2426
+ }
2427
+ else {
2428
+ const record = toRecord(evidenceSource);
2429
+ if (record) {
2430
+ evidenceChain.push(...parseEvidenceItemsFromRecord(record, 1));
2431
+ }
2432
+ }
2433
+ const claims = parseClaimItemsFromUnknown(claimsSource);
2434
+ const uncertainties = toStringArray(uncertaintySource).map(normalizeUncertaintyWording);
2435
+ const nextSteps = toStringArray(nextStepSource).map(normalizeNextStepWording);
2436
+ const metadataRecord = toRecord(metadataSource);
2437
+ const metadataClusterPolicy = normalizeClusterPolicy(metadataRecord ? readValueFromAliases(metadataRecord, ['clusterPolicy', 'cluster_policy']) : undefined);
2438
+ const rootClusterPolicy = normalizeClusterPolicy(readValueFromAliases(root, ['clusterPolicy', 'cluster_policy']));
2439
+ const metadataSceneId = normalizeSceneId(metadataRecord ? readValueFromAliases(metadataRecord, ['sceneId', 'scene_id', 'scene']) : undefined);
2440
+ const rootSceneId = normalizeSceneId(readValueFromAliases(root, ['sceneId', 'scene_id', 'scene']));
2441
+ const metadata = metadataRecord
2442
+ ? {
2443
+ confidencePercent: clampPercent(readSemanticNumber(metadataRecord, 'confidence')),
2444
+ rounds: (() => {
2445
+ const rounds = readSemanticNumber(metadataRecord, 'rounds');
2446
+ return typeof rounds === 'number' && Number.isFinite(rounds) ? Math.round(rounds) : undefined;
2447
+ })(),
2448
+ clusterPolicy: metadataClusterPolicy || rootClusterPolicy,
2449
+ sceneId: metadataSceneId || rootSceneId,
2450
+ }
2451
+ : {
2452
+ confidencePercent: clampPercent(readSemanticNumber(root, 'confidence')),
2453
+ rounds: (() => {
2454
+ const rounds = readSemanticNumber(root, 'rounds');
2455
+ return typeof rounds === 'number' && Number.isFinite(rounds) ? Math.round(rounds) : undefined;
2456
+ })(),
2457
+ clusterPolicy: rootClusterPolicy,
2458
+ sceneId: rootSceneId,
2459
+ };
2460
+ const contract = {
2461
+ schemaVersion: 'conclusion_contract_v1',
2462
+ mode,
2463
+ conclusions,
2464
+ clusters,
2465
+ evidenceChain,
2466
+ claims,
2467
+ uncertainties,
2468
+ nextSteps,
2469
+ metadata,
2470
+ };
2471
+ return sanitizeConclusionContract(contract, options);
2472
+ }
2473
+ function toDeterministicConclusionMarkdown(rawText, mode, options, emitter) {
2474
+ const text = String(rawText || '').trim();
2475
+ if (!text)
2476
+ return text;
2477
+ const contractFromJson = parseJsonToConclusionContract(text, mode, options);
2478
+ if (contractFromJson) {
2479
+ emitter.log('[conclusionGenerator] Rendered conclusion via structured contract JSON');
2480
+ return renderConclusionContract(contractFromJson, options);
2481
+ }
2482
+ let markdownCandidate = text;
2483
+ if (shouldNormalizeConclusionOutput(text)) {
2484
+ emitter.log('[conclusionGenerator] LLM returned non-markdown output, applying legacy normalizer before contract render');
2485
+ markdownCandidate = normalizeConclusionOutput(text);
2486
+ }
2487
+ const contractFromMarkdown = parseMarkdownToConclusionContract(markdownCandidate, mode, options);
2488
+ if (contractFromMarkdown) {
2489
+ emitter.log('[conclusionGenerator] Rendered conclusion via markdown->contract pipeline');
2490
+ return renderConclusionContract(contractFromMarkdown, options);
2491
+ }
2492
+ return markdownCandidate;
2493
+ }
2494
+ function deriveConclusionContract(rawText, options = {}) {
2495
+ const mode = options.mode || 'initial_report';
2496
+ const renderOptions = {
2497
+ singleFrameDrillDown: Boolean(options.singleFrameDrillDown),
2498
+ };
2499
+ const sceneIdHint = normalizeSceneId(options.sceneId);
2500
+ const text = String(rawText || '').trim();
2501
+ if (!text)
2502
+ return null;
2503
+ const applySceneIdHint = (contract) => {
2504
+ if (!sceneIdHint || contract.metadata?.sceneId)
2505
+ return contract;
2506
+ return {
2507
+ ...contract,
2508
+ metadata: {
2509
+ ...(contract.metadata || {}),
2510
+ sceneId: sceneIdHint,
2511
+ },
2512
+ };
2513
+ };
2514
+ const contractFromJson = parseJsonToConclusionContract(text, mode, renderOptions);
2515
+ if (contractFromJson)
2516
+ return applySceneIdHint(contractFromJson);
2517
+ const markdownCandidates = [text];
2518
+ const normalizedJsonLike = convertJsonLikeSectionsToMarkdown(text, renderOptions);
2519
+ if (normalizedJsonLike) {
2520
+ markdownCandidates.push(normalizedJsonLike);
2521
+ }
2522
+ const normalizedJson = convertJsonToMarkdown(text);
2523
+ if (normalizedJson && normalizedJson !== text) {
2524
+ markdownCandidates.push(normalizedJson);
2525
+ }
2526
+ for (const candidate of markdownCandidates) {
2527
+ const contract = parseMarkdownToConclusionContract(candidate, mode, renderOptions);
2528
+ if (contract)
2529
+ return applySceneIdHint(contract);
2530
+ }
2531
+ return null;
2532
+ }
2533
+ function renderConclusionContractMarkdown(contract, options = {}) {
2534
+ return renderConclusionContract(contract, {
2535
+ singleFrameDrillDown: Boolean(options.singleFrameDrillDown),
2536
+ });
2537
+ }
2538
+ const ANSWER_STREAM_MAX_CHARS_PER_CHUNK = 18;
2539
+ const ANSWER_STREAM_BOUNDARY_RE = /[\n。!?!?;;::,,]/;
2540
+ const ANSWER_STREAM_TOKEN_RE = /(\n+|[。!?!?;;::,,]|[^\s。!?!?;;::,,\n]+|\s+)/g;
2541
+ function tokenizeConclusionForStreaming(content) {
2542
+ const normalized = String(content || '');
2543
+ if (!normalized)
2544
+ return [];
2545
+ const rawTokens = normalized.match(ANSWER_STREAM_TOKEN_RE) || [normalized];
2546
+ const chunks = [];
2547
+ let buffer = '';
2548
+ const flush = () => {
2549
+ if (!buffer)
2550
+ return;
2551
+ chunks.push(buffer);
2552
+ buffer = '';
2553
+ };
2554
+ for (const token of rawTokens) {
2555
+ if (!token)
2556
+ continue;
2557
+ // Split oversized "word" tokens to keep UI refresh granular and stable.
2558
+ if (token.length > ANSWER_STREAM_MAX_CHARS_PER_CHUNK * 2 &&
2559
+ !ANSWER_STREAM_BOUNDARY_RE.test(token) &&
2560
+ !/\s/.test(token)) {
2561
+ for (let i = 0; i < token.length; i += ANSWER_STREAM_MAX_CHARS_PER_CHUNK) {
2562
+ const piece = token.slice(i, i + ANSWER_STREAM_MAX_CHARS_PER_CHUNK);
2563
+ if (buffer && buffer.length + piece.length > ANSWER_STREAM_MAX_CHARS_PER_CHUNK) {
2564
+ flush();
2565
+ }
2566
+ buffer += piece;
2567
+ flush();
2568
+ }
2569
+ continue;
2570
+ }
2571
+ if (buffer && buffer.length + token.length > ANSWER_STREAM_MAX_CHARS_PER_CHUNK) {
2572
+ flush();
2573
+ }
2574
+ buffer += token;
2575
+ if (ANSWER_STREAM_BOUNDARY_RE.test(token) || buffer.length >= ANSWER_STREAM_MAX_CHARS_PER_CHUNK) {
2576
+ flush();
2577
+ }
2578
+ }
2579
+ flush();
2580
+ return chunks;
2581
+ }
2582
+ function emitConclusionAsAnswerTokens(emitter, conclusion, options = {}) {
2583
+ const text = String(conclusion || '');
2584
+ const shouldEmitTokens = options.emitTokens !== false;
2585
+ const chunks = shouldEmitTokens ? tokenizeConclusionForStreaming(text) : [];
2586
+ for (const token of chunks) {
2587
+ emitter.emitUpdate('answer_token', { token });
2588
+ }
2589
+ emitter.emitUpdate('answer_token', {
2590
+ done: true,
2591
+ totalChars: text.length,
2592
+ });
2593
+ return text;
2594
+ }
2595
+ /**
2596
+ * Generate an AI-powered conclusion from analysis results.
2597
+ * Falls back to a simple markdown summary if LLM fails.
2598
+ */
2599
+ async function generateConclusion(sharedContext, allFindings, intent, modelRouter, emitter, stopReason, options = {}) {
2600
+ let hasModelTokenStream = false;
2601
+ const onModelToken = (token) => {
2602
+ if (!token)
2603
+ return;
2604
+ hasModelTokenStream = true;
2605
+ emitter.emitUpdate('answer_token', { token });
2606
+ };
2607
+ const streamConclusionAndReturn = (text) => emitConclusionAsAnswerTokens(emitter, text, {
2608
+ emitTokens: !hasModelTokenStream,
2609
+ });
2610
+ const sanitizedFindings = sanitizeFindingsForConclusion(allFindings);
2611
+ const confirmedHypotheses = Array.from(sharedContext.hypotheses.values())
2612
+ .filter(h => h.status === 'confirmed' || h.confidence >= 0.85);
2613
+ const turnCount = Number.isFinite(options.turnCount) ? Number(options.turnCount) : 0;
2614
+ const singleFrameDrillDown = isSingleFrameDrillDown(intent);
2615
+ const historyContext = singleFrameDrillDown ? '' : (options.historyContext || '');
2616
+ const frameMechanismRecords = sharedContext.frameMechanismRecords || [];
2617
+ const scopedJankSummary = singleFrameDrillDown ? undefined : sharedContext.jankCauseSummary;
2618
+ // Collect contradicted findings for explicit mention in prompt
2619
+ // Instead of filtering them out, we let LLM resolve contradictions with guidance
2620
+ const contradictedFindings = sanitizedFindings.filter(f => f.details?._contradicted);
2621
+ const contradictionReasons = contradictedFindings
2622
+ .map(f => f.details?._contradictionReason)
2623
+ .filter((r) => typeof r === 'string');
2624
+ // Sort findings by confidence (highest first) for better LLM processing
2625
+ const sortedFindings = [...sanitizedFindings].sort((a, b) => (b.confidence || 0.5) - (a.confidence || 0.5));
2626
+ // Filter out contradicted findings to prevent LLM from generating conflicting conclusions
2627
+ const findingsForPrompt = sortedFindings.filter(f => !f.details?._contradicted);
2628
+ // If all findings were filtered, keep top 5 by confidence as fallback
2629
+ const finalFindings = findingsForPrompt.length > 0
2630
+ ? findingsForPrompt
2631
+ : sortedFindings.slice(0, 5);
2632
+ const promptFindings = finalFindings.slice(0, PROMPT_FINDING_LIMIT);
2633
+ const attributionAssessment = deriveAttributionAssessment(finalFindings, scopedJankSummary);
2634
+ const insightEnabled = isInsightConclusionEnabled();
2635
+ const outputMode = resolveConclusionOutputMode({
2636
+ insightEnabled,
2637
+ turnCount,
2638
+ intent,
2639
+ findingsCount: sortedFindings.length,
2640
+ confirmedHypothesesCount: confirmedHypotheses.length,
2641
+ hasJankSummary: Boolean(scopedJankSummary && scopedJankSummary.totalJankFrames > 0),
2642
+ });
2643
+ const scenePromptHints = (0, conclusionSceneTemplates_1.buildConclusionScenePromptHints)({
2644
+ intent,
2645
+ findings: promptFindings,
2646
+ deepReasonLabel: analysisNarrative_1.DEEP_REASON_LABEL,
2647
+ });
2648
+ // Build contradiction section for prompt if any exist
2649
+ const contradictionSection = contradictionReasons.length > 0
2650
+ ? `\n⚠️ 数据矛盾提示:\n${contradictionReasons.map(r => `- ${r}`).join('\n')}\n`
2651
+ : '';
2652
+ // Build structured jank summary section (from per-frame analysis)
2653
+ const jankSummarySection = (0, jankCauseSummarizer_1.formatJankSummaryForPrompt)(scopedJankSummary);
2654
+ const includeAttributionPrompt = isJankSceneId(scenePromptHints.sceneId);
2655
+ const attributionAssessmentSection = includeAttributionPrompt
2656
+ ? buildAttributionAssessmentPromptSection(attributionAssessment)
2657
+ : '';
2658
+ const mechanismTriadSection = includeAttributionPrompt
2659
+ ? buildMechanismTriadPromptSection(attributionAssessment, scopedJankSummary, frameMechanismRecords)
2660
+ : '';
2661
+ const sceneFocusPromptSection = [
2662
+ '## 场景化分析焦点',
2663
+ `- 当前场景: ${scenePromptHints.sceneName}`,
2664
+ ...scenePromptHints.focusLines,
2665
+ ].join('\n');
2666
+ const sceneOutputRequirementSection = [
2667
+ ...scenePromptHints.outputRequirementLines,
2668
+ scenePromptHints.nextStepLine,
2669
+ ].join('\n');
2670
+ const nonInsightClusterGoalLine = scenePromptHints.clusterPolicy.outputMode === 'required'
2671
+ ? '6. 聚类/分组 Top3(按样本规模降序,先给 K1 大头)'
2672
+ : (scenePromptHints.clusterPolicy.outputMode === 'none'
2673
+ ? '6. 当前场景无需聚类分组,请省略 clusters 并说明原因'
2674
+ : '6. 若有分组证据可给出 Top 分组;若无可省略聚类并说明原因');
2675
+ const nonInsightClusterConstraint = scenePromptHints.clusterPolicy.outputMode === 'required'
2676
+ ? '- 必须输出 clusters(K1/K2/K3),并给出每类样本数和占比'
2677
+ : (scenePromptHints.clusterPolicy.outputMode === 'none'
2678
+ ? '- 当前场景 clusters 必须传空数组,不要虚构聚类'
2679
+ : '- 当前场景 clusters 可按时间阶段/样本分组给出;若无聚类证据可传空数组');
2680
+ const nonInsightConflictRulesSection = buildNonInsightConflictRulesSection(scenePromptHints, sharedContext.traceConfig);
2681
+ // Debug: Log whether jank summary is being included
2682
+ if (scopedJankSummary) {
2683
+ console.log(`[ConclusionGenerator] Using jankCauseSummary: ${scopedJankSummary.totalJankFrames} frames, primary=${scopedJankSummary.primaryCause?.label}`);
2684
+ }
2685
+ else if (singleFrameDrillDown) {
2686
+ console.log('[ConclusionGenerator] Single-frame drill-down: jankCauseSummary suppressed to avoid cross-turn cluster carry-over');
2687
+ }
2688
+ else {
2689
+ console.log(`[ConclusionGenerator] No jankCauseSummary available in sharedContext`);
2690
+ }
2691
+ const prompt = insightEnabled
2692
+ ? buildInsightFirstPrompt({
2693
+ mode: outputMode,
2694
+ turnCount,
2695
+ historyContext,
2696
+ intent,
2697
+ stopReason,
2698
+ confirmedHypotheses: confirmedHypotheses.map(h => ({
2699
+ description: h.description,
2700
+ confidence: h.confidence,
2701
+ status: h.status,
2702
+ })),
2703
+ findings: promptFindings,
2704
+ contradictionSection,
2705
+ jankSummary: scopedJankSummary,
2706
+ frameMechanismRecords,
2707
+ attributionAssessment,
2708
+ scenePromptHints,
2709
+ traceConfig: sharedContext.traceConfig,
2710
+ investigationPath: sharedContext.investigationPath,
2711
+ })
2712
+ : `基于以下分析结果生成诊断结论:
2713
+
2714
+ 用户目标: ${intent.primaryGoal}
2715
+ ${stopReason ? `提前终止原因: ${stopReason}` : ''}
2716
+ ${jankSummarySection}
2717
+ ${attributionAssessmentSection}
2718
+ ${mechanismTriadSection}
2719
+ ${sceneFocusPromptSection}
2720
+ 已确认的假设:
2721
+ ${confirmedHypotheses.map(h => `- ${h.description} (confidence: ${h.confidence.toFixed(2)})`).join('\n') || '无'}
2722
+
2723
+ 发现的问题(含数据证据):
2724
+ ${promptFindings.map(f => formatFindingWithEvidence(f)).join('\n\n') || '无'}
2725
+ ${contradictionSection}
2726
+ 调查路径:
2727
+ ${sharedContext.investigationPath.map(s => `${s.stepNumber}. [${s.agentId}] ${s.summary}`).join('\n')}
2728
+
2729
+ 请生成:
2730
+ 1. 根因分析(最可能的原因)
2731
+ 2. 证据支撑(每个结论的依据)
2732
+ 3. 置信度评估
2733
+ 4. 下一步最有信息增益的分析动作
2734
+ 5. 机制分层说明:直接原因 / 资源问题 / 放大因素
2735
+ ${nonInsightClusterGoalLine}
2736
+
2737
+ 重要约束:
2738
+ - 只基于上述提供的数据和证据得出结论,不要推测未提供的信息
2739
+ - 如果数据不足以得出某个结论,明确标注"证据不足"
2740
+ - 每个结论必须引用具体的数据来源(Finding 的标题或数据值)
2741
+ ${sceneOutputRequirementSection}
2742
+ - “下一步”至少包含 1 条行动项,使用 owner/priority/verification 明确责任与验收标准
2743
+ - 可给出最多 2 条与“${analysisNarrative_1.DEEP_REASON_LABEL}”一一对应的优化方向,避免泛化建议
2744
+ - ${nonInsightClusterConstraint}
2745
+ ${nonInsightConflictRulesSection}
2746
+
2747
+ ## 输出格式要求(必须严格遵守)
2748
+ - **只输出 Markdown 格式的纯文本**,方便人类阅读
2749
+ - **禁止输出 JSON**,不要用 {} 或 [] 包装内容
2750
+ - **禁止输出代码块**,不要用 \`\`\` 包装
2751
+ - 使用 ## 作为标题,使用 - 作为列表项
2752
+ - 示例格式:
2753
+ ## 根因分析
2754
+ 主要问题是 XXX,置信度 85%。
2755
+
2756
+ ## 证据支撑
2757
+ - 发现1:XXX
2758
+ - 发现2:XXX`;
2759
+ const contractRenderOptions = {
2760
+ singleFrameDrillDown,
2761
+ scenePromptHints,
2762
+ };
2763
+ try {
2764
+ const response = await modelRouter.callWithFallback(prompt, 'synthesis', {
2765
+ jsonMode: insightEnabled,
2766
+ onToken: onModelToken,
2767
+ sessionId: sharedContext.sessionId,
2768
+ traceId: sharedContext.traceId,
2769
+ maxTokens: insightEnabled ? 3000 : 2000,
2770
+ promptId: insightEnabled
2771
+ ? `agent.conclusionGenerator.insight.${outputMode}`
2772
+ : (turnCount >= 1 ? 'agent.conclusionGenerator.dialogue' : 'agent.conclusionGenerator'),
2773
+ promptVersion: '2.0.0',
2774
+ contractVersion: insightEnabled
2775
+ ? 'conclusion_contract_json@1.0.0'
2776
+ : (turnCount >= 1 ? 'conclusion_dialogue_text@1.0.0' : 'conclusion_text@1.0.0'),
2777
+ });
2778
+ let conclusion = toDeterministicConclusionMarkdown(response.response, outputMode, contractRenderOptions, emitter);
2779
+ // Ensure evidence IDs appear in the evidence-chain section when available.
2780
+ // This makes the output auditable even if the LLM forgets to cite.
2781
+ conclusion = finalizeConclusionMarkdown(conclusion, finalFindings, scopedJankSummary, { singleFrameDrillDown, scenePromptHints });
2782
+ if (isConclusionContradictingAttributionVerdict(conclusion, attributionAssessment)) {
2783
+ emitter.log('[conclusionGenerator] LLM conclusion contradicts attribution verdict, switching to rule-based safe fallback');
2784
+ emitter.emitUpdate('degraded', {
2785
+ module: 'conclusionGenerator',
2786
+ fallback: 'rule-based attribution-safe conclusion',
2787
+ });
2788
+ const safeFallback = generateAttributionSafeFallback(attributionAssessment, finalFindings, contradictionReasons, stopReason, scopedJankSummary, frameMechanismRecords);
2789
+ const deterministicFallback = toDeterministicConclusionMarkdown(safeFallback, outputMode, contractRenderOptions, emitter);
2790
+ const finalizedFallback = finalizeConclusionMarkdown(deterministicFallback, finalFindings, scopedJankSummary, { singleFrameDrillDown, scenePromptHints });
2791
+ return streamConclusionAndReturn(finalizedFallback);
2792
+ }
2793
+ return streamConclusionAndReturn(conclusion);
2794
+ }
2795
+ catch (error) {
2796
+ emitter.log(`Failed to generate conclusion: ${error}`);
2797
+ emitter.emitUpdate('degraded', {
2798
+ module: 'conclusionGenerator',
2799
+ fallback: insightEnabled ? `rule-based insight (${outputMode})` : (turnCount >= 1 ? 'rule-based dialogue' : 'rule-based summary'),
2800
+ });
2801
+ }
2802
+ if (insightEnabled) {
2803
+ const fallbackEvidenceFindings = outputMode === 'need_input' ? sortedFindings : finalFindings;
2804
+ const fallback = outputMode === 'need_input'
2805
+ ? generateInsightFallback(outputMode, sortedFindings, confirmedHypotheses.map(h => h.description), stopReason, historyContext, contradictionReasons)
2806
+ : generateAttributionSafeFallback(attributionAssessment, finalFindings, contradictionReasons, stopReason, scopedJankSummary, frameMechanismRecords);
2807
+ const deterministicFallback = toDeterministicConclusionMarkdown(fallback, outputMode, contractRenderOptions, emitter);
2808
+ const finalizedFallback = finalizeConclusionMarkdown(deterministicFallback, fallbackEvidenceFindings, scopedJankSummary, { singleFrameDrillDown, scenePromptHints });
2809
+ return streamConclusionAndReturn(finalizedFallback);
2810
+ }
2811
+ const plainFallback = turnCount >= 1
2812
+ ? generateDialogueFallback(sortedFindings, intent, stopReason, historyContext)
2813
+ : generateSimpleConclusion(sortedFindings, stopReason);
2814
+ return streamConclusionAndReturn(plainFallback);
2815
+ }
2816
+ function buildJankFrameBudgetSection(traceConfig) {
2817
+ const content = traceConfig
2818
+ ? (traceConfig.isVRR
2819
+ ? `- **VRR/LTPO 模式: ${traceConfig.vrrMode}**
2820
+ - **主导刷新率: ${traceConfig.refreshRateHz}Hz**(用于大部分帧的判断)
2821
+ - **帧预算范围: ${traceConfig.minFrameBudgetMs || traceConfig.vsyncPeriodMs}ms - ${traceConfig.maxFrameBudgetMs || traceConfig.vsyncPeriodMs}ms**
2822
+ - ⚠️ VRR 设备帧预算动态变化,使用最严格标准(${traceConfig.minFrameBudgetMs || traceConfig.vsyncPeriodMs}ms)判断 jank`
2823
+ : `- **检测到的刷新率: ${traceConfig.refreshRateHz}Hz**
2824
+ - **帧预算: ${traceConfig.vsyncPeriodMs}ms**
2825
+ - 数据来源: ${traceConfig.vsyncSource}`)
2826
+ : '- 刷新率未检测到,默认使用 120Hz(8.33ms)作为帧预算';
2827
+ return `## 刷新率与帧预算
2828
+ ${content}`;
2829
+ }
2830
+ function buildNonInsightConflictRulesSection(scenePromptHints, traceConfig) {
2831
+ if (!isJankSceneId(scenePromptHints.sceneId)) {
2832
+ return `## 矛盾数据处理规则
2833
+ 如果发现多个 findings 之间存在矛盾,请按以下规则处理:
2834
+
2835
+ 1. 同口径 + 同时间窗 + 同对象(进程/线程/实体)冲突,才标记为真实矛盾。
2836
+ 2. 若统计口径或时间窗不同,先解释差异来源,不要直接下“互相否定”结论。
2837
+ 3. 优先采信置信度更高且证据链更完整的 Finding,并明确说明取舍理由。`;
2838
+ }
2839
+ return `${buildJankFrameBudgetSection(traceConfig)}
2840
+
2841
+ ## 矛盾数据处理规则
2842
+ 如果发现多个 findings 之间存在矛盾,请按以下规则处理:
2843
+
2844
+ 1. **Q4(休眠/阻塞)占比高** vs **主线程耗时操作**:
2845
+ - 需要同时满足两个条件才判定为"阻塞/等待"问题:
2846
+ a) Q4 占比 > 30%
2847
+ b) Q4 绝对耗时 > 帧预算的 50%(如 120Hz 下 > 4ms)
2848
+ - 如果 Q4 占比高但绝对耗时很短(如 2ms),可能只是正常的 Binder/IPC 开销
2849
+ - 只有当 Q1+Q2(Running 状态)耗时超过帧预算时,才判定为"主线程耗时操作"
2850
+
2851
+ 2. **RenderThread 阻塞** vs **GPU 瓶颈**:
2852
+ - RenderThread 的 Q4 高可能是等待 GPU Fence 信号,而非 CPU 阻塞
2853
+ - 如果同时存在 GPU 频率/负载数据,应综合判断是 GPU 能力不足还是 CPU 等待
2854
+ - GPU Fence > 3ms 通常表示 GPU 瓶颈
2855
+
2856
+ 3. **App 侧正常** vs **消费端掉帧**:
2857
+ - App 帧生产正常但消费端掉帧,说明问题在 SurfaceFlinger/HWC 层
2858
+ - 此时不应归因于 App,而应指出系统合成层的瓶颈
2859
+ - 常见原因:SF 合成延迟、HWC 提交延迟、GPU 合成耗时
2860
+
2861
+ 4. **掉帧数量不一致**(如 "25 个卡顿帧" vs "38 个卡顿帧"):
2862
+ - 不同统计口径可能导致数量差异:
2863
+ - App 报告:App 自己统计的掉帧(可能漏报消费端问题)
2864
+ - 消费端检测:用户实际感知的掉帧(包含系统层问题)
2865
+ - 帧列表:逐帧分析的结果
2866
+ - 如果来自不同 session_id 或不同时间窗(例如区间1 vs 区间2),属于区间差异,不应判定为矛盾
2867
+ - 仅当“同口径 + 同时间窗 + 同进程”下出现冲突,才标记为矛盾
2868
+ - 应说明使用的是哪个口径,并引用具体 Finding 来源
2869
+
2870
+ 5. **CPU 频率低** vs **主线程耗时**:
2871
+ - 大核频率 < 1.2GHz 时,耗时问题可能是功耗策略导致
2872
+ - 此时应指出"CPU 调度/频率不足"而非"代码耗时"
2873
+
2874
+ 6. **优先采信置信度更高的 Finding**,但必须说明理由`;
2875
+ }
2876
+ /**
2877
+ * Generate a simple markdown-formatted conclusion without LLM.
2878
+ */
2879
+ function generateSimpleConclusion(findings, stopReason) {
2880
+ const critical = findings.filter(f => f.severity === 'critical');
2881
+ const warnings = findings.filter(f => f.severity === 'warning');
2882
+ let conclusion = '## 分析结论\n\n';
2883
+ if (critical.length > 0) {
2884
+ conclusion += `### 严重问题 (${critical.length})\n`;
2885
+ for (const f of critical) {
2886
+ conclusion += `- **${f.title}**\n`;
2887
+ }
2888
+ conclusion += '\n';
2889
+ }
2890
+ if (warnings.length > 0) {
2891
+ conclusion += `### 需要关注 (${warnings.length})\n`;
2892
+ for (const f of warnings) {
2893
+ conclusion += `- ${f.title}\n`;
2894
+ }
2895
+ conclusion += '\n';
2896
+ }
2897
+ if (findings.length === 0) {
2898
+ conclusion += '未发现明显的性能问题。\n';
2899
+ }
2900
+ if (stopReason) {
2901
+ conclusion += `\n> 备注:分析提前结束(${stopReason})。\n`;
2902
+ }
2903
+ return conclusion;
2904
+ }
2905
+ function buildInsightFirstPrompt(params) {
2906
+ const parts = [];
2907
+ const singleFrameDrillDown = isSingleFrameDrillDown(params.intent);
2908
+ parts.push(`你是 SmartPerfetto 的 AI 性能分析助手,正在进行多轮对话(当前第 ${params.turnCount + 1} 轮)。`);
2909
+ parts.push('你的目标:给出“洞见优先”的结论,而不是套模板。');
2910
+ parts.push('');
2911
+ parts.push('## 用户本轮输入');
2912
+ parts.push(params.intent.primaryGoal);
2913
+ parts.push('');
2914
+ if (params.intent.followUpType && params.intent.followUpType !== 'initial') {
2915
+ parts.push(`Follow-up 类型: ${params.intent.followUpType}`);
2916
+ if (params.intent.referencedEntities && params.intent.referencedEntities.length > 0) {
2917
+ parts.push(`引用实体: ${params.intent.referencedEntities.map(e => `${e.type}:${String(e.value ?? e.id)}`).join(', ')}`);
2918
+ }
2919
+ parts.push('');
2920
+ }
2921
+ if (params.stopReason) {
2922
+ parts.push('## 本轮停止原因');
2923
+ parts.push(params.stopReason);
2924
+ parts.push('');
2925
+ }
2926
+ if (params.historyContext) {
2927
+ parts.push('## 对话历史摘要(用于承接上下文)');
2928
+ parts.push(params.historyContext);
2929
+ parts.push('');
2930
+ }
2931
+ if (singleFrameDrillDown) {
2932
+ parts.push('## 单帧 Drill-Down 范围约束');
2933
+ parts.push('- 本轮只允许使用目标帧或同一时间窗的直接证据。');
2934
+ parts.push('- 禁止沿用历史轮次的聚类帧数/占比(如 K1/K2/K3 百分比)。');
2935
+ parts.push('- 若识别到主线程长 slice,必须解释“为什么这个 slice 慢”,并给出可执行优化方向。');
2936
+ parts.push('');
2937
+ }
2938
+ // Trace config summary (keep short)
2939
+ if (params.traceConfig) {
2940
+ try {
2941
+ const hz = params.traceConfig.refreshRateHz;
2942
+ const vsync = params.traceConfig.vsyncPeriodMs;
2943
+ const isVRR = params.traceConfig.isVRR;
2944
+ parts.push('## Trace 配置摘要');
2945
+ if (hz)
2946
+ parts.push(`- 刷新率: ${hz}Hz`);
2947
+ if (vsync)
2948
+ parts.push(`- 帧预算: ${vsync}ms`);
2949
+ if (typeof isVRR === 'boolean')
2950
+ parts.push(`- VRR: ${isVRR ? '是' : '否'}`);
2951
+ parts.push('');
2952
+ }
2953
+ catch {
2954
+ // best-effort only
2955
+ }
2956
+ }
2957
+ // Include jank cause summary if available
2958
+ if (params.jankSummary && params.jankSummary.totalJankFrames > 0) {
2959
+ parts.push((0, jankCauseSummarizer_1.formatJankSummaryForPrompt)(params.jankSummary));
2960
+ parts.push('');
2961
+ }
2962
+ if (params.confirmedHypotheses.length > 0) {
2963
+ parts.push('## 已确认假设(摘要)');
2964
+ for (const h of params.confirmedHypotheses.slice(0, 5)) {
2965
+ parts.push(`- ${h.description} (confidence: ${Number(h.confidence).toFixed(2)}, status: ${h.status})`);
2966
+ }
2967
+ parts.push('');
2968
+ }
2969
+ parts.push('## 关键发现(含数据证据)');
2970
+ if (params.findings.length === 0) {
2971
+ parts.push('无可用 findings。');
2972
+ }
2973
+ else {
2974
+ parts.push(params.findings.slice(0, PROMPT_FINDING_LIMIT).map(f => formatFindingWithEvidence(f)).join('\n\n'));
2975
+ }
2976
+ parts.push('');
2977
+ // Keep investigation path short for token efficiency
2978
+ if (Array.isArray(params.investigationPath) && params.investigationPath.length > 0) {
2979
+ parts.push('## 调查路径(摘要)');
2980
+ const tail = params.investigationPath.slice(-8);
2981
+ parts.push(tail.map(s => `${s.stepNumber}. [${s.agentId}] ${s.summary}`).join('\n'));
2982
+ parts.push('');
2983
+ }
2984
+ if (params.contradictionSection) {
2985
+ parts.push(params.contradictionSection.trim());
2986
+ parts.push('');
2987
+ }
2988
+ const includeAttributionPrompt = isJankSceneId(params.scenePromptHints.sceneId);
2989
+ if (includeAttributionPrompt) {
2990
+ parts.push(buildAttributionAssessmentPromptSection(params.attributionAssessment));
2991
+ parts.push('');
2992
+ parts.push(buildMechanismTriadPromptSection(params.attributionAssessment, params.jankSummary, params.frameMechanismRecords));
2993
+ parts.push('');
2994
+ }
2995
+ parts.push('## 场景化分析焦点');
2996
+ parts.push(`- 当前场景: ${params.scenePromptHints.sceneName}`);
2997
+ parts.push(...params.scenePromptHints.focusLines);
2998
+ parts.push('');
2999
+ if (includeAttributionPrompt &&
3000
+ (params.attributionAssessment.verdict === 'APP_TRIGGER' || params.attributionAssessment.verdict === 'MIXED')) {
3001
+ parts.push('## 归因提示');
3002
+ parts.push('- 逐帧根因显示主线程/APP 侧耗时信号占主导(例如 cause_type=slice)。');
3003
+ parts.push('- 若同时看到“消费端掉帧”,请区分:消费端是症状层,主线程长耗时是潜在触发层。');
3004
+ parts.push('');
3005
+ }
3006
+ if (includeAttributionPrompt && params.attributionAssessment.verdict === 'SF_CONSUMER') {
3007
+ parts.push('## 归因护栏');
3008
+ parts.push('- 当前证据显示 SF/消费端责任占主导。');
3009
+ parts.push('- 在该前提下,不要直接给出“主线程/Choreographer 是主要根因”的高置信度结论。');
3010
+ parts.push('- 若判定 App 主因,必须引用同一时间窗/同一帧的直接证据链(App Deadline Missed + 主线程耗时切片)。');
3011
+ parts.push('');
3012
+ }
3013
+ else if (includeAttributionPrompt && params.attributionAssessment.verdict === 'INSUFFICIENT') {
3014
+ parts.push('## 归因护栏');
3015
+ parts.push('- 当前证据不足以形成单侧归因,禁止输出“唯一根因”式结论。');
3016
+ parts.push('- 若需要给出方向,必须明确“证据不足”并说明待补数据。');
3017
+ parts.push('');
3018
+ }
3019
+ parts.push('## 输出要求(必须严格遵守)');
3020
+ parts.push('- 只输出合法 JSON;禁止输出 Markdown、代码块、SQL 或额外解释。');
3021
+ parts.push('- 只基于已提供的数据与证据;不允许编造未提供的数据。');
3022
+ parts.push('- 优先用通俗表达:先说现象和影响;若必须用术语,在术语后补一句人话解释。');
3023
+ parts.push(...params.scenePromptHints.outputRequirementLines);
3024
+ parts.push(params.scenePromptHints.nextStepLine);
3025
+ parts.push('- next_steps 至少 1 条使用固定格式:owner: <负责人>; priority: P0/P1/P2; action: <具体动作>; verification: <验收方式>。');
3026
+ parts.push(`- 可给出最多 2 条与“${analysisNarrative_1.DEEP_REASON_LABEL}”一一对应的优化方向,避免泛化建议。`);
3027
+ parts.push('- JSON 顶层字段固定为:schema_version, mode, conclusion, clusters, evidence_chain, claims, uncertainties, next_steps, metadata。');
3028
+ parts.push(`- mode 必须是 "${params.mode}"。schema_version 必须是 "conclusion_contract_v1"。`);
3029
+ parts.push('- 结论最终会渲染为“## 结论(按可能性排序)/## 聚类(先看大头)/## 证据链(对应上述结论)/## 逐句数据引用/## 不确定性与反例/## 下一步(最高信息增益)”。');
3030
+ parts.push('- conclusion 数组最多 3 项,每项包含:rank, statement, confidence, trigger, supply, amplification。');
3031
+ parts.push('- clusters 每项包含:cluster, description, frames, percentage;若有帧级证据可额外提供 frame_refs(string[])。');
3032
+ parts.push(`- trigger/supply/amplification 需要能映射为:${analysisNarrative_1.TRIAD_LABELS.trigger}/${analysisNarrative_1.TRIAD_LABELS.supply}/${analysisNarrative_1.TRIAD_LABELS.amplification}。`);
3033
+ parts.push(`- statement 建议包含可读三元组短句,例如:${analysisNarrative_1.TRIAD_LABELS.trigger}: ...;${analysisNarrative_1.TRIAD_LABELS.supply}: ...;${analysisNarrative_1.TRIAD_LABELS.amplification}: ...`);
3034
+ if (!singleFrameDrillDown && params.scenePromptHints.clusterPolicy.outputMode === 'required') {
3035
+ parts.push('- clusters 必须按样本数降序列出 Top3(K1/K2/K3),并标注样本数与占比。');
3036
+ }
3037
+ else if (!singleFrameDrillDown && params.scenePromptHints.clusterPolicy.outputMode === 'optional') {
3038
+ parts.push('- 当前场景 clusters 可按时间阶段/样本分组给出;若无聚类证据可传空数组。');
3039
+ }
3040
+ else if (!singleFrameDrillDown) {
3041
+ parts.push('- 当前场景 clusters 必须传空数组,不要虚构聚类。');
3042
+ }
3043
+ else {
3044
+ parts.push('- 单帧 drill-down 禁止复用历史 K1/K2/K3;clusters 传空数组。');
3045
+ }
3046
+ parts.push('- evidence_chain 必须按 C1/C2/C3 对齐(C1=结论1):每项包含 conclusion_id 和 evidence 文本,且包含至少 1 个 evidence id(ev_xxxxxxxxxxxx)。');
3047
+ parts.push('- claims 必须列出结论中出现的关键数值/实体判断,用于前端逐句核验;没有可核验数据时传空数组。');
3048
+ parts.push('- claims 每项包含:id(Q1...), conclusion_id(C1...), text, references。');
3049
+ parts.push('- claims[].references 每项包含:evidence_ref_id(优先使用 data:* 证据 ID), source_ref(如 表 1/摘要 1), source_tool_call_id(如可见), row_index(0-based,不是第几行的 1-based 编号), row_selector(行号不稳定时使用), column, value。');
3050
+ parts.push('- metadata 可包含 confidence(0-100 或 0-1)与 rounds(正整数)。');
3051
+ parts.push('- metadata 可包含 cluster_policy 对象:{ output_mode: required|optional|none, frame_list_mode: none|top|full, max_frames_per_cluster?: number }。');
3052
+ parts.push('- metadata 可包含 scene_id(例如 jank/startup),用于前端场景化标题渲染。');
3053
+ if (params.mode === 'focused_answer') {
3054
+ parts.push('- 本轮是 follow-up:优先直接回答用户本轮焦点,不要复述历史长文;总长度尽量控制在 25 行以内。');
3055
+ parts.push('- 如果证据不足以回答本轮问题:在“不确定性与反例”里说明缺口,并在“下一步”里给出 1-2 个最关键的问题或动作。');
3056
+ }
3057
+ else if (params.mode === 'need_input') {
3058
+ parts.push('- 当前证据不足:可以给出低置信度的方向,但必须明确“证据不足”。');
3059
+ parts.push('- 在“下一步”里给出最多 2 个必须回答的问题(每行以 "Q:" 开头),并给出 2-3 个可选动作(以 "A."/"B."/"C." 开头)。');
3060
+ }
3061
+ else {
3062
+ parts.push('- 首轮报告:允许更完整,但避免无关的长篇背景科普;引用具体 findings 数据。');
3063
+ }
3064
+ parts.push('- 全部中文。');
3065
+ return parts.join('\n');
3066
+ }
3067
+ function generateInsightFallback(mode, findings, hypothesisDescriptions, stopReason, historyContext, contradictionReasons) {
3068
+ const lines = [];
3069
+ const topFindings = findings.slice(0, 5);
3070
+ const topFindingTitles = topFindings
3071
+ .filter(f => typeof f.title === 'string' && f.title.trim().length > 0)
3072
+ .map(f => `[${f.severity}] ${f.title}`);
3073
+ lines.push('## 结论(按可能性排序)');
3074
+ if (topFindingTitles.length > 0) {
3075
+ lines.push(`1. 最可能的问题与本轮证据一致(置信度: 60%)。`);
3076
+ lines.push(`2. 仍存在其他可能方向需要排除(置信度: 40%)。`);
3077
+ }
3078
+ else if (hypothesisDescriptions.length > 0) {
3079
+ lines.push(`1. 当前仅有假设线索,尚缺少直接证据(置信度: 40%)。`);
3080
+ }
3081
+ else {
3082
+ lines.push('1. 当前证据不足,无法给出可靠诊断结论(置信度: 20%)。');
3083
+ }
3084
+ lines.push('');
3085
+ lines.push('## 证据链(对应上述结论)');
3086
+ if (topFindingTitles.length > 0) {
3087
+ const conclusionCount = 2;
3088
+ for (let i = 0; i < Math.min(conclusionCount, 3); i += 1) {
3089
+ const f = topFindings[i] || topFindings[0];
3090
+ const evIds = extractEvidenceIdsFromFinding(f).slice(0, 2);
3091
+ const evStr = evIds.length > 0 ? ` (${evIds.join('|')})` : '';
3092
+ lines.push(`- C${i + 1}: [${f.severity}] ${f.title}${evStr}`.trim());
3093
+ }
3094
+ }
3095
+ else if (hypothesisDescriptions.length > 0) {
3096
+ const combined = hypothesisDescriptions.slice(0, 2).join(';');
3097
+ lines.push(`- C1: 假设线索(证据不足,无 ev_ id):${combined}`);
3098
+ }
3099
+ else if (historyContext) {
3100
+ lines.push('- C1: 可用上下文来自对话历史摘要,但缺少结构化证据(findings/ev_)。');
3101
+ }
3102
+ else {
3103
+ lines.push('- C1: 暂无可引用的 findings/hypotheses。');
3104
+ }
3105
+ lines.push('');
3106
+ lines.push('## 不确定性与反例');
3107
+ if (Array.isArray(contradictionReasons) && contradictionReasons.length > 0) {
3108
+ lines.push(`- 当前存在数据矛盾:${contradictionReasons.slice(0, 2).join(';')}`);
3109
+ }
3110
+ else {
3111
+ lines.push('- 缺少关键证据或时间范围/实体引用,结论可能被后续数据推翻。');
3112
+ }
3113
+ if (stopReason) {
3114
+ lines.push(`- 备注:本轮提前结束(${stopReason})。`);
3115
+ }
3116
+ lines.push('');
3117
+ lines.push('## 下一步(最高信息增益)');
3118
+ if (mode === 'need_input') {
3119
+ lines.push('Q: 你希望我聚焦在哪个对象?(frame_id / session_id / 时间范围 / 进程名 任选其一即可)');
3120
+ lines.push('A. 指定一个卡顿帧(例如:frame_id=123)');
3121
+ lines.push('B. 指定一个滑动会话(例如:session_id=2)');
3122
+ lines.push('C. 指定一个时间范围(例如:1.2s~1.5s)');
3123
+ }
3124
+ else {
3125
+ lines.push('- 指定一个可 drill-down 的实体或时间范围(frame_id / session_id / 时间范围),我将只对该范围补证据并更新结论。');
3126
+ lines.push('- 如果你想“比较”,请同时给出两个实体(例如:frame_id=123 vs frame_id=456)。');
3127
+ }
3128
+ return lines.join('\n');
3129
+ }
3130
+ const EVIDENCE_ID_RE = /^ev_[0-9a-f]{12}$/;
3131
+ function readEvidenceId(value) {
3132
+ if (typeof value !== 'string') {
3133
+ return null;
3134
+ }
3135
+ const trimmed = value.trim();
3136
+ return EVIDENCE_ID_RE.test(trimmed) ? trimmed : null;
3137
+ }
3138
+ function extractEvidenceIdsFromFinding(f) {
3139
+ const ids = [];
3140
+ const arr = toEvidenceArray(f.evidence);
3141
+ for (const e of arr) {
3142
+ if (!e)
3143
+ continue;
3144
+ if (typeof e === 'string') {
3145
+ const id = readEvidenceId(e);
3146
+ if (id)
3147
+ ids.push(id);
3148
+ continue;
3149
+ }
3150
+ const evidenceObject = asEvidenceObject(e);
3151
+ if (evidenceObject) {
3152
+ const id = readEvidenceId(evidenceObject.evidenceId || evidenceObject.evidence_id);
3153
+ if (id)
3154
+ ids.push(id);
3155
+ }
3156
+ }
3157
+ const seen = new Set();
3158
+ return ids.filter(id => {
3159
+ if (seen.has(id))
3160
+ return false;
3161
+ seen.add(id);
3162
+ return true;
3163
+ });
3164
+ }
3165
+ function extractEvidenceRefsFromFindings(findings) {
3166
+ const out = [];
3167
+ const seen = new Set();
3168
+ for (const f of findings) {
3169
+ const arr = toEvidenceArray(f.evidence);
3170
+ for (const e of arr) {
3171
+ if (!e)
3172
+ continue;
3173
+ const evidenceObject = asEvidenceObject(e);
3174
+ if (evidenceObject) {
3175
+ const evidenceId = readEvidenceId(evidenceObject.evidenceId || evidenceObject.evidence_id);
3176
+ if (!evidenceId || seen.has(evidenceId))
3177
+ continue;
3178
+ seen.add(evidenceId);
3179
+ out.push({
3180
+ evidenceId,
3181
+ title: typeof evidenceObject.title === 'string' ? String(evidenceObject.title) : undefined,
3182
+ kind: typeof evidenceObject.kind === 'string' ? String(evidenceObject.kind) : undefined,
3183
+ });
3184
+ }
3185
+ else if (typeof e === 'string') {
3186
+ const evidenceId = readEvidenceId(e);
3187
+ if (evidenceId && !seen.has(evidenceId)) {
3188
+ seen.add(evidenceId);
3189
+ out.push({ evidenceId });
3190
+ }
3191
+ }
3192
+ }
3193
+ }
3194
+ return out;
3195
+ }
3196
+ function findMarkdownSection(text, headerRe) {
3197
+ const m = headerRe.exec(text);
3198
+ if (!m)
3199
+ return null;
3200
+ const headerStart = m.index;
3201
+ const headerEnd = headerStart + m[0].length;
3202
+ let bodyStart = headerEnd;
3203
+ if (text[bodyStart] === '\r' && text[bodyStart + 1] === '\n')
3204
+ bodyStart += 2;
3205
+ else if (text[bodyStart] === '\n')
3206
+ bodyStart += 1;
3207
+ const nextHeaderRe = /^##\s+/gm;
3208
+ nextHeaderRe.lastIndex = bodyStart;
3209
+ const next = nextHeaderRe.exec(text);
3210
+ const bodyEnd = next ? next.index : text.length;
3211
+ const body = text.slice(bodyStart, bodyEnd);
3212
+ return { headerStart, headerEnd, bodyStart, bodyEnd, body };
3213
+ }
3214
+ function extractConclusionItemsFromSection(sectionBody) {
3215
+ const lines = String(sectionBody || '').split(/\r?\n/);
3216
+ const items = [];
3217
+ let autoIndex = 1;
3218
+ for (const rawLine of lines) {
3219
+ const line = rawLine.trim();
3220
+ if (!line)
3221
+ continue;
3222
+ const mNum = /^([1-3])\s*[.)、]\s*(.+)$/.exec(line);
3223
+ if (mNum) {
3224
+ const idx = Number(mNum[1]);
3225
+ const text = mNum[2].trim();
3226
+ if (text)
3227
+ items.push({ index: idx, text });
3228
+ continue;
3229
+ }
3230
+ const mC = /^C([1-3])\s*[::]\s*(.+)$/.exec(line);
3231
+ if (mC) {
3232
+ const idx = Number(mC[1]);
3233
+ const text = mC[2].trim();
3234
+ if (text)
3235
+ items.push({ index: idx, text });
3236
+ continue;
3237
+ }
3238
+ const mBullet = /^-\s+(.+)$/.exec(line);
3239
+ if (mBullet && autoIndex <= 3) {
3240
+ const text = mBullet[1].trim();
3241
+ if (text)
3242
+ items.push({ index: autoIndex, text });
3243
+ autoIndex += 1;
3244
+ }
3245
+ }
3246
+ // Ensure order by index and keep at most 3.
3247
+ const byIndex = new Map();
3248
+ for (const it of items) {
3249
+ if (it.index < 1 || it.index > 3)
3250
+ continue;
3251
+ if (!byIndex.has(it.index))
3252
+ byIndex.set(it.index, it.text);
3253
+ }
3254
+ const out = [];
3255
+ for (const i of [1, 2, 3]) {
3256
+ const t = byIndex.get(i);
3257
+ if (t)
3258
+ out.push({ index: i, text: t });
3259
+ }
3260
+ return out;
3261
+ }
3262
+ function scoreConclusionToFinding(conclusionText, f) {
3263
+ const c = String(conclusionText || '').toLowerCase();
3264
+ const t = String(f.title || '').toLowerCase();
3265
+ const d = String(f.description || '').toLowerCase();
3266
+ const hay = `${t}\n${d}`;
3267
+ if (!c.trim() || !hay.trim())
3268
+ return 0;
3269
+ // Lightweight keyword overlap for CN/EN mixed strings (no tokenization needed).
3270
+ const keywords = [
3271
+ 'jank', 'fps', 'frame', 'vsync', 'budget', 'refresh',
3272
+ 'gpu', 'renderthread', 'surfaceflinger', 'sf', 'hwc',
3273
+ 'cpu', 'sched', 'freq', 'cluster',
3274
+ 'binder', 'ipc',
3275
+ 'io', 'block', 'irq',
3276
+ 'lmk', 'oom',
3277
+ 'gc', 'thermal', 'throttle', 'vrr', 'ltpo',
3278
+ '主线程', 'ui', '渲染', '合成', '掉帧', '卡顿', '滑动', '启动', '交互', 'anr',
3279
+ ];
3280
+ let score = 0;
3281
+ for (const k of keywords) {
3282
+ const kk = k.toLowerCase();
3283
+ if (c.includes(kk) && hay.includes(kk))
3284
+ score += 3;
3285
+ }
3286
+ // Bonus for direct substring hints.
3287
+ if (t && c.includes(t))
3288
+ score += 6;
3289
+ if (t && t.includes(c))
3290
+ score += 4;
3291
+ // Severity / confidence as a soft prior.
3292
+ const sevBoost = f.severity === 'critical' ? 3 : (f.severity === 'warning' ? 2 : 1);
3293
+ score += sevBoost;
3294
+ score += Math.round(((f.confidence ?? 0.5) * 10));
3295
+ return score;
3296
+ }
3297
+ function injectPerConclusionEvidenceMapping(markdown, findings) {
3298
+ const text = String(markdown || '');
3299
+ if (!text.trim())
3300
+ return text;
3301
+ const conclusionSection = findMarkdownSection(text, /^##\s*结论[((]按可能性排序[))]\s*$/m);
3302
+ const evidenceSection = findMarkdownSection(text, /^##\s*证据链[((]对应上述结论[))]\s*$/m);
3303
+ if (!evidenceSection)
3304
+ return text;
3305
+ const conclusions = conclusionSection
3306
+ ? extractConclusionItemsFromSection(conclusionSection.body).slice(0, 3)
3307
+ : [];
3308
+ const conclusionCount = conclusions.length > 0 ? conclusions.length : 1;
3309
+ const body = evidenceSection.body;
3310
+ const missing = [];
3311
+ for (let i = 1; i <= conclusionCount; i += 1) {
3312
+ const hasLineWithEv = new RegExp(`^\\s*-?\\s*C${i}\\b.*\\bev_[0-9a-f]{12}\\b`, 'm').test(body);
3313
+ if (!hasLineWithEv)
3314
+ missing.push(i);
3315
+ }
3316
+ if (missing.length === 0)
3317
+ return text;
3318
+ const usableFindings = findings.filter(f => !f.details?._contradicted);
3319
+ const candidates = usableFindings
3320
+ .map(f => ({ finding: f, evIds: extractEvidenceIdsFromFinding(f) }))
3321
+ .filter(c => c.evIds.length > 0);
3322
+ if (candidates.length === 0)
3323
+ return text;
3324
+ const truncate = (s, n) => (s.length > n ? s.slice(0, n - 1) + '…' : s);
3325
+ const usedEv = new Set();
3326
+ const usedFindingIds = new Set();
3327
+ const injectedLines = [];
3328
+ for (const idx of missing.slice(0, 3)) {
3329
+ const conclusionText = conclusions.find(c => c.index === idx)?.text || '';
3330
+ // Pick best matching finding; fall back to highest confidence.
3331
+ const scored = candidates
3332
+ .filter(c => !usedFindingIds.has(String(c.finding.id || '')))
3333
+ .map(c => ({ ...c, score: scoreConclusionToFinding(conclusionText, c.finding) }))
3334
+ .sort((a, b) => b.score - a.score);
3335
+ const picked = scored[0] || candidates[0];
3336
+ if (!picked)
3337
+ continue;
3338
+ const evIds = picked.evIds.filter(id => !usedEv.has(id)).slice(0, 2);
3339
+ const finalEvIds = evIds.length > 0 ? evIds : picked.evIds.slice(0, 1);
3340
+ for (const id of finalEvIds)
3341
+ usedEv.add(id);
3342
+ if (picked.finding.id)
3343
+ usedFindingIds.add(String(picked.finding.id));
3344
+ const evStr = finalEvIds.length > 0 ? `(${finalEvIds.join('|')})` : '';
3345
+ const cStr = conclusionText ? truncate(conclusionText, 56) : `对应结论 ${idx}`;
3346
+ const fStr = truncate(String(picked.finding.title || picked.finding.description || ''), 56);
3347
+ const attachFindingTitle = picked.score >= 16;
3348
+ injectedLines.push(`- C${idx}(自动补全): ${cStr} ← ${evStr}${attachFindingTitle && fStr ? ` ${fStr}` : ''}`.trim());
3349
+ }
3350
+ if (injectedLines.length === 0)
3351
+ return text;
3352
+ // If we are injecting evidence lines, remove placeholder "证据链信息缺失"
3353
+ // to avoid contradictory output ("auto-filled" + "missing" at the same time).
3354
+ const evidenceBody = String(evidenceSection.body || '');
3355
+ const sanitizedBody = evidenceBody
3356
+ .split('\n')
3357
+ .filter(line => !/^\s*-\s*证据链信息缺失\s*$/.test(line))
3358
+ .join('\n');
3359
+ return `${text.slice(0, evidenceSection.bodyStart)}${injectedLines.join('\n')}\n${sanitizedBody}${text.slice(evidenceSection.bodyEnd)}`;
3360
+ }
3361
+ function injectEvidenceIndexIntoEvidenceChain(markdown, findings) {
3362
+ const text = String(markdown || '');
3363
+ if (!text.trim())
3364
+ return text;
3365
+ const refs = extractEvidenceRefsFromFindings(findings).slice(0, 4);
3366
+ if (refs.length === 0)
3367
+ return text;
3368
+ const headerRe = /^##\s*证据链(对应上述结论)\s*$/m;
3369
+ const headerMatch = headerRe.exec(text);
3370
+ if (!headerMatch)
3371
+ return text;
3372
+ const headerIdx = headerMatch.index;
3373
+ const afterHeaderIdx = headerIdx + headerMatch[0].length;
3374
+ // Find next "##" heading after evidence section header.
3375
+ const nextHeaderRe = /^##\s+/gm;
3376
+ nextHeaderRe.lastIndex = afterHeaderIdx;
3377
+ const next = nextHeaderRe.exec(text);
3378
+ const sectionEnd = next ? next.index : text.length;
3379
+ const sectionBody = text.slice(afterHeaderIdx, sectionEnd);
3380
+ if (/\bev_[0-9a-f]{12}\b/.test(sectionBody))
3381
+ return text;
3382
+ const truncate = (s, n) => (s.length > n ? s.slice(0, n - 1) + '…' : s);
3383
+ const items = refs
3384
+ .map(r => `(${r.evidenceId}) ${truncate(String(r.title || r.kind || ''), 48)}`.trim())
3385
+ .join(';');
3386
+ const line = `- 证据索引(自动补全): ${items}`;
3387
+ return `${text.slice(0, sectionEnd).trimEnd()}\n${line}\n${text.slice(sectionEnd).trimStart()}`;
3388
+ }
3389
+ function generateDialogueFallback(findings, intent, stopReason, historyContext) {
3390
+ const lines = [];
3391
+ // 1) Minimal acknowledgement of the user request
3392
+ lines.push(`我理解你想继续推进:${intent.primaryGoal}`);
3393
+ // 2) Keep it short: surface what we have (if any)
3394
+ const topTitles = findings
3395
+ .filter(f => typeof f.title === 'string' && f.title.trim().length > 0)
3396
+ .slice(0, 3)
3397
+ .map(f => f.title.trim());
3398
+ if (topTitles.length > 0) {
3399
+ lines.push(`目前可承接的线索:${topTitles.join(';')}`);
3400
+ }
3401
+ else if (historyContext) {
3402
+ lines.push('目前我会基于已有对话上下文继续推进。');
3403
+ }
3404
+ if (stopReason) {
3405
+ lines.push(`备注:本轮提前结束(${stopReason})。`);
3406
+ }
3407
+ // 3) Ask the minimal next question(s)
3408
+ lines.push('Q: 你希望我下一步聚焦在哪里?(给出 frame_id / session_id / 时间范围 / 进程名之一即可)');
3409
+ lines.push('A. 深入某个卡顿帧(例如:frame_id=123)');
3410
+ lines.push('B. 深入某个滑动会话(例如:session_id=2)');
3411
+ lines.push('C. 重新指定一个时间范围(例如:1.2s~1.5s)');
3412
+ return lines.join('\n');
3413
+ }
3414
+ function shouldNormalizeConclusionOutput(text) {
3415
+ const t = String(text || '').trim();
3416
+ if (!t)
3417
+ return false;
3418
+ if (t.startsWith('{') || t.startsWith('[') || t.startsWith('```')) {
3419
+ return true;
3420
+ }
3421
+ const sectioned = parseJsonLikeSections(t);
3422
+ if (sectioned) {
3423
+ const signalCount = sectioned.conclusion.length +
3424
+ sectioned.evidence_chain.length +
3425
+ sectioned.uncertainties.length +
3426
+ sectioned.next_steps.length;
3427
+ if (signalCount > 0)
3428
+ return true;
3429
+ }
3430
+ return false;
3431
+ }
3432
+ function normalizeConclusionOutput(rawText) {
3433
+ const contractOptions = { singleFrameDrillDown: false };
3434
+ const directContract = parseJsonToConclusionContract(rawText, 'initial_report', contractOptions);
3435
+ if (directContract) {
3436
+ return renderConclusionContract(directContract, contractOptions);
3437
+ }
3438
+ const converted = convertJsonToMarkdown(rawText);
3439
+ const fromJsonLike = convertJsonLikeSectionsToMarkdown(rawText, contractOptions);
3440
+ const preferredMarkdown = looksLikeMarkdownConclusion(converted)
3441
+ ? converted
3442
+ : (fromJsonLike || converted);
3443
+ const markdownContract = parseMarkdownToConclusionContract(preferredMarkdown, 'initial_report', contractOptions);
3444
+ if (markdownContract) {
3445
+ return renderConclusionContract(markdownContract, contractOptions);
3446
+ }
3447
+ return preferredMarkdown;
3448
+ }
3449
+ function looksLikeMarkdownConclusion(text) {
3450
+ const t = String(text || '');
3451
+ return /^##\s*结论/m.test(t) || /^##\s*分析结论/m.test(t);
3452
+ }
3453
+ function convertJsonLikeSectionsToMarkdown(rawText, options = { singleFrameDrillDown: false }) {
3454
+ const sections = parseJsonLikeSections(rawText);
3455
+ if (!sections)
3456
+ return null;
3457
+ const lines = [];
3458
+ const conclusions = [];
3459
+ const clusterLines = [];
3460
+ const evidenceLines = [];
3461
+ const uncertainties = [];
3462
+ const nextSteps = [];
3463
+ const metadataLines = [];
3464
+ for (const line of sections.conclusion) {
3465
+ const obj = parseJsonLine(line);
3466
+ if (obj) {
3467
+ const statement = readSemanticText(obj, 'statement');
3468
+ const confidence = normalizeConfidencePercent(readSemanticNumber(obj, 'confidence'));
3469
+ if (statement) {
3470
+ conclusions.push({
3471
+ statement,
3472
+ confidence,
3473
+ });
3474
+ continue;
3475
+ }
3476
+ const trigger = readSemanticText(obj, 'trigger');
3477
+ const supply = readSemanticText(obj, 'supply');
3478
+ const amp = readSemanticText(obj, 'amplification');
3479
+ if (trigger || supply || amp) {
3480
+ const triadStatement = (0, analysisNarrative_1.buildTriadStatement)({
3481
+ ...(trigger ? { trigger } : {}),
3482
+ ...(supply ? { supply } : {}),
3483
+ ...(amp ? { amplification: amp } : {}),
3484
+ });
3485
+ conclusions.push({
3486
+ statement: triadStatement,
3487
+ confidence,
3488
+ });
3489
+ continue;
3490
+ }
3491
+ }
3492
+ const plain = stripBulletPrefix(line.trim());
3493
+ if (plain)
3494
+ conclusions.push({ statement: plain });
3495
+ }
3496
+ for (const line of sections.clusters) {
3497
+ const obj = parseJsonLine(line);
3498
+ if (obj) {
3499
+ const formatted = formatClusterLineFromJsonLikeObject(obj);
3500
+ if (formatted) {
3501
+ clusterLines.push(formatted);
3502
+ continue;
3503
+ }
3504
+ }
3505
+ const plain = stripBulletPrefix(line.trim());
3506
+ if (plain)
3507
+ clusterLines.push(`- ${plain}`);
3508
+ }
3509
+ for (const line of sections.evidence_chain) {
3510
+ const obj = parseJsonLine(line);
3511
+ if (obj) {
3512
+ const cid = readSemanticText(obj, 'conclusion_id') ||
3513
+ 'C1';
3514
+ const evidenceTexts = extractEvidenceTextsFromJsonLikeObject(obj);
3515
+ for (const evText of evidenceTexts) {
3516
+ if (/^C\d+[::]/i.test(evText)) {
3517
+ evidenceLines.push(`- ${evText}`);
3518
+ }
3519
+ else {
3520
+ evidenceLines.push(`- ${cid}: ${evText}`);
3521
+ }
3522
+ }
3523
+ if (evidenceTexts.length === 0) {
3524
+ evidenceLines.push(`- ${cid}: 原始证据项缺少可展示文本(需补充数据说明)`);
3525
+ }
3526
+ continue;
3527
+ }
3528
+ const plain = stripBulletPrefix(line.trim());
3529
+ if (plain)
3530
+ evidenceLines.push(`- ${plain}`);
3531
+ }
3532
+ for (const line of sections.uncertainties) {
3533
+ const obj = parseJsonLine(line);
3534
+ if (obj) {
3535
+ const point = readSemanticText(obj, 'uncertainty_point');
3536
+ const explanation = readSemanticText(obj, 'uncertainty_reason');
3537
+ if (point && explanation) {
3538
+ uncertainties.push(normalizeUncertaintyWording(`${point}:${explanation}`));
3539
+ continue;
3540
+ }
3541
+ if (point) {
3542
+ uncertainties.push(normalizeUncertaintyWording(point));
3543
+ continue;
3544
+ }
3545
+ if (explanation) {
3546
+ uncertainties.push(normalizeUncertaintyWording(explanation));
3547
+ continue;
3548
+ }
3549
+ }
3550
+ const plain = stripBulletPrefix(line.trim());
3551
+ if (plain)
3552
+ uncertainties.push(normalizeUncertaintyWording(plain));
3553
+ }
3554
+ for (const line of sections.next_steps) {
3555
+ const obj = parseJsonLine(line);
3556
+ if (obj) {
3557
+ const action = readSemanticText(obj, 'next_action');
3558
+ const reason = readSemanticText(obj, 'next_reason');
3559
+ if (action && reason) {
3560
+ nextSteps.push(normalizeNextStepWording(`${action}(原因:${reason})`));
3561
+ continue;
3562
+ }
3563
+ if (action) {
3564
+ nextSteps.push(normalizeNextStepWording(action));
3565
+ continue;
3566
+ }
3567
+ if (reason) {
3568
+ nextSteps.push(normalizeNextStepWording(reason));
3569
+ continue;
3570
+ }
3571
+ }
3572
+ const plain = stripBulletPrefix(line.trim());
3573
+ if (plain)
3574
+ nextSteps.push(normalizeNextStepWording(plain));
3575
+ }
3576
+ for (const line of sections.metadata) {
3577
+ const obj = parseJsonLine(line);
3578
+ if (obj) {
3579
+ const confidence = normalizeConfidencePercent(readSemanticNumber(obj, 'confidence'));
3580
+ if (typeof confidence === 'number') {
3581
+ metadataLines.push(`- 置信度: ${Math.round(confidence)}%`);
3582
+ }
3583
+ const rounds = readSemanticNumber(obj, 'rounds');
3584
+ if (typeof rounds === 'number' && rounds > 0) {
3585
+ metadataLines.push(`- 分析轮次: ${Math.round(rounds)}`);
3586
+ }
3587
+ continue;
3588
+ }
3589
+ const plain = stripBulletPrefix(line.trim());
3590
+ if (plain)
3591
+ metadataLines.push(`- ${plain}`);
3592
+ }
3593
+ const normalizedNextSteps = [...new Set(nextSteps.filter(Boolean))];
3594
+ lines.push('## 结论(按可能性排序)');
3595
+ if (conclusions.length === 0) {
3596
+ lines.push('1. 结论信息缺失(置信度: 40%)');
3597
+ }
3598
+ else {
3599
+ conclusions.slice(0, 3).forEach((item, idx) => {
3600
+ const conf = Number.isFinite(item.confidence) ? `(置信度: ${Math.round(item.confidence)}%)` : '';
3601
+ lines.push(`${idx + 1}. ${item.statement}${conf}`);
3602
+ });
3603
+ }
3604
+ lines.push('');
3605
+ lines.push(resolveClusterSectionHeading(options.scenePromptHints?.sceneId));
3606
+ if (clusterLines.length === 0) {
3607
+ lines.push('- 暂无');
3608
+ }
3609
+ else {
3610
+ lines.push(...clusterLines.slice(0, 5));
3611
+ }
3612
+ lines.push('');
3613
+ lines.push('## 证据链(对应上述结论)');
3614
+ if (evidenceLines.length === 0) {
3615
+ lines.push('- 证据链信息缺失');
3616
+ }
3617
+ else {
3618
+ lines.push(...evidenceLines);
3619
+ }
3620
+ lines.push('');
3621
+ lines.push('## 不确定性与反例');
3622
+ if (uncertainties.length === 0) {
3623
+ lines.push('- 暂无');
3624
+ }
3625
+ else {
3626
+ uncertainties.forEach((item) => lines.push(`- ${item}`));
3627
+ }
3628
+ lines.push('');
3629
+ lines.push('## 下一步(最高信息增益)');
3630
+ if (normalizedNextSteps.length === 0) {
3631
+ lines.push('- 暂无');
3632
+ }
3633
+ else {
3634
+ normalizedNextSteps.forEach((item) => lines.push(`- ${item}`));
3635
+ }
3636
+ if (metadataLines.length > 0) {
3637
+ lines.push('');
3638
+ lines.push('## 分析元数据');
3639
+ lines.push(...metadataLines);
3640
+ }
3641
+ return lines.join('\n');
3642
+ }
3643
+ function parseJsonLikeSections(rawText) {
3644
+ const sectionAlias = {
3645
+ conclusion: 'conclusion',
3646
+ 结论: 'conclusion',
3647
+ jank_clusters: 'clusters',
3648
+ jank_cluster: 'clusters',
3649
+ clusters: 'clusters',
3650
+ cluster: 'clusters',
3651
+ 掉帧聚类: 'clusters',
3652
+ 聚类: 'clusters',
3653
+ evidence_chain: 'evidence_chain',
3654
+ 证据链: 'evidence_chain',
3655
+ uncertainties: 'uncertainties',
3656
+ uncertainty: 'uncertainties',
3657
+ uncertainty_and_counterexamples: 'uncertainties',
3658
+ uncertainty_and_counterexample: 'uncertainties',
3659
+ 不确定性与反例: 'uncertainties',
3660
+ 不确定性: 'uncertainties',
3661
+ 反例: 'uncertainties',
3662
+ next_steps: 'next_steps',
3663
+ next_step: 'next_steps',
3664
+ 下一步: 'next_steps',
3665
+ analysis_metadata: 'metadata',
3666
+ analysis_meta: 'metadata',
3667
+ metadata: 'metadata',
3668
+ meta: 'metadata',
3669
+ 分析元数据: 'metadata',
3670
+ 元数据: 'metadata',
3671
+ };
3672
+ const out = {
3673
+ conclusion: [],
3674
+ clusters: [],
3675
+ evidence_chain: [],
3676
+ uncertainties: [],
3677
+ next_steps: [],
3678
+ metadata: [],
3679
+ };
3680
+ let current = null;
3681
+ let hitHeader = false;
3682
+ for (const rawLine of String(rawText || '').split(/\r?\n/)) {
3683
+ const line = rawLine.trim();
3684
+ const headerMatch = line.match(/^([A-Za-z_\u4e00-\u9fa5]+)\s*[::]\s*(.*)$/);
3685
+ if (headerMatch) {
3686
+ const mapped = sectionAlias[String(headerMatch[1] || '').toLowerCase()];
3687
+ if (mapped) {
3688
+ current = mapped;
3689
+ hitHeader = true;
3690
+ const inlineContent = String(headerMatch[2] || '').trim();
3691
+ if (inlineContent)
3692
+ out[current].push(inlineContent);
3693
+ continue;
3694
+ }
3695
+ if (current && line) {
3696
+ out[current].push(line);
3697
+ }
3698
+ continue;
3699
+ }
3700
+ if (/^#{1,6}\s+/.test(line)) {
3701
+ current = null;
3702
+ continue;
3703
+ }
3704
+ if (!current)
3705
+ continue;
3706
+ if (line)
3707
+ out[current].push(line);
3708
+ }
3709
+ if (!hitHeader)
3710
+ return null;
3711
+ const hasSignal = out.conclusion.length > 0 ||
3712
+ out.clusters.length > 0 ||
3713
+ out.evidence_chain.length > 0 ||
3714
+ out.uncertainties.length > 0 ||
3715
+ out.next_steps.length > 0 ||
3716
+ out.metadata.length > 0;
3717
+ return hasSignal ? out : null;
3718
+ }
3719
+ function parseJsonLine(line) {
3720
+ const s = String(line || '')
3721
+ .trim()
3722
+ .replace(/[·。]\s*$/, '')
3723
+ .replace(/,\s*$/, '');
3724
+ if (!(s.startsWith('{') && s.endsWith('}')))
3725
+ return null;
3726
+ try {
3727
+ const parsed = JSON.parse(s);
3728
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
3729
+ return parsed;
3730
+ }
3731
+ return null;
3732
+ }
3733
+ catch {
3734
+ return null;
3735
+ }
3736
+ }
3737
+ const SEMANTIC_TEXT_RULES = {
3738
+ statement: {
3739
+ aliases: ['statement', 'summary', 'conclusion', '结论', '描述', '说明'],
3740
+ patterns: [/statement|summary|conclusion|结论|描述|说明/i],
3741
+ },
3742
+ trigger: {
3743
+ aliases: ['trigger', 'trigger_factor', 'triggerFactor', '触发因子', '直接原因'],
3744
+ patterns: [/trigger|触发|直接原因/i],
3745
+ },
3746
+ supply: {
3747
+ aliases: ['supply', 'supply_constraint', 'supplyConstraint', '供给约束', '资源瓶颈', '资源问题'],
3748
+ patterns: [/supply|constraint|bottleneck|供给约束|资源瓶颈|资源问题|瓶颈/i],
3749
+ },
3750
+ amplification: {
3751
+ aliases: ['amplification', 'amplification_path', 'amplificationPath', '放大路径', '放大环节', '放大因素'],
3752
+ patterns: [/amplification|amplify|path|放大路径|放大环节|放大因素|放大/i],
3753
+ },
3754
+ conclusion_id: {
3755
+ aliases: ['conclusion_id', 'conclusionId', 'conclusion', '结论编号', '结论ID'],
3756
+ patterns: [/conclusionid|conclusion|结论编号|结论id|cid/i],
3757
+ },
3758
+ uncertainty_point: {
3759
+ aliases: ['point', 'title', 'statement', 'topic', '问题', '标题', '结论'],
3760
+ patterns: [/point|title|statement|topic|问题|标题|结论/i],
3761
+ },
3762
+ uncertainty_reason: {
3763
+ aliases: ['explanation', 'reason', 'detail', '说明', '原因', '描述'],
3764
+ patterns: [/explanation|reason|detail|说明|原因|描述/i],
3765
+ },
3766
+ next_action: {
3767
+ aliases: ['action', 'step', 'title', 'next_step', '下一步', '动作', '步骤', '建议'],
3768
+ patterns: [/action|step|title|nextstep|下一步|动作|步骤|建议/i],
3769
+ },
3770
+ next_reason: {
3771
+ aliases: ['reason', 'explanation', 'detail', '原因', '说明'],
3772
+ patterns: [/reason|explanation|detail|原因|说明/i],
3773
+ },
3774
+ source: {
3775
+ aliases: ['source', 'skill', '来源'],
3776
+ patterns: [/source|skill|来源/i],
3777
+ },
3778
+ cluster_label: {
3779
+ aliases: ['cluster', 'name', 'pattern', '聚类', '簇', 'clusterId', 'cluster_id'],
3780
+ patterns: [/cluster|name|pattern|聚类|簇/i],
3781
+ },
3782
+ cluster_description: {
3783
+ aliases: ['description', 'desc', '描述', '特征'],
3784
+ patterns: [/description|desc|描述|特征/i],
3785
+ },
3786
+ };
3787
+ const SEMANTIC_NUMBER_RULES = {
3788
+ confidence: {
3789
+ aliases: ['confidence', 'overall_confidence', '置信度'],
3790
+ patterns: [/confidence|overallconfidence|置信度/i],
3791
+ },
3792
+ rounds: {
3793
+ aliases: ['rounds', 'analysis_rounds', 'iterations', '分析轮次', '轮次'],
3794
+ patterns: [/rounds|analysisrounds|iterations|分析轮次|轮次/i],
3795
+ },
3796
+ cluster_rank: {
3797
+ aliases: ['rank', '排序', '序号'],
3798
+ patterns: [/rank|排序|序号/i],
3799
+ },
3800
+ cluster_frames: {
3801
+ aliases: ['frames', 'frameCount', 'frame_count', '帧数'],
3802
+ patterns: [/frames|framecount|帧数/i],
3803
+ },
3804
+ cluster_percentage: {
3805
+ aliases: ['percentage', 'pct', 'ratio', '占比', '比例'],
3806
+ patterns: [/percentage|pct|ratio|占比|比例/i],
3807
+ },
3808
+ };
3809
+ function normalizeJsonLikeKey(key) {
3810
+ return String(key || '')
3811
+ .trim()
3812
+ .replace(/[\s_\-]/g, '')
3813
+ .toLowerCase();
3814
+ }
3815
+ function buildNormalizedAliasSet(aliases) {
3816
+ return new Set(aliases.map((alias) => normalizeJsonLikeKey(alias)));
3817
+ }
3818
+ function readTextByRule(obj, rule) {
3819
+ const aliasSet = buildNormalizedAliasSet(rule.aliases);
3820
+ let fuzzyMatch = '';
3821
+ for (const [rawKey, rawValue] of Object.entries(obj)) {
3822
+ if (typeof rawValue !== 'string')
3823
+ continue;
3824
+ const text = stripBulletPrefix(rawValue.trim());
3825
+ if (!text)
3826
+ continue;
3827
+ const normalizedKey = normalizeJsonLikeKey(rawKey);
3828
+ if (aliasSet.has(normalizedKey)) {
3829
+ return text;
3830
+ }
3831
+ if (!fuzzyMatch && rule.patterns.some((pattern) => pattern.test(normalizedKey))) {
3832
+ fuzzyMatch = text;
3833
+ }
3834
+ }
3835
+ return fuzzyMatch;
3836
+ }
3837
+ function readSemanticText(obj, field) {
3838
+ return readTextByRule(obj, SEMANTIC_TEXT_RULES[field]);
3839
+ }
3840
+ function readNumberValue(raw) {
3841
+ if (typeof raw === 'number' && Number.isFinite(raw)) {
3842
+ return raw;
3843
+ }
3844
+ if (typeof raw !== 'string') {
3845
+ return undefined;
3846
+ }
3847
+ const normalized = raw.trim().replace(/[%%]/g, '');
3848
+ if (!normalized)
3849
+ return undefined;
3850
+ const value = Number(normalized);
3851
+ return Number.isFinite(value) ? value : undefined;
3852
+ }
3853
+ function readNumberByRule(obj, rule) {
3854
+ const aliasSet = buildNormalizedAliasSet(rule.aliases);
3855
+ let fuzzyMatch;
3856
+ for (const [rawKey, rawValue] of Object.entries(obj)) {
3857
+ const value = readNumberValue(rawValue);
3858
+ if (!Number.isFinite(value))
3859
+ continue;
3860
+ const normalizedKey = normalizeJsonLikeKey(rawKey);
3861
+ if (aliasSet.has(normalizedKey)) {
3862
+ return value;
3863
+ }
3864
+ if (fuzzyMatch === undefined && rule.patterns.some((pattern) => pattern.test(normalizedKey))) {
3865
+ fuzzyMatch = value;
3866
+ }
3867
+ }
3868
+ return fuzzyMatch;
3869
+ }
3870
+ function readSemanticNumber(obj, field) {
3871
+ return readNumberByRule(obj, SEMANTIC_NUMBER_RULES[field]);
3872
+ }
3873
+ function readValueFromAliases(obj, aliases) {
3874
+ const aliasSet = buildNormalizedAliasSet(aliases);
3875
+ for (const [rawKey, value] of Object.entries(obj)) {
3876
+ if (aliasSet.has(normalizeJsonLikeKey(rawKey))) {
3877
+ return value;
3878
+ }
3879
+ }
3880
+ return undefined;
3881
+ }
3882
+ function normalizeConfidencePercent(raw) {
3883
+ if (!Number.isFinite(raw))
3884
+ return undefined;
3885
+ if (raw <= 1)
3886
+ return raw * 100;
3887
+ return raw;
3888
+ }
3889
+ function extractEvidenceTextsFromJsonLikeObject(obj) {
3890
+ const out = [];
3891
+ const pushIfUseful = (raw) => {
3892
+ const text = stripBulletPrefix(String(raw || '').trim())
3893
+ .replace(/[((]\s*证据\s*[::]\s*[))]/g, '')
3894
+ .replace(/[((]\s*证据\s*ID\s*[::]\s*[))]/gi, '')
3895
+ .replace(/证据\s*ID\s*[::]\s*和\s*$/gi, '')
3896
+ .trim();
3897
+ if (!text)
3898
+ return;
3899
+ if (/^ev_[0-9a-f]{12}$/i.test(text))
3900
+ return;
3901
+ if (!out.includes(text))
3902
+ out.push(text);
3903
+ };
3904
+ const preferredFields = [
3905
+ 'data', 'description', 'detail', 'statement', 'observation', 'metric', 'reason',
3906
+ '数据', '描述', '详情', '说明', '观察', '指标', '原因',
3907
+ ];
3908
+ for (const key of preferredFields) {
3909
+ pushIfUseful(obj[key]);
3910
+ }
3911
+ const evidence = readValueFromAliases(obj, ['evidence', '证据']);
3912
+ if (Array.isArray(evidence)) {
3913
+ for (const item of evidence) {
3914
+ if (typeof item === 'string') {
3915
+ pushIfUseful(item);
3916
+ continue;
3917
+ }
3918
+ const evidenceObject = asEvidenceObject(item);
3919
+ if (evidenceObject) {
3920
+ pushIfUseful(evidenceObject.title);
3921
+ pushIfUseful(evidenceObject.description);
3922
+ pushIfUseful(evidenceObject.summary);
3923
+ }
3924
+ }
3925
+ }
3926
+ else if (typeof evidence === 'string') {
3927
+ pushIfUseful(evidence);
3928
+ }
3929
+ const source = readSemanticText(obj, 'source');
3930
+ if (source && out.length > 0) {
3931
+ const last = out[out.length - 1];
3932
+ if (!last.includes('来源:')) {
3933
+ out[out.length - 1] = `${last}(来源: ${source})`;
3934
+ }
3935
+ }
3936
+ return out.slice(0, 4);
3937
+ }
3938
+ function normalizeUncertaintyWording(text) {
3939
+ const line = String(text || '').trim();
3940
+ if (!line)
3941
+ return line;
3942
+ const isContradiction = /矛盾|不一致|冲突/.test(line);
3943
+ const hasPercentSignals = /\d+(?:\.\d+)?%/.test(line);
3944
+ const hasDefinitionContext = /口径|分母|定义|时间窗|统计方式/.test(line);
3945
+ if (isContradiction && hasPercentSignals && !hasDefinitionContext) {
3946
+ return `${line}(可能由统计口径/分母差异导致,需统一时间窗与分母定义后再比较)`;
3947
+ }
3948
+ return line;
3949
+ }
3950
+ function normalizeNextStepWording(text) {
3951
+ const line = String(text || '').trim();
3952
+ if (!line)
3953
+ return line;
3954
+ const asksMoreData = /补充/.test(line) && /数据/.test(line);
3955
+ const mentionsContradiction = /矛盾|冲突|不一致/.test(line);
3956
+ if (asksMoreData && mentionsContradiction) {
3957
+ const subject = line
3958
+ .replace(/^补充/, '')
3959
+ .replace(/的?矛盾数据.*/, '')
3960
+ .replace(/矛盾数据.*/, '')
3961
+ .replace(/数据.*/, '')
3962
+ .trim();
3963
+ if (subject) {
3964
+ return `在同一帧同一时间窗统一统计口径,复核${subject}的分母与计算方式`;
3965
+ }
3966
+ return '在同一帧同一时间窗统一统计口径,复核矛盾指标的分母与计算方式';
3967
+ }
3968
+ return line;
3969
+ }
3970
+ function formatClusterLineFromJsonLikeObject(obj) {
3971
+ const clusterRaw = readSemanticText(obj, 'cluster_label');
3972
+ const description = readSemanticText(obj, 'cluster_description');
3973
+ const rankNum = readSemanticNumber(obj, 'cluster_rank');
3974
+ const rankPrefix = typeof rankNum === 'number' && rankNum > 0 ? `K${Math.round(rankNum)}` : '';
3975
+ let clusterLabel = clusterRaw;
3976
+ if (!clusterLabel && description) {
3977
+ clusterLabel = description;
3978
+ }
3979
+ else if (clusterLabel && description && !clusterLabel.includes(description)) {
3980
+ if (/^K\d+\b/i.test(clusterLabel) || !/[::]/.test(clusterLabel)) {
3981
+ clusterLabel = `${clusterLabel}: ${description}`;
3982
+ }
3983
+ }
3984
+ if (rankPrefix) {
3985
+ if (!clusterLabel) {
3986
+ clusterLabel = rankPrefix;
3987
+ }
3988
+ else if (!new RegExp(`^${rankPrefix}\\b`, 'i').test(clusterLabel)) {
3989
+ clusterLabel = `${rankPrefix}: ${clusterLabel}`;
3990
+ }
3991
+ }
3992
+ if (!clusterLabel) {
3993
+ return null;
3994
+ }
3995
+ const frames = readSemanticNumber(obj, 'cluster_frames');
3996
+ const percentage = readSemanticNumber(obj, 'cluster_percentage');
3997
+ const metrics = [];
3998
+ if (typeof frames === 'number' && frames > 0) {
3999
+ metrics.push(`${Math.round(frames)}帧`);
4000
+ }
4001
+ if (typeof percentage === 'number') {
4002
+ metrics.push(`${percentage.toFixed(1)}%`);
4003
+ }
4004
+ const frameRefs = parseClusterFrameRefs(obj);
4005
+ const frameRefText = frameRefs.length > 0 ? `;帧: ${frameRefs.join(' / ')}` : '';
4006
+ return `- ${clusterLabel}${metrics.length > 0 ? `(${metrics.join(', ')})` : ''}${frameRefText}`;
4007
+ }
4008
+ function stripBulletPrefix(text) {
4009
+ return String(text || '').replace(/^\s*-\s*/, '').trim();
4010
+ }
4011
+ /**
4012
+ * Convert JSON response to Markdown when LLM ignores format instructions.
4013
+ * This is a fallback to ensure human-readable output.
4014
+ */
4015
+ function convertJsonToMarkdown(jsonStr) {
4016
+ // 1. Remove code block markers if present
4017
+ let cleaned = jsonStr
4018
+ .replace(/^```(?:json)?\s*\n?/, '')
4019
+ .replace(/\n?```$/, '')
4020
+ .trim();
4021
+ // 2. Try to parse as JSON
4022
+ try {
4023
+ const parsed = JSON.parse(cleaned);
4024
+ const lines = [];
4025
+ // Extract root cause analysis
4026
+ if (parsed.rootCauseAnalysis && Array.isArray(parsed.rootCauseAnalysis)) {
4027
+ lines.push('## 根因分析\n');
4028
+ for (const item of parsed.rootCauseAnalysis) {
4029
+ const conclusion = item.conclusion || item.title || '结论';
4030
+ const confidence = item.confidence ? ` (置信度: ${item.confidence})` : '';
4031
+ lines.push(`### ${conclusion}${confidence}\n`);
4032
+ if (item.evidence && Array.isArray(item.evidence)) {
4033
+ lines.push('**证据:**');
4034
+ for (const e of item.evidence) {
4035
+ lines.push(`- ${typeof e === 'object' ? JSON.stringify(e) : e}`);
4036
+ }
4037
+ lines.push('');
4038
+ }
4039
+ }
4040
+ }
4041
+ // Extract conclusion field if present
4042
+ if (parsed.conclusion && typeof parsed.conclusion === 'string') {
4043
+ if (lines.length === 0) {
4044
+ lines.push('## 分析结论\n');
4045
+ }
4046
+ lines.push(parsed.conclusion);
4047
+ lines.push('');
4048
+ }
4049
+ // Extract summary if present
4050
+ if (parsed.summary && typeof parsed.summary === 'string') {
4051
+ lines.push('## 总结\n');
4052
+ lines.push(parsed.summary);
4053
+ lines.push('');
4054
+ }
4055
+ // Extract findings array if present
4056
+ if (parsed.findings && Array.isArray(parsed.findings)) {
4057
+ lines.push('## 发现\n');
4058
+ for (const f of parsed.findings) {
4059
+ const title = f.title || f.name || '发现';
4060
+ const severity = f.severity ? `[${f.severity}] ` : '';
4061
+ lines.push(`- ${severity}${title}`);
4062
+ if (f.description) {
4063
+ lines.push(` ${f.description}`);
4064
+ }
4065
+ }
4066
+ lines.push('');
4067
+ }
4068
+ // If we extracted anything, return it
4069
+ if (lines.length > 0) {
4070
+ return lines.join('\n');
4071
+ }
4072
+ // Otherwise, format the entire object as a simple list
4073
+ return formatObjectAsMarkdown(parsed);
4074
+ }
4075
+ catch {
4076
+ // JSON parse failed, return cleaned string as-is
4077
+ return cleaned;
4078
+ }
4079
+ }
4080
+ /**
4081
+ * Format an arbitrary object as Markdown list.
4082
+ */
4083
+ function formatObjectAsMarkdown(obj, indent = '') {
4084
+ const lines = [];
4085
+ for (const [key, value] of Object.entries(obj)) {
4086
+ if (value === null || value === undefined)
4087
+ continue;
4088
+ if (Array.isArray(value)) {
4089
+ lines.push(`${indent}**${key}:**`);
4090
+ for (const item of value) {
4091
+ if (typeof item === 'object') {
4092
+ lines.push(`${indent}- ${JSON.stringify(item).slice(0, 200)}`);
4093
+ }
4094
+ else {
4095
+ lines.push(`${indent}- ${item}`);
4096
+ }
4097
+ }
4098
+ }
4099
+ else if (typeof value === 'object') {
4100
+ lines.push(`${indent}**${key}:**`);
4101
+ lines.push(formatObjectAsMarkdown(value, indent + ' '));
4102
+ }
4103
+ else {
4104
+ lines.push(`${indent}- **${key}:** ${value}`);
4105
+ }
4106
+ }
4107
+ return lines.join('\n');
4108
+ }
4109
+ //# sourceMappingURL=conclusionGenerator.js.map