@empiricalrun/test-gen 0.80.0 → 0.80.2
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 +15 -0
- package/dist/agent/chat/exports.d.ts +1 -1
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +3 -4
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +13 -9
- package/dist/agent/chat/prompt/skills.d.ts +3 -0
- package/dist/agent/chat/prompt/skills.d.ts.map +1 -0
- package/dist/agent/chat/prompt/skills.js +36 -0
- package/dist/agent/triage/index.d.ts.map +1 -1
- package/dist/agent/triage/index.js +2 -1
- package/dist/file-info/adapters/github/reader.d.ts +1 -9
- package/dist/file-info/adapters/github/reader.d.ts.map +1 -1
- package/dist/file-info/adapters/github/reader.js +8 -130
- package/dist/file-info/index.d.ts +0 -1
- package/dist/file-info/index.d.ts.map +1 -1
- package/dist/file-info/index.js +1 -3
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +2 -0
- package/dist/tools/api-client/index.d.ts.map +1 -1
- package/dist/tools/api-client/index.js +88 -3
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +12 -0
- package/dist/tools/fetch-file/index.d.ts.map +1 -1
- package/dist/tools/fetch-file/index.js +3 -11
- package/dist/tools/index.d.ts +1 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -23
- package/dist/tools/safe-bash/index.d.ts.map +1 -1
- package/dist/tools/safe-bash/index.js +55 -4
- package/dist/tools/slack-message/index.d.ts +3 -0
- package/dist/tools/slack-message/index.d.ts.map +1 -0
- package/dist/tools/slack-message/index.js +69 -0
- package/dist/tools/test-run-fetcher/types.d.ts +0 -36
- package/dist/tools/test-run-fetcher/types.d.ts.map +1 -1
- package/dist/tools/utils/apply-line-limit.d.ts +4 -0
- package/dist/tools/utils/apply-line-limit.d.ts.map +1 -0
- package/dist/tools/utils/apply-line-limit.js +18 -0
- package/package.json +6 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/file-info/adapters/github/index.d.ts +0 -12
- package/dist/file-info/adapters/github/index.d.ts.map +0 -1
- package/dist/file-info/adapters/github/index.js +0 -29
- package/dist/tools/utils/queue.d.ts +0 -5
- package/dist/tools/utils/queue.d.ts.map +0 -1
- package/dist/tools/utils/queue.js +0 -41
- package/dist/utils/SQSClient.d.ts +0 -14
- package/dist/utils/SQSClient.d.ts.map +0 -1
- package/dist/utils/SQSClient.js +0 -116
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.80.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [2d6f146]
|
|
8
|
+
- @empiricalrun/dashboard-client@0.2.1
|
|
9
|
+
|
|
10
|
+
## 0.80.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [3a315aa]
|
|
15
|
+
- @empiricalrun/reporter@0.28.1
|
|
16
|
+
- @empiricalrun/test-run@0.16.1
|
|
17
|
+
|
|
3
18
|
## 0.80.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { IChatModel } from "@empiricalrun/llm/chat";
|
|
2
2
|
export { createChatModel } from "@empiricalrun/llm/chat";
|
|
3
3
|
export { SUPPORTED_CHAT_MODELS } from "@empiricalrun/llm/chat/constants";
|
|
4
|
-
export { getFileInfoFromGitHub
|
|
4
|
+
export { getFileInfoFromGitHub } from "../../file-info/adapters/github/reader";
|
|
5
5
|
export type { AgentParams, OnToolCallCallback } from "../base";
|
|
6
6
|
export { BaseAgent } from "../base";
|
|
7
7
|
export type { CodeReviewResultV0, CodeReviewResultV1, CodeReviewResultV2, CodeReviewVersionedResult, } from "../code-review";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractAttachments = exports.LATEST_CHAT_STATE_VERSION = exports.fetchToolCallFromId = exports.ChatAgent = exports.TriageAgent = exports.FastTriageAgent = exports.CodeReviewAgent = exports.BaseAgent = exports.
|
|
3
|
+
exports.extractAttachments = exports.LATEST_CHAT_STATE_VERSION = exports.fetchToolCallFromId = exports.ChatAgent = exports.TriageAgent = exports.FastTriageAgent = exports.CodeReviewAgent = exports.BaseAgent = exports.getFileInfoFromGitHub = exports.SUPPORTED_CHAT_MODELS = exports.createChatModel = void 0;
|
|
4
4
|
var chat_1 = require("@empiricalrun/llm/chat");
|
|
5
5
|
Object.defineProperty(exports, "createChatModel", { enumerable: true, get: function () { return chat_1.createChatModel; } });
|
|
6
6
|
var constants_1 = require("@empiricalrun/llm/chat/constants");
|
|
7
7
|
Object.defineProperty(exports, "SUPPORTED_CHAT_MODELS", { enumerable: true, get: function () { return constants_1.SUPPORTED_CHAT_MODELS; } });
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "getFileInfoFromGitHub", { enumerable: true, get: function () { return
|
|
10
|
-
Object.defineProperty(exports, "viewFileUsingGitHub", { enumerable: true, get: function () { return github_1.viewFileUsingGitHub; } });
|
|
8
|
+
var reader_1 = require("../../file-info/adapters/github/reader");
|
|
9
|
+
Object.defineProperty(exports, "getFileInfoFromGitHub", { enumerable: true, get: function () { return reader_1.getFileInfoFromGitHub; } });
|
|
11
10
|
var base_1 = require("../base");
|
|
12
11
|
Object.defineProperty(exports, "BaseAgent", { enumerable: true, get: function () { return base_1.BaseAgent; } });
|
|
13
12
|
var code_review_1 = require("../code-review");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAsBpE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAsBpE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAOpC,qBAAa,SAAS,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC5C,SAAS,CAAC,QAAQ,IAAI,WAAW;IA8B3B,iBAAiB,CACrB,eAAe,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,GACvC,OAAO,CAAC,MAAM,CAAC;CA0GnB"}
|
package/dist/agent/chat/index.js
CHANGED
|
@@ -7,33 +7,35 @@ const analyse_video_1 = require("../../tools/definitions/analyse-video");
|
|
|
7
7
|
const grep_1 = require("../../tools/definitions/grep");
|
|
8
8
|
const list_tests_and_projects_1 = require("../../tools/definitions/list-tests-and-projects");
|
|
9
9
|
const run_test_1 = require("../../tools/definitions/run-test");
|
|
10
|
+
const test_gen_browser_1 = require("../../tools/definitions/test-gen-browser");
|
|
10
11
|
const diagnosis_fetcher_1 = require("../../tools/diagnosis-fetcher");
|
|
11
12
|
const fetch_file_1 = require("../../tools/fetch-file");
|
|
12
|
-
const
|
|
13
|
-
const test_run_fetcher_1 = require("../../tools/test-run-fetcher");
|
|
13
|
+
const slack_message_1 = require("../../tools/slack-message");
|
|
14
14
|
const base_1 = require("../base");
|
|
15
15
|
const pw_utils_docs_1 = require("./prompt/pw-utils-docs");
|
|
16
16
|
const repo_1 = require("./prompt/repo");
|
|
17
|
+
const skills_1 = require("./prompt/skills");
|
|
17
18
|
const test_case_def_1 = require("./prompt/test-case-def");
|
|
18
19
|
const trace_utils_docs_1 = require("./prompt/trace-utils-docs");
|
|
19
20
|
class ChatAgent extends base_1.BaseAgent {
|
|
20
21
|
getTools() {
|
|
21
|
-
const
|
|
22
|
+
const hasSlackTool = this.featureFlags.includes("has_slack_tool");
|
|
23
|
+
const hasSkills = this.featureFlags.includes("useSkills");
|
|
24
|
+
const hasAnalyseVideoTool = this.featureFlags.includes("has_analyse_video_tool");
|
|
22
25
|
const custom = [
|
|
23
|
-
analyse_video_1.analyseVideo,
|
|
26
|
+
...(hasAnalyseVideoTool ? [analyse_video_1.analyseVideo] : []),
|
|
24
27
|
run_test_1.runTestTool,
|
|
25
28
|
grep_1.grepTool,
|
|
26
|
-
...(
|
|
27
|
-
? [api_client_1.apiClientTool]
|
|
28
|
-
: [list_environments_1.listEnvironmentsTool, test_run_fetcher_1.fetchTestRunDetailsTool]),
|
|
29
|
+
...(hasSlackTool ? [slack_message_1.slackMessageTool] : []),
|
|
29
30
|
fetch_file_1.fetchFileTool,
|
|
30
31
|
list_tests_and_projects_1.listProjectsTool,
|
|
31
32
|
list_tests_and_projects_1.listTestsForProjectTool,
|
|
32
|
-
...tools_1.testGenerationTools,
|
|
33
33
|
diagnosis_fetcher_1.fetchDiagnosisReportTool,
|
|
34
34
|
...(0, tools_1.textEditorToolsForModel)(this.selectedModel),
|
|
35
35
|
tools_1.safeBashTool,
|
|
36
36
|
...(!(0, tools_1.hasBuiltInWebFetch)(this.selectedModel) ? [tools_1.scrapeHtmlTool] : []),
|
|
37
|
+
...tools_1.testGenerationToolsWithoutBrowserAgent,
|
|
38
|
+
...(!hasSkills ? [api_client_1.apiClientTool, test_gen_browser_1.generateTestWithBrowserAgent] : []),
|
|
37
39
|
];
|
|
38
40
|
return {
|
|
39
41
|
custom,
|
|
@@ -46,6 +48,8 @@ class ChatAgent extends base_1.BaseAgent {
|
|
|
46
48
|
async buildSystemPrompt(repoInfoBuilder) {
|
|
47
49
|
const repoInfo = await repoInfoBuilder();
|
|
48
50
|
const repoContext = await (0, repo_1.getRepoContextPrompt)(repoInfo);
|
|
51
|
+
const hasSkills = this.featureFlags.includes("useSkills");
|
|
52
|
+
const skillsInToolsPrompt = hasSkills ? skills_1.skillsToolsPrompt : "";
|
|
49
53
|
const preamble = `
|
|
50
54
|
You are a helpful assistant that can answer questions and help with tasks related to writing and maintaining Playwright tests.
|
|
51
55
|
|
|
@@ -71,7 +75,7 @@ fixed with modifications to the test code, and it is your job to do that.
|
|
|
71
75
|
|
|
72
76
|
You are given a set of tools (= functions) to help you fulfill the user's request. Read their descriptions
|
|
73
77
|
to understand what each tool does. You are HIGHLY encouraged to use tools and generate a high quality output.
|
|
74
|
-
|
|
78
|
+
${skillsInToolsPrompt}
|
|
75
79
|
For example,
|
|
76
80
|
|
|
77
81
|
1. If you are adding or modifying a test, run the test to ensure it works well.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const skillsToolsPrompt: string;
|
|
2
|
+
export declare const skillsProactivenessPrompt = "\nIf your listed tools don't seem sufficient for a task, load a relevant skill file using the bash tool to learn how to accomplish the task with your existing tools.\n";
|
|
3
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../../../src/agent/chat/prompt/skills.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,iBAAiB,QAO7B,CAAC;AAEF,eAAO,MAAM,yBAAyB,4KAErC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.skillsProactivenessPrompt = exports.skillsToolsPrompt = void 0;
|
|
4
|
+
const availableSkills = [
|
|
5
|
+
{
|
|
6
|
+
name: "empirical-api",
|
|
7
|
+
description: "Interact with the Empirical dashboard via API. Load this skill whenever you need to access dashboard data such as test runs, resources, or any project-level information.",
|
|
8
|
+
location: "/opt/skills/empirical-api/SKILL.md",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: "playwright-cli",
|
|
12
|
+
description: "Interact with browsers via playwright-cli for test generation, debugging, and exploration. Use when asked to generate, modify, or fix Playwright tests, explore a website or debug test failures.",
|
|
13
|
+
location: "/opt/skills/playwright-cli/SKILL.md",
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
const skillToXml = (s) => {
|
|
17
|
+
return `<skill>
|
|
18
|
+
<name>${s.name}</name>
|
|
19
|
+
<description>${s.description}</description>
|
|
20
|
+
<location>${s.location}</location>
|
|
21
|
+
</skill>`;
|
|
22
|
+
};
|
|
23
|
+
const skillCatalogXml = `<available_skills>
|
|
24
|
+
${availableSkills.map(skillToXml).join("\n")}
|
|
25
|
+
</available_skills>`;
|
|
26
|
+
exports.skillsToolsPrompt = `
|
|
27
|
+
You have access to **skill files** — documentation that teaches you how to accomplish tasks using your existing safeBash tool.
|
|
28
|
+
Skills are NOT callable functions. To use a skill, read its file with bash, then follow the instructions inside.
|
|
29
|
+
|
|
30
|
+
${skillCatalogXml}
|
|
31
|
+
|
|
32
|
+
To use a skill: run \`cat <location>\` using the bash tool, then follow the instructions in the output.
|
|
33
|
+
`;
|
|
34
|
+
exports.skillsProactivenessPrompt = `
|
|
35
|
+
If your listed tools don't seem sufficient for a task, load a relevant skill file using the bash tool to learn how to accomplish the task with your existing tools.
|
|
36
|
+
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/triage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAepE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,qBAAa,WAAW,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC9C,SAAS,CAAC,QAAQ,IAAI,WAAW;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/triage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAepE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIpC,qBAAa,WAAW,CAAC,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC9C,SAAS,CAAC,QAAQ,IAAI,WAAW;cA6BjB,iBAAiB,CAC/B,eAAe,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,GACvC,OAAO,CAAC,MAAM,CAAC;CAgEnB"}
|
|
@@ -19,6 +19,7 @@ const repo_1 = require("../chat/prompt/repo");
|
|
|
19
19
|
const test_case_def_1 = require("../chat/prompt/test-case-def");
|
|
20
20
|
class TriageAgent extends base_1.BaseAgent {
|
|
21
21
|
getTools() {
|
|
22
|
+
const hasAnalyseVideoTool = this.featureFlags.includes("has_analyse_video_tool");
|
|
22
23
|
const tools = [
|
|
23
24
|
// Tools to understand test run (open report)
|
|
24
25
|
diagnosis_fetcher_1.fetchDiagnosisReportTool,
|
|
@@ -26,7 +27,7 @@ class TriageAgent extends base_1.BaseAgent {
|
|
|
26
27
|
list_environments_1.listEnvironmentsTool,
|
|
27
28
|
// Tools to analyse report artifacts
|
|
28
29
|
fetch_file_1.fetchFileTool,
|
|
29
|
-
analyse_video_1.analyseVideo,
|
|
30
|
+
...(hasAnalyseVideoTool ? [analyse_video_1.analyseVideo] : []),
|
|
30
31
|
trace_dot_zip_1.traceDotZip,
|
|
31
32
|
// Tools to get test case context from the repo
|
|
32
33
|
grep_1.grepTool,
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { IDashboardAPIClient } from "@empiricalrun/shared-types/api/base";
|
|
2
|
-
import { FileInfo
|
|
3
|
-
export declare class GitHubFileReader {
|
|
4
|
-
private repoName;
|
|
5
|
-
private apiClient;
|
|
6
|
-
constructor(repoName: string, apiClient: IDashboardAPIClient);
|
|
7
|
-
resolveBranchName(branchName: string | undefined, baseBranch: string): Promise<string>;
|
|
8
|
-
readFile(filePath: string, branchName: string, baseBranch: string): Promise<FileReadResult | null>;
|
|
9
|
-
private readDirectory;
|
|
10
|
-
}
|
|
2
|
+
import { FileInfo } from "@empiricalrun/shared-types/test-gen";
|
|
11
3
|
export declare function getFileInfoFromGitHub(repoName: string, apiClient: IDashboardAPIClient, branchName: string, baseBranchName: string): Promise<FileInfo>;
|
|
12
4
|
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../../src/file-info/adapters/github/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../../src/file-info/adapters/github/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAqF/D,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,QAAQ,CAAC,CAyFnB"}
|
|
@@ -3,134 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GitHubFileReader = void 0;
|
|
7
6
|
exports.getFileInfoFromGitHub = getFileInfoFromGitHub;
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
function
|
|
10
|
-
const base = path_1.default.basename(filename);
|
|
11
|
-
return base.startsWith(".") && base !== "." && base !== "..";
|
|
12
|
-
}
|
|
13
|
-
function isDirectory(filename) {
|
|
14
|
-
const hasFileExtension = path_1.default.extname(filename) !== "";
|
|
15
|
-
return !isDotfile(filename) && !hasFileExtension;
|
|
16
|
-
}
|
|
17
|
-
class GitHubFileReader {
|
|
18
|
-
repoName;
|
|
19
|
-
apiClient;
|
|
20
|
-
constructor(repoName, apiClient) {
|
|
21
|
-
this.repoName = repoName;
|
|
22
|
-
this.apiClient = apiClient;
|
|
23
|
-
}
|
|
24
|
-
async resolveBranchName(branchName, baseBranch) {
|
|
25
|
-
if (!branchName || branchName === baseBranch) {
|
|
26
|
-
return baseBranch;
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
await this.apiClient.callGitHubProxy({
|
|
30
|
-
method: "GET",
|
|
31
|
-
url: `/repos/empirical-run/${this.repoName}/branches/${branchName}`,
|
|
32
|
-
});
|
|
33
|
-
console.log(`[GitHubFileReader] Branch ${branchName} exists`);
|
|
34
|
-
return branchName;
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
console.log(`[GitHubFileReader] Branch ${branchName} not found, falling back to ${baseBranch}`);
|
|
38
|
-
return baseBranch;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async readFile(filePath, branchName, baseBranch) {
|
|
42
|
-
const resolvedBranch = await this.resolveBranchName(branchName, baseBranch);
|
|
43
|
-
if (isDirectory(filePath)) {
|
|
44
|
-
console.log(`[GitHubFileReader] Reading as directory: ${filePath}`);
|
|
45
|
-
return this.readDirectory(filePath, resolvedBranch);
|
|
46
|
-
}
|
|
47
|
-
// For dotfiles without extensions (e.g. .empiricalrun, .github), we can't
|
|
48
|
-
// tell if they're files or directories by name alone. Try directory first
|
|
49
|
-
// since that API is faster and won't hang for misclassified paths.
|
|
50
|
-
if (isDotfile(filePath) && !path_1.default.extname(filePath)) {
|
|
51
|
-
console.log(`[GitHubFileReader] Dotfile without extension, trying directory first: ${filePath}`);
|
|
52
|
-
const dirResult = await this.readDirectory(filePath, resolvedBranch);
|
|
53
|
-
if (dirResult) {
|
|
54
|
-
return dirResult;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
console.log(`[GitHubFileReader] Reading as file: ${filePath}, resolved branch: ${resolvedBranch}`);
|
|
59
|
-
const params = {
|
|
60
|
-
repo: this.repoName,
|
|
61
|
-
path: filePath,
|
|
62
|
-
ref: resolvedBranch,
|
|
63
|
-
};
|
|
64
|
-
const response = await this.apiClient.request(`/api/github/files`, {
|
|
65
|
-
method: "GET",
|
|
66
|
-
params,
|
|
67
|
-
});
|
|
68
|
-
if (response.data?.fileContents.available) {
|
|
69
|
-
return {
|
|
70
|
-
content: response.data.fileContents.content,
|
|
71
|
-
isDirectory: false,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
console.log(`[GitHubFileReader] File not available: ${filePath}`);
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
console.log(`[GitHubFileReader] Error reading file ${filePath}:`, error);
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async readDirectory(filePath, resolvedBranch) {
|
|
83
|
-
try {
|
|
84
|
-
console.log(`[GitHubFileReader] Reading directory: ${filePath}, resolved branch: ${resolvedBranch}`);
|
|
85
|
-
const params = {
|
|
86
|
-
repo: this.repoName,
|
|
87
|
-
path: filePath || ".", // Handle empty path
|
|
88
|
-
ref: resolvedBranch,
|
|
89
|
-
};
|
|
90
|
-
const treeResponse = await this.apiClient.request(`/api/github/tree`, {
|
|
91
|
-
method: "GET",
|
|
92
|
-
params,
|
|
93
|
-
});
|
|
94
|
-
if (treeResponse.data?.tree) {
|
|
95
|
-
const targetPath = filePath === "." || filePath === "" ? "" : filePath;
|
|
96
|
-
const files = treeResponse.data.tree.tree
|
|
97
|
-
.map((item) => item.path)
|
|
98
|
-
.filter((itemPath) => {
|
|
99
|
-
if (!itemPath)
|
|
100
|
-
return false;
|
|
101
|
-
// Check if item is a direct child of the target directory
|
|
102
|
-
const itemDir = path_1.default.dirname(itemPath);
|
|
103
|
-
// Normalize "." to "" for root directory comparison
|
|
104
|
-
const normalizedItemDir = itemDir === "." ? "" : itemDir;
|
|
105
|
-
return normalizedItemDir === targetPath;
|
|
106
|
-
})
|
|
107
|
-
.map((itemPath) => path_1.default.basename(itemPath))
|
|
108
|
-
.sort()
|
|
109
|
-
.join("\n");
|
|
110
|
-
if (files.length === 0) {
|
|
111
|
-
// No files means directory is invalid
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
return { content: files, isDirectory: true };
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
console.log(`[GitHubFileReader] Error reading directory ${filePath}:`, error);
|
|
121
|
-
}
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.GitHubFileReader = GitHubFileReader;
|
|
126
|
-
async function getFileContent(repoName, path, apiClient, branchName) {
|
|
8
|
+
async function getFileContent(repoName, path, apiClient, branchName, baseBranch) {
|
|
127
9
|
const params = {
|
|
128
10
|
repo: repoName,
|
|
129
11
|
path: path,
|
|
12
|
+
ref: branchName,
|
|
13
|
+
baseBranch,
|
|
130
14
|
};
|
|
131
|
-
if (branchName) {
|
|
132
|
-
params.ref = branchName;
|
|
133
|
-
}
|
|
134
15
|
const response = await apiClient.request(`/api/github/files`, {
|
|
135
16
|
method: "GET",
|
|
136
17
|
params,
|
|
@@ -140,14 +21,13 @@ async function getFileContent(repoName, path, apiClient, branchName) {
|
|
|
140
21
|
}
|
|
141
22
|
return response.data.fileContents.content;
|
|
142
23
|
}
|
|
143
|
-
async function getContentsForDirectory({ repo, path, }, apiClient, branchName) {
|
|
24
|
+
async function getContentsForDirectory({ repo, path, }, apiClient, branchName, baseBranch) {
|
|
144
25
|
const params = {
|
|
145
26
|
repo: repo,
|
|
146
27
|
path: path,
|
|
28
|
+
ref: branchName,
|
|
29
|
+
baseBranch,
|
|
147
30
|
};
|
|
148
|
-
if (branchName) {
|
|
149
|
-
params.ref = branchName;
|
|
150
|
-
}
|
|
151
31
|
const response = await apiClient.request(`/api/github/tree`, {
|
|
152
32
|
method: "GET",
|
|
153
33
|
params,
|
|
@@ -158,9 +38,7 @@ async function getContentsForDirectory({ repo, path, }, apiClient, branchName) {
|
|
|
158
38
|
return response.data.tree;
|
|
159
39
|
}
|
|
160
40
|
async function getFileInfoFromGitHub(repoName, apiClient, branchName, baseBranchName) {
|
|
161
|
-
const
|
|
162
|
-
const resolvedBranch = await fileReader.resolveBranchName(branchName, baseBranchName);
|
|
163
|
-
const files = await getContentsForDirectory({ repo: repoName, path: "" }, apiClient, resolvedBranch);
|
|
41
|
+
const files = await getContentsForDirectory({ repo: repoName, path: "" }, apiClient, branchName, baseBranchName);
|
|
164
42
|
const root = [];
|
|
165
43
|
const nodeMap = {};
|
|
166
44
|
if (!files) {
|
|
@@ -184,7 +62,7 @@ async function getFileInfoFromGitHub(repoName, apiClient, branchName, baseBranch
|
|
|
184
62
|
type: "file",
|
|
185
63
|
path: currentPath,
|
|
186
64
|
name: fileName,
|
|
187
|
-
getContent: async () => getFileContent(repoName, currentPath, apiClient,
|
|
65
|
+
getContent: async () => getFileContent(repoName, currentPath, apiClient, branchName, baseBranchName),
|
|
188
66
|
}
|
|
189
67
|
: {
|
|
190
68
|
type: "directory",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file-info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file-info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC"}
|
package/dist/file-info/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getFileInfoFromFS = exports.FilesystemFileReader = exports.viewFileUsingFileSystem = void 0;
|
|
4
4
|
var file_system_1 = require("./adapters/file-system");
|
|
5
5
|
Object.defineProperty(exports, "viewFileUsingFileSystem", { enumerable: true, get: function () { return file_system_1.viewFileUsingFileSystem; } });
|
|
6
6
|
var reader_1 = require("./adapters/file-system/reader");
|
|
7
7
|
Object.defineProperty(exports, "FilesystemFileReader", { enumerable: true, get: function () { return reader_1.FilesystemFileReader; } });
|
|
8
8
|
Object.defineProperty(exports, "getFileInfoFromFS", { enumerable: true, get: function () { return reader_1.getFileInfoFromFS; } });
|
|
9
|
-
var github_1 = require("./adapters/github");
|
|
10
|
-
Object.defineProperty(exports, "viewFileUsingGitHub", { enumerable: true, get: function () { return github_1.viewFileUsingGitHub; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,KAAK,EACN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAM3E,MAAM,MAAM,YAAY,GAAG;IACzB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAsB,UAAU,CAC9B,KAAK,EAAE,cAAc,EACrB,GAAG,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,eAAe,EAAE,MAAM,EACvB,GAAG,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,EACxB,GAAG,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,KAAK,EACN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAM3E,MAAM,MAAM,YAAY,GAAG;IACzB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAsB,UAAU,CAC9B,KAAK,EAAE,cAAc,EACrB,GAAG,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,eAAe,EAAE,MAAM,EACvB,GAAG,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,EACxB,GAAG,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBhB"}
|
package/dist/telemetry/index.js
CHANGED
|
@@ -80,6 +80,8 @@ async function trackLLMResponse(opts) {
|
|
|
80
80
|
tokens_output: opts.usage.tokens?.output || 0,
|
|
81
81
|
cost_input: opts.usage.cost?.input || 0,
|
|
82
82
|
cost_output: opts.usage.cost?.output || 0,
|
|
83
|
+
tokens_cache_read: opts.usage.tokens?.cache_read || 0,
|
|
84
|
+
tokens_cache_creation: opts.usage.tokens?.cache_creation || 0,
|
|
83
85
|
// Moving project_repo_name -> repo_name for consistency with other events
|
|
84
86
|
project_repo_name: opts.projectRepoName,
|
|
85
87
|
repo_name: opts.projectRepoName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/api-client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAkBlE,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/api-client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAkBlE,eAAO,MAAM,aAAa,EAAE,IA2I3B,CAAC"}
|
|
@@ -39,6 +39,94 @@ Returns: { data: { test_runs: [...], total, limit, offset } }
|
|
|
39
39
|
\`GET /api/test-runs/:id\`
|
|
40
40
|
|
|
41
41
|
Returns: { data: { test_run: { testRun: { id, state, duration, environment_name, environment_slug, build_url, build_branch, commit, run_started_at, run_ended_at, ... } } } }
|
|
42
|
+
|
|
43
|
+
### List files
|
|
44
|
+
\`GET /api/files\`
|
|
45
|
+
|
|
46
|
+
Returns uploaded project files (docs, videos, etc).
|
|
47
|
+
|
|
48
|
+
Query params:
|
|
49
|
+
- page: Page number (1-indexed, default 1)
|
|
50
|
+
- per_page: Items per page (default 20)
|
|
51
|
+
|
|
52
|
+
Returns: { data: { files: [{ id, name, url, description, mime_type, size_bytes, status, access_level, created_at, ... }] }, pagination: { page, per_page, total, total_pages } }
|
|
53
|
+
For link-type files (e.g. Google Sheets), access_level is "read_write", "read", or "none".
|
|
54
|
+
|
|
55
|
+
### Get a file by ID
|
|
56
|
+
\`GET /api/files/:id\`
|
|
57
|
+
|
|
58
|
+
Returns: { data: { file: { id, name, url, description, mime_type, size_bytes, status, created_at, ... } } }
|
|
59
|
+
|
|
60
|
+
### Create a file
|
|
61
|
+
\`POST /api/files\`
|
|
62
|
+
|
|
63
|
+
Body: { project_id: number, name: string, mime_type?: string, size_bytes?: number, url?: string, description?: string }
|
|
64
|
+
|
|
65
|
+
Returns: { data: { file: { id, name, upload_url, ... } } }
|
|
66
|
+
The upload_url is a presigned URL for uploading the file content via PUT.
|
|
67
|
+
|
|
68
|
+
**Link-type files (e.g. Google Sheets):** Pass \`url\` to create a link file instead of uploading. The file is immediately marked as "uploaded" with no R2 storage needed.
|
|
69
|
+
Example: { "name": "Test Cases Sheet", "url": "https://docs.google.com/spreadsheets/d/abc123/edit", "description": "Main test cases tracking sheet" }
|
|
70
|
+
|
|
71
|
+
### Update a file
|
|
72
|
+
\`PATCH /api/files/:id\`
|
|
73
|
+
|
|
74
|
+
Body: { name?: string, description?: string, status?: "uploaded" }
|
|
75
|
+
After uploading file content, set status to "uploaded" to make it visible.
|
|
76
|
+
|
|
77
|
+
Returns: { data: { file: { ... } } }
|
|
78
|
+
|
|
79
|
+
### Delete a file
|
|
80
|
+
\`DELETE /api/files/:id\`
|
|
81
|
+
|
|
82
|
+
Returns: { data: { result: { success: true } } }
|
|
83
|
+
|
|
84
|
+
### Google Sheets proxy
|
|
85
|
+
\`POST /api/gsheet/proxy\`
|
|
86
|
+
|
|
87
|
+
Read, write, or append to a Google Sheet via the dashboard's service account.
|
|
88
|
+
|
|
89
|
+
Body:
|
|
90
|
+
- action: "read" | "write" | "append"
|
|
91
|
+
- spreadsheet_id: The spreadsheet ID (from the Google Sheet URL between /d/ and /edit)
|
|
92
|
+
- range: Sheet range (e.g. "Sheet1", "Sheet1!A1:D10")
|
|
93
|
+
- values: 2D array of strings (required for write and append actions)
|
|
94
|
+
|
|
95
|
+
**Read example:**
|
|
96
|
+
\`\`\`json
|
|
97
|
+
{ "action": "read", "spreadsheet_id": "abc123", "range": "Sheet1!A1:D10" }
|
|
98
|
+
\`\`\`
|
|
99
|
+
Returns: { data: { values: [["row1col1", "row1col2"], ...] } }
|
|
100
|
+
|
|
101
|
+
**Write (overwrite) example:**
|
|
102
|
+
\`\`\`json
|
|
103
|
+
{ "action": "write", "spreadsheet_id": "abc123", "range": "Sheet1!A1:B2", "values": [["a","b"],["c","d"]] }
|
|
104
|
+
\`\`\`
|
|
105
|
+
Returns: { data: { updated_cells: 4 } }
|
|
106
|
+
|
|
107
|
+
**Append rows example:**
|
|
108
|
+
\`\`\`json
|
|
109
|
+
{ "action": "append", "spreadsheet_id": "abc123", "range": "Sheet1", "values": [["new","row"]] }
|
|
110
|
+
\`\`\`
|
|
111
|
+
Returns: { data: { updated_cells: 2 } }
|
|
112
|
+
|
|
113
|
+
**Important:** The append action auto-detects table boundaries and may place data in unexpected columns. For precise cell placement, use the "write" action with an explicit cell range (e.g. "Sheet1!D6") instead.
|
|
114
|
+
|
|
115
|
+
## Using curl via bash
|
|
116
|
+
|
|
117
|
+
You can also make these API calls using curl in the bash tool. The API key is available as \`$EMPIRICALRUN_API_KEY\` and the dashboard base URL is \`https://dash.empirical.run\` (or \`$DASHBOARD_DOMAIN\` if set).
|
|
118
|
+
|
|
119
|
+
Example - list files:
|
|
120
|
+
\`\`\`
|
|
121
|
+
curl -s -H "Authorization: Bearer $EMPIRICALRUN_API_KEY" "https://dash.empirical.run/api/files"
|
|
122
|
+
\`\`\`
|
|
123
|
+
|
|
124
|
+
Example - download a file (use the signed \`url\` from a file response):
|
|
125
|
+
\`\`\`
|
|
126
|
+
curl -s -o output_file "<signed_url>"
|
|
127
|
+
\`\`\`
|
|
128
|
+
|
|
129
|
+
This is especially useful for downloading files (via signed URLs) to the local filesystem for processing.
|
|
42
130
|
`,
|
|
43
131
|
parameters: APIClientSchema,
|
|
44
132
|
},
|
|
@@ -55,9 +143,6 @@ Returns: { data: { test_run: { testRun: { id, state, duration, environment_name,
|
|
|
55
143
|
params,
|
|
56
144
|
...(input.body && { body: input.body }),
|
|
57
145
|
});
|
|
58
|
-
if (response?.data?.test_run?.flattenedSummaryDetails) {
|
|
59
|
-
delete response.data.test_run.flattenedSummaryDetails;
|
|
60
|
-
}
|
|
61
146
|
return {
|
|
62
147
|
isError: false,
|
|
63
148
|
result: JSON.stringify(response, null, 2),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/executor/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/executor/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAEjE,YAAY,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,YAAY,EACV,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,YAAa,SAAQ,gBAAgB;gBACpC,MAAM,EAAE,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC;CAiCzD"}
|
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ToolExecutor = exports.gitPushChanges = exports.BaseToolExecutor = void 0;
|
|
4
4
|
const analyse_video_1 = require("../analyse-video");
|
|
5
|
+
const api_client_1 = require("../api-client");
|
|
5
6
|
const create_pull_request_1 = require("../create-pull-request");
|
|
6
7
|
const delete_file_1 = require("../delete-file");
|
|
7
8
|
const diagnosis_fetcher_1 = require("../diagnosis-fetcher");
|
|
8
9
|
const fetch_file_1 = require("../fetch-file");
|
|
9
10
|
const fetch_session_diff_1 = require("../fetch-session-diff");
|
|
10
11
|
const file_operations_1 = require("../file-operations");
|
|
12
|
+
const firecrawl_scrape_1 = require("../firecrawl-scrape");
|
|
11
13
|
const grep_1 = require("../grep");
|
|
12
14
|
const issues_v1_1 = require("../issues-v1");
|
|
15
|
+
const create_issue_1 = require("../issues-v2/create-issue");
|
|
16
|
+
const set_issue_description_1 = require("../issues-v2/set-issue-description");
|
|
17
|
+
const update_issue_1 = require("../issues-v2/update-issue");
|
|
13
18
|
const list_environments_1 = require("../list-environments");
|
|
14
19
|
const list_tests_and_projects_1 = require("../list-tests-and-projects");
|
|
15
20
|
const merge_conflicts_1 = require("../merge-conflicts");
|
|
@@ -17,6 +22,7 @@ const publish_markdown_report_1 = require("../publish-markdown-report");
|
|
|
17
22
|
const rename_file_1 = require("../rename-file");
|
|
18
23
|
const run_test_1 = require("../run-test");
|
|
19
24
|
const safe_bash_1 = require("../safe-bash");
|
|
25
|
+
const slack_message_1 = require("../slack-message");
|
|
20
26
|
const test_gen_browser_1 = require("../test-gen-browser");
|
|
21
27
|
const test_run_fetcher_1 = require("../test-run-fetcher");
|
|
22
28
|
const trace_dot_zip_1 = require("../trace-dot-zip");
|
|
@@ -50,6 +56,12 @@ class ToolExecutor extends base_1.BaseToolExecutor {
|
|
|
50
56
|
fetch_session_diff_1.fetchSessionDiffTool,
|
|
51
57
|
list_tests_and_projects_1.listTestsForProjectTool,
|
|
52
58
|
safe_bash_1.safeBashTool,
|
|
59
|
+
api_client_1.apiClientTool,
|
|
60
|
+
create_issue_1.createIssueTool,
|
|
61
|
+
set_issue_description_1.setIssueDescriptionTool,
|
|
62
|
+
update_issue_1.updateIssueTool,
|
|
63
|
+
firecrawl_scrape_1.scrapeHtmlTool,
|
|
64
|
+
slack_message_1.slackMessageTool,
|
|
53
65
|
...file_operations_1.textEditorTools,
|
|
54
66
|
];
|
|
55
67
|
super({ ...params, tools });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/fetch-file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAGL,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/fetch-file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAGL,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmGxB,QAAA,MAAM,eAAe;;iBAEnB,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAqJ/D,CAAC"}
|
|
@@ -8,6 +8,7 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const zod_1 = require("zod");
|
|
10
10
|
const url_validation_1 = require("../../utils/url-validation");
|
|
11
|
+
const apply_line_limit_1 = require("../utils/apply-line-limit");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
12
13
|
const SUPPORTED_IMAGE_TYPES = [
|
|
13
14
|
"image/png",
|
|
@@ -16,15 +17,6 @@ const SUPPORTED_IMAGE_TYPES = [
|
|
|
16
17
|
"image/webp",
|
|
17
18
|
];
|
|
18
19
|
const SUPPORTED_TEXT_TYPES = ["text/markdown", "text/plain"];
|
|
19
|
-
function applyLineLimit(text, url) {
|
|
20
|
-
const lines = text.split("\n");
|
|
21
|
-
if (lines.length <= 100) {
|
|
22
|
-
return text;
|
|
23
|
-
}
|
|
24
|
-
const trimmedText = lines.slice(0, 100).join("\n");
|
|
25
|
-
const message = `\n\n[Output trimmed: This file contains ${lines.length} lines, showing first 100 lines. To get the full output, use the Bash tool to fetch via curl and search the response: curl "${url}"]`;
|
|
26
|
-
return trimmedText + message;
|
|
27
|
-
}
|
|
28
20
|
async function handleLocalFile(filePath, logger, featureFlags) {
|
|
29
21
|
const ext = path_1.default.extname(filePath).toLowerCase();
|
|
30
22
|
const isImage = [".png", ".jpg", ".jpeg", ".gif", ".webp"].includes(ext);
|
|
@@ -64,7 +56,7 @@ async function handleLocalFile(filePath, logger, featureFlags) {
|
|
|
64
56
|
}
|
|
65
57
|
else {
|
|
66
58
|
const text = buffer.toString("utf-8");
|
|
67
|
-
const processedText = applyLineLimit(text, `file://${filePath}`);
|
|
59
|
+
const processedText = (0, apply_line_limit_1.applyLineLimit)(text, (0, apply_line_limit_1.fetchFileTrimMessage)(`file://${filePath}`));
|
|
68
60
|
logger.info("Successfully read local text file", {
|
|
69
61
|
tool: "fetchFileTool",
|
|
70
62
|
filePath,
|
|
@@ -200,7 +192,7 @@ time of test failures. Both of these are available in the attachments section of
|
|
|
200
192
|
// Handle text/markdown files
|
|
201
193
|
const contentResponse = await fetch(url);
|
|
202
194
|
const text = await contentResponse.text();
|
|
203
|
-
const processedText = applyLineLimit(text, url);
|
|
195
|
+
const processedText = (0, apply_line_limit_1.applyLineLimit)(text, (0, apply_line_limit_1.fetchFileTrimMessage)(url));
|
|
204
196
|
logger.info("Successfully fetched text file", {
|
|
205
197
|
tool: "fetchFileTool",
|
|
206
198
|
url,
|