@empiricalrun/test-gen 0.73.1 → 0.74.0

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 (313) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/actions/utils/index.d.ts.map +1 -1
  3. package/dist/actions/utils/index.js +1 -2
  4. package/dist/agent/browsing/index.d.ts.map +1 -1
  5. package/dist/agent/browsing/index.js +9 -7
  6. package/dist/agent/browsing/utils.d.ts.map +1 -1
  7. package/dist/agent/browsing/utils.js +3 -4
  8. package/dist/agent/chat/agent-loop.d.ts +7 -8
  9. package/dist/agent/chat/agent-loop.d.ts.map +1 -1
  10. package/dist/agent/chat/agent-loop.js +13 -17
  11. package/dist/agent/chat/exports.d.ts +5 -4
  12. package/dist/agent/chat/exports.d.ts.map +1 -1
  13. package/dist/agent/chat/exports.js +9 -4
  14. package/dist/agent/chat/filesystem-cache.d.ts +12 -0
  15. package/dist/agent/chat/filesystem-cache.d.ts.map +1 -0
  16. package/dist/agent/chat/filesystem-cache.js +101 -0
  17. package/dist/agent/chat/index.d.ts +4 -1
  18. package/dist/agent/chat/index.d.ts.map +1 -1
  19. package/dist/agent/chat/index.js +44 -22
  20. package/dist/agent/chat/models.d.ts +2 -1
  21. package/dist/agent/chat/models.d.ts.map +1 -1
  22. package/dist/agent/chat/models.js +25 -3
  23. package/dist/agent/chat/prompt/index.d.ts +3 -1
  24. package/dist/agent/chat/prompt/index.d.ts.map +1 -1
  25. package/dist/agent/chat/prompt/index.js +77 -2
  26. package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
  27. package/dist/agent/chat/prompt/repo.js +1 -0
  28. package/dist/agent/chat/state.d.ts +6 -5
  29. package/dist/agent/chat/state.d.ts.map +1 -1
  30. package/dist/agent/chat/state.js +35 -5
  31. package/dist/agent/chat/utils.d.ts +1 -0
  32. package/dist/agent/chat/utils.d.ts.map +1 -1
  33. package/dist/agent/chat/utils.js +16 -3
  34. package/dist/agent/cua/index.js +1 -1
  35. package/dist/agent/cua/model.js +1 -1
  36. package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +1 -1
  37. package/dist/agent/cua/pw-codegen/pw-pause/index.js +0 -1
  38. package/dist/agent/master/browser-tests/fixtures.d.ts.map +1 -1
  39. package/dist/agent/master/browser-tests/fixtures.js +0 -1
  40. package/dist/agent/master/element-annotation.d.ts.map +1 -1
  41. package/dist/agent/master/element-annotation.js +1 -2
  42. package/dist/agent/master/execute-browser-action.d.ts.map +1 -1
  43. package/dist/agent/master/execute-browser-action.js +8 -6
  44. package/dist/agent/master/icon-descriptor/index.js +2 -2
  45. package/dist/agent/master/next-action.js +1 -1
  46. package/dist/agent/master/planner.js +1 -1
  47. package/dist/agent/master/scroller.js +2 -2
  48. package/dist/agent/master/with-hints.d.ts.map +1 -1
  49. package/dist/agent/master/with-hints.js +6 -5
  50. package/dist/agent/planner/run-time-planner.js +1 -1
  51. package/dist/agent/planner/run.d.ts.map +1 -1
  52. package/dist/agent/planner/run.js +4 -2
  53. package/dist/auth/cli-auth.js +1 -1
  54. package/dist/auth/token-store.d.ts.map +1 -1
  55. package/dist/auth/token-store.js +4 -6
  56. package/dist/bin/index.js +30 -163
  57. package/dist/bin/utils/context.js +1 -1
  58. package/dist/bin/utils/index.d.ts +0 -12
  59. package/dist/bin/utils/index.d.ts.map +1 -1
  60. package/dist/bin/utils/index.js +0 -70
  61. package/dist/bin/utils/platform/web/index.d.ts +2 -2
  62. package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
  63. package/dist/bin/utils/platform/web/index.js +7 -5
  64. package/dist/bin/utils/scenarios/index.d.ts +11 -3
  65. package/dist/bin/utils/scenarios/index.d.ts.map +1 -1
  66. package/dist/browser-injected-scripts/annotate-elements.spec.js +0 -5
  67. package/dist/browser-injected-scripts/annotate-elements.spec.ts +0 -5
  68. package/dist/dashboard/client.d.ts +2 -2
  69. package/dist/dashboard/client.d.ts.map +1 -1
  70. package/dist/dashboard/client.js +4 -1
  71. package/dist/file-info/adapters/file-system/index.d.ts +9 -0
  72. package/dist/file-info/adapters/file-system/index.d.ts.map +1 -0
  73. package/dist/file-info/adapters/file-system/index.js +25 -0
  74. package/dist/file-info/adapters/file-system/reader.d.ts +6 -0
  75. package/dist/file-info/adapters/file-system/reader.d.ts.map +1 -0
  76. package/dist/file-info/{file-system.js → adapters/file-system/reader.js} +16 -0
  77. package/dist/file-info/adapters/github/index.d.ts +11 -0
  78. package/dist/file-info/adapters/github/index.d.ts.map +1 -0
  79. package/dist/file-info/adapters/github/index.js +29 -0
  80. package/dist/file-info/adapters/github/reader.d.ts +16 -0
  81. package/dist/file-info/adapters/github/reader.d.ts.map +1 -0
  82. package/dist/file-info/adapters/github/reader.js +185 -0
  83. package/dist/file-info/index.d.ts +4 -0
  84. package/dist/file-info/index.d.ts.map +1 -0
  85. package/dist/file-info/index.js +10 -0
  86. package/dist/index.d.ts +2 -0
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +6 -1
  89. package/dist/recorder/index.d.ts +7 -3
  90. package/dist/recorder/index.d.ts.map +1 -1
  91. package/dist/recorder/index.js +181 -64
  92. package/dist/recorder/temp-files.d.ts +1 -1
  93. package/dist/recorder/temp-files.d.ts.map +1 -1
  94. package/dist/recorder/temp-files.js +2 -2
  95. package/dist/recorder/upload.d.ts +1 -1
  96. package/dist/recorder/upload.d.ts.map +1 -1
  97. package/dist/recorder/upload.js +3 -3
  98. package/dist/tools/{commit-and-create-pr.d.ts → commit-and-create-pr/index.d.ts} +1 -1
  99. package/dist/tools/commit-and-create-pr/index.d.ts.map +1 -0
  100. package/dist/tools/{commit-and-create-pr.js → commit-and-create-pr/index.js} +8 -28
  101. package/dist/tools/definitions/commit-and-create-pr.d.ts +3 -0
  102. package/dist/tools/definitions/commit-and-create-pr.d.ts.map +1 -0
  103. package/dist/tools/definitions/commit-and-create-pr.js +31 -0
  104. package/dist/tools/definitions/delete-file.d.ts +3 -0
  105. package/dist/tools/definitions/delete-file.d.ts.map +1 -0
  106. package/dist/tools/definitions/delete-file.js +20 -0
  107. package/dist/tools/{download-build.d.ts → definitions/download-build.d.ts} +2 -2
  108. package/dist/tools/definitions/download-build.d.ts.map +1 -0
  109. package/dist/tools/definitions/download-build.js +18 -0
  110. package/dist/tools/definitions/fetch-video-analysis.d.ts +11 -0
  111. package/dist/tools/definitions/fetch-video-analysis.d.ts.map +1 -0
  112. package/dist/tools/definitions/fetch-video-analysis.js +26 -0
  113. package/dist/tools/definitions/grep.d.ts +3 -0
  114. package/dist/tools/definitions/grep.d.ts.map +1 -0
  115. package/dist/tools/definitions/grep.js +29 -0
  116. package/dist/tools/definitions/merge-conflicts.d.ts +3 -0
  117. package/dist/tools/definitions/merge-conflicts.d.ts.map +1 -0
  118. package/dist/tools/definitions/merge-conflicts.js +24 -0
  119. package/dist/tools/definitions/run-test.d.ts +2 -2
  120. package/dist/tools/definitions/run-test.d.ts.map +1 -1
  121. package/dist/tools/definitions/run-test.js +4 -7
  122. package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -1
  123. package/dist/tools/definitions/str_replace_editor.js +9 -5
  124. package/dist/tools/definitions/test-gen-browser.d.ts +5 -5
  125. package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -1
  126. package/dist/tools/definitions/test-gen-browser.js +4 -7
  127. package/dist/tools/definitions/upgrade-packages.d.ts +36 -0
  128. package/dist/tools/definitions/upgrade-packages.d.ts.map +1 -0
  129. package/dist/tools/definitions/upgrade-packages.js +21 -0
  130. package/dist/tools/definitions/utils.d.ts +15 -0
  131. package/dist/tools/definitions/utils.d.ts.map +1 -0
  132. package/dist/tools/definitions/utils.js +16 -0
  133. package/dist/tools/{delete-file.d.ts → delete-file/index.d.ts} +1 -1
  134. package/dist/tools/delete-file/index.d.ts.map +1 -0
  135. package/dist/tools/{delete-file.js → delete-file/index.js} +4 -16
  136. package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
  137. package/dist/tools/diagnosis-fetcher.js +13 -11
  138. package/dist/tools/download-build/index.d.ts +3 -0
  139. package/dist/tools/download-build/index.d.ts.map +1 -0
  140. package/dist/tools/{download-build.js → download-build/index.js} +4 -14
  141. package/dist/tools/executor/index.d.ts.map +1 -1
  142. package/dist/tools/executor/index.js +19 -4
  143. package/dist/tools/executor/utils/git.js +1 -1
  144. package/dist/tools/executor/utils/pr-description.d.ts +1 -1
  145. package/dist/tools/executor/utils/pr-description.d.ts.map +1 -1
  146. package/dist/tools/fetch-image/index.d.ts +10 -1
  147. package/dist/tools/fetch-image/index.d.ts.map +1 -1
  148. package/dist/tools/fetch-image/index.js +1 -0
  149. package/dist/tools/fetch-last-successful-test-run/index.d.ts +3 -0
  150. package/dist/tools/fetch-last-successful-test-run/index.d.ts.map +1 -0
  151. package/dist/tools/fetch-last-successful-test-run/index.js +60 -0
  152. package/dist/tools/fetch-video-analysis/index.d.ts +5 -0
  153. package/dist/tools/fetch-video-analysis/index.d.ts.map +1 -0
  154. package/dist/tools/fetch-video-analysis/index.js +89 -0
  155. package/dist/tools/fetch-video-analysis/local-ffmpeg-client.d.ts +24 -0
  156. package/dist/tools/fetch-video-analysis/local-ffmpeg-client.d.ts.map +1 -0
  157. package/dist/tools/fetch-video-analysis/local-ffmpeg-client.js +209 -0
  158. package/dist/tools/fetch-video-analysis/utils.d.ts +10 -0
  159. package/dist/tools/fetch-video-analysis/utils.d.ts.map +1 -0
  160. package/dist/tools/fetch-video-analysis/utils.js +72 -0
  161. package/dist/tools/fetch-video-analysis/video-analysis.d.ts +7 -0
  162. package/dist/tools/fetch-video-analysis/video-analysis.d.ts.map +1 -0
  163. package/dist/tools/fetch-video-analysis/video-analysis.js +54 -0
  164. package/dist/tools/file-operations/create.d.ts +11 -0
  165. package/dist/tools/file-operations/create.d.ts.map +1 -0
  166. package/dist/tools/file-operations/create.js +60 -0
  167. package/dist/tools/file-operations/index.d.ts +15 -0
  168. package/dist/tools/file-operations/index.d.ts.map +1 -0
  169. package/dist/tools/file-operations/index.js +143 -0
  170. package/dist/tools/file-operations/insert.d.ts +11 -0
  171. package/dist/tools/file-operations/insert.d.ts.map +1 -0
  172. package/dist/tools/file-operations/insert.js +61 -0
  173. package/dist/tools/file-operations/replace.d.ts +11 -0
  174. package/dist/tools/file-operations/replace.d.ts.map +1 -0
  175. package/dist/tools/file-operations/replace.js +80 -0
  176. package/dist/tools/file-operations/shared/git-helper.d.ts +4 -0
  177. package/dist/tools/file-operations/shared/git-helper.d.ts.map +1 -0
  178. package/dist/tools/file-operations/shared/git-helper.js +29 -0
  179. package/dist/tools/file-operations/shared/helpers.d.ts +19 -0
  180. package/dist/tools/file-operations/shared/helpers.d.ts.map +1 -0
  181. package/dist/tools/file-operations/shared/helpers.js +133 -0
  182. package/dist/tools/file-operations/view/index.d.ts +14 -0
  183. package/dist/tools/file-operations/view/index.d.ts.map +1 -0
  184. package/dist/tools/file-operations/view/index.js +56 -0
  185. package/dist/tools/grep/index.d.ts.map +1 -1
  186. package/dist/tools/grep/index.js +2 -9
  187. package/dist/tools/grep/ripgrep/index.d.ts +2 -2
  188. package/dist/tools/grep/ripgrep/index.d.ts.map +1 -1
  189. package/dist/tools/grep/ripgrep/index.js +3 -3
  190. package/dist/tools/grep/types.d.ts.map +1 -0
  191. package/dist/tools/index.d.ts +7 -2
  192. package/dist/tools/index.d.ts.map +1 -1
  193. package/dist/tools/index.js +66 -22
  194. package/dist/tools/issues/create-issue.d.ts +3 -0
  195. package/dist/tools/issues/create-issue.d.ts.map +1 -0
  196. package/dist/tools/issues/create-issue.js +76 -0
  197. package/dist/tools/issues/index.d.ts +4 -0
  198. package/dist/tools/issues/index.d.ts.map +1 -0
  199. package/dist/tools/issues/index.js +9 -0
  200. package/dist/tools/issues/list-issues.d.ts +3 -0
  201. package/dist/tools/issues/list-issues.d.ts.map +1 -0
  202. package/dist/tools/issues/list-issues.js +32 -0
  203. package/dist/tools/issues/metadata-schema.d.ts +24 -0
  204. package/dist/tools/issues/metadata-schema.d.ts.map +1 -0
  205. package/dist/tools/issues/metadata-schema.js +22 -0
  206. package/dist/tools/issues/update-issue.d.ts +3 -0
  207. package/dist/tools/issues/update-issue.d.ts.map +1 -0
  208. package/dist/tools/issues/update-issue.js +75 -0
  209. package/dist/tools/issues/utils.d.ts +5 -0
  210. package/dist/tools/issues/utils.d.ts.map +1 -0
  211. package/dist/tools/issues/utils.js +26 -0
  212. package/dist/tools/list-environments.d.ts.map +1 -1
  213. package/dist/tools/list-environments.js +4 -0
  214. package/dist/tools/{merge-conflicts.d.ts → merge-conflicts/index.d.ts} +1 -1
  215. package/dist/tools/merge-conflicts/index.d.ts.map +1 -0
  216. package/dist/tools/{merge-conflicts.js → merge-conflicts/index.js} +3 -19
  217. package/dist/tools/test-gen-browser.js +4 -4
  218. package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
  219. package/dist/tools/test-run-fetcher/index.js +4 -0
  220. package/dist/tools/trace-dot-zip/index.d.ts +3 -0
  221. package/dist/tools/trace-dot-zip/index.d.ts.map +1 -0
  222. package/dist/tools/trace-dot-zip/index.js +48 -0
  223. package/dist/tools/trace-dot-zip/types.d.ts +86 -0
  224. package/dist/tools/trace-dot-zip/types.d.ts.map +1 -0
  225. package/dist/tools/trace-dot-zip/types.js +2 -0
  226. package/dist/tools/trace-dot-zip/utils/console-trace.d.ts +7 -0
  227. package/dist/tools/trace-dot-zip/utils/console-trace.d.ts.map +1 -0
  228. package/dist/tools/trace-dot-zip/utils/console-trace.js +34 -0
  229. package/dist/tools/trace-dot-zip/utils/extract-zip.d.ts +21 -0
  230. package/dist/tools/trace-dot-zip/utils/extract-zip.d.ts.map +1 -0
  231. package/dist/tools/trace-dot-zip/utils/extract-zip.js +174 -0
  232. package/dist/tools/trace-dot-zip/utils/network-trace.d.ts +21 -0
  233. package/dist/tools/trace-dot-zip/utils/network-trace.d.ts.map +1 -0
  234. package/dist/tools/trace-dot-zip/utils/network-trace.js +189 -0
  235. package/dist/tools/triage-summary/index.d.ts +3 -0
  236. package/dist/tools/triage-summary/index.d.ts.map +1 -0
  237. package/dist/tools/triage-summary/index.js +51 -0
  238. package/dist/tools/triage-summary/types.d.ts +5 -0
  239. package/dist/tools/triage-summary/types.d.ts.map +1 -0
  240. package/dist/tools/triage-summary/types.js +2 -0
  241. package/dist/tools/triage-summary/utils.d.ts +4 -0
  242. package/dist/tools/triage-summary/utils.d.ts.map +1 -0
  243. package/dist/tools/triage-summary/utils.js +16 -0
  244. package/dist/tools/upgrade-packages/index.d.ts.map +1 -1
  245. package/dist/tools/upgrade-packages/index.js +5 -15
  246. package/dist/tools/view-failed-test-run-report/index.d.ts +12 -0
  247. package/dist/tools/view-failed-test-run-report/index.d.ts.map +1 -0
  248. package/dist/tools/view-failed-test-run-report/index.js +163 -0
  249. package/dist/trace-utils/index.d.ts +4 -0
  250. package/dist/trace-utils/index.d.ts.map +1 -0
  251. package/dist/trace-utils/index.js +10 -0
  252. package/dist/utils/dedup-image-fs.d.ts +27 -0
  253. package/dist/utils/dedup-image-fs.d.ts.map +1 -0
  254. package/dist/utils/dedup-image-fs.js +88 -0
  255. package/dist/utils/dedup-image.d.ts +25 -0
  256. package/dist/utils/dedup-image.d.ts.map +1 -0
  257. package/dist/utils/dedup-image.js +80 -0
  258. package/dist/utils/env.d.ts.map +1 -1
  259. package/dist/utils/env.js +0 -1
  260. package/dist/utils/json.js +1 -1
  261. package/dist/utils/model.d.ts +3 -0
  262. package/dist/utils/model.d.ts.map +1 -0
  263. package/dist/utils/model.js +18 -0
  264. package/dist/utils/playwright-report-parser.d.ts +13 -0
  265. package/dist/utils/playwright-report-parser.d.ts.map +1 -0
  266. package/dist/utils/playwright-report-parser.js +138 -0
  267. package/dist/utils/slug.d.ts +1 -0
  268. package/dist/utils/slug.d.ts.map +1 -1
  269. package/dist/utils/slug.js +9 -1
  270. package/dist/utils/stripAnsi.d.ts.map +1 -1
  271. package/dist/utils/stripAnsi.js +1 -3
  272. package/eslint.config.mjs +43 -0
  273. package/package.json +22 -6
  274. package/tsconfig.tsbuildinfo +1 -1
  275. package/dist/agent/codegen/generate-code-apply-changes.d.ts +0 -13
  276. package/dist/agent/codegen/generate-code-apply-changes.d.ts.map +0 -1
  277. package/dist/agent/codegen/generate-code-apply-changes.js +0 -379
  278. package/dist/agent/codegen/repo-edit.d.ts +0 -23
  279. package/dist/agent/codegen/repo-edit.d.ts.map +0 -1
  280. package/dist/agent/codegen/repo-edit.js +0 -81
  281. package/dist/agent/codegen/run.d.ts +0 -20
  282. package/dist/agent/codegen/run.d.ts.map +0 -1
  283. package/dist/agent/codegen/run.js +0 -116
  284. package/dist/agent/enrich-prompt/index.d.ts +0 -12
  285. package/dist/agent/enrich-prompt/index.d.ts.map +0 -1
  286. package/dist/agent/enrich-prompt/index.js +0 -80
  287. package/dist/agent/enrich-prompt/utils.d.ts +0 -6
  288. package/dist/agent/enrich-prompt/utils.d.ts.map +0 -1
  289. package/dist/agent/enrich-prompt/utils.js +0 -11
  290. package/dist/agent/infer-agent/index.d.ts +0 -10
  291. package/dist/agent/infer-agent/index.d.ts.map +0 -1
  292. package/dist/agent/infer-agent/index.js +0 -60
  293. package/dist/evals/add-scenario-agent.evals.d.ts +0 -4
  294. package/dist/evals/add-scenario-agent.evals.d.ts.map +0 -1
  295. package/dist/evals/add-scenario-agent.evals.js +0 -44
  296. package/dist/evals/infer-master-or-code-agent.evals.d.ts +0 -4
  297. package/dist/evals/infer-master-or-code-agent.evals.d.ts.map +0 -1
  298. package/dist/evals/infer-master-or-code-agent.evals.js +0 -22
  299. package/dist/file-info/file-system.d.ts +0 -3
  300. package/dist/file-info/file-system.d.ts.map +0 -1
  301. package/dist/file-info/github.d.ts +0 -3
  302. package/dist/file-info/github.d.ts.map +0 -1
  303. package/dist/file-info/github.js +0 -107
  304. package/dist/tools/commit-and-create-pr.d.ts.map +0 -1
  305. package/dist/tools/delete-file.d.ts.map +0 -1
  306. package/dist/tools/download-build.d.ts.map +0 -1
  307. package/dist/tools/grep/ripgrep/types.d.ts.map +0 -1
  308. package/dist/tools/merge-conflicts.d.ts.map +0 -1
  309. package/dist/tools/str_replace_editor.d.ts +0 -22
  310. package/dist/tools/str_replace_editor.d.ts.map +0 -1
  311. package/dist/tools/str_replace_editor.js +0 -429
  312. /package/dist/tools/grep/{ripgrep/types.d.ts → types.d.ts} +0 -0
  313. /package/dist/tools/grep/{ripgrep/types.js → types.js} +0 -0
