@empiricalrun/test-gen 0.79.3 → 0.79.4

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 (117) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/agent/chat/index.d.ts.map +1 -1
  3. package/dist/agent/chat/index.js +21 -2
  4. package/dist/agent/chat/prompt/pw-utils-docs.d.ts +1 -1
  5. package/dist/agent/chat/prompt/pw-utils-docs.d.ts.map +1 -1
  6. package/dist/agent/chat/prompt/pw-utils-docs.js +1 -1
  7. package/dist/agent/chat/prompt/trace-utils-docs.d.ts +2 -0
  8. package/dist/agent/chat/prompt/trace-utils-docs.d.ts.map +1 -0
  9. package/dist/agent/chat/prompt/trace-utils-docs.js +208 -0
  10. package/dist/agent/code-review/index.d.ts +1 -1
  11. package/dist/agent/code-review/index.d.ts.map +1 -1
  12. package/dist/agent/code-review/index.js +4 -4
  13. package/dist/agent/code-review/{parser.d.ts → xml-parser.d.ts} +1 -1
  14. package/dist/agent/code-review/xml-parser.d.ts.map +1 -0
  15. package/dist/agent/code-review/{parser.js → xml-parser.js} +1 -1
  16. package/dist/agent/fast-triage/index.d.ts.map +1 -1
  17. package/dist/agent/fast-triage/index.js +31 -3
  18. package/dist/agent/master/element-annotation.d.ts.map +1 -1
  19. package/dist/agent/master/element-annotation.js +2 -19
  20. package/dist/bin/index.js +0 -2
  21. package/dist/constants/index.d.ts +1 -1
  22. package/dist/constants/index.js +1 -1
  23. package/dist/dashboard/client.d.ts +5 -0
  24. package/dist/dashboard/client.d.ts.map +1 -1
  25. package/dist/dashboard/client.js +11 -0
  26. package/dist/dashboard/index.d.ts +1 -0
  27. package/dist/dashboard/index.d.ts.map +1 -1
  28. package/dist/dashboard/index.js +4 -1
  29. package/dist/dashboard/tool-response-from-sandbox.d.ts +5 -0
  30. package/dist/dashboard/tool-response-from-sandbox.d.ts.map +1 -0
  31. package/dist/dashboard/tool-response-from-sandbox.js +40 -0
  32. package/dist/dashboard/tool-response.d.ts +1 -0
  33. package/dist/dashboard/tool-response.d.ts.map +1 -1
  34. package/dist/dashboard/tool-response.js +1 -0
  35. package/dist/file-info/adapters/github/reader.d.ts.map +1 -1
  36. package/dist/file-info/adapters/github/reader.js +9 -3
  37. package/dist/generate-summary/generate-error-stack-summary.js +1 -4
  38. package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.d.ts.map +1 -1
  39. package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.js +8 -8
  40. package/dist/generate-summary/generate-grouped-summary.js +1 -4
  41. package/dist/generate-summary/merge-summary.js +1 -4
  42. package/dist/telemetry/index.d.ts +3 -3
  43. package/dist/telemetry/index.d.ts.map +1 -1
  44. package/dist/telemetry/index.js +8 -5
  45. package/dist/tools/analyse-video/index.js +1 -1
  46. package/dist/tools/definitions/publish-markdown-report.d.ts +8 -0
  47. package/dist/tools/definitions/publish-markdown-report.d.ts.map +1 -0
  48. package/dist/tools/definitions/publish-markdown-report.js +29 -0
  49. package/dist/tools/diagnosis-fetcher.d.ts +5 -0
  50. package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
  51. package/dist/tools/diagnosis-fetcher.js +17 -12
  52. package/dist/tools/executor/index.d.ts.map +1 -1
  53. package/dist/tools/executor/index.js +2 -2
  54. package/dist/tools/fetch-file/index.d.ts.map +1 -1
  55. package/dist/tools/fetch-file/index.js +11 -10
  56. package/dist/tools/fetch-file/utils.d.ts +13 -1
  57. package/dist/tools/fetch-file/utils.d.ts.map +1 -1
  58. package/dist/tools/fetch-file/utils.js +44 -118
  59. package/dist/tools/index.d.ts +1 -1
  60. package/dist/tools/index.d.ts.map +1 -1
  61. package/dist/tools/index.js +9 -5
  62. package/dist/tools/issues-v1/index.d.ts +0 -2
  63. package/dist/tools/issues-v1/index.d.ts.map +1 -1
  64. package/dist/tools/issues-v1/index.js +1 -5
  65. package/dist/tools/publish-markdown-report/index.d.ts +3 -0
  66. package/dist/tools/publish-markdown-report/index.d.ts.map +1 -0
  67. package/dist/tools/publish-markdown-report/index.js +196 -0
  68. package/dist/tools/test-gen-browser.js +1 -1
  69. package/dist/tools/trace-dot-zip/index.d.ts.map +1 -1
  70. package/dist/tools/trace-dot-zip/index.js +19 -9
  71. package/dist/utils/model.d.ts.map +1 -1
  72. package/dist/utils/model.js +2 -6
  73. package/package.json +2 -11
  74. package/tsconfig.tsbuildinfo +1 -1
  75. package/dist/agent/code-review/parser.d.ts.map +0 -1
  76. package/dist/agent/master/icon-descriptor/index.d.ts +0 -22
  77. package/dist/agent/master/icon-descriptor/index.d.ts.map +0 -1
  78. package/dist/agent/master/icon-descriptor/index.js +0 -249
  79. package/dist/agent/master/icon-descriptor/normalize-svg.d.ts +0 -2
  80. package/dist/agent/master/icon-descriptor/normalize-svg.d.ts.map +0 -1
  81. package/dist/agent/master/icon-descriptor/normalize-svg.js +0 -247
  82. package/dist/tools/issues-v1/create-issue.d.ts +0 -3
  83. package/dist/tools/issues-v1/create-issue.d.ts.map +0 -1
  84. package/dist/tools/issues-v1/create-issue.js +0 -72
  85. package/dist/tools/issues-v1/update-issue.d.ts +0 -3
  86. package/dist/tools/issues-v1/update-issue.d.ts.map +0 -1
  87. package/dist/tools/issues-v1/update-issue.js +0 -74
  88. package/dist/trace-utils/cli.d.ts +0 -3
  89. package/dist/trace-utils/cli.d.ts.map +0 -1
  90. package/dist/trace-utils/cli.js +0 -302
  91. package/dist/trace-utils/console.d.ts +0 -11
  92. package/dist/trace-utils/console.d.ts.map +0 -1
  93. package/dist/trace-utils/console.js +0 -74
  94. package/dist/trace-utils/dom-snapshot.d.ts +0 -19
  95. package/dist/trace-utils/dom-snapshot.d.ts.map +0 -1
  96. package/dist/trace-utils/dom-snapshot.js +0 -328
  97. package/dist/trace-utils/index.d.ts +0 -12
  98. package/dist/trace-utils/index.d.ts.map +0 -1
  99. package/dist/trace-utils/index.js +0 -28
  100. package/dist/trace-utils/network.d.ts +0 -16
  101. package/dist/trace-utils/network.d.ts.map +0 -1
  102. package/dist/trace-utils/network.js +0 -178
  103. package/dist/trace-utils/normalize-trace-url.d.ts +0 -2
  104. package/dist/trace-utils/normalize-trace-url.d.ts.map +0 -1
  105. package/dist/trace-utils/normalize-trace-url.js +0 -15
  106. package/dist/trace-utils/screenshots.d.ts +0 -24
  107. package/dist/trace-utils/screenshots.d.ts.map +0 -1
  108. package/dist/trace-utils/screenshots.js +0 -197
  109. package/dist/trace-utils/steps.d.ts +0 -10
  110. package/dist/trace-utils/steps.d.ts.map +0 -1
  111. package/dist/trace-utils/steps.js +0 -126
  112. package/dist/trace-utils/types.d.ts +0 -51
  113. package/dist/trace-utils/types.d.ts.map +0 -1
  114. package/dist/trace-utils/types.js +0 -2
  115. package/dist/utils/playwright-report-parser.d.ts +0 -2
  116. package/dist/utils/playwright-report-parser.d.ts.map +0 -1
  117. package/dist/utils/playwright-report-parser.js +0 -10
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createIssueTool = void 0;
4
- const zod_1 = require("zod");
5
- const utils_1 = require("./utils");
6
- const createIssueSchema = zod_1.z.object({
7
- title: zod_1.z.string().describe("A short, descriptive title for the issue"),
8
- description: zod_1.z
9
- .string()
10
- .describe("A concise description that includes failing line, diagnosis summary (gathered from going through test run report attachments), and reasoning for issue_type."),
11
- issue_type: zod_1.z
12
- .enum(["app", "test", "unknown"])
13
- .describe("The type of issue. Options: app, test, unknown. You can use 'unknown' if you are unsure about the type."),
14
- test_issue_prompt: zod_1.z
15
- .string()
16
- .optional()
17
- .describe("A prompt that suggests how to fix test type issues. This prompt is used to modify the test to adapt to the new state of the application. Provide URLs for build and run reports where the issue originated, so that the developer can understand full context."),
18
- });
19
- exports.createIssueTool = {
20
- schema: {
21
- name: "createIssue",
22
- description: `This tool allows you to create an issue in the project's issue tracking system. You MUST check if a similar issue already exists with the list issues tool before creating a new one.`,
23
- parameters: createIssueSchema,
24
- },
25
- needsBrowser: false,
26
- isInlineTool: true,
27
- execute: async ({ input, apiClient, chatSession }) => {
28
- try {
29
- const { title, description, issue_type = "unknown", test_issue_prompt, } = input;
30
- if (!chatSession?.id) {
31
- throw new Error("Cannot create issue without a chat session ID.");
32
- }
33
- if (issue_type === "test" && !test_issue_prompt) {
34
- throw new Error("test_issue_prompt is required for test type issues.");
35
- }
36
- if (!apiClient) {
37
- throw new Error("Dashboard API client is not available.");
38
- }
39
- const response = await (0, utils_1.createIssue)(apiClient, {
40
- title,
41
- description,
42
- issue_type,
43
- test_issue_prompt,
44
- triage_session_id: chatSession?.id,
45
- });
46
- if (!response.data?.issue) {
47
- return {
48
- isError: true,
49
- result: `Failed to create issue: ${response.error?.message}`,
50
- };
51
- }
52
- const issue = response.data?.issue;
53
- const baseUrl = apiClient.getBaseUrl();
54
- const issueUrl = `${baseUrl}/issues/${issue?.id}`;
55
- const result = `Successfully created issue #${issue?.id}: ${issue?.title}
56
- Issue URL: ${issueUrl}
57
- Issue JSON:
58
- ${JSON.stringify(issue, null, 2)}
59
- `;
60
- return {
61
- isError: false,
62
- result,
63
- };
64
- }
65
- catch (error) {
66
- return {
67
- isError: true,
68
- result: `Failed to create issue: ${error instanceof Error ? error.message : String(error)}`,
69
- };
70
- }
71
- },
72
- };
@@ -1,3 +0,0 @@
1
- import type { Tool } from "@empiricalrun/shared-types/chat-agent";
2
- export declare const updateIssueTool: Tool;
3
- //# sourceMappingURL=update-issue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-issue.d.ts","sourceRoot":"","sources":["../../../src/tools/issues-v1/update-issue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAsBlE,eAAO,MAAM,eAAe,EAAE,IAwD7B,CAAC"}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateIssueTool = void 0;
4
- const zod_1 = require("zod");
5
- const utils_1 = require("./utils");
6
- const updateIssueSchema = zod_1.z.object({
7
- id: zod_1.z.number().describe("The ID of the issue to update"),
8
- title: zod_1.z.string().optional().describe("Updated title of the issue"),
9
- description: zod_1.z
10
- .string()
11
- .optional()
12
- .describe("Updated description of the issue"),
13
- issue_type: zod_1.z
14
- .enum(["app", "test", "unknown"])
15
- .optional()
16
- .describe("Updated issue type"),
17
- test_issue_prompt: zod_1.z
18
- .string()
19
- .optional()
20
- .describe("Updated test issue prompt"),
21
- });
22
- exports.updateIssueTool = {
23
- schema: {
24
- name: "updateIssue",
25
- description: `This tool allows you to update an existing issue in the project's issue tracking system. You can update the title, description, issue type, or test issue prompt. use this tool to update existing issue to prevent duplication of issues.`,
26
- parameters: updateIssueSchema,
27
- },
28
- needsBrowser: false,
29
- isInlineTool: true,
30
- execute: async ({ input, apiClient }) => {
31
- try {
32
- const { id, title, description, issue_type, test_issue_prompt } = input;
33
- if (!apiClient) {
34
- throw new Error("Dashboard API client is not available.");
35
- }
36
- const updateData = {};
37
- if (title !== undefined) {
38
- updateData.title = title;
39
- }
40
- if (description !== undefined) {
41
- updateData.description = description;
42
- }
43
- if (issue_type !== undefined) {
44
- updateData.issue_type = issue_type;
45
- }
46
- if (test_issue_prompt !== undefined) {
47
- updateData.test_issue_prompt = test_issue_prompt;
48
- }
49
- const response = await (0, utils_1.updateIssue)(apiClient, id, updateData);
50
- if (!response.data?.issue) {
51
- return {
52
- isError: true,
53
- result: `Failed to update issue: ${response.error?.message}`,
54
- };
55
- }
56
- const issue = response.data?.issue;
57
- const result = `Successfully updated issue #${issue?.id}: ${issue?.title}
58
-
59
- Updated Issue JSON:
60
- ${JSON.stringify(issue, null, 2)}
61
- `;
62
- return {
63
- isError: false,
64
- result,
65
- };
66
- }
67
- catch (error) {
68
- return {
69
- isError: true,
70
- result: `Failed to update issue: ${error instanceof Error ? error.message : String(error)}`,
71
- };
72
- }
73
- },
74
- };
@@ -1,3 +0,0 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- export declare function buildTraceUtilsCommand(): Command<[], {}, {}>;
3
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/trace-utils/cli.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAQtD,wBAAgB,sBAAsB,wBAyWrC"}
@@ -1,302 +0,0 @@
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.buildTraceUtilsCommand = buildTraceUtilsCommand;
7
- const node_crypto_1 = require("node:crypto");
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const extra_typings_1 = require("@commander-js/extra-typings");
10
- const console_1 = require("./console");
11
- const dom_snapshot_1 = require("./dom-snapshot");
12
- const network_1 = require("./network");
13
- const screenshots_1 = require("./screenshots");
14
- const steps_1 = require("./steps");
15
- function buildTraceUtilsCommand() {
16
- const traceUtils = new extra_typings_1.Command("trace-utils").description("CLI for inspecting Playwright trace.zip files");
17
- traceUtils
18
- .command("steps")
19
- .description("List all test steps from a trace")
20
- .requiredOption("--file <path>", "Path or URL to trace.zip")
21
- .option("--json", "Output as JSON", false)
22
- .action(async (opts) => {
23
- try {
24
- const { steps } = await (0, steps_1.listSteps)({ file: opts.file });
25
- if (opts.json) {
26
- console.log(JSON.stringify(steps, null, 2));
27
- }
28
- else {
29
- const formatted = (0, steps_1.formatStepsForDisplay)(steps);
30
- console.log(formatted.join("\n") + `\n\nTotal steps: ${steps.length}`);
31
- }
32
- }
33
- catch (error) {
34
- console.error("❌ Error extracting trace steps:", error.message);
35
- process.exit(1);
36
- }
37
- process.exit(0);
38
- });
39
- traceUtils
40
- .command("screenshots")
41
- .description("Extract screenshots from a trace")
42
- .requiredOption("--file <path>", "Path or URL to trace.zip")
43
- .option("--step <id>", "Step callId to extract around")
44
- .option("--start <time>", "Start time (HH:MM:SS.mmm)")
45
- .option("--end <time>", "End time (HH:MM:SS.mmm)")
46
- .option("--before <ms>", "Milliseconds before step (only with --step)", "2000")
47
- .option("--after <ms>", "Milliseconds after step (only with --step)", "2000")
48
- .option("--max <count>", "Maximum screenshots", "10")
49
- .option("--output <dir>", "Output directory (default: auto-generated in /tmp)")
50
- .action(async (opts) => {
51
- try {
52
- if (!opts.step && (!opts.start || !opts.end)) {
53
- console.error("❌ Either --step or both --start and --end are required");
54
- process.exit(1);
55
- }
56
- let result;
57
- if (opts.step) {
58
- result = await (0, screenshots_1.extractScreenshots)({
59
- file: opts.file,
60
- step: opts.step,
61
- beforeMs: parseInt(opts.before, 10),
62
- afterMs: parseInt(opts.after, 10),
63
- max: parseInt(opts.max, 10),
64
- });
65
- if (!result.step) {
66
- console.error(`❌ Step "${opts.step}" not found in trace`);
67
- console.log("\nAvailable steps:");
68
- const { steps } = await (0, steps_1.listSteps)({ file: opts.file });
69
- steps
70
- .slice(0, 20)
71
- .forEach((s) => console.log(` ${s.callId}: ${s.apiName}`));
72
- if (steps.length > 20) {
73
- console.log(` ... and ${steps.length - 20} more`);
74
- }
75
- process.exit(1);
76
- }
77
- }
78
- else {
79
- result = await (0, screenshots_1.extractScreenshots)({
80
- file: opts.file,
81
- start: opts.start,
82
- end: opts.end,
83
- max: parseInt(opts.max, 10),
84
- });
85
- }
86
- if (result.screenshots.length === 0) {
87
- console.log("⚠️ No screenshots found in the specified time window");
88
- process.exit(0);
89
- }
90
- const outputDir = opts.output ||
91
- node_path_1.default.join("/tmp", `screenshots-${(0, node_crypto_1.randomBytes)(4).toString("hex")}`);
92
- const filePrefix = opts.step
93
- ? opts.step
94
- : `${opts.start}-${opts.end}`.replace(/:/g, "");
95
- const savedPaths = await (0, screenshots_1.saveScreenshotsToDir)(result.screenshots, outputDir, filePrefix);
96
- console.log(`✅ Extracted ${result.screenshots.length} screenshots for:`);
97
- console.log(` ${result.label}`);
98
- console.log(`\nSaved to ${outputDir}/`);
99
- savedPaths.forEach((p) => console.log(` - ${node_path_1.default.resolve(outputDir, p)}`));
100
- }
101
- catch (error) {
102
- console.error("❌ Error extracting screenshots:", error.message);
103
- process.exit(1);
104
- }
105
- process.exit(0);
106
- });
107
- traceUtils
108
- .command("network")
109
- .description("Search network requests")
110
- .requiredOption("--file <path>", "Path or URL to trace.zip")
111
- .option("--step <callId>", "Filter to requests during a specific step")
112
- .option("--before <ms>", "Time before step to include (with --step)", "2000")
113
- .option("--after <ms>", "Time after step to include (with --step)", "2000")
114
- .option("--errors", "Show only failed requests (4xx, 5xx, no response)")
115
- .option("--url <pattern>", "Filter by URL pattern (regex)")
116
- .option("--method <method>", "Filter by HTTP method")
117
- .option("--status <codes>", "Filter by status codes (e.g., 404,500)")
118
- .option("--json", "Output as JSON", false)
119
- .action(async (opts) => {
120
- try {
121
- if (!opts.step &&
122
- !opts.errors &&
123
- !opts.url &&
124
- !opts.method &&
125
- !opts.status) {
126
- console.error("❌ At least one filter is required (--step, --errors, --url, --method, or --status)");
127
- process.exit(1);
128
- }
129
- const statusCodes = opts.status
130
- ? opts.status.split(",").map((s) => parseInt(s.trim(), 10))
131
- : undefined;
132
- const result = await (0, network_1.searchNetwork)({
133
- file: opts.file,
134
- step: opts.step,
135
- beforeMs: parseInt(opts.before, 10),
136
- afterMs: parseInt(opts.after, 10),
137
- errors: opts.errors,
138
- urlPattern: opts.url,
139
- method: opts.method,
140
- status: statusCodes,
141
- });
142
- if (opts.json) {
143
- console.log(JSON.stringify(result, null, 2));
144
- }
145
- else {
146
- if (result.matches.length === 0) {
147
- console.log("No matching network requests found.");
148
- }
149
- else {
150
- console.log(`Found ${result.matches.length} matching request(s):\n`);
151
- for (const entry of result.matches) {
152
- console.log(`${entry.method} ${entry.url}`);
153
- console.log(` Status: ${entry.status} | Duration: ${entry.durationMs}ms`);
154
- console.log(` Time: ${entry.timestamp}`);
155
- if (entry.requestBody) {
156
- const preview = entry.requestBody.slice(0, 200);
157
- console.log(` Request: ${preview}${entry.requestBody.length > 200 ? "..." : ""}`);
158
- }
159
- if (entry.responseBody) {
160
- const preview = entry.responseBody.slice(0, 200);
161
- console.log(` Response: ${preview}${entry.responseBody.length > 200 ? "..." : ""}`);
162
- }
163
- console.log();
164
- }
165
- }
166
- }
167
- }
168
- catch (error) {
169
- console.error("❌ Error searching network requests:", error.message);
170
- process.exit(1);
171
- }
172
- process.exit(0);
173
- });
174
- traceUtils
175
- .command("console")
176
- .description("View browser console output")
177
- .requiredOption("--file <path>", "Path or URL to trace.zip")
178
- .option("--level <level>", "Minimum level: error, warning, info, debug", "error")
179
- .option("--search <text>", "Filter logs containing text")
180
- .option("--json", "Output as JSON", false)
181
- .action(async (opts) => {
182
- try {
183
- const validLevels = [
184
- "error",
185
- "warning",
186
- "info",
187
- "debug",
188
- ];
189
- if (!validLevels.includes(opts.level)) {
190
- console.error(`❌ Invalid level: ${opts.level}. Use one of: ${validLevels.join(", ")}`);
191
- process.exit(1);
192
- }
193
- const result = await (0, console_1.getConsoleLogs)({
194
- file: opts.file,
195
- level: opts.level,
196
- search: opts.search,
197
- });
198
- if (opts.json) {
199
- console.log(JSON.stringify(result, null, 2));
200
- }
201
- else {
202
- if (result.logs.length === 0) {
203
- console.log("No console logs found matching criteria.");
204
- }
205
- else {
206
- console.log(`Found ${result.logs.length} console log(s):\n`);
207
- for (const log of result.logs) {
208
- const levelTag = `[${log.level.toUpperCase()}]`;
209
- console.log(`${levelTag} ${log.text}`);
210
- if (log.location) {
211
- console.log(` at ${log.location.url}:${log.location.lineNumber}:${log.location.columnNumber}`);
212
- }
213
- console.log();
214
- }
215
- }
216
- }
217
- }
218
- catch (error) {
219
- console.error("❌ Error reading console logs:", error.message);
220
- process.exit(1);
221
- }
222
- process.exit(0);
223
- });
224
- traceUtils
225
- .command("dom-snapshot")
226
- .description("Extract DOM snapshot from a trace")
227
- .requiredOption("--file <path>", "Path or URL to trace.zip")
228
- .option("--step <id>", "Step callId to extract snapshot for")
229
- .option("--time <time>", "Time to extract snapshot at (HH:MM:SS.mmm)")
230
- .option("--type <type>", "Snapshot type: before, after, input (only with --step)", "before")
231
- .option("--output <file>", "Output file path")
232
- .option("--json", "Output as JSON", false)
233
- .action(async (opts) => {
234
- try {
235
- if (!opts.step && !opts.time) {
236
- console.error("❌ Either --step or --time is required");
237
- process.exit(1);
238
- }
239
- const validTypes = ["before", "after", "input"];
240
- if (!validTypes.includes(opts.type)) {
241
- console.error(`❌ Invalid type: ${opts.type}. Use one of: ${validTypes.join(", ")}`);
242
- process.exit(1);
243
- }
244
- let result;
245
- if (opts.step) {
246
- result = await (0, dom_snapshot_1.getDomSnapshot)({
247
- file: opts.file,
248
- step: opts.step,
249
- snapshotType: opts.type,
250
- });
251
- if (!result.snapshot) {
252
- console.error(`❌ Step "${opts.step}" not found in trace`);
253
- console.log("\nAvailable steps:");
254
- const { steps } = await (0, steps_1.listSteps)({ file: opts.file });
255
- steps
256
- .slice(0, 20)
257
- .forEach((s) => console.log(` ${s.callId}: ${s.apiName}`));
258
- if (steps.length > 20) {
259
- console.log(` ... and ${steps.length - 20} more`);
260
- }
261
- process.exit(1);
262
- }
263
- }
264
- else {
265
- result = await (0, dom_snapshot_1.getDomSnapshot)({
266
- file: opts.file,
267
- time: opts.time,
268
- });
269
- if (!result.snapshot) {
270
- console.error("❌ No DOM snapshot found at the specified time");
271
- process.exit(1);
272
- }
273
- }
274
- if (opts.json) {
275
- console.log(JSON.stringify(result.snapshot, null, 2));
276
- }
277
- else if (opts.output) {
278
- const savedPath = await (0, dom_snapshot_1.saveDomSnapshotToFile)(result.snapshot, opts.output);
279
- console.log(`✅ DOM snapshot saved to: ${savedPath}`);
280
- console.log(` URL: ${result.snapshot.frameUrl}`);
281
- console.log(` Viewport: ${result.snapshot.viewport.width}x${result.snapshot.viewport.height}`);
282
- }
283
- else {
284
- console.log(`# DOM Snapshot: ${result.label}`);
285
- if (result.step) {
286
- console.log(`# Step: ${result.step.callId}`);
287
- }
288
- console.log(`# URL: ${result.snapshot.frameUrl}`);
289
- console.log(`# Viewport: ${result.snapshot.viewport.width}x${result.snapshot.viewport.height}`);
290
- console.log(`# Snapshot type: ${result.snapshot.snapshotName || "unknown"}`);
291
- console.log();
292
- console.log(result.snapshot.html);
293
- }
294
- }
295
- catch (error) {
296
- console.error("❌ Error extracting DOM snapshot:", error.message);
297
- process.exit(1);
298
- }
299
- process.exit(0);
300
- });
301
- return traceUtils;
302
- }
@@ -1,11 +0,0 @@
1
- import type { ConsoleEntry, ConsoleLevel } from "./types";
2
- export type GetConsoleLogsArgs = {
3
- file: string;
4
- level?: ConsoleLevel;
5
- search?: string;
6
- };
7
- export type GetConsoleLogsResult = {
8
- logs: ConsoleEntry[];
9
- };
10
- export declare function getConsoleLogs(args: GetConsoleLogsArgs): Promise<GetConsoleLogsResult>;
11
- //# sourceMappingURL=console.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/trace-utils/console.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuC1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,YAAY,EAAE,CAAC;CACtB,CAAC;AAEF,wBAAsB,cAAc,CAClC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAyD/B"}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConsoleLogs = getConsoleLogs;
4
- const extract_zip_1 = require("../tools/trace-dot-zip/utils/extract-zip");
5
- const normalize_trace_url_1 = require("./normalize-trace-url");
6
- const LEVEL_ORDER = ["debug", "info", "warning", "error"];
7
- function messageTypeToLevel(messageType) {
8
- switch (messageType) {
9
- case "error":
10
- return "error";
11
- case "warning":
12
- return "warning";
13
- case "info":
14
- return "info";
15
- case "log":
16
- return "info";
17
- case "debug":
18
- return "debug";
19
- default:
20
- return "info";
21
- }
22
- }
23
- function meetsMinLevel(level, minLevel) {
24
- return LEVEL_ORDER.indexOf(level) >= LEVEL_ORDER.indexOf(minLevel);
25
- }
26
- async function getConsoleLogs(args) {
27
- const zipUrl = (0, normalize_trace_url_1.normalizeTraceZipUrl)(args.file);
28
- const minLevel = args.level ?? "error";
29
- const searchLower = args.search?.toLowerCase();
30
- const allLogs = [];
31
- // Discover all .trace files (excluding test.trace)
32
- const allFiles = await (0, extract_zip_1.getFilenamesInZip)(zipUrl);
33
- const traceFiles = allFiles.filter((f) => f.endsWith(".trace") && f !== "test.trace");
34
- if (traceFiles.length === 0) {
35
- return { logs: [] };
36
- }
37
- await (0, extract_zip_1.extractFileFromZipFromUrl)({
38
- zipUrl,
39
- fileNames: traceFiles,
40
- chunkProcessor: () => {
41
- let tempBuffer = "";
42
- return (chunk) => {
43
- tempBuffer += chunk;
44
- const lines = tempBuffer.split("\n");
45
- lines.slice(0, -1).forEach((line) => {
46
- try {
47
- const event = JSON.parse(line);
48
- if (event.type === "console") {
49
- const pwEvent = event;
50
- const level = messageTypeToLevel(pwEvent.messageType);
51
- if (!meetsMinLevel(level, minLevel))
52
- return;
53
- const text = pwEvent.text || pwEvent.args?.join(" ") || "";
54
- if (searchLower && !text.toLowerCase().includes(searchLower)) {
55
- return;
56
- }
57
- allLogs.push({
58
- level,
59
- text,
60
- timestamp: pwEvent.time,
61
- location: pwEvent.location,
62
- });
63
- }
64
- }
65
- catch {
66
- // skip malformed lines
67
- }
68
- });
69
- tempBuffer = lines[lines.length - 1] || "";
70
- };
71
- },
72
- });
73
- return { logs: allLogs };
74
- }
@@ -1,19 +0,0 @@
1
- import type { DomSnapshot, TraceStep } from "./types";
2
- export type GetDomSnapshotByStepArgs = {
3
- file: string;
4
- step: string;
5
- snapshotType?: "before" | "after" | "input";
6
- };
7
- export type GetDomSnapshotByTimeArgs = {
8
- file: string;
9
- time: string;
10
- };
11
- export type GetDomSnapshotArgs = GetDomSnapshotByStepArgs | GetDomSnapshotByTimeArgs;
12
- export type GetDomSnapshotResult = {
13
- snapshot?: DomSnapshot;
14
- step?: TraceStep;
15
- label: string;
16
- };
17
- export declare function getDomSnapshot(args: GetDomSnapshotArgs): Promise<GetDomSnapshotResult>;
18
- export declare function saveDomSnapshotToFile(snapshot: DomSnapshot, outputPath: string): Promise<string>;
19
- //# sourceMappingURL=dom-snapshot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dom-snapshot.d.ts","sourceRoot":"","sources":["../../src/trace-utils/dom-snapshot.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAmNtD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,wBAAwB,GACxB,wBAAwB,CAAC;AAE7B,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAwBF,wBAAsB,cAAc,CAClC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAiC/B;AA8ID,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAKjB"}