simplify3x-connect 0.0.0-stage → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -3
  3. package/dist/acText.d.ts +12 -0
  4. package/dist/acText.d.ts.map +1 -0
  5. package/dist/acText.js +44 -0
  6. package/dist/acText.js.map +1 -0
  7. package/dist/adapters/factory.d.ts +25 -0
  8. package/dist/adapters/factory.d.ts.map +1 -0
  9. package/dist/adapters/factory.js +55 -0
  10. package/dist/adapters/factory.js.map +1 -0
  11. package/dist/adapters/http.d.ts +62 -0
  12. package/dist/adapters/http.d.ts.map +1 -0
  13. package/dist/adapters/http.js +138 -0
  14. package/dist/adapters/http.js.map +1 -0
  15. package/dist/adapters/remoteMcp/adapter.d.ts +112 -0
  16. package/dist/adapters/remoteMcp/adapter.d.ts.map +1 -0
  17. package/dist/adapters/remoteMcp/adapter.js +259 -0
  18. package/dist/adapters/remoteMcp/adapter.js.map +1 -0
  19. package/dist/adapters/simplifyqa/adapter.d.ts +1390 -0
  20. package/dist/adapters/simplifyqa/adapter.d.ts.map +1 -0
  21. package/dist/adapters/simplifyqa/adapter.js +9126 -0
  22. package/dist/adapters/simplifyqa/adapter.js.map +1 -0
  23. package/dist/adapters/simplifyqa/apiFailureReason.d.ts +11 -0
  24. package/dist/adapters/simplifyqa/apiFailureReason.d.ts.map +1 -0
  25. package/dist/adapters/simplifyqa/apiFailureReason.js +35 -0
  26. package/dist/adapters/simplifyqa/apiFailureReason.js.map +1 -0
  27. package/dist/adapters/simplifyqa/desktopConditions.d.ts +50 -0
  28. package/dist/adapters/simplifyqa/desktopConditions.d.ts.map +1 -0
  29. package/dist/adapters/simplifyqa/desktopConditions.js +95 -0
  30. package/dist/adapters/simplifyqa/desktopConditions.js.map +1 -0
  31. package/dist/adapters/simplifyqa/executionFailures.d.ts +59 -0
  32. package/dist/adapters/simplifyqa/executionFailures.d.ts.map +1 -0
  33. package/dist/adapters/simplifyqa/executionFailures.js +641 -0
  34. package/dist/adapters/simplifyqa/executionFailures.js.map +1 -0
  35. package/dist/adapters/simplifyqa/failureCategory.d.ts +26 -0
  36. package/dist/adapters/simplifyqa/failureCategory.d.ts.map +1 -0
  37. package/dist/adapters/simplifyqa/failureCategory.js +208 -0
  38. package/dist/adapters/simplifyqa/failureCategory.js.map +1 -0
  39. package/dist/adapters/simplifyqa/failureReport.d.ts +50 -0
  40. package/dist/adapters/simplifyqa/failureReport.d.ts.map +1 -0
  41. package/dist/adapters/simplifyqa/failureReport.js +383 -0
  42. package/dist/adapters/simplifyqa/failureReport.js.map +1 -0
  43. package/dist/adapters/simplifyqa/failureTypes.d.ts +193 -0
  44. package/dist/adapters/simplifyqa/failureTypes.d.ts.map +1 -0
  45. package/dist/adapters/simplifyqa/failureTypes.js +8 -0
  46. package/dist/adapters/simplifyqa/failureTypes.js.map +1 -0
  47. package/dist/adapters/simplifyqa/flow.d.ts +58 -0
  48. package/dist/adapters/simplifyqa/flow.d.ts.map +1 -0
  49. package/dist/adapters/simplifyqa/flow.js +335 -0
  50. package/dist/adapters/simplifyqa/flow.js.map +1 -0
  51. package/dist/adapters/simplifyqa/functionMatch.d.ts +53 -0
  52. package/dist/adapters/simplifyqa/functionMatch.d.ts.map +1 -0
  53. package/dist/adapters/simplifyqa/functionMatch.js +110 -0
  54. package/dist/adapters/simplifyqa/functionMatch.js.map +1 -0
  55. package/dist/adapters/simplifyqa/heal/apply.d.ts +59 -0
  56. package/dist/adapters/simplifyqa/heal/apply.d.ts.map +1 -0
  57. package/dist/adapters/simplifyqa/heal/apply.js +213 -0
  58. package/dist/adapters/simplifyqa/heal/apply.js.map +1 -0
  59. package/dist/adapters/simplifyqa/heal/diagnose.d.ts +24 -0
  60. package/dist/adapters/simplifyqa/heal/diagnose.d.ts.map +1 -0
  61. package/dist/adapters/simplifyqa/heal/diagnose.js +211 -0
  62. package/dist/adapters/simplifyqa/heal/diagnose.js.map +1 -0
  63. package/dist/adapters/simplifyqa/heal/index.d.ts +37 -0
  64. package/dist/adapters/simplifyqa/heal/index.d.ts.map +1 -0
  65. package/dist/adapters/simplifyqa/heal/index.js +83 -0
  66. package/dist/adapters/simplifyqa/heal/index.js.map +1 -0
  67. package/dist/adapters/simplifyqa/heal/plan.d.ts +67 -0
  68. package/dist/adapters/simplifyqa/heal/plan.d.ts.map +1 -0
  69. package/dist/adapters/simplifyqa/heal/plan.js +338 -0
  70. package/dist/adapters/simplifyqa/heal/plan.js.map +1 -0
  71. package/dist/adapters/simplifyqa/heal/store.d.ts +10 -0
  72. package/dist/adapters/simplifyqa/heal/store.d.ts.map +1 -0
  73. package/dist/adapters/simplifyqa/heal/store.js +40 -0
  74. package/dist/adapters/simplifyqa/heal/store.js.map +1 -0
  75. package/dist/adapters/simplifyqa/mapLimit.d.ts +3 -0
  76. package/dist/adapters/simplifyqa/mapLimit.d.ts.map +1 -0
  77. package/dist/adapters/simplifyqa/mapLimit.js +14 -0
  78. package/dist/adapters/simplifyqa/mapLimit.js.map +1 -0
  79. package/dist/adapters/simplifyqa/mapper.d.ts +159 -0
  80. package/dist/adapters/simplifyqa/mapper.d.ts.map +1 -0
  81. package/dist/adapters/simplifyqa/mapper.js +1767 -0
  82. package/dist/adapters/simplifyqa/mapper.js.map +1 -0
  83. package/dist/adapters/simplifyqa/planTree.d.ts +31 -0
  84. package/dist/adapters/simplifyqa/planTree.d.ts.map +1 -0
  85. package/dist/adapters/simplifyqa/planTree.js +110 -0
  86. package/dist/adapters/simplifyqa/planTree.js.map +1 -0
  87. package/dist/adapters/simplifyqa/searchEngine.d.ts +254 -0
  88. package/dist/adapters/simplifyqa/searchEngine.d.ts.map +1 -0
  89. package/dist/adapters/simplifyqa/searchEngine.js +1248 -0
  90. package/dist/adapters/simplifyqa/searchEngine.js.map +1 -0
  91. package/dist/adapters/simplifyqa/searchRegistry.d.ts +117 -0
  92. package/dist/adapters/simplifyqa/searchRegistry.d.ts.map +1 -0
  93. package/dist/adapters/simplifyqa/searchRegistry.js +1664 -0
  94. package/dist/adapters/simplifyqa/searchRegistry.js.map +1 -0
  95. package/dist/adapters/simplifyqa/searchResolve.d.ts +84 -0
  96. package/dist/adapters/simplifyqa/searchResolve.d.ts.map +1 -0
  97. package/dist/adapters/simplifyqa/searchResolve.js +319 -0
  98. package/dist/adapters/simplifyqa/searchResolve.js.map +1 -0
  99. package/dist/adapters/simplifyqa/stepDiagnostics.d.ts +25 -0
  100. package/dist/adapters/simplifyqa/stepDiagnostics.d.ts.map +1 -0
  101. package/dist/adapters/simplifyqa/stepDiagnostics.js +89 -0
  102. package/dist/adapters/simplifyqa/stepDiagnostics.js.map +1 -0
  103. package/dist/adapters/simplifyqa/stepRules.d.ts +91 -0
  104. package/dist/adapters/simplifyqa/stepRules.d.ts.map +1 -0
  105. package/dist/adapters/simplifyqa/stepRules.js +228 -0
  106. package/dist/adapters/simplifyqa/stepRules.js.map +1 -0
  107. package/dist/adapters/types.d.ts +514 -0
  108. package/dist/adapters/types.d.ts.map +1 -0
  109. package/dist/adapters/types.js +2 -0
  110. package/dist/adapters/types.js.map +1 -0
  111. package/dist/adapters/walnut/actionTypes.d.ts +16 -0
  112. package/dist/adapters/walnut/actionTypes.d.ts.map +1 -0
  113. package/dist/adapters/walnut/actionTypes.js +178 -0
  114. package/dist/adapters/walnut/actionTypes.js.map +1 -0
  115. package/dist/adapters/walnut/adapter.d.ts +235 -0
  116. package/dist/adapters/walnut/adapter.d.ts.map +1 -0
  117. package/dist/adapters/walnut/adapter.js +1120 -0
  118. package/dist/adapters/walnut/adapter.js.map +1 -0
  119. package/dist/adapters/walnut/mapper.d.ts +55 -0
  120. package/dist/adapters/walnut/mapper.d.ts.map +1 -0
  121. package/dist/adapters/walnut/mapper.js +364 -0
  122. package/dist/adapters/walnut/mapper.js.map +1 -0
  123. package/dist/cli.d.ts +3 -0
  124. package/dist/cli.d.ts.map +1 -0
  125. package/dist/cli.js +38 -0
  126. package/dist/cli.js.map +1 -0
  127. package/dist/config.d.ts +109 -0
  128. package/dist/config.d.ts.map +1 -0
  129. package/dist/config.js +272 -0
  130. package/dist/config.js.map +1 -0
  131. package/dist/connection.d.ts +105 -0
  132. package/dist/connection.d.ts.map +1 -0
  133. package/dist/connection.js +255 -0
  134. package/dist/connection.js.map +1 -0
  135. package/dist/domain/heal.d.ts +163 -0
  136. package/dist/domain/heal.d.ts.map +1 -0
  137. package/dist/domain/heal.js +55 -0
  138. package/dist/domain/heal.js.map +1 -0
  139. package/dist/domain/types.d.ts +1328 -0
  140. package/dist/domain/types.d.ts.map +1 -0
  141. package/dist/domain/types.js +8 -0
  142. package/dist/domain/types.js.map +1 -0
  143. package/dist/domain/validate.d.ts +3 -0
  144. package/dist/domain/validate.d.ts.map +1 -0
  145. package/dist/domain/validate.js +67 -0
  146. package/dist/domain/validate.js.map +1 -0
  147. package/dist/drafts/apiPatch.d.ts +9 -0
  148. package/dist/drafts/apiPatch.d.ts.map +1 -0
  149. package/dist/drafts/apiPatch.js +27 -0
  150. package/dist/drafts/apiPatch.js.map +1 -0
  151. package/dist/drafts/bulk.d.ts +24 -0
  152. package/dist/drafts/bulk.d.ts.map +1 -0
  153. package/dist/drafts/bulk.js +44 -0
  154. package/dist/drafts/bulk.js.map +1 -0
  155. package/dist/drafts/duplicate.d.ts +12 -0
  156. package/dist/drafts/duplicate.d.ts.map +1 -0
  157. package/dist/drafts/duplicate.js +59 -0
  158. package/dist/drafts/duplicate.js.map +1 -0
  159. package/dist/drafts/store.d.ts +91 -0
  160. package/dist/drafts/store.d.ts.map +1 -0
  161. package/dist/drafts/store.js +244 -0
  162. package/dist/drafts/store.js.map +1 -0
  163. package/dist/gateway.d.ts +37 -0
  164. package/dist/gateway.d.ts.map +1 -0
  165. package/dist/gateway.js +71 -0
  166. package/dist/gateway.js.map +1 -0
  167. package/dist/httpMain.d.ts +3 -0
  168. package/dist/httpMain.d.ts.map +1 -0
  169. package/dist/httpMain.js +20 -0
  170. package/dist/httpMain.js.map +1 -0
  171. package/dist/index.d.ts +3 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +46 -0
  174. package/dist/index.js.map +1 -0
  175. package/dist/initAgents.d.ts +2 -0
  176. package/dist/initAgents.d.ts.map +1 -0
  177. package/dist/initAgents.js +508 -0
  178. package/dist/initAgents.js.map +1 -0
  179. package/dist/log.d.ts +17 -0
  180. package/dist/log.d.ts.map +1 -0
  181. package/dist/log.js +49 -0
  182. package/dist/log.js.map +1 -0
  183. package/dist/mcpResult.d.ts +39 -0
  184. package/dist/mcpResult.d.ts.map +1 -0
  185. package/dist/mcpResult.js +19 -0
  186. package/dist/mcpResult.js.map +1 -0
  187. package/dist/mount.d.ts +33 -0
  188. package/dist/mount.d.ts.map +1 -0
  189. package/dist/mount.js +213 -0
  190. package/dist/mount.js.map +1 -0
  191. package/dist/paramTokens.d.ts +18 -0
  192. package/dist/paramTokens.d.ts.map +1 -0
  193. package/dist/paramTokens.js +50 -0
  194. package/dist/paramTokens.js.map +1 -0
  195. package/dist/projectStore.d.ts +5 -0
  196. package/dist/projectStore.d.ts.map +1 -0
  197. package/dist/projectStore.js +60 -0
  198. package/dist/projectStore.js.map +1 -0
  199. package/dist/requestConnection.d.ts +22 -0
  200. package/dist/requestConnection.d.ts.map +1 -0
  201. package/dist/requestConnection.js +50 -0
  202. package/dist/requestConnection.js.map +1 -0
  203. package/dist/serve.d.ts +10 -0
  204. package/dist/serve.d.ts.map +1 -0
  205. package/dist/serve.js +37 -0
  206. package/dist/serve.js.map +1 -0
  207. package/dist/server.d.ts +41 -0
  208. package/dist/server.d.ts.map +1 -0
  209. package/dist/server.js +370 -0
  210. package/dist/server.js.map +1 -0
  211. package/dist/tools/actionCatalog.d.ts +24 -0
  212. package/dist/tools/actionCatalog.d.ts.map +1 -0
  213. package/dist/tools/actionCatalog.js +56 -0
  214. package/dist/tools/actionCatalog.js.map +1 -0
  215. package/dist/tools/attachment.tools.d.ts +15 -0
  216. package/dist/tools/attachment.tools.d.ts.map +1 -0
  217. package/dist/tools/attachment.tools.js +104 -0
  218. package/dist/tools/attachment.tools.js.map +1 -0
  219. package/dist/tools/backlog.tools.d.ts +13 -0
  220. package/dist/tools/backlog.tools.d.ts.map +1 -0
  221. package/dist/tools/backlog.tools.js +690 -0
  222. package/dist/tools/backlog.tools.js.map +1 -0
  223. package/dist/tools/connection.tools.d.ts +16 -0
  224. package/dist/tools/connection.tools.d.ts.map +1 -0
  225. package/dist/tools/connection.tools.js +120 -0
  226. package/dist/tools/connection.tools.js.map +1 -0
  227. package/dist/tools/defects.tools.d.ts +7 -0
  228. package/dist/tools/defects.tools.d.ts.map +1 -0
  229. package/dist/tools/defects.tools.js +108 -0
  230. package/dist/tools/defects.tools.js.map +1 -0
  231. package/dist/tools/discovery.tools.d.ts +23 -0
  232. package/dist/tools/discovery.tools.d.ts.map +1 -0
  233. package/dist/tools/discovery.tools.js +1746 -0
  234. package/dist/tools/discovery.tools.js.map +1 -0
  235. package/dist/tools/executionPlan.tools.d.ts +14 -0
  236. package/dist/tools/executionPlan.tools.d.ts.map +1 -0
  237. package/dist/tools/executionPlan.tools.js +184 -0
  238. package/dist/tools/executionPlan.tools.js.map +1 -0
  239. package/dist/tools/failure.tools.d.ts +14 -0
  240. package/dist/tools/failure.tools.d.ts.map +1 -0
  241. package/dist/tools/failure.tools.js +65 -0
  242. package/dist/tools/failure.tools.js.map +1 -0
  243. package/dist/tools/formulas.tools.d.ts +7 -0
  244. package/dist/tools/formulas.tools.d.ts.map +1 -0
  245. package/dist/tools/formulas.tools.js +84 -0
  246. package/dist/tools/formulas.tools.js.map +1 -0
  247. package/dist/tools/functionReuse.d.ts +77 -0
  248. package/dist/tools/functionReuse.d.ts.map +1 -0
  249. package/dist/tools/functionReuse.js +384 -0
  250. package/dist/tools/functionReuse.js.map +1 -0
  251. package/dist/tools/gapAnalysis.tools.d.ts +31 -0
  252. package/dist/tools/gapAnalysis.tools.d.ts.map +1 -0
  253. package/dist/tools/gapAnalysis.tools.js +287 -0
  254. package/dist/tools/gapAnalysis.tools.js.map +1 -0
  255. package/dist/tools/heal.tools.d.ts +20 -0
  256. package/dist/tools/heal.tools.d.ts.map +1 -0
  257. package/dist/tools/heal.tools.js +268 -0
  258. package/dist/tools/heal.tools.js.map +1 -0
  259. package/dist/tools/impactAnalysis.tools.d.ts +17 -0
  260. package/dist/tools/impactAnalysis.tools.d.ts.map +1 -0
  261. package/dist/tools/impactAnalysis.tools.js +352 -0
  262. package/dist/tools/impactAnalysis.tools.js.map +1 -0
  263. package/dist/tools/markdown.d.ts +13 -0
  264. package/dist/tools/markdown.d.ts.map +1 -0
  265. package/dist/tools/markdown.js +145 -0
  266. package/dist/tools/markdown.js.map +1 -0
  267. package/dist/tools/objects.tools.d.ts +7 -0
  268. package/dist/tools/objects.tools.d.ts.map +1 -0
  269. package/dist/tools/objects.tools.js +458 -0
  270. package/dist/tools/objects.tools.js.map +1 -0
  271. package/dist/tools/pipeline.tools.d.ts +11 -0
  272. package/dist/tools/pipeline.tools.d.ts.map +1 -0
  273. package/dist/tools/pipeline.tools.js +100 -0
  274. package/dist/tools/pipeline.tools.js.map +1 -0
  275. package/dist/tools/preference.tools.d.ts +15 -0
  276. package/dist/tools/preference.tools.d.ts.map +1 -0
  277. package/dist/tools/preference.tools.js +114 -0
  278. package/dist/tools/preference.tools.js.map +1 -0
  279. package/dist/tools/privileges.tools.d.ts +65 -0
  280. package/dist/tools/privileges.tools.d.ts.map +1 -0
  281. package/dist/tools/privileges.tools.js +186 -0
  282. package/dist/tools/privileges.tools.js.map +1 -0
  283. package/dist/tools/project.tools.d.ts +13 -0
  284. package/dist/tools/project.tools.d.ts.map +1 -0
  285. package/dist/tools/project.tools.js +199 -0
  286. package/dist/tools/project.tools.js.map +1 -0
  287. package/dist/tools/query.tools.d.ts +23 -0
  288. package/dist/tools/query.tools.d.ts.map +1 -0
  289. package/dist/tools/query.tools.js +368 -0
  290. package/dist/tools/query.tools.js.map +1 -0
  291. package/dist/tools/recording.tools.d.ts +58 -0
  292. package/dist/tools/recording.tools.d.ts.map +1 -0
  293. package/dist/tools/recording.tools.js +1050 -0
  294. package/dist/tools/recording.tools.js.map +1 -0
  295. package/dist/tools/recordingNames.d.ts +3 -0
  296. package/dist/tools/recordingNames.d.ts.map +1 -0
  297. package/dist/tools/recordingNames.js +16 -0
  298. package/dist/tools/recordingNames.js.map +1 -0
  299. package/dist/tools/report.tools.d.ts +12 -0
  300. package/dist/tools/report.tools.d.ts.map +1 -0
  301. package/dist/tools/report.tools.js +104 -0
  302. package/dist/tools/report.tools.js.map +1 -0
  303. package/dist/tools/run.tools.d.ts +25 -0
  304. package/dist/tools/run.tools.d.ts.map +1 -0
  305. package/dist/tools/run.tools.js +1295 -0
  306. package/dist/tools/run.tools.js.map +1 -0
  307. package/dist/tools/schemas.d.ts +860 -0
  308. package/dist/tools/schemas.d.ts.map +1 -0
  309. package/dist/tools/schemas.js +220 -0
  310. package/dist/tools/schemas.js.map +1 -0
  311. package/dist/tools/storySync.tools.d.ts +167 -0
  312. package/dist/tools/storySync.tools.d.ts.map +1 -0
  313. package/dist/tools/storySync.tools.js +678 -0
  314. package/dist/tools/storySync.tools.js.map +1 -0
  315. package/dist/tools/suiteManage.tools.d.ts +14 -0
  316. package/dist/tools/suiteManage.tools.d.ts.map +1 -0
  317. package/dist/tools/suiteManage.tools.js +112 -0
  318. package/dist/tools/suiteManage.tools.js.map +1 -0
  319. package/dist/tools/tasks.tools.d.ts +7 -0
  320. package/dist/tools/tasks.tools.d.ts.map +1 -0
  321. package/dist/tools/tasks.tools.js +101 -0
  322. package/dist/tools/tasks.tools.js.map +1 -0
  323. package/dist/tools/tcEditPublisher.d.ts +29 -0
  324. package/dist/tools/tcEditPublisher.d.ts.map +1 -0
  325. package/dist/tools/tcEditPublisher.js +61 -0
  326. package/dist/tools/tcEditPublisher.js.map +1 -0
  327. package/dist/tools/testCaseLint.d.ts +5 -0
  328. package/dist/tools/testCaseLint.d.ts.map +1 -0
  329. package/dist/tools/testCaseLint.js +112 -0
  330. package/dist/tools/testCaseLint.js.map +1 -0
  331. package/dist/tools/testPlan.tools.d.ts +12 -0
  332. package/dist/tools/testPlan.tools.d.ts.map +1 -0
  333. package/dist/tools/testPlan.tools.js +104 -0
  334. package/dist/tools/testPlan.tools.js.map +1 -0
  335. package/dist/tools/testcase.tools.d.ts +86 -0
  336. package/dist/tools/testcase.tools.d.ts.map +1 -0
  337. package/dist/tools/testcase.tools.js +1591 -0
  338. package/dist/tools/testcase.tools.js.map +1 -0
  339. package/dist/tools/testdata.tools.d.ts +7 -0
  340. package/dist/tools/testdata.tools.d.ts.map +1 -0
  341. package/dist/tools/testdata.tools.js +636 -0
  342. package/dist/tools/testdata.tools.js.map +1 -0
  343. package/dist/tools/xlsx.d.ts +8 -0
  344. package/dist/tools/xlsx.d.ts.map +1 -0
  345. package/dist/tools/xlsx.js +113 -0
  346. package/dist/tools/xlsx.js.map +1 -0
  347. package/dist/vendor/actionSignatures.d.ts +117 -0
  348. package/dist/vendor/actionSignatures.d.ts.map +1 -0
  349. package/dist/vendor/actionSignatures.js +420 -0
  350. package/dist/vendor/actionSignatures.js.map +1 -0
  351. package/dist/vendor/logger.d.ts +43 -0
  352. package/dist/vendor/logger.d.ts.map +1 -0
  353. package/dist/vendor/logger.js +184 -0
  354. package/dist/vendor/logger.js.map +1 -0
  355. package/dist/version.d.ts +10 -0
  356. package/dist/version.d.ts.map +1 -0
  357. package/dist/version.js +10 -0
  358. package/dist/version.js.map +1 -0
  359. package/dist/versionName.d.ts +21 -0
  360. package/dist/versionName.d.ts.map +1 -0
  361. package/dist/versionName.js +48 -0
  362. package/dist/versionName.js.map +1 -0
  363. package/package.json +62 -4