@@ -0,0 +1,86 @@
1
+ export type CapturedNetworkFailure = {
2
+ endpoint: string;
3
+ status: number;
4
+ timestamp: string;
5
+ distanceFromFailureInMilliseconds: number;
6
+ method: string;
7
+ request: {
8
+ headers: {
9
+ [any: string]: string;
10
+ }[] | [];
11
+ };
12
+ response: {
13
+ headers: {
14
+ [any: string]: string;
15
+ }[] | [];
16
+ };
17
+ };
18
+ export type CapturedConsoleLog = {
19
+ type: "console";
20
+ messageType: "log" | "info" | "warning" | "error" | string;
21
+ text: string;
22
+ args: any[];
23
+ location: {
24
+ url: string;
25
+ lineNumber: number;
26
+ columnNumber: number;
27
+ };
28
+ time: number;
29
+ pageId: string;
30
+ };
31
+ export type PlaywrightNetworkTrace = {
32
+ type: string;
33
+ snapshot: {
34
+ _frameref: string;
35
+ _monotonicTime: number;
36
+ startedDateTime: string;
37
+ time: number;
38
+ request: {
39
+ method: string;
40
+ url: string;
41
+ httpVersion: string;
42
+ cookies: any[];
43
+ headers: any[];
44
+ queryString: any[];
45
+ headersSize: number;
46
+ bodySize: number;
47
+ postData: {
48
+ mimeType: string;
49
+ text: string;
50
+ params: any[];
51
+ _sha1: string;
52
+ };
53
+ };
54
+ response: {
55
+ status: number;
56
+ statusText: string;
57
+ httpVersion: string;
58
+ cookies: any[];
59
+ headers: any[];
60
+ headersSize: number;
61
+ bodySize: number;
62
+ redirectURL: string;
63
+ _transferSize: number;
64
+ };
65
+ cache: any;
66
+ timings: {
67
+ dns: number;
68
+ connect: number;
69
+ ssl: number;
70
+ send: number;
71
+ wait: number;
72
+ receive: number;
73
+ };
74
+ pageref: string;
75
+ serverIPAddress: string;
76
+ _serverPort: number;
77
+ _securityDetails: {
78
+ protocol: string;
79
+ subjectName: string;
80
+ issuer: string;
81
+ validFrom: number;
82
+ validTo: number;
83
+ };
84
+ };
85
+ };
86
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/trace-dot-zip/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC,EAAE,MAAM,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE;QACP,OAAO,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,EAAE,GAAG,EAAE,CAAC;KAC3C,CAAC;IACF,QAAQ,EAAE;QACR,OAAO,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,EAAE,GAAG,EAAE,CAAC;KAC3C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE;YACP,MAAM,EAAE,MAAM,CAAC;YACf,GAAG,EAAE,MAAM,CAAC;YACZ,WAAW,EAAE,MAAM,CAAC;YACpB,OAAO,EAAE,GAAG,EAAE,CAAC;YACf,OAAO,EAAE,GAAG,EAAE,CAAC;YACf,WAAW,EAAE,GAAG,EAAE,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC;YACjB,QAAQ,EAAE;gBACR,QAAQ,EAAE,MAAM,CAAC;gBACjB,IAAI,EAAE,MAAM,CAAC;gBACb,MAAM,EAAE,GAAG,EAAE,CAAC;gBACd,KAAK,EAAE,MAAM,CAAC;aACf,CAAC;SACH,CAAC;QACF,QAAQ,EAAE;YACR,MAAM,EAAE,MAAM,CAAC;YACf,UAAU,EAAE,MAAM,CAAC;YACnB,WAAW,EAAE,MAAM,CAAC;YACpB,OAAO,EAAE,GAAG,EAAE,CAAC;YACf,OAAO,EAAE,GAAG,EAAE,CAAC;YACf,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC;YACjB,WAAW,EAAE,MAAM,CAAC;YACpB,aAAa,EAAE,MAAM,CAAC;SACvB,CAAC;QACF,KAAK,EAAE,GAAG,CAAC;QACX,OAAO,EAAE;YACP,GAAG,EAAE,MAAM,CAAC;YACZ,OAAO,EAAE,MAAM,CAAC;YAChB,GAAG,EAAE,MAAM,CAAC;YACZ,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;QACF,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE;YAChB,QAAQ,EAAE,MAAM,CAAC;YACjB,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,EAAE,MAAM,CAAC;YACf,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,CAAC;CACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { CapturedConsoleLog } from "../types";
2
+ type ArgsT = {
3
+ url: string;
4
+ };
5
+ export declare const generateConsoleTraceFromZipUrl: ({ url, }: ArgsT) => Promise<CapturedConsoleLog[]>;
6
+ export {};
7
+ //# sourceMappingURL=console-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-trace.d.ts","sourceRoot":"","sources":["../../../../src/tools/trace-dot-zip/utils/console-trace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9C,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,8BAA8B,GAAU,UAElD,KAAK,KAAG,OAAO,CAAC,kBAAkB,EAAE,CA2BtC,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateConsoleTraceFromZipUrl = void 0;
4
+ const extract_zip_1 = require("./extract-zip");
5
+ const TRACE_FILE_NAME = "0-trace.trace";
6
+ const generateConsoleTraceFromZipUrl = async ({ url, }) => {
7
+ try {
8
+ const consoleErrors = [];
9
+ await (0, extract_zip_1.extractFileFromZipFromUrl)({
10
+ zipUrl: url,
11
+ fileNames: [TRACE_FILE_NAME],
12
+ chunkProcessor: () => {
13
+ let tempBuffer = "";
14
+ return (chunk) => {
15
+ tempBuffer += chunk;
16
+ let lines = tempBuffer.split("\n");
17
+ lines.slice(0, -1).forEach((line) => {
18
+ const parsed = JSON.parse(line);
19
+ if (parsed?.type === "console" && parsed?.messageType === "error") {
20
+ consoleErrors.push(parsed);
21
+ }
22
+ });
23
+ tempBuffer = lines[lines.length - 1] || "";
24
+ };
25
+ },
26
+ });
27
+ return consoleErrors;
28
+ }
29
+ catch (error) {
30
+ console.error(`Error fetching or processing the zip file: ${url}`, error);
31
+ }
32
+ return [];
33
+ };
34
+ exports.generateConsoleTraceFromZipUrl = generateConsoleTraceFromZipUrl;
@@ -0,0 +1,21 @@
1
+ import { Buffer } from "buffer";
2
+ export declare const extractFileFromZipFromUrl: ({ zipUrl, fileNames, chunkProcessor, withCache, }: {
3
+ zipUrl: string;
4
+ fileNames: string[];
5
+ chunkProcessor: (breakAndResolve: () => void, currentFileGettingProcessed: string) => (chunk: Buffer) => void;
6
+ withCache?: boolean;
7
+ }) => Promise<void>;
8
+ /**
9
+ * Returns a list of file names contained in a zip file located at `zipUrl`.
10
+ *
11
+ * @param zipUrl - The URL or file path (file://...) of the zip file.
12
+ * @param options.withCache - Whether to use cached fetch logic (if available).
13
+ * @param options.recursive - If `false`, only return top-level files (files with no slash).
14
+ * If `true`, return all files in any subdirectory.
15
+ * @returns An array of file names in the ZIP.
16
+ */
17
+ export declare function getFilenamesInZip(zipUrl: string, { withCache, recursive, }?: {
18
+ withCache?: boolean;
19
+ recursive?: boolean;
20
+ }): Promise<string[]>;
21
+ //# sourceMappingURL=extract-zip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-zip.d.ts","sourceRoot":"","sources":["../../../../src/tools/trace-dot-zip/utils/extract-zip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AA0FhC,eAAO,MAAM,yBAAyB,GAAU,mDAK7C;IACD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,CACd,eAAe,EAAE,MAAM,IAAI,EAC3B,2BAA2B,EAAE,MAAM,KAChC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,KAAG,OAAO,CAAC,IAAI,CAuEf,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,EACE,SAAiB,EACjB,SAAgB,GACjB,GAAE;IACD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CAChB,GACL,OAAO,CAAC,MAAM,EAAE,CAAC,CAoCnB"}
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractFileFromZipFromUrl = void 0;
7
+ exports.getFilenamesInZip = getFilenamesInZip;
8
+ const buffer_1 = require("buffer");
9
+ const fs_1 = require("fs");
10
+ const stream_1 = require("stream");
11
+ const util_1 = require("util");
12
+ const yauzl_1 = __importDefault(require("yauzl"));
13
+ const fromBuffer = (0, util_1.promisify)(yauzl_1.default.fromBuffer);
14
+ const convertToNodeReadableStream = (webReadableStream) => {
15
+ const nodeReadableStream = new stream_1.Readable({
16
+ read() { },
17
+ });
18
+ const reader = webReadableStream.getReader();
19
+ void (async function readStream() {
20
+ try {
21
+ while (true) {
22
+ const { done, value } = await reader.read();
23
+ if (done) {
24
+ nodeReadableStream.push(null);
25
+ break;
26
+ }
27
+ nodeReadableStream.push(value);
28
+ }
29
+ }
30
+ catch (error) {
31
+ nodeReadableStream.destroy(error);
32
+ }
33
+ })();
34
+ return nodeReadableStream;
35
+ };
36
+ async function streamToBuffer(webStream) {
37
+ const chunks = [];
38
+ return new Promise((resolve, reject) => {
39
+ const nodeStream = convertToNodeReadableStream(webStream);
40
+ nodeStream.on("data", (chunk) => chunks.push(chunk));
41
+ nodeStream.on("end", () => resolve(buffer_1.Buffer.concat(chunks)));
42
+ nodeStream.on("error", reject);
43
+ });
44
+ }
45
+ const cache = {};
46
+ const cachedFetch = async (url) => {
47
+ if (url in cache) {
48
+ return cache[url];
49
+ }
50
+ const response = await fetch(url);
51
+ if (!response.ok) {
52
+ throw new Error(`HTTP error! Status: ${response.status}`);
53
+ }
54
+ // Convert the stream to a buffer
55
+ const buffer = await streamToBuffer(response.body);
56
+ cache[url] = buffer;
57
+ return buffer;
58
+ };
59
+ /**
60
+ * Fetches or reads a zip file from URL or file path, then returns a Buffer.
61
+ */
62
+ async function getZipBuffer(zipUrl, withCache) {
63
+ if (zipUrl.startsWith("file://")) {
64
+ const filePath = zipUrl.replace(/^file:\/\//, "");
65
+ return fs_1.promises.readFile(filePath);
66
+ }
67
+ else if (withCache) {
68
+ return await cachedFetch(zipUrl);
69
+ }
70
+ else {
71
+ const response = await fetch(zipUrl);
72
+ if (!response.ok) {
73
+ throw new Error(`HTTP error! Status: ${response.status}`);
74
+ }
75
+ return streamToBuffer(response.body);
76
+ }
77
+ }
78
+ const extractFileFromZipFromUrl = async ({ zipUrl, fileNames, chunkProcessor, withCache, }) => {
79
+ try {
80
+ const buffer = await getZipBuffer(zipUrl, withCache);
81
+ // Ensure buffer is not empty
82
+ if (buffer.length === 0) {
83
+ throw new Error("Empty buffer received.");
84
+ }
85
+ // Process the zip file from the buffer
86
+ const zipfile = await fromBuffer(buffer, { lazyEntries: true });
87
+ const fileProcessingPromises = [];
88
+ // Use promises for entry reading
89
+ await new Promise((resolve) => {
90
+ zipfile.on("entry", (entry) => {
91
+ if (fileNames.includes(entry.fileName)) {
92
+ const filePromise = new Promise((fileResolve) => {
93
+ zipfile.openReadStream(entry, (err, readStream) => {
94
+ if (err) {
95
+ console.error(`error reading file - ${entry.fileName}`, err);
96
+ fileResolve();
97
+ return;
98
+ }
99
+ const done = () => {
100
+ fileResolve();
101
+ };
102
+ const processChunk = chunkProcessor(done, entry.fileName);
103
+ readStream.on("data", processChunk);
104
+ readStream.on("end", () => {
105
+ fileResolve();
106
+ });
107
+ readStream.on("error", (error) => {
108
+ console.error(`error reading file - ${entry.fileName}`, error);
109
+ fileResolve();
110
+ });
111
+ });
112
+ });
113
+ // Push each file's promise to the array
114
+ fileProcessingPromises.push(filePromise);
115
+ }
116
+ zipfile.readEntry();
117
+ });
118
+ zipfile.on("end", () => {
119
+ resolve();
120
+ });
121
+ zipfile.on("error", (error) => {
122
+ console.error(`Error reading entry`, error);
123
+ resolve();
124
+ });
125
+ zipfile.readEntry();
126
+ });
127
+ await Promise.all(fileProcessingPromises);
128
+ }
129
+ catch (error) {
130
+ console.error(`Error fetching or processing the zip file url - "${zipUrl}"`, error);
131
+ }
132
+ };
133
+ exports.extractFileFromZipFromUrl = extractFileFromZipFromUrl;
134
+ /**
135
+ * Returns a list of file names contained in a zip file located at `zipUrl`.
136
+ *
137
+ * @param zipUrl - The URL or file path (file://...) of the zip file.
138
+ * @param options.withCache - Whether to use cached fetch logic (if available).
139
+ * @param options.recursive - If `false`, only return top-level files (files with no slash).
140
+ * If `true`, return all files in any subdirectory.
141
+ * @returns An array of file names in the ZIP.
142
+ */
143
+ async function getFilenamesInZip(zipUrl, { withCache = false, recursive = true, } = {}) {
144
+ // 1. Get the zip contents as a Buffer
145
+ const buffer = await getZipBuffer(zipUrl, withCache);
146
+ // 2. Parse the zip file with yauzl
147
+ const zipfile = await fromBuffer(buffer, { lazyEntries: true });
148
+ const fileNames = [];
149
+ await new Promise((resolve, reject) => {
150
+ zipfile.on("entry", (entry) => {
151
+ // Identify directories by trailing slash
152
+ const isDirectory = entry.fileName.endsWith("/");
153
+ // We don't list directories, only files
154
+ if (!isDirectory) {
155
+ if (recursive) {
156
+ // Include all files
157
+ fileNames.push(entry.fileName);
158
+ }
159
+ else {
160
+ // Only include top-level files (no slash in the path)
161
+ if (!entry.fileName.includes("/")) {
162
+ fileNames.push(entry.fileName);
163
+ }
164
+ }
165
+ }
166
+ // Proceed to the next entry
167
+ zipfile.readEntry();
168
+ });
169
+ zipfile.on("error", (err) => reject(err));
170
+ zipfile.on("end", () => resolve());
171
+ zipfile.readEntry();
172
+ });
173
+ return fileNames;
174
+ }
@@ -0,0 +1,21 @@
1
+ import { CapturedNetworkFailure } from "../types";
2
+ type ArgsT = {
3
+ url: string;
4
+ logPrefix?: string;
5
+ failure?: {
6
+ startTime?: string;
7
+ location: {
8
+ file: string;
9
+ line: number;
10
+ column: number;
11
+ } | undefined;
12
+ };
13
+ };
14
+ export declare const generateNetworkTrace: ({ logPrefix, url, failure, }: ArgsT) => Promise<{
15
+ allFailedCalls: CapturedNetworkFailure[];
16
+ failedCallsWithinTimeRange: CapturedNetworkFailure[];
17
+ }>;
18
+ export declare const generateNetworkTraceFromZipUrl: ({ url, }: ArgsT) => Promise<CapturedNetworkFailure[]>;
19
+ export declare const stripIrrelevantInfoFromNetworkFailureArray: (failures: CapturedNetworkFailure[]) => Partial<CapturedNetworkFailure>[];
20
+ export {};
21
+ //# sourceMappingURL=network-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-trace.d.ts","sourceRoot":"","sources":["../../../../src/tools/trace-dot-zip/utils/network-trace.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,sBAAsB,EAA0B,MAAM,UAAU,CAAC;AAU1E,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,EACJ;YACE,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;SAChB,GACD,SAAS,CAAC;KACf,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,8BAIxC,KAAK,KAAG,OAAO,CAAC;IACjB,cAAc,EAAE,sBAAsB,EAAE,CAAC;IACzC,0BAA0B,EAAE,sBAAsB,EAAE,CAAC;CACtD,CA8KA,CAAC;AAEF,eAAO,MAAM,8BAA8B,GAAU,UAElD,KAAK,KAAG,OAAO,CAAC,sBAAsB,EAAE,CAmC1C,CAAC;AAoBF,eAAO,MAAM,0CAA0C,GACrD,UAAU,sBAAsB,EAAE,KACjC,OAAO,CAAC,sBAAsB,CAAC,EAUjC,CAAC"}
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stripIrrelevantInfoFromNetworkFailureArray = exports.generateNetworkTraceFromZipUrl = exports.generateNetworkTrace = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ const extract_zip_1 = require("./extract-zip");
6
+ const NON_RELEVANT_NETWORK_CALL_KEYWORDS = [
7
+ "sentry",
8
+ "intercom",
9
+ "clarity.ms",
10
+ "nr-data.net",
11
+ ];
12
+ const generateNetworkTrace = async ({ logPrefix = "network-trace", url, failure, }) => {
13
+ let networkFailures = {
14
+ allFailedCalls: [],
15
+ failedCallsWithinTimeRange: [],
16
+ };
17
+ // first check the test.trace file
18
+ // and find the exact timestamp when our test failed
19
+ // then we will look in the 0-trace.network file
20
+ // to find the network calls that happened before and after the test failure
21
+ try {
22
+ let failedTestStatementTimeOffset; // in milliseconds
23
+ if (!url) {
24
+ throw new Error(`${logPrefix}: no trace file found for testRunId`);
25
+ }
26
+ await (0, extract_zip_1.extractFileFromZipFromUrl)({
27
+ zipUrl: url,
28
+ fileNames: ["test.trace"],
29
+ chunkProcessor: (breakAndResolve) => {
30
+ let tempBuffer = "";
31
+ let initialOffset;
32
+ return (chunk) => {
33
+ tempBuffer += chunk;
34
+ let lines = tempBuffer.split("\n");
35
+ lines.slice(0, -1).forEach((line) => {
36
+ const parsedTestTrace = JSON.parse(line);
37
+ if (!initialOffset && parsedTestTrace.startTime) {
38
+ initialOffset = parsedTestTrace.startTime;
39
+ }
40
+ if (parsedTestTrace.type === "before" &&
41
+ parsedTestTrace.stack.find((errorStack) => {
42
+ return (errorStack?.file === failure?.location?.file &&
43
+ errorStack?.column === failure?.location?.column &&
44
+ errorStack?.line === failure?.location?.line);
45
+ })) {
46
+ failedTestStatementTimeOffset =
47
+ parsedTestTrace.startTime - initialOffset;
48
+ breakAndResolve();
49
+ }
50
+ });
51
+ tempBuffer = lines[lines.length - 1] || "";
52
+ };
53
+ },
54
+ });
55
+ const failedCalls = [];
56
+ await (0, extract_zip_1.extractFileFromZipFromUrl)({
57
+ zipUrl: url,
58
+ fileNames: ["0-trace.network"],
59
+ chunkProcessor: () => {
60
+ let tempBuffer = "";
61
+ return (chunk) => {
62
+ tempBuffer += chunk;
63
+ let lines = tempBuffer.split("\n");
64
+ lines.slice(0, -1).forEach((line) => {
65
+ const parsedNetworkTrace = JSON.parse(line);
66
+ const responseStatus = parsedNetworkTrace?.snapshot?.response?.status;
67
+ // const networkTriggerTime =
68
+ // parsedNetworkTrace?.snapshot?.startedDateTime;
69
+ if (400 <= responseStatus && responseStatus < 600) {
70
+ failedCalls.push(parsedNetworkTrace);
71
+ }
72
+ });
73
+ tempBuffer = lines[lines.length - 1] || "";
74
+ };
75
+ },
76
+ });
77
+ const failedTestStatementTimestamp = (0, date_fns_1.addMilliseconds)(new Date(failure?.startTime), failedTestStatementTimeOffset);
78
+ const lowerWindow = 3; // 3 seconds
79
+ const upperWindow = 2; // 2 seconds
80
+ const networkFailureLowerWindow = (0, date_fns_1.subSeconds)(new Date(failedTestStatementTimestamp), lowerWindow);
81
+ const networkFailureUpperWindow = (0, date_fns_1.addSeconds)(new Date(failedTestStatementTimestamp), upperWindow);
82
+ const { allFailedCalls, failedCallsWithinTimeRange } = failedCalls.reduce((acc, call) => {
83
+ const url = call?.snapshot?.request?.url ?? "";
84
+ if (NON_RELEVANT_NETWORK_CALL_KEYWORDS.some((keyword) => url.includes(keyword))) {
85
+ return acc;
86
+ }
87
+ const networkTriggerTime = call?.snapshot?.startedDateTime;
88
+ const isWithin = (0, date_fns_1.isWithinInterval)(networkTriggerTime, {
89
+ start: networkFailureLowerWindow,
90
+ end: networkFailureUpperWindow,
91
+ });
92
+ const formattedCall = {
93
+ endpoint: call?.snapshot?.request?.url,
94
+ status: call?.snapshot?.response?.status,
95
+ timestamp: new Date(call?.snapshot?.startedDateTime).toUTCString(),
96
+ distanceFromFailureInMilliseconds: (0, date_fns_1.differenceInMilliseconds)(networkTriggerTime, failedTestStatementTimestamp),
97
+ method: call?.snapshot?.request?.method,
98
+ request: {
99
+ headers: call?.snapshot?.request?.headers ?? [],
100
+ },
101
+ response: {
102
+ headers: call?.snapshot?.response?.headers ?? [],
103
+ },
104
+ };
105
+ acc.allFailedCalls.push(formattedCall);
106
+ if (isWithin) {
107
+ acc.failedCallsWithinTimeRange.push(formattedCall);
108
+ }
109
+ return acc;
110
+ }, { allFailedCalls: [], failedCallsWithinTimeRange: [] });
111
+ const uniqueCallEntries = new Set();
112
+ const uniqueFailedCalls = [];
113
+ failedCallsWithinTimeRange.forEach((call) => {
114
+ const key = `${call.endpoint}|${call.status}`;
115
+ if (!uniqueCallEntries.has(key)) {
116
+ uniqueCallEntries.add(key);
117
+ uniqueFailedCalls.push(call);
118
+ }
119
+ });
120
+ return {
121
+ allFailedCalls,
122
+ failedCallsWithinTimeRange: uniqueFailedCalls,
123
+ };
124
+ }
125
+ catch (error) {
126
+ console.error(`${logPrefix}: Error fetching or processing the zip file: ${url}`, error);
127
+ }
128
+ return networkFailures;
129
+ };
130
+ exports.generateNetworkTrace = generateNetworkTrace;
131
+ const generateNetworkTraceFromZipUrl = async ({ url, }) => {
132
+ try {
133
+ const failedCalls = [];
134
+ await (0, extract_zip_1.extractFileFromZipFromUrl)({
135
+ zipUrl: url,
136
+ fileNames: ["0-trace.network"],
137
+ chunkProcessor: () => {
138
+ let tempBuffer = "";
139
+ return (chunk) => {
140
+ tempBuffer += chunk;
141
+ let lines = tempBuffer.split("\n");
142
+ lines.slice(0, -1).forEach((line) => {
143
+ const parsedNetworkTrace = JSON.parse(line);
144
+ const responseStatus = parsedNetworkTrace?.snapshot?.response?.status;
145
+ // const networkTriggerTime =
146
+ // parsedNetworkTrace?.snapshot?.startedDateTime;
147
+ if (400 <= responseStatus && responseStatus < 600) {
148
+ failedCalls.push(parsedNetworkTrace);
149
+ }
150
+ });
151
+ tempBuffer = lines[lines.length - 1] || "";
152
+ };
153
+ },
154
+ });
155
+ return failedCalls.map(formatNetworkFailure);
156
+ }
157
+ catch (error) {
158
+ console.error(`Error fetching or processing the zip file: ${url}`, error);
159
+ }
160
+ return [];
161
+ };
162
+ exports.generateNetworkTraceFromZipUrl = generateNetworkTraceFromZipUrl;
163
+ const formatNetworkFailure = (call) => {
164
+ return {
165
+ endpoint: call?.snapshot?.request?.url,
166
+ status: call?.snapshot?.response?.status,
167
+ timestamp: new Date(call?.snapshot?.startedDateTime).toUTCString(),
168
+ distanceFromFailureInMilliseconds: 0,
169
+ method: call?.snapshot?.request?.method,
170
+ request: {
171
+ headers: call?.snapshot?.request?.headers ?? [],
172
+ },
173
+ response: {
174
+ headers: call?.snapshot?.response?.headers ?? [],
175
+ },
176
+ };
177
+ };
178
+ const stripIrrelevantInfoFromNetworkFailureArray = (failures) => {
179
+ return failures.map(({ endpoint, status, timestamp, method }) => {
180
+ const strippedFailureInfo = {
181
+ endpoint,
182
+ status,
183
+ timestamp,
184
+ method,
185
+ };
186
+ return strippedFailureInfo;
187
+ });
188
+ };
189
+ exports.stripIrrelevantInfoFromNetworkFailureArray = stripIrrelevantInfoFromNetworkFailureArray;
@@ -0,0 +1,3 @@
1
+ import { Tool } from "@empiricalrun/shared-types";
2
+ export declare const sendTriageSummaryTool: Tool;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/triage-summary/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAmB9D,eAAO,MAAM,qBAAqB,EAAE,IA6CnC,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendTriageSummaryTool = void 0;
4
+ const zod_1 = require("zod");
5
+ const utils_1 = require("./utils");
6
+ const TriageSummaryInputSchema = zod_1.z.object({
7
+ issues: zod_1.z
8
+ .array(zod_1.z.object({
9
+ id: zod_1.z.number(),
10
+ action: zod_1.z.enum(["created", "updated"]),
11
+ }))
12
+ .describe("A list of issues which were created or updated during a triage session. The 'action' field is either 'created' or 'updated'."),
13
+ });
14
+ exports.sendTriageSummaryTool = {
15
+ schema: {
16
+ name: "sendTriageSummary",
17
+ description: `This tool must be called upon completion of a triage session. It sends a slack update on the summary of the work done in a triage session to users, specifically which issues were creted or updated in that triage session`,
18
+ parameters: TriageSummaryInputSchema,
19
+ },
20
+ needsBrowser: false,
21
+ isInlineTool: true,
22
+ execute: async ({ input, apiClient, chatSession }) => {
23
+ try {
24
+ const triagedIssuesList = input.issues;
25
+ if (!triagedIssuesList) {
26
+ return {
27
+ isError: true,
28
+ result: "Issues not found",
29
+ };
30
+ }
31
+ if (!apiClient) {
32
+ throw new Error("Dashboard API client is not available.");
33
+ }
34
+ if (!chatSession?.id) {
35
+ throw new Error("Chat session ID is not available.");
36
+ }
37
+ const data = await (0, utils_1.triggerSlackMessageWithTriageSummary)(triagedIssuesList, apiClient, chatSession.id);
38
+ return {
39
+ isError: false,
40
+ result: data,
41
+ };
42
+ }
43
+ catch (error) {
44
+ console.error("Error sending triage summary to slack", error);
45
+ return {
46
+ isError: true,
47
+ result: error instanceof Error ? error.message : String(error),
48
+ };
49
+ }
50
+ },
51
+ };
@@ -0,0 +1,5 @@
1
+ export interface TriagedIssue {
2
+ id: number;
3
+ action: "created" | "updated";
4
+ }
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/triage-summary/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { IDashboardAPIClient } from "@empiricalrun/shared-types";
2
+ import { TriagedIssue } from "./types";
3
+ export declare const triggerSlackMessageWithTriageSummary: (issues: TriagedIssue[], apiClient: IDashboardAPIClient, chatSessionId: number) => Promise<string>;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/triage-summary/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,eAAO,MAAM,oCAAoC,GAC/C,QAAQ,YAAY,EAAE,EACtB,WAAW,mBAAmB,EAC9B,eAAe,MAAM,KACpB,OAAO,CAAC,MAAM,CAahB,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.triggerSlackMessageWithTriageSummary = void 0;
4
+ const triggerSlackMessageWithTriageSummary = async (issues, apiClient, chatSessionId) => {
5
+ if (!issues.length)
6
+ return "message not sent as no issues were created/updated";
7
+ const response = await apiClient.request("/api/slack/triage-summary", {
8
+ method: "POST",
9
+ body: {
10
+ chat_session_id: chatSessionId,
11
+ issues: issues,
12
+ },
13
+ });
14
+ return `Triage summary sent to Slack successfully. Response: ${JSON.stringify(response)}`;
15
+ };
16
+ exports.triggerSlackMessageWithTriageSummary = triggerSlackMessageWithTriageSummary;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/upgrade-packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAyBvD,eAAO,MAAM,mBAAmB,EAAE,IA2HjC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/upgrade-packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAoBvD,eAAO,MAAM,mBAAmB,EAAE,IAyHjC,CAAC"}