@empiricalrun/test-gen 0.79.2 → 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.
- package/CHANGELOG.md +14 -0
- package/dist/agent/chat/exports.d.ts +1 -0
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +3 -1
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +22 -3
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts.map +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.js +1 -1
- package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
- package/dist/agent/chat/prompt/repo.js +4 -3
- package/dist/agent/chat/prompt/trace-utils-docs.d.ts +2 -0
- package/dist/agent/chat/prompt/trace-utils-docs.d.ts.map +1 -0
- package/dist/agent/chat/prompt/trace-utils-docs.js +208 -0
- package/dist/agent/code-review/index.d.ts +1 -1
- package/dist/agent/code-review/index.d.ts.map +1 -1
- package/dist/agent/code-review/index.js +4 -4
- package/dist/agent/code-review/{parser.d.ts → xml-parser.d.ts} +1 -1
- package/dist/agent/code-review/xml-parser.d.ts.map +1 -0
- package/dist/agent/code-review/{parser.js → xml-parser.js} +1 -1
- package/dist/agent/fast-triage/index.d.ts +8 -0
- package/dist/agent/fast-triage/index.d.ts.map +1 -0
- package/dist/agent/fast-triage/index.js +79 -0
- package/dist/agent/index.d.ts +2 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +4 -1
- package/dist/agent/master/element-annotation.d.ts.map +1 -1
- package/dist/agent/master/element-annotation.js +2 -19
- package/dist/agent/triage/index.js +2 -2
- package/dist/bin/index.js +3 -3
- package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
- package/dist/bin/utils/platform/web/index.js +3 -2
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/dashboard/client.d.ts +16 -1
- package/dist/dashboard/client.d.ts.map +1 -1
- package/dist/dashboard/client.js +33 -9
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +4 -1
- package/dist/dashboard/tool-response-from-sandbox.d.ts +5 -0
- package/dist/dashboard/tool-response-from-sandbox.d.ts.map +1 -0
- package/dist/dashboard/tool-response-from-sandbox.js +40 -0
- package/dist/dashboard/tool-response.d.ts +1 -0
- package/dist/dashboard/tool-response.d.ts.map +1 -1
- package/dist/dashboard/tool-response.js +1 -0
- package/dist/file-info/adapters/github/index.d.ts.map +1 -1
- package/dist/file-info/adapters/github/index.js +1 -1
- package/dist/file-info/adapters/github/reader.d.ts.map +1 -1
- package/dist/file-info/adapters/github/reader.js +9 -3
- package/dist/generate-summary/frame-sampling.d.ts +12 -0
- package/dist/generate-summary/frame-sampling.d.ts.map +1 -0
- package/dist/generate-summary/frame-sampling.js +72 -0
- package/dist/generate-summary/generate-error-stack-summary.d.ts +11 -0
- package/dist/generate-summary/generate-error-stack-summary.d.ts.map +1 -0
- package/dist/generate-summary/generate-error-stack-summary.js +41 -0
- package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.d.ts +58 -0
- package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.d.ts.map +1 -0
- package/dist/generate-summary/generate-failed-step-screenshot-diff-summary.js +460 -0
- package/dist/generate-summary/generate-grouped-summary.d.ts +18 -0
- package/dist/generate-summary/generate-grouped-summary.d.ts.map +1 -0
- package/dist/generate-summary/generate-grouped-summary.js +88 -0
- package/dist/generate-summary/merge-summary.d.ts +16 -0
- package/dist/generate-summary/merge-summary.d.ts.map +1 -0
- package/dist/generate-summary/merge-summary.js +43 -0
- package/dist/generate-summary/pick-videos-for-comparison.d.ts +9 -0
- package/dist/generate-summary/pick-videos-for-comparison.d.ts.map +1 -0
- package/dist/generate-summary/pick-videos-for-comparison.js +54 -0
- package/dist/telemetry/index.d.ts +3 -3
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +11 -6
- package/dist/tools/analyse-video/index.js +1 -1
- package/dist/tools/definitions/delete-file.js +1 -1
- package/dist/tools/definitions/grep.d.ts.map +1 -1
- package/dist/tools/definitions/grep.js +1 -1
- package/dist/tools/definitions/publish-markdown-report.d.ts +8 -0
- package/dist/tools/definitions/publish-markdown-report.d.ts.map +1 -0
- package/dist/tools/definitions/publish-markdown-report.js +29 -0
- package/dist/tools/definitions/rename-file.js +2 -2
- package/dist/tools/definitions/safe-bash.d.ts.map +1 -1
- package/dist/tools/definitions/safe-bash.js +10 -8
- package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/definitions/str_replace_editor.js +12 -4
- package/dist/tools/definitions/trace-dot-zip.d.ts +7 -0
- package/dist/tools/definitions/trace-dot-zip.d.ts.map +1 -0
- package/dist/tools/definitions/trace-dot-zip.js +16 -0
- package/dist/tools/definitions/utils.js +1 -1
- package/dist/tools/delete-file/index.d.ts.map +1 -1
- package/dist/tools/delete-file/index.js +9 -6
- package/dist/tools/diagnosis-fetcher.d.ts +5 -0
- package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
- package/dist/tools/diagnosis-fetcher.js +56 -13
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +2 -2
- package/dist/tools/fetch-file/index.d.ts.map +1 -1
- package/dist/tools/fetch-file/index.js +110 -10
- package/dist/tools/fetch-file/utils.d.ts +13 -1
- package/dist/tools/fetch-file/utils.d.ts.map +1 -1
- package/dist/tools/fetch-file/utils.js +44 -118
- package/dist/tools/file-operations/index.d.ts.map +1 -1
- package/dist/tools/file-operations/index.js +7 -5
- package/dist/tools/file-operations/shared/helpers.d.ts +13 -0
- package/dist/tools/file-operations/shared/helpers.d.ts.map +1 -1
- package/dist/tools/file-operations/shared/helpers.js +24 -0
- package/dist/tools/file-operations/view/index.d.ts.map +1 -1
- package/dist/tools/file-operations/view/index.js +9 -3
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +7 -2
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +14 -10
- package/dist/tools/issues-v1/index.d.ts +0 -2
- package/dist/tools/issues-v1/index.d.ts.map +1 -1
- package/dist/tools/issues-v1/index.js +1 -5
- package/dist/tools/merge-conflicts/index.d.ts.map +1 -1
- package/dist/tools/merge-conflicts/index.js +8 -8
- package/dist/tools/publish-markdown-report/index.d.ts +3 -0
- package/dist/tools/publish-markdown-report/index.d.ts.map +1 -0
- package/dist/tools/publish-markdown-report/index.js +196 -0
- package/dist/tools/rename-file/index.d.ts.map +1 -1
- package/dist/tools/rename-file/index.js +11 -7
- package/dist/tools/run-test.d.ts.map +1 -1
- package/dist/tools/run-test.js +12 -7
- package/dist/tools/safe-bash/index.d.ts.map +1 -1
- package/dist/tools/safe-bash/index.js +18 -2
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +13 -10
- package/dist/tools/trace-dot-zip/index.d.ts +3 -1
- package/dist/tools/trace-dot-zip/index.d.ts.map +1 -1
- package/dist/tools/trace-dot-zip/index.js +21 -23
- package/dist/tools/trace-dot-zip/utils/console-trace.d.ts.map +1 -1
- package/dist/tools/trace-dot-zip/utils/console-trace.js +11 -5
- package/dist/tools/trace-dot-zip/utils/extract-screenshots.d.ts +27 -0
- package/dist/tools/trace-dot-zip/utils/extract-screenshots.d.ts.map +1 -0
- package/dist/tools/trace-dot-zip/utils/extract-screenshots.js +128 -0
- package/dist/tools/trace-dot-zip/utils/extract-steps.d.ts +12 -0
- package/dist/tools/trace-dot-zip/utils/extract-steps.d.ts.map +1 -0
- package/dist/tools/trace-dot-zip/utils/extract-steps.js +130 -0
- package/dist/tools/trace-dot-zip/utils/extract-zip.d.ts +13 -16
- package/dist/tools/trace-dot-zip/utils/extract-zip.d.ts.map +1 -1
- package/dist/tools/trace-dot-zip/utils/extract-zip.js +27 -167
- package/dist/tools/trace-dot-zip/utils/network-trace.d.ts.map +1 -1
- package/dist/tools/trace-dot-zip/utils/network-trace.js +136 -105
- package/dist/utils/model.d.ts.map +1 -1
- package/dist/utils/model.js +2 -6
- package/dist/video-core/index.d.ts.map +1 -1
- package/dist/video-core/index.js +17 -33
- package/package.json +13 -16
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/agent/code-review/parser.d.ts.map +0 -1
- package/dist/agent/master/icon-descriptor/index.d.ts +0 -22
- package/dist/agent/master/icon-descriptor/index.d.ts.map +0 -1
- package/dist/agent/master/icon-descriptor/index.js +0 -249
- package/dist/agent/master/icon-descriptor/normalize-svg.d.ts +0 -2
- package/dist/agent/master/icon-descriptor/normalize-svg.d.ts.map +0 -1
- package/dist/agent/master/icon-descriptor/normalize-svg.js +0 -247
- package/dist/tools/issues-v1/create-issue.d.ts +0 -3
- package/dist/tools/issues-v1/create-issue.d.ts.map +0 -1
- package/dist/tools/issues-v1/create-issue.js +0 -72
- package/dist/tools/issues-v1/update-issue.d.ts +0 -3
- package/dist/tools/issues-v1/update-issue.d.ts.map +0 -1
- package/dist/tools/issues-v1/update-issue.js +0 -74
- package/dist/trace-utils/index.d.ts +0 -4
- package/dist/trace-utils/index.d.ts.map +0 -1
- package/dist/trace-utils/index.js +0 -10
- package/dist/utils/playwright-report-parser.d.ts +0 -13
- package/dist/utils/playwright-report-parser.d.ts.map +0 -1
- package/dist/utils/playwright-report-parser.js +0 -138
|
@@ -1,249 +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.loadIconsKnowledge = loadIconsKnowledge;
|
|
7
|
-
exports.saveIconsKnowledge = saveIconsKnowledge;
|
|
8
|
-
exports.generateKey = generateKey;
|
|
9
|
-
exports.reverseKey = reverseKey;
|
|
10
|
-
exports.createNodeFromHTML = createNodeFromHTML;
|
|
11
|
-
exports.getIconDescription = getIconDescription;
|
|
12
|
-
const llm_1 = require("@empiricalrun/llm");
|
|
13
|
-
const fs_1 = __importDefault(require("fs"));
|
|
14
|
-
const jsdom_1 = require("jsdom");
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const constants_1 = require("../../../constants");
|
|
17
|
-
const normalize_svg_1 = require("./normalize-svg");
|
|
18
|
-
const OLD_ICONS_KNOWLEDGE_PATH = path_1.default.join(process.cwd(), "icons.json");
|
|
19
|
-
const EMPIRICAL_RUN_DIR = path_1.default.join(process.cwd(), ".empiricalrun");
|
|
20
|
-
const ICONS_KNOWLEDGE_PATH = path_1.default.join(EMPIRICAL_RUN_DIR, "icons.json");
|
|
21
|
-
function loadIconsKnowledge() {
|
|
22
|
-
// Check if file exists in the new location
|
|
23
|
-
if (fs_1.default.existsSync(ICONS_KNOWLEDGE_PATH)) {
|
|
24
|
-
const raw = fs_1.default.readFileSync(ICONS_KNOWLEDGE_PATH, "utf-8");
|
|
25
|
-
if (raw) {
|
|
26
|
-
try {
|
|
27
|
-
return JSON.parse(raw);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
console.log("error parsing iconsKnowledge json");
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
// Check if file exists in the old location and move it if it does
|
|
37
|
-
if (fs_1.default.existsSync(OLD_ICONS_KNOWLEDGE_PATH)) {
|
|
38
|
-
try {
|
|
39
|
-
const raw = fs_1.default.readFileSync(OLD_ICONS_KNOWLEDGE_PATH, "utf-8");
|
|
40
|
-
let iconData = [];
|
|
41
|
-
if (raw) {
|
|
42
|
-
try {
|
|
43
|
-
iconData = JSON.parse(raw);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
console.log("error parsing iconsKnowledge json from old location");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// Create the directory and move the file
|
|
50
|
-
if (!fs_1.default.existsSync(EMPIRICAL_RUN_DIR)) {
|
|
51
|
-
fs_1.default.mkdirSync(EMPIRICAL_RUN_DIR, { recursive: true });
|
|
52
|
-
}
|
|
53
|
-
// Save to new location
|
|
54
|
-
fs_1.default.writeFileSync(ICONS_KNOWLEDGE_PATH, JSON.stringify(iconData, null, 2), "utf-8");
|
|
55
|
-
// Remove the old file
|
|
56
|
-
fs_1.default.unlinkSync(OLD_ICONS_KNOWLEDGE_PATH);
|
|
57
|
-
return iconData;
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
console.log("Error moving icons knowledge file:", err);
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
async function saveIconsKnowledge(iconsData) {
|
|
67
|
-
// Ensure the directory exists
|
|
68
|
-
if (!fs_1.default.existsSync(EMPIRICAL_RUN_DIR)) {
|
|
69
|
-
fs_1.default.mkdirSync(EMPIRICAL_RUN_DIR, { recursive: true });
|
|
70
|
-
}
|
|
71
|
-
const content = JSON.stringify(iconsData, null, 2);
|
|
72
|
-
fs_1.default.writeFileSync(ICONS_KNOWLEDGE_PATH, content, "utf-8");
|
|
73
|
-
// If old file exists, remove it
|
|
74
|
-
if (fs_1.default.existsSync(OLD_ICONS_KNOWLEDGE_PATH)) {
|
|
75
|
-
fs_1.default.unlinkSync(OLD_ICONS_KNOWLEDGE_PATH);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function generateKey(htmlString) {
|
|
79
|
-
const normalized = (0, normalize_svg_1.normalizeSVG)(htmlString);
|
|
80
|
-
// generate base64 string
|
|
81
|
-
const encoded = Buffer.from(normalized).toString("base64");
|
|
82
|
-
return `icon_${encoded}`;
|
|
83
|
-
}
|
|
84
|
-
function reverseKey(hash) {
|
|
85
|
-
const encoded = hash.replace(/^icon_/, "");
|
|
86
|
-
return Buffer.from(encoded, "base64").toString();
|
|
87
|
-
}
|
|
88
|
-
function createNodeFromHTML(htmlString) {
|
|
89
|
-
const dom = new jsdom_1.JSDOM(htmlString);
|
|
90
|
-
const document = dom.window.document;
|
|
91
|
-
const node = document.body.firstElementChild;
|
|
92
|
-
return {
|
|
93
|
-
node, // Return the first node
|
|
94
|
-
descendant: node ? Array.from(node.querySelectorAll("*")) : [], // Convert HTMLCollection to array
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function processSvgWithUseElements(svgElement, document) {
|
|
98
|
-
try {
|
|
99
|
-
const useElements = svgElement.querySelectorAll("use");
|
|
100
|
-
for (const useEl of Array.from(useElements)) {
|
|
101
|
-
const href = useEl.getAttribute("href") || useEl.getAttribute("xlink:href");
|
|
102
|
-
if (!href)
|
|
103
|
-
continue;
|
|
104
|
-
const id = href.startsWith("#") ? href.substring(1) : href;
|
|
105
|
-
const referencedElement = document.getElementById(id);
|
|
106
|
-
if (referencedElement) {
|
|
107
|
-
if (referencedElement.tagName.toLowerCase() === "symbol" ||
|
|
108
|
-
referencedElement.tagName.toLowerCase() === "svg") {
|
|
109
|
-
const group = document.createElement("g");
|
|
110
|
-
Array.from(useEl.attributes).forEach((attr) => {
|
|
111
|
-
if (attr.name !== "href" && attr.name !== "xlink:href") {
|
|
112
|
-
group.setAttribute(attr.name, attr.value);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
if (referencedElement.hasAttribute("viewBox")) {
|
|
116
|
-
group.setAttribute("viewBox", referencedElement.getAttribute("viewBox") || "");
|
|
117
|
-
}
|
|
118
|
-
group.innerHTML = referencedElement.innerHTML;
|
|
119
|
-
useEl.parentNode?.replaceChild(group, useEl);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
console.error("Error processing SVG with use elements:", error);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Extracts and returns an SVG element from a given HTML string.
|
|
130
|
-
*
|
|
131
|
-
* This function checks whether the provided HTML string contains an SVG element
|
|
132
|
-
* either as the root node or as a child node.
|
|
133
|
-
*/
|
|
134
|
-
function getHtmlForDescription(elementHtml, pageHtml) {
|
|
135
|
-
const dom = new jsdom_1.JSDOM(pageHtml);
|
|
136
|
-
const page = dom.window.document;
|
|
137
|
-
const { node, descendant } = createNodeFromHTML(elementHtml);
|
|
138
|
-
if (!node) {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
if (node.tagName.toLowerCase() === "svg") {
|
|
142
|
-
processSvgWithUseElements(node, page);
|
|
143
|
-
return node.outerHTML;
|
|
144
|
-
}
|
|
145
|
-
const svgChildren = descendant?.filter((child) => child?.tagName?.toLowerCase() === "svg");
|
|
146
|
-
if (svgChildren && svgChildren.length > 0) {
|
|
147
|
-
for (const svgChild of svgChildren) {
|
|
148
|
-
processSvgWithUseElements(svgChild, page);
|
|
149
|
-
}
|
|
150
|
-
return node.outerHTML;
|
|
151
|
-
}
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
async function describeSVGElementWithLLM({ element, trace, }) {
|
|
155
|
-
try {
|
|
156
|
-
const svgDescriptionSpan = trace?.span({
|
|
157
|
-
name: "get-svg-description",
|
|
158
|
-
input: {
|
|
159
|
-
element,
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
const messages = [
|
|
163
|
-
{
|
|
164
|
-
role: "system",
|
|
165
|
-
content: `
|
|
166
|
-
You are an expert at reading svg icons. You are given a task to provide the description of an icon based on the given HTML element string.
|
|
167
|
-
If the string does not contain any svg element, return NA.
|
|
168
|
-
`,
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
role: "user",
|
|
172
|
-
content: `
|
|
173
|
-
Provide the description of below element:
|
|
174
|
-
${element}
|
|
175
|
-
|
|
176
|
-
Follow below steps to provide the description:
|
|
177
|
-
- Identify the svg element in the given HTML string
|
|
178
|
-
- If the string does not contain any svg element, return NA
|
|
179
|
-
- Else, read the svg element and provide a single line description for the element
|
|
180
|
-
- The description should be precise and readable
|
|
181
|
-
- Only provide the element description and nothing else
|
|
182
|
-
`,
|
|
183
|
-
},
|
|
184
|
-
];
|
|
185
|
-
const llm = new llm_1.LLM({
|
|
186
|
-
trace: svgDescriptionSpan,
|
|
187
|
-
provider: "anthropic",
|
|
188
|
-
defaultModel: "claude-3-5-sonnet-latest",
|
|
189
|
-
providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
|
|
190
|
-
});
|
|
191
|
-
const svgDescription = await llm.createChatCompletion({
|
|
192
|
-
messages,
|
|
193
|
-
modelParameters: {
|
|
194
|
-
temperature: 0.3,
|
|
195
|
-
},
|
|
196
|
-
responseFormat: {
|
|
197
|
-
type: "json_schema",
|
|
198
|
-
json_schema: {
|
|
199
|
-
name: "describe-svg-element",
|
|
200
|
-
strict: true,
|
|
201
|
-
schema: {
|
|
202
|
-
type: "object",
|
|
203
|
-
properties: {
|
|
204
|
-
description: {
|
|
205
|
-
type: "string",
|
|
206
|
-
description: "A clear description of what the SVG visually represents",
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
additionalProperties: false,
|
|
210
|
-
required: ["description"],
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
svgDescriptionSpan?.end({ output: svgDescription });
|
|
216
|
-
return svgDescription?.content ?? undefined;
|
|
217
|
-
}
|
|
218
|
-
catch (err) {
|
|
219
|
-
console.error(`Error generating svg description ${err}`);
|
|
220
|
-
return undefined;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
async function getIconDescription({ htmlString, pageHtml, trace, }) {
|
|
224
|
-
const elementStringForDescription = getHtmlForDescription(htmlString, pageHtml);
|
|
225
|
-
if (!elementStringForDescription) {
|
|
226
|
-
return undefined;
|
|
227
|
-
}
|
|
228
|
-
const key = generateKey(elementStringForDescription);
|
|
229
|
-
const iconsData = loadIconsKnowledge();
|
|
230
|
-
const cachedIcon = iconsData.find((icon) => icon.key === key);
|
|
231
|
-
if (cachedIcon) {
|
|
232
|
-
return cachedIcon.description;
|
|
233
|
-
}
|
|
234
|
-
const description = await describeSVGElementWithLLM({
|
|
235
|
-
element: elementStringForDescription,
|
|
236
|
-
trace,
|
|
237
|
-
});
|
|
238
|
-
if (description) {
|
|
239
|
-
const newIconEntry = {
|
|
240
|
-
description,
|
|
241
|
-
key,
|
|
242
|
-
normalized: htmlString,
|
|
243
|
-
createdAt: new Date(),
|
|
244
|
-
};
|
|
245
|
-
iconsData.push(newIconEntry);
|
|
246
|
-
await saveIconsKnowledge(iconsData);
|
|
247
|
-
}
|
|
248
|
-
return description;
|
|
249
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-svg.d.ts","sourceRoot":"","sources":["../../../../src/agent/master/icon-descriptor/normalize-svg.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA8BpD"}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeSVG = normalizeSVG;
|
|
4
|
-
const jsdom_1 = require("jsdom");
|
|
5
|
-
function normalizeSVG(svgHtml) {
|
|
6
|
-
// Parse the SVG HTML into a DOM structure using JSDOM
|
|
7
|
-
const dom = new jsdom_1.JSDOM(svgHtml);
|
|
8
|
-
const document = dom.window.document;
|
|
9
|
-
const svgElement = document.querySelector("svg");
|
|
10
|
-
if (!svgElement) {
|
|
11
|
-
throw new Error("No SVG element found in the provided HTML");
|
|
12
|
-
}
|
|
13
|
-
// Normalize whitespace and formatting
|
|
14
|
-
normalizeWhitespace(svgElement);
|
|
15
|
-
// Normalize attribute order
|
|
16
|
-
normalizeAttributeOrder(svgElement);
|
|
17
|
-
// Normalize transform values
|
|
18
|
-
normalizeTransforms(svgElement);
|
|
19
|
-
// Normalize color formats (convert rgb to hex, standardize hex case)
|
|
20
|
-
normalizeColors(svgElement);
|
|
21
|
-
// Normalize path data (standardize spacing, remove redundant commands)
|
|
22
|
-
normalizePaths(svgElement);
|
|
23
|
-
// Normalize viewBox and preserveAspectRatio
|
|
24
|
-
normalizeViewBox(svgElement);
|
|
25
|
-
// Return the normalized SVG string
|
|
26
|
-
return svgElement.outerHTML;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Normalizes whitespace in SVG element
|
|
30
|
-
* @param element - The element to normalize
|
|
31
|
-
*/
|
|
32
|
-
function normalizeWhitespace(element) {
|
|
33
|
-
// Convert text nodes to have consistent spacing
|
|
34
|
-
const walkNodes = (node) => {
|
|
35
|
-
if (node.nodeType === 3) {
|
|
36
|
-
// TEXT_NODE
|
|
37
|
-
if (node.textContent?.trim() === "") {
|
|
38
|
-
node.textContent = "";
|
|
39
|
-
}
|
|
40
|
-
else if (node.textContent) {
|
|
41
|
-
node.textContent = node.textContent.trim().replace(/\s+/g, " ");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (node.nodeType === 1) {
|
|
45
|
-
// ELEMENT_NODE
|
|
46
|
-
for (let child of Array.from(node.childNodes)) {
|
|
47
|
-
walkNodes(child);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
walkNodes(element);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Normalizes attribute order on SVG elements
|
|
55
|
-
* @param element - The element to normalize
|
|
56
|
-
*/
|
|
57
|
-
function normalizeAttributeOrder(element) {
|
|
58
|
-
const walkElements = (node) => {
|
|
59
|
-
if (node.nodeType === 1) {
|
|
60
|
-
// ELEMENT_NODE
|
|
61
|
-
const elementNode = node;
|
|
62
|
-
// Get all attributes in a sorted array
|
|
63
|
-
const attributes = Array.from(elementNode.attributes);
|
|
64
|
-
const sortedAttributes = attributes.sort((a, b) => a.name.localeCompare(b.name));
|
|
65
|
-
// Remove all attributes
|
|
66
|
-
for (const attr of attributes) {
|
|
67
|
-
elementNode.removeAttribute(attr.name);
|
|
68
|
-
}
|
|
69
|
-
// Add them back in sorted order
|
|
70
|
-
for (const attr of sortedAttributes) {
|
|
71
|
-
elementNode.setAttribute(attr.name, attr.value);
|
|
72
|
-
}
|
|
73
|
-
// Process children
|
|
74
|
-
for (let child of Array.from(node.childNodes)) {
|
|
75
|
-
walkElements(child);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
walkElements(element);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Normalizes transform values to a consistent format
|
|
83
|
-
* @param element - The element to normalize
|
|
84
|
-
*/
|
|
85
|
-
function normalizeTransforms(element) {
|
|
86
|
-
const walkElements = (node) => {
|
|
87
|
-
if (node.nodeType === 1) {
|
|
88
|
-
// ELEMENT_NODE
|
|
89
|
-
const elementNode = node;
|
|
90
|
-
if (elementNode.hasAttribute("transform")) {
|
|
91
|
-
const transform = elementNode.getAttribute("transform");
|
|
92
|
-
if (transform) {
|
|
93
|
-
// Normalize transform by ensuring consistent spacing and order
|
|
94
|
-
const normalizedTransform = transform
|
|
95
|
-
.replace(/\s*,\s*/g, ",")
|
|
96
|
-
.replace(/\s+/g, " ")
|
|
97
|
-
.replace(/\(\s+/g, "(")
|
|
98
|
-
.replace(/\s+\)/g, ")");
|
|
99
|
-
elementNode.setAttribute("transform", normalizedTransform);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// Process children
|
|
103
|
-
for (let child of Array.from(node.childNodes)) {
|
|
104
|
-
walkElements(child);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
walkElements(element);
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Normalizes color formats to consistent hex values
|
|
112
|
-
* @param element - The element to normalize
|
|
113
|
-
*/
|
|
114
|
-
function normalizeColors(element) {
|
|
115
|
-
const colorAttributes = ["fill", "stroke", "stop-color", "color"];
|
|
116
|
-
const convertRgbToHex = (rgb) => {
|
|
117
|
-
// Convert rgb(r, g, b) or rgba(r, g, b, a) to hex
|
|
118
|
-
const rgbMatch = rgb.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([0-9.]+))?\)/);
|
|
119
|
-
if (rgbMatch) {
|
|
120
|
-
const r = parseInt(rgbMatch[1], 10);
|
|
121
|
-
const g = parseInt(rgbMatch[2], 10);
|
|
122
|
-
const b = parseInt(rgbMatch[3], 10);
|
|
123
|
-
// Convert to hex
|
|
124
|
-
const toHex = (c) => {
|
|
125
|
-
const hex = c.toString(16);
|
|
126
|
-
return hex.length === 1 ? "0" + hex : hex;
|
|
127
|
-
};
|
|
128
|
-
let hexColor = "#" + toHex(r) + toHex(g) + toHex(b);
|
|
129
|
-
// If there's alpha, we need to handle it separately (SVG doesn't use hex for alpha)
|
|
130
|
-
if (rgbMatch[4] && rgbMatch[4] !== "1") {
|
|
131
|
-
// Keep original rgba format but with normalized spacing
|
|
132
|
-
return `rgba(${r},${g},${b},${parseFloat(rgbMatch[4])})`;
|
|
133
|
-
}
|
|
134
|
-
return hexColor.toLowerCase();
|
|
135
|
-
}
|
|
136
|
-
return rgb;
|
|
137
|
-
};
|
|
138
|
-
const normalizeHex = (hex) => {
|
|
139
|
-
// Ensure lowercase for hex colors
|
|
140
|
-
if (hex.match(/#[0-9a-fA-F]{3,8}/)) {
|
|
141
|
-
return hex.toLowerCase();
|
|
142
|
-
}
|
|
143
|
-
return hex;
|
|
144
|
-
};
|
|
145
|
-
const walkElements = (node) => {
|
|
146
|
-
if (node.nodeType === 1) {
|
|
147
|
-
// ELEMENT_NODE
|
|
148
|
-
const elementNode = node;
|
|
149
|
-
// Check for color attributes
|
|
150
|
-
for (const attr of colorAttributes) {
|
|
151
|
-
if (elementNode.hasAttribute(attr)) {
|
|
152
|
-
let value = elementNode.getAttribute(attr);
|
|
153
|
-
if (value) {
|
|
154
|
-
value = convertRgbToHex(value);
|
|
155
|
-
value = normalizeHex(value);
|
|
156
|
-
elementNode.setAttribute(attr, value);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Check for style attribute with colors
|
|
161
|
-
if (elementNode.hasAttribute("style")) {
|
|
162
|
-
let style = elementNode.getAttribute("style");
|
|
163
|
-
if (style) {
|
|
164
|
-
// Replace any colors in the style attribute
|
|
165
|
-
for (const attr of colorAttributes) {
|
|
166
|
-
style = style.replace(new RegExp(`${attr}:\\s*([^;]+)`, "g"), (match, color) => {
|
|
167
|
-
const normalizedColor = normalizeHex(convertRgbToHex(color));
|
|
168
|
-
return `${attr}: ${normalizedColor}`;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
elementNode.setAttribute("style", style);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
// Process children
|
|
175
|
-
for (let child of Array.from(node.childNodes)) {
|
|
176
|
-
walkElements(child);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
walkElements(element);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Normalizes SVG path data
|
|
184
|
-
* @param element - The element to normalize
|
|
185
|
-
*/
|
|
186
|
-
function normalizePaths(element) {
|
|
187
|
-
const walkElements = (node) => {
|
|
188
|
-
if (node.nodeType === 1) {
|
|
189
|
-
// ELEMENT_NODE
|
|
190
|
-
const elementNode = node;
|
|
191
|
-
if (elementNode.tagName.toLowerCase() === "path" &&
|
|
192
|
-
elementNode.hasAttribute("d")) {
|
|
193
|
-
const pathData = elementNode.getAttribute("d");
|
|
194
|
-
if (pathData) {
|
|
195
|
-
// Normalize spacing in path data
|
|
196
|
-
const normalizedPathData = pathData
|
|
197
|
-
.replace(/\s+/g, " ")
|
|
198
|
-
.replace(/\s*([MmLlHhVvCcSsQqTtAaZz])\s*/g, "$1")
|
|
199
|
-
.replace(/\s*,\s*/g, ",")
|
|
200
|
-
.trim();
|
|
201
|
-
elementNode.setAttribute("d", normalizedPathData);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
// Process children
|
|
205
|
-
for (let child of Array.from(node.childNodes)) {
|
|
206
|
-
walkElements(child);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
walkElements(element);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Normalizes viewBox and preserveAspectRatio attributes
|
|
214
|
-
* @param element - The element to normalize
|
|
215
|
-
*/
|
|
216
|
-
function normalizeViewBox(element) {
|
|
217
|
-
if (element.tagName.toLowerCase() === "svg") {
|
|
218
|
-
if (element.hasAttribute("viewBox")) {
|
|
219
|
-
const viewBoxAttr = element.getAttribute("viewBox");
|
|
220
|
-
if (viewBoxAttr) {
|
|
221
|
-
// Normalize viewBox format
|
|
222
|
-
const viewBox = viewBoxAttr
|
|
223
|
-
.trim()
|
|
224
|
-
.replace(/\s+/g, " ")
|
|
225
|
-
.split(" ")
|
|
226
|
-
.map((val) => parseFloat(val).toString())
|
|
227
|
-
.join(" ");
|
|
228
|
-
element.setAttribute("viewBox", viewBox);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (element.hasAttribute("preserveAspectRatio")) {
|
|
232
|
-
const aspectRatio = element.getAttribute("preserveAspectRatio");
|
|
233
|
-
if (aspectRatio) {
|
|
234
|
-
// Normalize preserveAspectRatio to consistent formatting
|
|
235
|
-
const value = aspectRatio.trim();
|
|
236
|
-
element.setAttribute("preserveAspectRatio", value);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
// Process children (in case of nested SVGs)
|
|
241
|
-
for (let child of Array.from(element.childNodes)) {
|
|
242
|
-
if (child.nodeType === 1) {
|
|
243
|
-
// ELEMENT_NODE
|
|
244
|
-
normalizeViewBox(child);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-issue.d.ts","sourceRoot":"","sources":["../../../src/tools/issues-v1/create-issue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAyBlE,eAAO,MAAM,eAAe,EAAE,IA+D7B,CAAC"}
|
|
@@ -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 +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,4 +0,0 @@
|
|
|
1
|
-
export { extractFileFromZipFromUrl, getFilenamesInZip, } from "../tools/trace-dot-zip/utils/extract-zip";
|
|
2
|
-
export { generateNetworkTrace } from "../tools/trace-dot-zip/utils/network-trace";
|
|
3
|
-
export { deduplicateImages } from "../utils/dedup/dedup-image";
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trace-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC"}
|