@@ -0,0 +1,636 @@
1
+ import { z } from 'zod';
2
+ import { ok, err } from '../mcpResult.js';
3
+ function describeError(e) {
4
+ return e instanceof Error ? e.message : String(e);
5
+ }
6
+ /** Human-readable dump of iterations: one line per row, `name = value` cells. */
7
+ function summarizeTestdata(rows) {
8
+ const head = `${rows.entityType === 'SU' ? 'Suite' : rows.entityType === 'FN' ? 'Function' : 'Test case'} ${rows.id} · ` +
9
+ `env ${rows.environmentType} · ${rows.iterations.length} row(s)`;
10
+ const lines = rows.iterations.map((it) => {
11
+ const isDefault = rows.defaultIterationId && String(it.id) === String(rows.defaultIterationId);
12
+ const cells = it.data
13
+ .filter((c) => c.paramId != null)
14
+ .map((c) => {
15
+ const name = c.name ?? rows.parameterNames[String(c.paramId)] ?? String(c.paramId);
16
+ const value = c.formulaValue ? `${c.value ?? ''} [${c.formulaValue}]` : (c.value ?? '');
17
+ return `${name}=${value}`;
18
+ });
19
+ const shown = cells.slice(0, 15).join(', ');
20
+ const more = cells.length > 15 ? ` … (+${cells.length - 15} more)` : '';
21
+ return `- ${it.name || it.id}${isDefault ? ' (default)' : ''}: ${shown || '(no cells)'}${more}`;
22
+ });
23
+ return `${head}\n${lines.join('\n')}`;
24
+ }
25
+ /** Reject an `environmentType` that doesn't match a real configured env. Null means accepted
26
+ * (a match, or listing wasn't possible — the adapter's own call is then the judge). */
27
+ async function rejectUnlistedEnv(adapter, environmentType) {
28
+ let envs;
29
+ try {
30
+ envs = await adapter.listEnvironments();
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ if (!envs.length)
36
+ return null;
37
+ const wanted = environmentType.trim().toLowerCase();
38
+ const match = envs.some((e) => (e.key ?? e.id)?.toLowerCase() === wanted);
39
+ if (match)
40
+ return null;
41
+ const options = envs.map((e) => `${e.name} · key: ${e.key ?? e.id}`).join(', ');
42
+ return (`"${environmentType}" is not a configured environment for this project — configured options are: ` +
43
+ `${options}. Call tc_list_environments, show these to the user, ask which one, and retry with the ` +
44
+ 'real `key` value (don\'t guess or reuse a value from a different project).');
45
+ }
46
+ async function checkVersionSelection(adapter, tcId, versionId, entityType = 'TC') {
47
+ if (versionId !== undefined)
48
+ return { versionId: versionId === '' ? undefined : versionId };
49
+ if (entityType === 'FN') {
50
+ if (!adapter.getFunction)
51
+ return { versionId: undefined };
52
+ const fn = await adapter.getFunction(tcId);
53
+ const fnVersions = fn.versions ?? [];
54
+ if (fnVersions.length > 1) {
55
+ const listing = fnVersions
56
+ .map((v) => ` • \`${v.id}\` — **${v.name}**${v.isCurrent ? ' (current)' : ''}`)
57
+ .join('\n');
58
+ return {
59
+ error: `Function ${fn.id ?? tcId} has ${fnVersions.length} versions — ASK the user which one ` +
60
+ `they want testdata for, then call again with \`versionId\`. Pass \`versionId: ''\` to accept ` +
61
+ `the current version.\n\n${listing}`,
62
+ };
63
+ }
64
+ return { versionId: undefined };
65
+ }
66
+ const preview = await adapter.getTestCase(tcId);
67
+ const versions = preview.versions ?? [];
68
+ if (versions.length > 1) {
69
+ const listing = versions
70
+ .map((v) => ` • \`${v.id}\` — **${v.name}**${v.isCurrent ? ' (current)' : ''}${v.reviewApproveStatus ? ` · ${v.reviewApproveStatus}` : ''}`)
71
+ .join('\n');
72
+ return {
73
+ error: `Test case ${preview.id ?? tcId} has ${versions.length} versions — ASK the user which one ` +
74
+ `they want testdata for, then call again with \`versionId\`. Pass \`versionId: ''\` to accept ` +
75
+ `the current version.\n\n${listing}`,
76
+ };
77
+ }
78
+ return { versionId: undefined };
79
+ }
80
+ export function registerTestdataTools(server, deps) {
81
+ server.registerTool('tc_list_environments', {
82
+ title: 'List environments configured for the connected project',
83
+ description: 'List every environment configured for the currently connected project (e.g. general, staging, ' +
84
+ 'production). Testdata is stored PER ENVIRONMENT — each env has its own iteration rows. ALWAYS ' +
85
+ 'call this before tc_get_testdata / tc_generate_testdata, show the user the options, and ASK which ' +
86
+ 'env they want to generate testdata for. Never assume. The value to pass onward as ' +
87
+ '`environmentType` is the `key` field on each returned env.',
88
+ inputSchema: {},
89
+ annotations: { readOnlyHint: true },
90
+ }, async () => {
91
+ const adapter = deps.getAdapter?.();
92
+ if (!adapter)
93
+ return err('Not connected to a product. Use qa_connect first.');
94
+ try {
95
+ const envs = await adapter.listEnvironments();
96
+ if (!envs.length) {
97
+ return ok('This project reports zero configured environments. Do NOT assume "general" — confirm ' +
98
+ 'with the user before calling tc_get_testdata / tc_generate_testdata, since environments ' +
99
+ 'may exist under a different key than expected.', { environments: [] });
100
+ }
101
+ const text = `${envs.length} environment${envs.length === 1 ? '' : 's'} configured — ask the user which ` +
102
+ `one, even if there is only one option, since "general" is not guaranteed to be among them:\n\n` +
103
+ envs.map((e) => `- ${e.name}${e.isDefault ? ' (default)' : ''} · key: ${e.key ?? e.id}`).join('\n');
104
+ return ok(text, { environments: envs });
105
+ }
106
+ catch (e) {
107
+ return err(`Could not list environments: ${describeError(e)}`);
108
+ }
109
+ });
110
+ server.registerTool('tc_get_testdata', {
111
+ title: 'Read the current testdata template for a test case',
112
+ description: 'Fetch the default iteration (template row) for TC `tcId` in a specific environment — the ' +
113
+ 'parameter list plus the CURRENT seed values. Testdata is per-env: seeds may differ across ' +
114
+ 'envs. `environmentType` is REQUIRED — this tool refuses when it is omitted, since silently ' +
115
+ 'guessing an env previously caused false "testdata not found" results. FIRST call ' +
116
+ 'tc_list_environments and ask the user which env they want. Then read the template here, and ' +
117
+ 'use the seeds + the test case\'s steps (from tc_get) to reason about realistic values before ' +
118
+ 'calling tc_generate_testdata.\n\n' +
119
+ 'VERSIONS: SimplifyQA TCs can have multiple versions with different params/seeds. When the TC ' +
120
+ 'has more than one version and `versionId` is omitted, this tool REFUSES and lists the ' +
121
+ 'available versions — ASK the user which one, then call again with `versionId`. Pass ' +
122
+ '`versionId: \'\'` to accept the TC\'s currently-selected version. Single-version TCs are read directly.\n\n' +
123
+ 'FUNCTIONS: if a step in this TC calls a reusable FUNCTION, the `parameters` array (and the ' +
124
+ 'row list in this response\'s text) includes ONE extra row for it — a row whose "seed" is the ' +
125
+ 'function\'s NAME + VERSION, not its testdata (a called function\'s testdata is its own ' +
126
+ 'separate tc_get_testdata call, never guessed or fabricated here). It is a normal row in the ' +
127
+ 'SAME table as the TC\'s own parameters — do not pull it out into separate prose afterward. ' +
128
+ 'When one or more functions were called, this response ALSO ends with an explicit prompt ' +
129
+ 'listing each one and the exact tc_get_testdata args to fetch its testdata — ASK the user ' +
130
+ 'which (if any) they want BEFORE calling tc_get_testdata again for a function; do not fetch ' +
131
+ 'one unprompted, and do not skip the ask just because there is only one.',
132
+ inputSchema: {
133
+ tcId: z.string().describe('Test case id (or business key like TC_123). With entityType "FN": the function id.'),
134
+ entityType: z.enum(['TC', 'FN']).optional().describe("'TC' (default) = `tcId` is a test case. 'FN' = `tcId` is a reusable FUNCTION id — reads/saves the " +
135
+ "FUNCTION's own testdata iterations."),
136
+ environmentType: z.string().optional()
137
+ .describe('Env `key` (from tc_list_environments). REQUIRED — this tool refuses when omitted. Ask the user which env before reading testdata.'),
138
+ versionId: z.string().optional().describe("Version to read testdata for (an id from the TC's `versions[]`). Omit to trigger the " +
139
+ "ASK-user prompt when the TC has multiple versions. Pass '' to accept the TC's currently-" +
140
+ 'selected version without prompting.'),
141
+ },
142
+ annotations: { readOnlyHint: true },
143
+ }, async ({ tcId, environmentType, versionId, entityType }) => {
144
+ const adapter = deps.getAdapter?.();
145
+ if (!adapter)
146
+ return err('Not connected to a product. Use qa_connect first.');
147
+ if (!adapter.getDefaultIteration) {
148
+ return err('This provider does not expose a testdata store.');
149
+ }
150
+ if (!environmentType || !environmentType.trim()) {
151
+ return err('environmentType is required — testdata is stored per environment and this tool refuses to ' +
152
+ 'guess (a silent guess previously produced false "testdata not found" results). Call ' +
153
+ 'tc_list_environments, show the user the options, ask which env, then call tc_get_testdata ' +
154
+ 'again with that env `key` as `environmentType`.');
155
+ }
156
+ const envError = await rejectUnlistedEnv(adapter, environmentType);
157
+ if (envError)
158
+ return err(envError);
159
+ try {
160
+ const vsel = await checkVersionSelection(adapter, tcId, versionId, entityType ?? 'TC');
161
+ if ('error' in vsel)
162
+ return err(vsel.error);
163
+ const tpl = await adapter.getDefaultIteration({
164
+ tcId,
165
+ ...(entityType ? { entityType } : {}),
166
+ ...(vsel.versionId !== undefined ? { versionId: vsel.versionId } : {}),
167
+ ...(environmentType !== undefined ? { environmentType } : {}),
168
+ });
169
+ // List called functions by NAME + VERSION only — their own testdata lives in a separate
170
+ // row (a separate tc_get_testdata call against that function), never fetched or guessed here.
171
+ let calledFunctions = [];
172
+ try {
173
+ const tc = await adapter.getTestCase(tcId, tpl.versionId);
174
+ const seen = new Set();
175
+ for (const s of tc.steps) {
176
+ const fc = s.functionCall;
177
+ if (!fc?.testCaseId)
178
+ continue;
179
+ const key = `${fc.testCaseId}::${fc.versionId ?? ''}`;
180
+ if (seen.has(key))
181
+ continue;
182
+ seen.add(key);
183
+ calledFunctions.push({
184
+ id: fc.testCaseId,
185
+ ...(fc.testCaseCode ? { code: fc.testCaseCode } : {}),
186
+ ...(fc.testCaseName ? { name: fc.testCaseName } : {}),
187
+ ...(fc.versionId ? { versionId: fc.versionId } : {}),
188
+ ...(fc.versionName ? { versionName: fc.versionName } : {}),
189
+ });
190
+ }
191
+ }
192
+ catch {
193
+ // Best-effort — a TC's own testdata is still useful without the called-function list.
194
+ }
195
+ // Synthetic ROWS added directly into the SAME `parameters` array the TC's own fields are
196
+ // in (paramId is a negative sentinel — never a real backend param id) so a called function
197
+ // is structurally IDENTICAL to a real row wherever this array gets rendered as a table,
198
+ // instead of living in a side-channel field that a renderer would show separately.
199
+ const fnParamRows = calledFunctions.map((f, i) => ({
200
+ paramId: -1 - i,
201
+ name: `${[f.code, f.name].filter(Boolean).join(' - ') || f.id} (called function)`,
202
+ seed: f.versionName ?? f.versionId ?? 'current',
203
+ }));
204
+ const displayParams = [...tpl.parameters, ...fnParamRows];
205
+ if (!displayParams.length) {
206
+ return ok(`Test case "${tcId}" has no parameterized fields in env "${tpl.environmentType}" — nothing to generate.`, { tcId, parameters: [] });
207
+ }
208
+ const fnAskNote = calledFunctions.length
209
+ ? `\n\nASK the user which called function's testdata they want (do not guess or fetch one unasked):\n` +
210
+ calledFunctions
211
+ .map((f) => `- ${[f.code, f.name].filter(Boolean).join(' - ') || f.id} (${f.versionName ?? f.versionId ?? 'current'}) — ` +
212
+ `call tc_get_testdata again with tcId: "${f.id}", entityType: "FN"${f.versionId ? `, versionId: "${f.versionId}"` : ''}, ` +
213
+ `environmentType: "${tpl.environmentType}"`)
214
+ .join('\n')
215
+ : '';
216
+ const text = `Testdata template for ${tcId} · env ${tpl.environmentType} · version ${tpl.versionId}\n` +
217
+ `${displayParams.length} row(s)${fnParamRows.length ? ` (${fnParamRows.length} of these is a called function's name + version, not its testdata)` : ''}:\n` +
218
+ displayParams
219
+ .map((p) => p.protected
220
+ ? `- ${p.name} = ${p.seed} [PROTECTED — value hidden, not exposed by this tool]`
221
+ : `- ${p.name} = "${p.seed}"`)
222
+ .join('\n') +
223
+ fnAskNote;
224
+ return ok(text, {
225
+ tcId,
226
+ versionId: tpl.versionId,
227
+ environmentType: tpl.environmentType,
228
+ parameters: displayParams,
229
+ });
230
+ }
231
+ catch (e) {
232
+ return err(`Could not read testdata for "${tcId}": ${describeError(e)}`);
233
+ }
234
+ });
235
+ server.registerTool('tc_generate_testdata', {
236
+ title: 'Save generated testdata rows to a test case',
237
+ description: 'Persist up to 20 testdata rows for TC `tcId` into a SPECIFIC environment. Testdata is stored ' +
238
+ 'per environment — rows saved here only affect the env you pass. WORKFLOW: (1) call ' +
239
+ 'tc_list_environments and ASK the user which env; (2) call tc_get_testdata with that env to ' +
240
+ 'read seeds; (3) call this tool with the SAME `environmentType`. `environmentType` is REQUIRED ' +
241
+ 'here — this tool refuses when it is omitted. Two ways to feed values:\n' +
242
+ ' 1) Model-generated — pass `rows: [{paramName: value}, ...]`. Call tc_get_testdata first ' +
243
+ 'for the parameter names + seeds, tc_get for step context, then produce rows that fit the flow.\n' +
244
+ ' 2) Formula-driven — pass `formulas: {paramName: {name, args?}}` (names from tc_list_formulas). ' +
245
+ 'Each formula is evaluated per row by the SimplifyQA desktop AGENT (the same engine the UI and the ' +
246
+ 'executor use, so every formula from tc_list_formulas works, including nested ones) and both the ' +
247
+ 'value and the source `=NAME(...)` expression are stamped. The agent must be running (QA_MCP_URL). ' +
248
+ 'For nested / custom formulas pass `expression` instead of `name`+`args`. Use `count` to say how many rows, or provide `rows` ' +
249
+ 'for constant columns; mixing is fine (formulas win over row values for the same param).\n' +
250
+ 'Rows are appended as new iterations; they do not become the default. Hard cap: 20 rows.\n\n' +
251
+ 'VERSIONS: SimplifyQA TCs can have multiple versions with different params. When the TC has ' +
252
+ 'more than one version and `versionId` is omitted, this tool REFUSES and lists the available ' +
253
+ 'versions — ASK the user which one, then call again with `versionId`. Pass `versionId: \'\'` ' +
254
+ 'to accept the TC\'s currently-selected version.',
255
+ inputSchema: {
256
+ tcId: z.string().describe('Test case id (or business key like TC_123). With entityType "FN": the function id.'),
257
+ entityType: z.enum(['TC', 'FN']).optional().describe("'TC' (default) = `tcId` is a test case. 'FN' = `tcId` is a reusable FUNCTION id — reads/saves the " +
258
+ "FUNCTION's own testdata iterations."),
259
+ versionId: z.string().optional().describe("Version to save testdata into (an id from the TC's `versions[]`). Omit to trigger the " +
260
+ "ASK-user prompt when the TC has multiple versions. Pass '' to accept the TC's currently-" +
261
+ 'selected version without prompting.'),
262
+ rows: z.array(z.record(z.string(), z.string())).max(20).optional()
263
+ .describe('Rows keyed by param name (from tc_get_testdata). 1..20 rows. Omit when using formulas + count.'),
264
+ count: z.number().int().min(1).max(20).optional()
265
+ .describe('How many rows to generate when using formulas without explicit rows. Ignored if rows is set.'),
266
+ formulas: z.record(z.string(), z.object({
267
+ name: z.string().optional().describe('RAW formula name from tc_list_formulas — the identifier only, no parens, no arg list. Correct: "FIRST_NAME". Wrong: "FIRST_NAME()", "FIRST_NAME(country,sex)". Give this OR `expression`.'),
268
+ args: z.record(z.string(), z.string()).optional()
269
+ .describe('Named args. Keys MUST match Formula.parameters[].keyName exactly, no trailing colons or extra whitespace. Correct: {"country name": "United States"}. Wrong: {"country name:": "..."}.'),
270
+ expression: z.string().optional().describe('A complete formula, used as written — for nested or custom formulas, e.g. `=UPPER(FIRST_NAME("United States"))` or `=CONCATENATE(FIRST_NAME(),"@test.com")`. Use instead of name/args.'),
271
+ })).optional()
272
+ .describe('Per-column formula assignments applied to every row. Outer keys are param names from tc_get_testdata. Wins over rows[i] for the same key.'),
273
+ environmentType: z.string().optional()
274
+ .describe('Env `key` (from tc_list_environments). REQUIRED — this tool refuses when omitted. Ask the user which env before generating.'),
275
+ },
276
+ annotations: { readOnlyHint: false },
277
+ }, async ({ tcId, rows, count, formulas, environmentType, versionId, entityType }) => {
278
+ const adapter = deps.getAdapter?.();
279
+ if (!adapter)
280
+ return err('Not connected to a product. Use qa_connect first.');
281
+ if (!adapter.getDefaultIteration || !adapter.saveGeneratedIterations) {
282
+ return err('This provider does not expose a testdata store.');
283
+ }
284
+ if (!environmentType || !environmentType.trim()) {
285
+ return err('environmentType is required — testdata is stored per environment and this tool refuses to ' +
286
+ 'guess. Call tc_list_environments, show the user the options, ask which env, then call ' +
287
+ 'tc_generate_testdata again with that env `key` as `environmentType`.');
288
+ }
289
+ const envError = await rejectUnlistedEnv(adapter, environmentType);
290
+ if (envError)
291
+ return err(envError);
292
+ const vsel = await checkVersionSelection(adapter, tcId, versionId, entityType ?? 'TC');
293
+ if ('error' in vsel)
294
+ return err(vsel.error);
295
+ const hasFormulas = formulas != null && Object.keys(formulas).length > 0;
296
+ if (hasFormulas) {
297
+ const incomplete = Object.entries(formulas).filter(([, f]) => !f.name && !f.expression?.trim()).map(([k]) => k);
298
+ if (incomplete.length) {
299
+ return err(`Formula for column(s) ${incomplete.join(', ')} needs a \`name\` (from tc_list_formulas) or a full \`expression\`.`);
300
+ }
301
+ }
302
+ // Reconcile rows vs count. Explicit rows always win; otherwise formulas + count seeds N empty
303
+ // rows that the adapter fills column-by-column via evaluateFormula.
304
+ let baseRows;
305
+ if (rows && rows.length > 0) {
306
+ baseRows = rows;
307
+ }
308
+ else if (hasFormulas && count && count > 0) {
309
+ baseRows = Array.from({ length: count }, () => ({}));
310
+ }
311
+ else {
312
+ return err('Provide either `rows` (1..20) or `formulas` together with `count` (1..20).');
313
+ }
314
+ if (baseRows.length > 20)
315
+ return err('Max 20 rows per call.');
316
+ // Resolve version + env by re-reading the template. Server-side env resolution honors project
317
+ // config; passing rows without this echo would risk saving into the wrong env.
318
+ let tpl;
319
+ try {
320
+ tpl = await adapter.getDefaultIteration({
321
+ tcId,
322
+ ...(entityType ? { entityType } : {}),
323
+ ...(vsel.versionId !== undefined ? { versionId: vsel.versionId } : {}),
324
+ ...(environmentType !== undefined ? { environmentType } : {}),
325
+ });
326
+ }
327
+ catch (e) {
328
+ return err(`Could not fetch the default iteration for "${tcId}": ${describeError(e)}`);
329
+ }
330
+ if (!tpl.parameters?.length) {
331
+ return err(`Test case "${tcId}" has no parameterized fields — nothing to save.`);
332
+ }
333
+ const known = new Set(tpl.parameters.map((p) => p.name));
334
+ // Sheet headers rarely match the stored parameter's spelling exactly ("Username" vs the
335
+ // existing project-wide "username"), and the backend matches parameter names
336
+ // case-insensitively. Fold to the template's canonical spelling before anything else, so the
337
+ // rows, the unknown-name report and the preview all talk about the same columns.
338
+ const byLower = new Map(tpl.parameters.map((p) => [p.name.trim().toLowerCase(), p.name]));
339
+ const canonical = (k) => known.has(k) ? k : byLower.get(k.trim().toLowerCase());
340
+ const unknown = new Set();
341
+ const normalizedRows = baseRows.map((r) => {
342
+ const out = {};
343
+ for (const [k, v] of Object.entries(r)) {
344
+ const name = canonical(k);
345
+ if (!name) {
346
+ unknown.add(k);
347
+ continue;
348
+ }
349
+ out[name] = v;
350
+ }
351
+ return out;
352
+ });
353
+ const normalizedFormulas = hasFormulas
354
+ ? Object.fromEntries(Object.entries(formulas).flatMap(([k, v]) => {
355
+ const name = canonical(k);
356
+ if (!name) {
357
+ unknown.add(k);
358
+ return [];
359
+ }
360
+ return [[name, v]];
361
+ }))
362
+ : undefined;
363
+ // A cell written as "=NAME(...)" IS a formula — that is exactly how the SQA test-data grid
364
+ // treats it. Saving it through `rows` would store the text as a literal value, so at run time
365
+ // the executor would TYPE "=CONCATENATE(...)" into the application instead of evaluating it
366
+ // (and no formulaValue would be recorded). Promote such cells to the formula path.
367
+ const promoted = {};
368
+ for (const row of normalizedRows) {
369
+ for (const [k, v] of Object.entries(row)) {
370
+ if (typeof v === 'string' && /^\s*=/.test(v)) {
371
+ promoted[k] = { expression: v.trim() };
372
+ delete row[k];
373
+ }
374
+ }
375
+ }
376
+ // An explicit `formulas` entry wins over a promoted cell for the same column.
377
+ const formulaMap = { ...promoted, ...(normalizedFormulas ?? {}) };
378
+ const formulaColumns = Object.keys(formulaMap);
379
+ let result;
380
+ try {
381
+ result = await adapter.saveGeneratedIterations({
382
+ tcId,
383
+ ...(entityType ? { entityType } : {}),
384
+ versionId: tpl.versionId,
385
+ environmentType: tpl.environmentType,
386
+ rows: normalizedRows,
387
+ parameters: tpl.parameters, // reuse the just-fetched template; adapter skips its own re-fetch
388
+ ...(formulaColumns.length ? { formulas: formulaMap } : {}),
389
+ });
390
+ }
391
+ catch (e) {
392
+ return err(`Save failed: ${describeError(e)}`);
393
+ }
394
+ const paramNames = tpl.parameters.map((p) => p.name);
395
+ const protectedNames = new Set(tpl.parameters.filter((p) => p.protected).map((p) => p.name));
396
+ // Mask protected columns before they reach the text or structuredContent.
397
+ const preview = normalizedRows.slice(0, 3).map((r) => {
398
+ const masked = { ...r };
399
+ for (const n of protectedNames)
400
+ if (n in masked)
401
+ masked[n] = masked[n] ? '*****' : '(empty)';
402
+ return masked;
403
+ });
404
+ const formulaNote = formulaColumns.length
405
+ ? `\nFormula columns: ${formulaColumns.join(', ')} (evaluated per row).`
406
+ : '';
407
+ const warn = unknown.size
408
+ ? `\n(Ignored unknown param name(s): ${[...unknown].join(', ')} — not in the template.)`
409
+ : '';
410
+ const protectedNote = protectedNames.size
411
+ ? `\nProtected column(s) [${[...protectedNames].join(', ')}] are masked below — their values are never echoed by this tool.`
412
+ : '';
413
+ const link = result.datasetUrl ? `\n${result.datasetUrl}` : '';
414
+ const text = `Saved ${result.inserted} testdata row(s) for ${tcId} · env ${tpl.environmentType}.${link}${formulaNote}${warn}${protectedNote}\n\n` +
415
+ `Preview (first ${preview.length}, formula values shown as their param name):\n` +
416
+ preview
417
+ .map((r, i) => `${i + 1}. ${paramNames.map((n) => `${n}=${r[n] ?? (formulaMap[n] ? `<${('expression' in formulaMap[n] ? formulaMap[n].expression : formulaMap[n].name)}>` : '')}`).join(' | ')}`)
418
+ .join('\n');
419
+ return ok(text, {
420
+ tcId,
421
+ generated: result.inserted,
422
+ params: paramNames,
423
+ preview,
424
+ ...(formulaColumns.length ? { formulasUsed: formulaColumns } : {}),
425
+ ...(result.datasetUrl ? { datasetUrl: result.datasetUrl } : {}),
426
+ ...(result.iterationIds ? { iterationIds: result.iterationIds } : {}),
427
+ });
428
+ });
429
+ server.registerTool('tc_update_testdata', {
430
+ title: 'Update the existing test data (default iteration) of a test case',
431
+ description: 'UPDATE the test data a run actually uses — the DEFAULT iteration (ITR-1) — instead of appending a ' +
432
+ 'new row. Use this for "change/set/fix the test data", "add a formula to the test data", or whenever ' +
433
+ 'a value or formula must apply to the NEXT run. (tc_generate_testdata APPENDS iterations; an appended ' +
434
+ 'row never becomes the default, so a formula saved there does not affect the run.)\n\n' +
435
+ 'Each cell takes a literal `value` or a `formula` ({ name, args? } from tc_list_formulas, or a full ' +
436
+ '`expression` — nested formulas are supported). Formulas are evaluated by the SimplifyQA desktop agent; ' +
437
+ 'the evaluated value AND the canonical =NAME(...) expression are stored, and the executor re-evaluates ' +
438
+ 'at run time. Unknown/invented names and unevaluatable formulas are rejected BEFORE anything is ' +
439
+ 'written. Only the named cells change — every other column keeps its value — and the row is read back.',
440
+ inputSchema: {
441
+ tcId: z.string().describe('Test case id or business key (e.g. TC_123).'),
442
+ environmentType: z.string().describe('Env `key` from tc_list_environments. REQUIRED — test data is per environment.'),
443
+ versionId: z.string().optional().describe("Version id from the TC's versions[]. Omit on a single-version TC; pass '' to accept the current one."),
444
+ cells: z.array(z.object({
445
+ param: z.string().describe('Parameter name exactly as tc_get_testdata shows it.'),
446
+ value: z.string().optional().describe('Literal value to store. Give this OR `formula`.'),
447
+ formula: z.object({
448
+ name: z.string().optional().describe('Raw formula name from tc_list_formulas (identifier only, no parens).'),
449
+ args: z.record(z.string(), z.string()).optional().describe("Formula arguments keyed by the formula's parameter keyName. Literal values only."),
450
+ expression: z.string().optional().describe('Full expression — use for nested formulas, e.g. "=CONCATENATE(FULL_NAME(),CREDIT_CARD_NUMBER())".'),
451
+ }).optional().describe('Formula to store on that cell (takes precedence over `value`).'),
452
+ })).min(1).describe('Cells to change. Only these are touched.'),
453
+ },
454
+ annotations: { readOnlyHint: false },
455
+ }, async ({ tcId, environmentType, versionId, cells }) => {
456
+ const adapter = deps.getAdapter?.();
457
+ if (!adapter)
458
+ return err('Not connected to a product. Use qa_connect first.');
459
+ if (!adapter.patchTestdataCells)
460
+ return err('This provider cannot update existing test data.');
461
+ const envError = await rejectUnlistedEnv(adapter, environmentType);
462
+ if (envError)
463
+ return err(envError);
464
+ let vsel;
465
+ try {
466
+ vsel = await checkVersionSelection(adapter, tcId, versionId);
467
+ }
468
+ catch (e) {
469
+ return err(`Could not resolve the test case version: ${describeError(e)}`);
470
+ }
471
+ if ('error' in vsel)
472
+ return err(vsel.error);
473
+ const patch = [];
474
+ const notes = [];
475
+ for (const cell of cells) {
476
+ if (cell.formula) {
477
+ if (!adapter.evaluateFormula)
478
+ return err('This provider cannot evaluate formulas.');
479
+ const call = {
480
+ ...(cell.formula.name ? { name: cell.formula.name } : {}),
481
+ ...(cell.formula.args ? { args: cell.formula.args } : {}),
482
+ ...(cell.formula.expression ? { expression: cell.formula.expression } : {}),
483
+ };
484
+ if (!call.name && !call.expression)
485
+ return err(`Cell "${cell.param}": give the formula as { name } or { expression }.`);
486
+ try {
487
+ const { value, expression } = await adapter.evaluateFormula(call);
488
+ patch.push({ paramName: cell.param, value, formulaValue: expression });
489
+ notes.push(`${cell.param} = ${expression} → ${value}`);
490
+ }
491
+ catch (e) {
492
+ return err(`Formula for "${cell.param}" could not be applied — nothing was written: ${describeError(e)}`);
493
+ }
494
+ }
495
+ else if (cell.value !== undefined) {
496
+ patch.push({ paramName: cell.param, value: cell.value });
497
+ notes.push(`${cell.param} = ${cell.value === '' ? '(empty)' : cell.value}`);
498
+ }
499
+ else {
500
+ return err(`Cell "${cell.param}": give a \`value\` or a \`formula\`.`);
501
+ }
502
+ }
503
+ let res;
504
+ try {
505
+ res = await adapter.patchTestdataCells({
506
+ tcId,
507
+ cells: patch,
508
+ ...(vsel.versionId !== undefined ? { versionId: vsel.versionId } : {}),
509
+ environmentType,
510
+ overwriteFormula: true,
511
+ });
512
+ }
513
+ catch (e) {
514
+ return err(`Update failed: ${describeError(e)}`);
515
+ }
516
+ let after = [];
517
+ try {
518
+ const tpl = adapter.getDefaultIteration
519
+ ? await adapter.getDefaultIteration({
520
+ tcId,
521
+ ...(vsel.versionId !== undefined ? { versionId: vsel.versionId } : {}),
522
+ environmentType,
523
+ })
524
+ : null;
525
+ after = tpl ? tpl.parameters.map((p) => ({ name: p.name, seed: p.protected ? '*****' : p.seed })) : [];
526
+ }
527
+ catch { /* read-back is best-effort */ }
528
+ const skippedNote = res.skipped.length ? `\nSkipped: ${res.skipped.join('; ')}` : '';
529
+ const readBack = after.length
530
+ ? `\n\nDefault iteration (ITR-1) now:\n` + after.map((p) => `- ${p.name} = ${p.seed === '' ? '(empty)' : p.seed}`).join('\n')
531
+ : '';
532
+ return ok(`Updated ${res.patched} cell(s) on the DEFAULT test data row of ${tcId} · env ${environmentType}.\n` +
533
+ notes.map((n) => `- ${n}`).join('\n') + skippedNote + readBack, { tcId, environmentType, patched: res.patched, skipped: res.skipped, readBack: after });
534
+ });
535
+ server.registerTool('suite_get_testdata', {
536
+ title: "Read a suite's SUITE-LEVEL test data",
537
+ description: 'Read the SUITE-LEVEL test-data iterations of suite `suiteId` (SU-24) in an environment. ' +
538
+ 'Suite-level test data is a SEPARATE store from the member test cases\' own test data. When the ' +
539
+ 'user says "SU-24 test data", ALWAYS use this — never tc_get_testdata on a member test case. ' +
540
+ '`environmentType` is REQUIRED: call tc_list_environments, show the keys, and ASK which env. ' +
541
+ 'The result lists every iteration (name, default marker, parameter=value cells).',
542
+ inputSchema: {
543
+ suiteId: z.string().describe('Suite id or business key (SU-24).'),
544
+ environmentType: z.string().describe('Environment key from tc_list_environments (e.g. general, general_1).'),
545
+ },
546
+ annotations: { readOnlyHint: true },
547
+ }, async ({ suiteId, environmentType }) => {
548
+ const adapter = deps.getAdapter?.();
549
+ if (!adapter)
550
+ return err('Not connected to a product. Use qa_connect first.');
551
+ if (!adapter.getSuiteTestdata)
552
+ return err('Suite-level test data is not supported by the connected provider.');
553
+ const envErr = await rejectUnlistedEnv(adapter, environmentType);
554
+ if (envErr)
555
+ return err(envErr);
556
+ try {
557
+ const rows = await adapter.getSuiteTestdata({ suiteId, environmentType });
558
+ return ok(summarizeTestdata(rows), rows);
559
+ }
560
+ catch (e) {
561
+ return err(`Could not read suite-level test data for ${suiteId}: ${describeError(e)}`);
562
+ }
563
+ });
564
+ server.registerTool('suite_copy_testdata', {
565
+ title: 'Copy a SUITE-LEVEL test-data row and save it on the suite',
566
+ description: 'Copy ONE existing suite-level row of suite `suiteId` into a NEW suite-level row and save it. ' +
567
+ 'Use for "copy ITR-1 into ITR-2 in SU-24\'s test data and save". The copy is written to the ' +
568
+ 'SUITE-LEVEL test data ONLY — member test cases\' own test data is NEVER touched. `from` names ' +
569
+ 'the source row (default: the suite default row, normally ITR-1); `name` names the new row ' +
570
+ '(default: the next free ITR-N). The tool then reads the suite\'s test data back and confirms the ' +
571
+ 'new row exists. Refuses a duplicate row name.',
572
+ inputSchema: {
573
+ suiteId: z.string().describe('Suite id or business key (SU-24).'),
574
+ environmentType: z.string().describe('Environment key from tc_list_environments (e.g. general, general_1).'),
575
+ from: z.string().optional().describe('Source iteration name (e.g. "ITR-1") or id. Default: the suite default row.'),
576
+ name: z.string().optional().describe('Name for the new row (e.g. "ITR-2"). Default: next free ITR-N.'),
577
+ },
578
+ }, async ({ suiteId, environmentType, from, name }) => {
579
+ const adapter = deps.getAdapter?.();
580
+ if (!adapter)
581
+ return err('Not connected to a product. Use qa_connect first.');
582
+ if (!adapter.copySuiteTestdataIteration)
583
+ return err('Suite-level test data is not supported by the connected provider.');
584
+ const envErr = await rejectUnlistedEnv(adapter, environmentType);
585
+ if (envErr)
586
+ return err(envErr);
587
+ try {
588
+ const res = await adapter.copySuiteTestdataIteration({
589
+ suiteId, environmentType,
590
+ ...(from ? { from } : {}),
591
+ ...(name ? { name } : {}),
592
+ });
593
+ return ok(`Created suite-level iteration "${res.name}" (id ${res.iterationId}) on suite ${suiteId} — ` +
594
+ `member test cases were not touched. Read back after the save:\n\n` + summarizeTestdata(res.rows), { suiteId, iterationId: res.iterationId, name: res.name, rows: res.rows });
595
+ }
596
+ catch (e) {
597
+ return err(`Could not copy suite-level test data for ${suiteId}: ${describeError(e)}`);
598
+ }
599
+ });
600
+ server.registerTool('testdata_delete_iterations', {
601
+ title: 'Delete test-data iteration rows (test case or suite level)',
602
+ description: 'Delete one or more test-data iteration rows by NAME (e.g. "ITR-2") or id. Works at TEST CASE level ' +
603
+ '(`entityType:"TC"` + `tcId`) and at SUITE level (`entityType:"SU"` + `suiteId`). The DEFAULT row is ' +
604
+ 'refused. Use this to remove rows created by mistake. It reads the rows back after deleting and ' +
605
+ 'reports what remains.',
606
+ inputSchema: {
607
+ entityType: z.enum(['TC', 'SU']).optional().describe('TC = a test case\'s own test data; SU = suite-level test data. Default TC.'),
608
+ tcId: z.string().optional().describe('Test case id / TC-123 (required when entityType is TC).'),
609
+ suiteId: z.string().optional().describe('Suite id / SU-24 (required when entityType is SU).'),
610
+ environmentType: z.string().describe('Environment key from tc_list_environments (e.g. general, general_1).'),
611
+ iterations: z.array(z.string()).min(1).describe('Iteration names (e.g. ["ITR-2"]) or ids to delete.'),
612
+ },
613
+ }, async ({ entityType, tcId, suiteId, environmentType, iterations }) => {
614
+ const adapter = deps.getAdapter?.();
615
+ if (!adapter)
616
+ return err('Not connected to a product. Use qa_connect first.');
617
+ if (!adapter.deleteTestdataIterations)
618
+ return err('Deleting test-data rows is not supported by the connected provider.');
619
+ const type = entityType ?? (suiteId ? 'SU' : 'TC');
620
+ const id = type === 'SU' ? suiteId : tcId;
621
+ if (!id)
622
+ return err(type === 'SU' ? 'Pass suiteId for entityType "SU".' : 'Pass tcId for entityType "TC".');
623
+ const envErr = await rejectUnlistedEnv(adapter, environmentType);
624
+ if (envErr)
625
+ return err(envErr);
626
+ try {
627
+ const res = await adapter.deleteTestdataIterations({ entityType: type, id, environmentType, iterations });
628
+ return ok(`Deleted ${res.deleted.length} iteration row(s) from ${type === 'SU' ? 'suite' : 'test case'} ${id} — env ${environmentType}. ` +
629
+ `Rows now:\n\n` + summarizeTestdata(res.rows), { deleted: res.deleted, rows: res.rows });
630
+ }
631
+ catch (e) {
632
+ return err(`Could not delete test-data row(s): ${describeError(e)}`);
633
+ }
634
+ });
635
+ }
636
+ //# sourceMappingURL=testdata.tools.js.map