@empiricalrun/test-gen 0.79.1 → 0.79.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 +6 -0
- package/dist/agent/base/index.d.ts +2 -0
- package/dist/agent/base/index.d.ts.map +1 -1
- package/dist/agent/base/index.js +4 -0
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +0 -1
- package/dist/agent/chat/exports.d.ts +2 -2
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +1 -2
- package/dist/agent/cua/model.d.ts +1 -0
- package/dist/agent/cua/model.d.ts.map +1 -1
- package/dist/agent/cua/model.js +4 -3
- package/dist/artifacts/index.d.ts +0 -39
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +8 -68
- package/dist/telemetry/index.d.ts +18 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +83 -0
- package/dist/tools/analyse-video/index.d.ts.map +1 -1
- package/dist/tools/analyse-video/index.js +14 -2
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +0 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -2
- package/dist/tools/run-test.js +1 -1
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +12 -1
- package/dist/video-core/index.d.ts +9 -12
- package/dist/video-core/index.d.ts.map +1 -1
- package/dist/video-core/index.js +93 -111
- package/dist/video-core/utils.d.ts +2 -1
- package/dist/video-core/utils.d.ts.map +1 -1
- package/dist/video-core/utils.js +15 -0
- package/package.json +12 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/tools/definitions/review-pull-request.d.ts +0 -3
- package/dist/tools/definitions/review-pull-request.d.ts.map +0 -1
- package/dist/tools/definitions/review-pull-request.js +0 -16
- package/dist/tools/review-pull-request/index.d.ts +0 -3
- package/dist/tools/review-pull-request/index.d.ts.map +0 -1
- package/dist/tools/review-pull-request/index.js +0 -83
package/CHANGELOG.md
CHANGED
|
@@ -25,6 +25,7 @@ export type AgentParams<T> = AgentParamsWithoutPrompt<T> & ({
|
|
|
25
25
|
repoInfoBuilder: () => Promise<FileInfo>;
|
|
26
26
|
});
|
|
27
27
|
export type OnToolResultsProcessedCallback = (newChatState: ChatState) => Promise<void>;
|
|
28
|
+
export type OnToolCallCallback = (toolCalls: PendingToolCall[]) => Promise<void>;
|
|
28
29
|
export type OnLLMResponseCallback<T> = (response: T, selectedModel: SupportedChatModels) => Promise<void>;
|
|
29
30
|
export declare abstract class BaseAgent<T> {
|
|
30
31
|
featureFlags: string[];
|
|
@@ -37,6 +38,7 @@ export declare abstract class BaseAgent<T> {
|
|
|
37
38
|
systemPrompt: string | undefined;
|
|
38
39
|
repoInfoBuilder: (() => Promise<FileInfo>) | undefined;
|
|
39
40
|
onToolResultsProcessed?: OnToolResultsProcessedCallback;
|
|
41
|
+
onToolCall?: OnToolCallCallback;
|
|
40
42
|
onLLMResponse?: OnLLMResponseCallback<T>;
|
|
41
43
|
constructor({ featureFlags, selectedModel, workerEnv, chatState, toolExecutor, trace, systemPrompt, repoInfoBuilder, }: AgentParams<T>);
|
|
42
44
|
protected abstract getTools(): ToolsForLLM;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,eAAe,EACf,8BAA8B,EAC9B,UAAU,EACV,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;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16,6 +16,7 @@ class BaseAgent {
|
|
|
16
16
|
systemPrompt;
|
|
17
17
|
repoInfoBuilder;
|
|
18
18
|
onToolResultsProcessed;
|
|
19
|
+
onToolCall;
|
|
19
20
|
onLLMResponse;
|
|
20
21
|
constructor({ featureFlags, selectedModel, workerEnv, chatState, toolExecutor, trace, systemPrompt, repoInfoBuilder, }) {
|
|
21
22
|
this.featureFlags = featureFlags || [];
|
|
@@ -107,6 +108,9 @@ class BaseAgent {
|
|
|
107
108
|
if (!this.toolExecutor) {
|
|
108
109
|
throw new Error("No toolExecutor configured");
|
|
109
110
|
}
|
|
111
|
+
if (this.onToolCall) {
|
|
112
|
+
await this.onToolCall(toolCalls);
|
|
113
|
+
}
|
|
110
114
|
const result = await this.toolExecutor.execute(toolCalls);
|
|
111
115
|
if (result.status === "completed") {
|
|
112
116
|
const newChatState = this.processToolResults(toolCalls, result.toolResults, result.checkpoint);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/agent-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAK/C,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACzB,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC9B,wBAAwB,CAAC,EAAE,4BAA4B,CAAC;IACxD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,WAAW,CAAC;IACnB,iBAAiB,E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AAa,EAAE,mBAAmB,KAC/B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAsB,aAAa,CAAC,CAAC,GAAG,gBAAgB,EAAE,EACxD,SAAS,EACT,QAAQ,EACR,wBAAwB,EACxB,KAAK,EACL,MAAM,EACN,YAAY,EACZ,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,YAAY,GACb,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CpC"}
|
|
@@ -16,7 +16,6 @@ async function chatAgentLoop({ chatModel, reporter, streamingMessageReporter, tr
|
|
|
16
16
|
await onPendingToolCall(toolCalls);
|
|
17
17
|
break;
|
|
18
18
|
}
|
|
19
|
-
(0, utils_1.log)(`${(0, utils_1.getModelName)(chatModel.selectedModel)} is working...`);
|
|
20
19
|
const response = await chatModel.getLLMResponse({
|
|
21
20
|
systemPrompt,
|
|
22
21
|
tools,
|
|
@@ -2,10 +2,10 @@ 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
4
|
export { getFileInfoFromGitHub, viewFileUsingGitHub, } from "../../file-info/adapters/github";
|
|
5
|
-
export type { AgentParams } from "../base";
|
|
5
|
+
export type { AgentParams, OnToolCallCallback } from "../base";
|
|
6
6
|
export { BaseAgent } from "../base";
|
|
7
7
|
export type { CodeReviewResultV0, CodeReviewResultV1, CodeReviewResultV2, CodeReviewVersionedResult, } from "../code-review";
|
|
8
|
-
export { CodeReviewAgent
|
|
8
|
+
export { CodeReviewAgent } from "../code-review";
|
|
9
9
|
export { TriageAgent } from "../triage";
|
|
10
10
|
export { ChatAgent } from "./index";
|
|
11
11
|
export { fetchToolCallFromId, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, } from "./state";
|
|
@@ -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,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
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,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,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,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractAttachments = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.fetchToolCallFromId = exports.ChatAgent = exports.TriageAgent = exports.
|
|
3
|
+
exports.extractAttachments = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.fetchToolCallFromId = exports.ChatAgent = exports.TriageAgent = exports.CodeReviewAgent = exports.BaseAgent = exports.viewFileUsingGitHub = 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");
|
|
@@ -12,7 +12,6 @@ var base_1 = require("../base");
|
|
|
12
12
|
Object.defineProperty(exports, "BaseAgent", { enumerable: true, get: function () { return base_1.BaseAgent; } });
|
|
13
13
|
var code_review_1 = require("../code-review");
|
|
14
14
|
Object.defineProperty(exports, "CodeReviewAgent", { enumerable: true, get: function () { return code_review_1.CodeReviewAgent; } });
|
|
15
|
-
Object.defineProperty(exports, "convertXmlToV2Format", { enumerable: true, get: function () { return code_review_1.convertXmlToV2Format; } });
|
|
16
15
|
var triage_1 = require("../triage");
|
|
17
16
|
Object.defineProperty(exports, "TriageAgent", { enumerable: true, get: function () { return triage_1.TriageAgent; } });
|
|
18
17
|
var index_1 = require("./index");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
2
|
import { Response, ResponseInputItem } from "openai/resources/responses/responses.mjs";
|
|
3
|
+
export declare const CUA_MODEL = "computer-use-preview-2025-03-11";
|
|
3
4
|
export declare function callComputerUseModel({ input, previousResponseId, screenWidth, screenHeight, openAIClient, }: {
|
|
4
5
|
input: ResponseInputItem[];
|
|
5
6
|
previousResponseId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/model.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAEL,QAAQ,EACR,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/agent/cua/model.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAEL,QAAQ,EACR,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAElD,eAAO,MAAM,SAAS,oCAAoC,CAAC;AAiC3D,wBAAsB,oBAAoB,CAAC,EACzC,KAAK,EACL,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,YAAY,GACb,EAAE;IACD,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuBpB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,qBAAqB,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD;;;;EAMA"}
|
package/dist/agent/cua/model.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CUA_MODEL = void 0;
|
|
3
4
|
exports.callComputerUseModel = callComputerUseModel;
|
|
4
5
|
exports.tokensToCost = tokensToCost;
|
|
5
6
|
const llm_1 = require("@empiricalrun/llm");
|
|
6
|
-
|
|
7
|
+
exports.CUA_MODEL = "computer-use-preview-2025-03-11";
|
|
7
8
|
const INSTRUCTIONS = `You will be asked to execute some actions in a browser context.
|
|
8
9
|
Don't ask the user for confirmations - just execute the actions.
|
|
9
10
|
|
|
@@ -34,7 +35,7 @@ const pageGotoTool = {
|
|
|
34
35
|
};
|
|
35
36
|
async function callComputerUseModel({ input, previousResponseId, screenWidth, screenHeight, openAIClient, }) {
|
|
36
37
|
const response = await openAIClient.responses.create({
|
|
37
|
-
model: CUA_MODEL,
|
|
38
|
+
model: exports.CUA_MODEL,
|
|
38
39
|
previous_response_id: previousResponseId,
|
|
39
40
|
parallel_tool_calls: false,
|
|
40
41
|
tools: [
|
|
@@ -61,5 +62,5 @@ function tokensToCost(usage) {
|
|
|
61
62
|
...usage,
|
|
62
63
|
total_tokens: usage.input_tokens + usage.output_tokens,
|
|
63
64
|
};
|
|
64
|
-
return (0, llm_1.calculateOpenAITokenCosts)({ usage: fullUsage, model: CUA_MODEL });
|
|
65
|
+
return (0, llm_1.calculateOpenAITokenCosts)({ usage: fullUsage, model: exports.CUA_MODEL });
|
|
65
66
|
}
|
|
@@ -1,44 +1,5 @@
|
|
|
1
1
|
import { Artifact, ArtifactInput } from "@empiricalrun/shared-types/chat-agent";
|
|
2
2
|
export declare function isArtifactCollectionEnabled(): string | undefined;
|
|
3
|
-
/**
|
|
4
|
-
* Collects artifacts from the repository directory and returns their URLs.
|
|
5
|
-
*
|
|
6
|
-
* @param inputs - An array of artifact inputs.
|
|
7
|
-
* @param repoDir - The absolute path to the repository directory.
|
|
8
|
-
* @param toolCallId - Unique identifier for the tool call.
|
|
9
|
-
* @returns An array of artifacts with their URLs.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* // Collect artifacts from both file paths and in-memory data
|
|
13
|
-
* const artifacts = await collectArtifacts([
|
|
14
|
-
* {
|
|
15
|
-
* name: "screenshot.png",
|
|
16
|
-
* contentType: "image/png",
|
|
17
|
-
* path: "/Users/project/screenshots/test.png"
|
|
18
|
-
* },
|
|
19
|
-
* {
|
|
20
|
-
* name: "log.txt",
|
|
21
|
-
* contentType: "text/plain",
|
|
22
|
-
* data: Buffer.from("test log content")
|
|
23
|
-
* }
|
|
24
|
-
* ], "/Users/project", "tool-123");
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Returns empty array when artifact collection is disabled
|
|
28
|
-
* const artifacts = await collectArtifacts([], "/Users/project", "tool-123");
|
|
29
|
-
* // Returns: []
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* // Throws error for invalid file paths
|
|
33
|
-
* await collectArtifacts([
|
|
34
|
-
* {
|
|
35
|
-
* name: "test.png",
|
|
36
|
-
* contentType: "image/png",
|
|
37
|
-
* path: "relative/path/test.png" // Invalid - not absolute path
|
|
38
|
-
* }
|
|
39
|
-
* ], "/Users/project", "tool-123");
|
|
40
|
-
* // Throws: "Invalid path: relative/path/test.png..."
|
|
41
|
-
*/
|
|
42
3
|
export declare function collectArtifacts(inputs: ArtifactInput[], repoDir: string, toolCallId: string): Promise<Artifact[]>;
|
|
43
4
|
export declare class UploadArtifactsQueue {
|
|
44
5
|
private toolCallId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,aAAa,EAId,MAAM,uCAAuC,CAAC;AAwB/C,wBAAgB,2BAA2B,uBAM1C;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,aAAa,EAId,MAAM,uCAAuC,CAAC;AAwB/C,wBAAgB,2BAA2B,uBAM1C;AAwGD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,EAAE,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAsErB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAoC;gBAE7C,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAK7C,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAiBlD,iBAAiB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;CAMtD"}
|
package/dist/artifacts/index.js
CHANGED
|
@@ -24,7 +24,10 @@ function isArtifactCollectionEnabled() {
|
|
|
24
24
|
process.env.R2_ACCESS_KEY_ID &&
|
|
25
25
|
process.env.R2_SECRET_ACCESS_KEY);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const bucket = {
|
|
28
|
+
name: "test-report",
|
|
29
|
+
baseUrl: "https://reports-r2.empirical.run",
|
|
30
|
+
};
|
|
28
31
|
async function collectInMemoryArtifacts(artifacts, { destinationDir, }) {
|
|
29
32
|
const dataFiles = artifacts.reduce((acc, a) => {
|
|
30
33
|
if (!Buffer.isBuffer(a.data)) {
|
|
@@ -49,7 +52,7 @@ async function collectInMemoryArtifacts(artifacts, { destinationDir, }) {
|
|
|
49
52
|
return (0, r2_uploader_1.uploadInMemoryFiles)({
|
|
50
53
|
files: dataFiles,
|
|
51
54
|
destinationDir,
|
|
52
|
-
uploadBucket:
|
|
55
|
+
uploadBucket: bucket.name,
|
|
53
56
|
accountId: process.env.R2_ACCOUNT_ID,
|
|
54
57
|
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
55
58
|
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
@@ -71,7 +74,7 @@ async function collectFilePathArtifacts(artifacts, { destinationDir, sourceDir,
|
|
|
71
74
|
fileList: filePaths,
|
|
72
75
|
sourceDir,
|
|
73
76
|
destinationDir,
|
|
74
|
-
uploadBucket:
|
|
77
|
+
uploadBucket: bucket.name,
|
|
75
78
|
accountId: process.env.R2_ACCOUNT_ID,
|
|
76
79
|
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
77
80
|
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
@@ -81,79 +84,16 @@ async function collectFilePathArtifacts(artifacts, { destinationDir, sourceDir,
|
|
|
81
84
|
files: filePaths,
|
|
82
85
|
sourceDir,
|
|
83
86
|
destinationDir,
|
|
84
|
-
bucket:
|
|
87
|
+
bucket: bucket.name,
|
|
85
88
|
});
|
|
86
89
|
throw error;
|
|
87
90
|
});
|
|
88
91
|
console.log("Uploaded path-based files:", urls);
|
|
89
92
|
return urls;
|
|
90
93
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Checks if a given path is a full (absolute) path that starts with the repository directory.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* // Valid full path
|
|
96
|
-
* const repoDir = "/Users/aashishwork/flash-tests";
|
|
97
|
-
* const path1 = "/Users/aashishwork/flash-tests/src/test.spec.ts";
|
|
98
|
-
* isFullPath(path1, repoDir); // Returns true
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* // Invalid - relative path
|
|
102
|
-
* const path2 = "src/test.spec.ts";
|
|
103
|
-
* isFullPath(path2, repoDir); // Returns false
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* // Invalid - absolute path but outside repo
|
|
107
|
-
* const path3 = "/Users/otheruser/project/test.spec.ts";
|
|
108
|
-
* isFullPath(path3, repoDir); // Returns false
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* // Valid full path with trailing slash
|
|
112
|
-
* const path4 = "/Users/aashishwork/flash-tests/";
|
|
113
|
-
* isFullPath(path4, repoDir); // Returns true
|
|
114
|
-
*/
|
|
115
94
|
function isFullPath(path, repoDir) {
|
|
116
95
|
return path.startsWith("/") && path.startsWith(repoDir);
|
|
117
96
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Collects artifacts from the repository directory and returns their URLs.
|
|
120
|
-
*
|
|
121
|
-
* @param inputs - An array of artifact inputs.
|
|
122
|
-
* @param repoDir - The absolute path to the repository directory.
|
|
123
|
-
* @param toolCallId - Unique identifier for the tool call.
|
|
124
|
-
* @returns An array of artifacts with their URLs.
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* // Collect artifacts from both file paths and in-memory data
|
|
128
|
-
* const artifacts = await collectArtifacts([
|
|
129
|
-
* {
|
|
130
|
-
* name: "screenshot.png",
|
|
131
|
-
* contentType: "image/png",
|
|
132
|
-
* path: "/Users/project/screenshots/test.png"
|
|
133
|
-
* },
|
|
134
|
-
* {
|
|
135
|
-
* name: "log.txt",
|
|
136
|
-
* contentType: "text/plain",
|
|
137
|
-
* data: Buffer.from("test log content")
|
|
138
|
-
* }
|
|
139
|
-
* ], "/Users/project", "tool-123");
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* // Returns empty array when artifact collection is disabled
|
|
143
|
-
* const artifacts = await collectArtifacts([], "/Users/project", "tool-123");
|
|
144
|
-
* // Returns: []
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* // Throws error for invalid file paths
|
|
148
|
-
* await collectArtifacts([
|
|
149
|
-
* {
|
|
150
|
-
* name: "test.png",
|
|
151
|
-
* contentType: "image/png",
|
|
152
|
-
* path: "relative/path/test.png" // Invalid - not absolute path
|
|
153
|
-
* }
|
|
154
|
-
* ], "/Users/project", "tool-123");
|
|
155
|
-
* // Throws: "Invalid path: relative/path/test.png..."
|
|
156
|
-
*/
|
|
157
97
|
async function collectArtifacts(inputs, repoDir, toolCallId) {
|
|
158
98
|
if (!isArtifactCollectionEnabled())
|
|
159
99
|
return [];
|
|
@@ -197,7 +137,7 @@ async function collectArtifacts(inputs, repoDir, toolCallId) {
|
|
|
197
137
|
? path_1.default.relative(repoDir, artifact.path)
|
|
198
138
|
: artifact.fileName;
|
|
199
139
|
const pathInBucket = path_1.default.join(destinationDir, relativePath);
|
|
200
|
-
url =
|
|
140
|
+
url = `${bucket.baseUrl}/${pathInBucket}`;
|
|
201
141
|
}
|
|
202
142
|
return {
|
|
203
143
|
name: artifact.name,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PendingToolCall, ToolResult, Usage } from "@empiricalrun/shared-types/chat-agent";
|
|
2
|
+
import type { TelemetryEvent } from "@empiricalrun/shared-types/telemetry";
|
|
3
|
+
export type TelemetryEnv = {
|
|
4
|
+
EMPIRICAL_TELEMETRY_API_KEY?: string;
|
|
5
|
+
ENVIRONMENT?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function trackEvent(event: TelemetryEvent, env?: TelemetryEnv): Promise<void>;
|
|
8
|
+
export declare function trackToolExecutionStarted(toolCall: PendingToolCall, chatSessionId: number, queuedTimestamp: number, env?: TelemetryEnv): Promise<void>;
|
|
9
|
+
export declare function trackToolExecutionCompleted(toolCall: PendingToolCall, toolResult: ToolResult, chatSessionId: number, queuedTimestamp: number, startedTimestamp: number, env?: TelemetryEnv): Promise<void>;
|
|
10
|
+
export declare function trackLLMResponse(opts: {
|
|
11
|
+
modelName: string;
|
|
12
|
+
projectRepoName: string;
|
|
13
|
+
chatSessionId?: number;
|
|
14
|
+
chatSessionSource: string;
|
|
15
|
+
usage: Usage;
|
|
16
|
+
env?: TelemetryEnv;
|
|
17
|
+
}): void;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,CAsBf;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,MAAM,EACrB,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,EACrB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,EACxB,GAAG,CAAC,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,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,IAAI,CAoBP"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackEvent = trackEvent;
|
|
4
|
+
exports.trackToolExecutionStarted = trackToolExecutionStarted;
|
|
5
|
+
exports.trackToolExecutionCompleted = trackToolExecutionCompleted;
|
|
6
|
+
exports.trackLLMResponse = trackLLMResponse;
|
|
7
|
+
const tools_1 = require("../tools");
|
|
8
|
+
const TELEMETRY_WORKER_URL = "https://telemetry-worker.empirical-run.workers.dev";
|
|
9
|
+
async function trackEvent(event, env) {
|
|
10
|
+
const apiKey = env?.EMPIRICAL_TELEMETRY_API_KEY || process.env.EMPIRICAL_TELEMETRY_API_KEY;
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`${TELEMETRY_WORKER_URL}/track`, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
Authorization: `Bearer ${apiKey}`,
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify(event),
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error(`Telemetry request failed: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Don't throw - telemetry failures shouldn't break the application
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function trackToolExecutionStarted(toolCall, chatSessionId, queuedTimestamp, env) {
|
|
32
|
+
const event = {
|
|
33
|
+
name: "tool_call_started",
|
|
34
|
+
properties: {
|
|
35
|
+
environment: env?.ENVIRONMENT || process.env.ENVIRONMENT || "unknown",
|
|
36
|
+
tool_name: (0, tools_1.nameForTelemetry)(toolCall),
|
|
37
|
+
tool_needs_browser: (0, tools_1.toolsNeedBrowser)([toolCall]),
|
|
38
|
+
tool_call_id: toolCall.id,
|
|
39
|
+
ms_since_queued: Date.now() - queuedTimestamp,
|
|
40
|
+
chat_session_id: chatSessionId,
|
|
41
|
+
machine_id: "inline",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
await trackEvent(event, env);
|
|
45
|
+
}
|
|
46
|
+
async function trackToolExecutionCompleted(toolCall, toolResult, chatSessionId, queuedTimestamp, startedTimestamp, env) {
|
|
47
|
+
const errorMessage = toolResult.isError && typeof toolResult.result === "string"
|
|
48
|
+
? toolResult.result
|
|
49
|
+
: null;
|
|
50
|
+
const event = {
|
|
51
|
+
name: "tool_call_completed",
|
|
52
|
+
properties: {
|
|
53
|
+
environment: env?.ENVIRONMENT || process.env.ENVIRONMENT || "unknown",
|
|
54
|
+
chat_session_id: chatSessionId,
|
|
55
|
+
tool_name: (0, tools_1.nameForTelemetry)(toolCall),
|
|
56
|
+
tool_needs_browser: (0, tools_1.toolsNeedBrowser)([toolCall]),
|
|
57
|
+
tool_call_id: toolCall.id,
|
|
58
|
+
is_error: toolResult.isError,
|
|
59
|
+
error_message: errorMessage,
|
|
60
|
+
machine_id: "inline",
|
|
61
|
+
ms_since_queued: Date.now() - queuedTimestamp,
|
|
62
|
+
ms_since_started: Date.now() - startedTimestamp,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
await trackEvent(event, env);
|
|
66
|
+
}
|
|
67
|
+
function trackLLMResponse(opts) {
|
|
68
|
+
const environment = opts.env?.ENVIRONMENT || process.env.ENVIRONMENT || "unknown";
|
|
69
|
+
void trackEvent({
|
|
70
|
+
name: "llm_response_generated",
|
|
71
|
+
properties: {
|
|
72
|
+
environment,
|
|
73
|
+
model_name: opts.modelName,
|
|
74
|
+
project_repo_name: opts.projectRepoName,
|
|
75
|
+
chat_session_id: opts.chatSessionId,
|
|
76
|
+
chat_session_source: opts.chatSessionSource,
|
|
77
|
+
tokens_input: opts.usage.tokens?.input || 0,
|
|
78
|
+
tokens_output: opts.usage.tokens?.output || 0,
|
|
79
|
+
cost_input: opts.usage.cost?.input || 0,
|
|
80
|
+
cost_output: opts.usage.cost?.output || 0,
|
|
81
|
+
},
|
|
82
|
+
}, opts.env);
|
|
83
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/analyse-video/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,IAAI,EAEL,MAAM,uCAAuC,CAAC;AAE/C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/analyse-video/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,IAAI,EAEL,MAAM,uCAAuC,CAAC;AAE/C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,OAAO,EACL,kBAAkB,EAEnB,MAAM,8BAA8B,CAAC;AAetC,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CA8DjE,CAAC"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.analyseVideo = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const constants_1 = require("../../constants");
|
|
9
|
+
const telemetry_1 = require("../../telemetry");
|
|
9
10
|
const hash_1 = require("../../utils/hash");
|
|
10
11
|
const url_validation_1 = require("../../utils/url-validation");
|
|
11
12
|
const video_core_1 = require("../../video-core");
|
|
@@ -19,7 +20,7 @@ function getVideoAnalysisParams(params) {
|
|
|
19
20
|
}
|
|
20
21
|
exports.analyseVideo = {
|
|
21
22
|
...analyse_video_1.analyseVideo,
|
|
22
|
-
execute: async ({ input, repoPath, logger }) => {
|
|
23
|
+
execute: async ({ input, repoPath, chatSession, logger }) => {
|
|
23
24
|
const { url } = input;
|
|
24
25
|
const params = getVideoAnalysisParams(input.params);
|
|
25
26
|
const videoHash = (0, hash_1.createHashBasedOnParams)(url, params);
|
|
@@ -36,11 +37,12 @@ exports.analyseVideo = {
|
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
const workingDirectory = node_path_1.default.join(repoPath, "video-analysis", videoHash);
|
|
39
|
-
const { result, error, interleaved_tool_result } = await (0, video_core_1.runVideoAnalysis)({
|
|
40
|
+
const { result, error, interleaved_tool_result, usage } = await (0, video_core_1.runVideoAnalysis)({
|
|
40
41
|
url,
|
|
41
42
|
videoHash,
|
|
42
43
|
params,
|
|
43
44
|
workingDirectory,
|
|
45
|
+
logger,
|
|
44
46
|
});
|
|
45
47
|
if (error) {
|
|
46
48
|
return {
|
|
@@ -48,6 +50,15 @@ exports.analyseVideo = {
|
|
|
48
50
|
result: error,
|
|
49
51
|
};
|
|
50
52
|
}
|
|
53
|
+
if (usage) {
|
|
54
|
+
(0, telemetry_1.trackLLMResponse)({
|
|
55
|
+
modelName: params.model,
|
|
56
|
+
projectRepoName: chatSession?.repoName || "unknown",
|
|
57
|
+
chatSessionId: chatSession?.id,
|
|
58
|
+
chatSessionSource: "video_analysis",
|
|
59
|
+
usage,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
51
62
|
const finalResult = [
|
|
52
63
|
{
|
|
53
64
|
type: "text",
|
|
@@ -58,6 +69,7 @@ exports.analyseVideo = {
|
|
|
58
69
|
return {
|
|
59
70
|
isError: error !== null,
|
|
60
71
|
result: finalResult,
|
|
72
|
+
usage,
|
|
61
73
|
};
|
|
62
74
|
},
|
|
63
75
|
};
|
|
@@ -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":"AAwBA,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;CA8BzD"}
|
|
@@ -15,7 +15,6 @@ const list_environments_1 = require("../list-environments");
|
|
|
15
15
|
const list_tests_and_projects_1 = require("../list-tests-and-projects");
|
|
16
16
|
const merge_conflicts_1 = require("../merge-conflicts");
|
|
17
17
|
const rename_file_1 = require("../rename-file");
|
|
18
|
-
const review_pull_request_1 = require("../review-pull-request");
|
|
19
18
|
const run_test_1 = require("../run-test");
|
|
20
19
|
const safe_bash_1 = require("../safe-bash");
|
|
21
20
|
const test_gen_browser_1 = require("../test-gen-browser");
|
|
@@ -53,7 +52,6 @@ class ToolExecutor extends base_1.BaseToolExecutor {
|
|
|
53
52
|
triage_summary_1.sendTriageSummaryTool,
|
|
54
53
|
list_tests_and_projects_1.listProjectsTool,
|
|
55
54
|
fetch_session_diff_1.fetchSessionDiffTool,
|
|
56
|
-
review_pull_request_1.reviewPullRequestTool,
|
|
57
55
|
list_tests_and_projects_1.listTestsForProjectTool,
|
|
58
56
|
safe_bash_1.safeBashTool,
|
|
59
57
|
...file_operations_1.textEditorTools,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,IAAI,EACJ,cAAc,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,IAAI,EACJ,cAAc,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AAiCjF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,KAAK,oBAAoB,GAAG,IAAI,GAAG,cAAc,CAAC;AAIlD,eAAO,MAAM,WAAW,EAAE,oBAAoB,EAS7C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAAoB,EAOrD,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAAoB,EAerD,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,WAE9D;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,mBAAmB,GACzB,oBAAoB,EAAE,CAExB;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,mBAAmB,GACzB,oBAAoB,EAAE,CAExB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,eAAe,EAAE,WAM5D;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAQlE;AAED,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,cAAc,iBAoBzE"}
|
package/dist/tools/index.js
CHANGED
|
@@ -16,7 +16,6 @@ const grep_1 = require("./definitions/grep");
|
|
|
16
16
|
const list_tests_and_projects_1 = require("./definitions/list-tests-and-projects");
|
|
17
17
|
const merge_conflicts_1 = require("./definitions/merge-conflicts");
|
|
18
18
|
const rename_file_1 = require("./definitions/rename-file");
|
|
19
|
-
const review_pull_request_1 = require("./definitions/review-pull-request");
|
|
20
19
|
const run_test_1 = require("./definitions/run-test");
|
|
21
20
|
const str_replace_editor_1 = require("./definitions/str_replace_editor");
|
|
22
21
|
const test_gen_browser_1 = require("./definitions/test-gen-browser");
|
|
@@ -63,7 +62,6 @@ exports.allToolsDefinitions = [
|
|
|
63
62
|
...exports.testGenerationTools,
|
|
64
63
|
analyse_video_1.analyseVideo,
|
|
65
64
|
triage_summary_1.sendTriageSummaryTool,
|
|
66
|
-
review_pull_request_1.reviewPullRequestTool,
|
|
67
65
|
issues_v1_1.listIssuesTool,
|
|
68
66
|
issues_v1_1.createIssueTool,
|
|
69
67
|
issues_v1_1.updateIssueTool,
|
package/dist/tools/run-test.js
CHANGED
|
@@ -12,7 +12,7 @@ const utils_1 = require("../artifacts/utils");
|
|
|
12
12
|
const json_1 = require("../utils/json");
|
|
13
13
|
const run_test_1 = require("./definitions/run-test");
|
|
14
14
|
function buildReportUrl(projectName, testRunId) {
|
|
15
|
-
return `https://reports.empirical.run/${projectName}/${testRunId}/index.html`;
|
|
15
|
+
return `https://reports-r2.empirical.run/${projectName}/${testRunId}/index.html`;
|
|
16
16
|
}
|
|
17
17
|
function buildResult({ hasTestPassed, summaryJson, reportUrl, }) {
|
|
18
18
|
const summaryWithoutConfig = { ...summaryJson, config: undefined };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,IAAI,EACL,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"test-gen-browser.d.ts","sourceRoot":"","sources":["../../src/tools/test-gen-browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,IAAI,EACL,MAAM,uCAAuC,CAAC;AAyB/C,eAAO,MAAM,4BAA4B,EAAE,IAoP1C,CAAC"}
|
|
@@ -9,15 +9,17 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const run_1 = require("../agent/browsing/run");
|
|
11
11
|
const utils_1 = require("../agent/browsing/utils");
|
|
12
|
+
const model_1 = require("../agent/cua/model");
|
|
12
13
|
const pw_codegen_1 = require("../agent/cua/pw-codegen");
|
|
13
14
|
const pw_pause_1 = require("../agent/cua/pw-codegen/pw-pause");
|
|
14
15
|
const utils_2 = require("../artifacts/utils");
|
|
15
16
|
const web_1 = require("../bin/utils/platform/web");
|
|
16
17
|
const scenarios_1 = require("../bin/utils/scenarios");
|
|
18
|
+
const telemetry_1 = require("../telemetry");
|
|
17
19
|
const test_gen_browser_1 = require("./definitions/test-gen-browser");
|
|
18
20
|
exports.generateTestWithBrowserAgent = {
|
|
19
21
|
...test_gen_browser_1.generateTestWithBrowserAgent,
|
|
20
|
-
execute: async ({ input, repoPath, trace, collectArtifacts, environmentOverrides = {},
|
|
22
|
+
execute: async ({ input, repoPath, trace, collectArtifacts, environmentOverrides = {}, chatSession, logger, }) => {
|
|
21
23
|
const { filePath, project } = input;
|
|
22
24
|
const absoluteFilePath = path_1.default.join(repoPath, filePath);
|
|
23
25
|
if (!fs_1.default.existsSync(absoluteFilePath)) {
|
|
@@ -119,6 +121,15 @@ exports.generateTestWithBrowserAgent = {
|
|
|
119
121
|
await (0, pw_pause_1.revertToOriginalPwCode)(repoPath);
|
|
120
122
|
fs_1.default.writeFileSync(absoluteFilePath, fileBackup, "utf-8");
|
|
121
123
|
const { isError, error, result: toolResult, usage } = agentResult;
|
|
124
|
+
if (usage) {
|
|
125
|
+
(0, telemetry_1.trackLLMResponse)({
|
|
126
|
+
modelName: model_1.CUA_MODEL,
|
|
127
|
+
projectRepoName: chatSession?.repoName || "unknown",
|
|
128
|
+
chatSessionId: chatSession?.id,
|
|
129
|
+
chatSessionSource: "browser_agent",
|
|
130
|
+
usage,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
122
133
|
const screenshotArtifacts = (toolResult || [])
|
|
123
134
|
.filter((item) => item.type === "screenshot")
|
|
124
135
|
.map((item) => item.screenshot)
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ToolResultPart, Usage } from "@empiricalrun/shared-types/chat-agent";
|
|
2
|
+
import { VideoAnalysisParams, VideoAnalysisResultV1 } from "@empiricalrun/shared-types/test-gen";
|
|
3
|
+
import { type VideostilLogger } from "videostil";
|
|
4
|
+
type VideoCoreParams = {
|
|
4
5
|
url: string;
|
|
5
6
|
videoHash: string;
|
|
6
7
|
params: VideoAnalysisParams;
|
|
7
8
|
workingDirectory: string;
|
|
8
9
|
skipUpload?: boolean;
|
|
9
|
-
|
|
10
|
+
logger?: VideostilLogger;
|
|
11
|
+
};
|
|
12
|
+
export declare function runVideoAnalysis({ url, videoHash, params, workingDirectory, skipUpload, logger, }: VideoCoreParams): Promise<{
|
|
10
13
|
result: VideoAnalysisResultV1;
|
|
11
|
-
unique_frames: UniqueFrameInfos[];
|
|
12
|
-
interleaved_tool_result: ToolResultPart[];
|
|
13
|
-
chat_messages: CanonicalMessage[];
|
|
14
14
|
error: null;
|
|
15
|
-
} | {
|
|
16
|
-
result: VideoAnalysisResultV1;
|
|
17
|
-
unique_frames: UniqueFrameInfos[];
|
|
18
15
|
interleaved_tool_result: ToolResultPart[];
|
|
19
|
-
|
|
20
|
-
error: string;
|
|
16
|
+
usage: Usage;
|
|
21
17
|
}>;
|
|
18
|
+
export {};
|
|
22
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/video-core/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/video-core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACd,KAAK,EACN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AAgBnB,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,EACrC,GAAG,EACH,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,MAAM,GACP,EAAE,eAAe;;;;;GAqJjB"}
|
package/dist/video-core/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const constants_1 = require("../constants");
|
|
|
6
6
|
const model_limits_1 = require("./model-limits");
|
|
7
7
|
const storage_manager_1 = require("./storage-manager");
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
|
-
async function runVideoAnalysis({ url, videoHash, params, workingDirectory, skipUpload, }) {
|
|
9
|
+
async function runVideoAnalysis({ url, videoHash, params, workingDirectory, skipUpload, logger, }) {
|
|
10
10
|
const result = {
|
|
11
11
|
version: "1.0",
|
|
12
12
|
total_extracted_frames: 0,
|
|
@@ -23,119 +23,101 @@ async function runVideoAnalysis({ url, videoHash, params, workingDirectory, skip
|
|
|
23
23
|
let uniqueFrameInfos = [];
|
|
24
24
|
let interleavedResults = [];
|
|
25
25
|
let allMessages = [];
|
|
26
|
-
let currentStep = "initialization";
|
|
27
26
|
let finalError = null;
|
|
27
|
+
let extractionResult;
|
|
28
|
+
const startTime = params.startTime
|
|
29
|
+
? (0, utils_1.formatTimestampToSeconds)(params.startTime)
|
|
30
|
+
: 0;
|
|
28
31
|
try {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
threshold: constants_1.VIDEO_ANALYSIS.DEFAULT_THRESHOLD,
|
|
39
|
-
startTime,
|
|
40
|
-
duration: params.duration,
|
|
41
|
-
workingDir: workingDirectory,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
throw new Error(`Frame extraction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
46
|
-
}
|
|
47
|
-
const { totalFramesCount, uniqueFrames: extractedFrames, videoDurationSeconds, } = extractionResult;
|
|
48
|
-
// Map videostil FrameInfo to test-gen UniqueFrameInfos
|
|
49
|
-
uniqueFrameInfos = extractedFrames.map((frame) => ({
|
|
50
|
-
index: frame.index,
|
|
51
|
-
path: frame.path,
|
|
52
|
-
fileName: frame.fileName,
|
|
53
|
-
url: frame.url || `${(0, utils_1.getR2BaseUrlByHash)(videoHash)}${frame.fileName}`,
|
|
54
|
-
base64: frame.base64 || "",
|
|
55
|
-
timestamp: frame.timestamp || 0,
|
|
56
|
-
}));
|
|
57
|
-
result.total_extracted_frames = totalFramesCount;
|
|
58
|
-
result.video_duration = (0, utils_1.formatSecondsToTimestamp)(videoDurationSeconds);
|
|
59
|
-
result.unique_frames_count = uniqueFrameInfos.length;
|
|
60
|
-
currentStep = "batch_size_calculation";
|
|
61
|
-
let batchSize;
|
|
62
|
-
try {
|
|
63
|
-
batchSize = await (0, model_limits_1.calculateOptimalBatchSize)(params.model, uniqueFrameInfos);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
throw new Error(`Batch size calculation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
67
|
-
}
|
|
68
|
-
const uniqueFramesBatch = uniqueFrameInfos.slice(0, batchSize);
|
|
69
|
-
const frameBatch = uniqueFramesBatch.map((f) => ({
|
|
70
|
-
name: f.fileName,
|
|
71
|
-
contentType: "image/png",
|
|
72
|
-
base64Data: f.base64,
|
|
73
|
-
}));
|
|
74
|
-
currentStep = "video_analysis";
|
|
75
|
-
let analysis, parsedXml;
|
|
76
|
-
try {
|
|
77
|
-
const analysisResult = await (0, videostil_1.analyseFrames)({
|
|
78
|
-
selectedModel: params.model,
|
|
79
|
-
frameBatch,
|
|
80
|
-
});
|
|
81
|
-
analysis = analysisResult.analysis;
|
|
82
|
-
allMessages = analysisResult.allMessages;
|
|
83
|
-
parsedXml = analysisResult.parsedXml;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
throw new Error(`Video analysis failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
87
|
-
}
|
|
88
|
-
const allFramesLength = uniqueFrameInfos.length;
|
|
89
|
-
const isTruncated = allFramesLength !== batchSize;
|
|
90
|
-
const finalFrameTimestamp = (0, utils_1.formatSecondsToTimestamp)(uniqueFramesBatch[uniqueFramesBatch.length - 1]?.timestamp || 0);
|
|
91
|
-
result.is_truncated = isTruncated;
|
|
92
|
-
result.frames_processed = batchSize;
|
|
93
|
-
result.last_processed_frame_timestamp = finalFrameTimestamp;
|
|
94
|
-
result.analysis = isTruncated
|
|
95
|
-
? `NOTE: the unique frames to be processed were truncated to ${batchSize} due to limitations on the number of frames that can be processed in a single batch. The last frame processed was at timestamp ${finalFrameTimestamp}.`
|
|
96
|
-
: `Successfully analysed all ${allFramesLength} unique frames from the video without truncation.`;
|
|
97
|
-
currentStep = "interleaved_results";
|
|
98
|
-
try {
|
|
99
|
-
interleavedResults = (0, utils_1.createInterleavedResults)(parsedXml, uniqueFrameInfos);
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
throw new Error(`Interleaved results creation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
103
|
-
}
|
|
104
|
-
if (!skipUpload) {
|
|
105
|
-
currentStep = "upload_all";
|
|
106
|
-
const uploadPromises = [
|
|
107
|
-
(0, storage_manager_1.uploadFramesToR2)(videoHash, uniqueFrameInfos).catch((error) => {
|
|
108
|
-
throw new Error(`Frame upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
109
|
-
}),
|
|
110
|
-
(0, storage_manager_1.uploadSummaryToR2)({
|
|
111
|
-
...result,
|
|
112
|
-
interleaved_tool_result: interleavedResults,
|
|
113
|
-
}).catch((error) => {
|
|
114
|
-
throw new Error(`Summary upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
115
|
-
}),
|
|
116
|
-
(0, storage_manager_1.uploadChatStateToR2)(allMessages, videoHash).catch((error) => {
|
|
117
|
-
throw new Error(`Chat state upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
118
|
-
}),
|
|
119
|
-
];
|
|
120
|
-
await Promise.all(uploadPromises);
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
result,
|
|
124
|
-
unique_frames: uniqueFrameInfos,
|
|
125
|
-
interleaved_tool_result: interleavedResults,
|
|
126
|
-
chat_messages: allMessages,
|
|
127
|
-
error: finalError,
|
|
128
|
-
};
|
|
32
|
+
extractionResult = await (0, videostil_1.extractUniqueFrames)({
|
|
33
|
+
videoUrl: url,
|
|
34
|
+
fps: constants_1.VIDEO_ANALYSIS.DEFAULT_FPS,
|
|
35
|
+
threshold: constants_1.VIDEO_ANALYSIS.DEFAULT_THRESHOLD,
|
|
36
|
+
startTime,
|
|
37
|
+
duration: params.duration,
|
|
38
|
+
workingDir: workingDirectory,
|
|
39
|
+
logger,
|
|
40
|
+
});
|
|
129
41
|
}
|
|
130
42
|
catch (error) {
|
|
131
|
-
|
|
132
|
-
finalError = `Error at step [${currentStep}]: ${errorMessage}`;
|
|
133
|
-
return {
|
|
134
|
-
result,
|
|
135
|
-
unique_frames: uniqueFrameInfos,
|
|
136
|
-
interleaved_tool_result: interleavedResults,
|
|
137
|
-
chat_messages: allMessages,
|
|
138
|
-
error: finalError,
|
|
139
|
-
};
|
|
43
|
+
throw new Error(`Frame extraction failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
140
44
|
}
|
|
45
|
+
const { totalFramesCount, uniqueFrames: extractedFrames, videoDurationSeconds, } = extractionResult;
|
|
46
|
+
// Map videostil FrameInfo to test-gen UniqueFrameInfos
|
|
47
|
+
uniqueFrameInfos = extractedFrames.map((frame) => ({
|
|
48
|
+
index: frame.index,
|
|
49
|
+
path: frame.path,
|
|
50
|
+
fileName: frame.fileName,
|
|
51
|
+
url: frame.url || `${(0, utils_1.getR2BaseUrlByHash)(videoHash)}${frame.fileName}`,
|
|
52
|
+
base64: frame.base64 || "",
|
|
53
|
+
timestamp: frame.timestamp || 0,
|
|
54
|
+
}));
|
|
55
|
+
result.total_extracted_frames = totalFramesCount;
|
|
56
|
+
result.video_duration = (0, utils_1.formatSecondsToTimestamp)(videoDurationSeconds);
|
|
57
|
+
result.unique_frames_count = uniqueFrameInfos.length;
|
|
58
|
+
let batchSize;
|
|
59
|
+
try {
|
|
60
|
+
batchSize = await (0, model_limits_1.calculateOptimalBatchSize)(params.model, uniqueFrameInfos);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
throw new Error(`Batch size calculation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
64
|
+
}
|
|
65
|
+
const uniqueFramesBatch = uniqueFrameInfos.slice(0, batchSize);
|
|
66
|
+
const frameBatch = uniqueFramesBatch.map((f) => ({
|
|
67
|
+
name: f.fileName,
|
|
68
|
+
contentType: "image/png",
|
|
69
|
+
base64Data: f.base64,
|
|
70
|
+
}));
|
|
71
|
+
let analysis, parsedXml;
|
|
72
|
+
try {
|
|
73
|
+
const analysisResult = await (0, videostil_1.analyseFrames)({
|
|
74
|
+
selectedModel: params.model,
|
|
75
|
+
frameBatch,
|
|
76
|
+
});
|
|
77
|
+
analysis = analysisResult.analysis;
|
|
78
|
+
allMessages = analysisResult.allMessages;
|
|
79
|
+
parsedXml = analysisResult.parsedXml;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw new Error(`Video analysis failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
83
|
+
}
|
|
84
|
+
const allFramesLength = uniqueFrameInfos.length;
|
|
85
|
+
const isTruncated = allFramesLength !== batchSize;
|
|
86
|
+
const finalFrameTimestamp = (0, utils_1.formatSecondsToTimestamp)(uniqueFramesBatch[uniqueFramesBatch.length - 1]?.timestamp || 0);
|
|
87
|
+
result.is_truncated = isTruncated;
|
|
88
|
+
result.frames_processed = batchSize;
|
|
89
|
+
result.last_processed_frame_timestamp = finalFrameTimestamp;
|
|
90
|
+
result.analysis = isTruncated
|
|
91
|
+
? `NOTE: the unique frames to be processed were truncated to ${batchSize} due to limitations on the number of frames that can be processed in a single batch. The last frame processed was at timestamp ${finalFrameTimestamp}.`
|
|
92
|
+
: `Successfully analysed all ${allFramesLength} unique frames from the video without truncation.`;
|
|
93
|
+
try {
|
|
94
|
+
interleavedResults = (0, utils_1.createInterleavedResults)(parsedXml, uniqueFrameInfos);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw new Error(`Interleaved results creation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
98
|
+
}
|
|
99
|
+
if (!skipUpload) {
|
|
100
|
+
const uploadPromises = [
|
|
101
|
+
(0, storage_manager_1.uploadFramesToR2)(videoHash, uniqueFrameInfos).catch((error) => {
|
|
102
|
+
throw new Error(`Frame upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
103
|
+
}),
|
|
104
|
+
(0, storage_manager_1.uploadSummaryToR2)({
|
|
105
|
+
...result,
|
|
106
|
+
interleaved_tool_result: interleavedResults,
|
|
107
|
+
}).catch((error) => {
|
|
108
|
+
throw new Error(`Summary upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
109
|
+
}),
|
|
110
|
+
(0, storage_manager_1.uploadChatStateToR2)(allMessages, videoHash).catch((error) => {
|
|
111
|
+
throw new Error(`Chat state upload failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
112
|
+
}),
|
|
113
|
+
];
|
|
114
|
+
await Promise.all(uploadPromises);
|
|
115
|
+
}
|
|
116
|
+
const usage = (0, utils_1.aggregateUsageFromMessages)(allMessages);
|
|
117
|
+
return {
|
|
118
|
+
result,
|
|
119
|
+
error: finalError,
|
|
120
|
+
interleaved_tool_result: interleavedResults,
|
|
121
|
+
usage,
|
|
122
|
+
};
|
|
141
123
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolResultPart } from "@empiricalrun/shared-types/chat-agent";
|
|
1
|
+
import { CanonicalMessage, ToolResultPart, Usage } from "@empiricalrun/shared-types/chat-agent";
|
|
2
2
|
import { UniqueFrameInfos } from "@empiricalrun/shared-types/test-gen";
|
|
3
3
|
import { VideoAnalysisToolResponse } from "@empiricalrun/shared-types/tool-results";
|
|
4
4
|
export declare function formatSecondsToTimestamp(seconds: number | undefined): string;
|
|
@@ -10,4 +10,5 @@ export interface VideoValidationResult {
|
|
|
10
10
|
error?: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function validateVideoAccess(videoUrl: string): Promise<VideoValidationResult>;
|
|
13
|
+
export declare function aggregateUsageFromMessages(messages: CanonicalMessage[]): Usage;
|
|
13
14
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/video-core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/video-core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,EACN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAW5E;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA+BlE;AAED,eAAO,MAAM,kBAAkB,GAAI,cAAc,MAAM,WAEtD,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,yBAAyB,EAAE,EAC3C,gBAAgB,EAAE,gBAAgB,EAAE,GACnC,cAAc,EAAE,CAwClB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,qBAAqB,CAAC,CAgBhC;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,KAAK,CAsBP"}
|
package/dist/video-core/utils.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.formatSecondsToTimestamp = formatSecondsToTimestamp;
|
|
|
5
5
|
exports.formatTimestampToSeconds = formatTimestampToSeconds;
|
|
6
6
|
exports.createInterleavedResults = createInterleavedResults;
|
|
7
7
|
exports.validateVideoAccess = validateVideoAccess;
|
|
8
|
+
exports.aggregateUsageFromMessages = aggregateUsageFromMessages;
|
|
8
9
|
function formatSecondsToTimestamp(seconds) {
|
|
9
10
|
if (seconds === undefined)
|
|
10
11
|
return "N/A";
|
|
@@ -99,3 +100,17 @@ async function validateVideoAccess(videoUrl) {
|
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
function aggregateUsageFromMessages(messages) {
|
|
104
|
+
const messageUsages = messages
|
|
105
|
+
.map((msg) => msg.usage)
|
|
106
|
+
.filter((usage) => !!usage);
|
|
107
|
+
const tokens = messageUsages.reduce((acc, usage) => ({
|
|
108
|
+
input: acc.input + (usage.tokens?.input || 0),
|
|
109
|
+
output: acc.output + (usage.tokens?.output || 0),
|
|
110
|
+
}), { input: 0, output: 0 });
|
|
111
|
+
const cost = messageUsages.reduce((acc, usage) => ({
|
|
112
|
+
input: acc.input + (usage.cost?.input || 0),
|
|
113
|
+
output: acc.output + (usage.cost?.output || 0),
|
|
114
|
+
}), { input: 0, output: 0 });
|
|
115
|
+
return { tokens, cost };
|
|
116
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/test-gen",
|
|
3
|
-
"version": "0.79.
|
|
3
|
+
"version": "0.79.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"registry": "https://registry.npmjs.org/",
|
|
6
6
|
"access": "public"
|
|
@@ -42,9 +42,17 @@
|
|
|
42
42
|
"types": "./dist/dashboard/index.d.ts",
|
|
43
43
|
"default": "./dist/dashboard/index.js"
|
|
44
44
|
},
|
|
45
|
+
"./file-info": {
|
|
46
|
+
"types": "./dist/file-info/index.d.ts",
|
|
47
|
+
"default": "./dist/file-info/index.js"
|
|
48
|
+
},
|
|
45
49
|
"./trace-utils": {
|
|
46
50
|
"types": "./dist/trace-utils/index.d.ts",
|
|
47
51
|
"default": "./dist/trace-utils/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./telemetry": {
|
|
54
|
+
"types": "./dist/telemetry/index.d.ts",
|
|
55
|
+
"default": "./dist/telemetry/index.js"
|
|
48
56
|
}
|
|
49
57
|
},
|
|
50
58
|
"repository": {
|
|
@@ -90,11 +98,11 @@
|
|
|
90
98
|
"@empiricalrun/ast-parser": "^0.0.10",
|
|
91
99
|
"@empiricalrun/llm": "^0.25.2",
|
|
92
100
|
"@empiricalrun/r2-uploader": "^0.9.0",
|
|
93
|
-
"@empiricalrun/test-run": "^0.14.
|
|
101
|
+
"@empiricalrun/test-run": "^0.14.1",
|
|
94
102
|
"videostil": "0.3.4"
|
|
95
103
|
},
|
|
96
104
|
"devDependencies": {
|
|
97
|
-
"@playwright/test": "1.
|
|
105
|
+
"@playwright/test": "1.57.0",
|
|
98
106
|
"@types/async-retry": "^1.4.8",
|
|
99
107
|
"@types/console-log-level": "^1.4.5",
|
|
100
108
|
"@types/detect-port": "^1.3.5",
|
|
@@ -107,7 +115,7 @@
|
|
|
107
115
|
"@types/serve-handler": "^6.1.4",
|
|
108
116
|
"@types/yauzl": "^2.10.3",
|
|
109
117
|
"js-levenshtein": "^1.1.6",
|
|
110
|
-
"playwright": "1.
|
|
118
|
+
"playwright": "1.57.0",
|
|
111
119
|
"serve-handler": "^6.1.6",
|
|
112
120
|
"ts-patch": "^3.3.0",
|
|
113
121
|
"@empiricalrun/shared-types": "0.12.0"
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/logger.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/cli.ts","./src/agent/index.ts","./src/agent/base/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/chat/prompt/pw-utils-docs.ts","./src/agent/chat/prompt/repo.ts","./src/agent/chat/prompt/test-case-def.ts","./src/agent/code-review/index.ts","./src/agent/code-review/parser.ts","./src/agent/code-review/types.ts","./src/agent/code-review/executor/index.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/factory.ts","./src/agent/cua/pw-codegen/index.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/version.ts","./src/agent/cua/pw-codegen/pw-event-sink/index.ts","./src/agent/cua/pw-codegen/pw-pause/for-recorder.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/ipc.ts","./src/agent/cua/pw-codegen/pw-pause/patch.ts","./src/agent/cua/pw-codegen/pw-pause/types.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/agent/triage/index.ts","./src/artifacts/index.ts","./src/artifacts/utils.ts","./src/auth/cli-auth.ts","./src/auth/index.ts","./src/auth/token-store.ts","./src/bin/environments.ts","./src/bin/index.ts","./src/bin/setup.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/dashboard/client.ts","./src/dashboard/index.ts","./src/dashboard/tool-response.ts","./src/dashboard/totp.ts","./src/dashboard/types.ts","./src/errors/index.ts","./src/file/client.ts","./src/file/server.ts","./src/file-info/index.ts","./src/file-info/adapters/file-system/index.ts","./src/file-info/adapters/file-system/reader.ts","./src/file-info/adapters/github/index.ts","./src/file-info/adapters/github/reader.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/recorder/env-variables.ts","./src/recorder/index.ts","./src/recorder/request.ts","./src/recorder/temp-files.ts","./src/recorder/upload.ts","./src/recorder/validation.ts","./src/test-build/index.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/index.ts","./src/tools/list-environments.ts","./src/tools/run-test.ts","./src/tools/test-gen-browser.ts","./src/tools/analyse-video/index.ts","./src/tools/create-pull-request/index.ts","./src/tools/create-pull-request/utils.ts","./src/tools/definitions/analyse-video.ts","./src/tools/definitions/delete-file.ts","./src/tools/definitions/download-build.ts","./src/tools/definitions/grep.ts","./src/tools/definitions/list-tests-and-projects.ts","./src/tools/definitions/merge-conflicts.ts","./src/tools/definitions/rename-file.ts","./src/tools/definitions/
|
|
1
|
+
{"root":["./src/index.ts","./src/logger.ts","./src/actions/assert.ts","./src/actions/click.ts","./src/actions/done.ts","./src/actions/fill.ts","./src/actions/goto.ts","./src/actions/hover.ts","./src/actions/index.ts","./src/actions/next-task.ts","./src/actions/press.ts","./src/actions/text-content.ts","./src/actions/constants/index.ts","./src/actions/utils/index.ts","./src/agent/cli.ts","./src/agent/index.ts","./src/agent/base/index.ts","./src/agent/browsing/index.ts","./src/agent/browsing/run.ts","./src/agent/browsing/utils.ts","./src/agent/chat/agent-loop.ts","./src/agent/chat/exports.ts","./src/agent/chat/index.ts","./src/agent/chat/models.ts","./src/agent/chat/state.ts","./src/agent/chat/types.ts","./src/agent/chat/utils.ts","./src/agent/chat/prompt/pw-utils-docs.ts","./src/agent/chat/prompt/repo.ts","./src/agent/chat/prompt/test-case-def.ts","./src/agent/code-review/index.ts","./src/agent/code-review/parser.ts","./src/agent/code-review/types.ts","./src/agent/code-review/executor/index.ts","./src/agent/cua/computer.ts","./src/agent/cua/index.ts","./src/agent/cua/model.ts","./src/agent/cua/pw-codegen/element-from-point.ts","./src/agent/cua/pw-codegen/factory.ts","./src/agent/cua/pw-codegen/index.ts","./src/agent/cua/pw-codegen/types.ts","./src/agent/cua/pw-codegen/version.ts","./src/agent/cua/pw-codegen/pw-event-sink/index.ts","./src/agent/cua/pw-codegen/pw-pause/for-recorder.ts","./src/agent/cua/pw-codegen/pw-pause/index.ts","./src/agent/cua/pw-codegen/pw-pause/ipc.ts","./src/agent/cua/pw-codegen/pw-pause/patch.ts","./src/agent/cua/pw-codegen/pw-pause/types.ts","./src/agent/cua/pw-codegen/pw-pause/utils.ts","./src/agent/master/action-tool-calls.ts","./src/agent/master/element-annotation.ts","./src/agent/master/execute-browser-action.ts","./src/agent/master/next-action.ts","./src/agent/master/planner.ts","./src/agent/master/run.ts","./src/agent/master/scroller.ts","./src/agent/master/with-hints.ts","./src/agent/master/browser-tests/cua.spec.ts","./src/agent/master/browser-tests/fixtures.ts","./src/agent/master/browser-tests/index.spec.ts","./src/agent/master/icon-descriptor/index.ts","./src/agent/master/icon-descriptor/normalize-svg.ts","./src/agent/planner/run-time-planner.ts","./src/agent/planner/run.ts","./src/agent/triage/index.ts","./src/artifacts/index.ts","./src/artifacts/utils.ts","./src/auth/cli-auth.ts","./src/auth/index.ts","./src/auth/token-store.ts","./src/bin/environments.ts","./src/bin/index.ts","./src/bin/setup.ts","./src/bin/logger/index.ts","./src/bin/utils/context.ts","./src/bin/utils/index.ts","./src/bin/utils/fs/index.ts","./src/bin/utils/platform/web/index.ts","./src/bin/utils/platform/web/test-files/ts-path-import-validate.ts","./src/bin/utils/scenarios/index.ts","./src/browser-injected-scripts/annotate-elements.spec.ts","./src/constants/index.ts","./src/dashboard/client.ts","./src/dashboard/index.ts","./src/dashboard/tool-response.ts","./src/dashboard/totp.ts","./src/dashboard/types.ts","./src/errors/index.ts","./src/file/client.ts","./src/file/server.ts","./src/file-info/index.ts","./src/file-info/adapters/file-system/index.ts","./src/file-info/adapters/file-system/reader.ts","./src/file-info/adapters/github/index.ts","./src/file-info/adapters/github/reader.ts","./src/human-in-the-loop/cli.ts","./src/human-in-the-loop/index.ts","./src/human-in-the-loop/ipc.ts","./src/page/index.ts","./src/prompts/lib/ts-transformer.ts","./src/recorder/env-variables.ts","./src/recorder/index.ts","./src/recorder/request.ts","./src/recorder/temp-files.ts","./src/recorder/upload.ts","./src/recorder/validation.ts","./src/telemetry/index.ts","./src/test-build/index.ts","./src/tools/diagnosis-fetcher.ts","./src/tools/index.ts","./src/tools/list-environments.ts","./src/tools/run-test.ts","./src/tools/test-gen-browser.ts","./src/tools/analyse-video/index.ts","./src/tools/create-pull-request/index.ts","./src/tools/create-pull-request/utils.ts","./src/tools/definitions/analyse-video.ts","./src/tools/definitions/delete-file.ts","./src/tools/definitions/download-build.ts","./src/tools/definitions/grep.ts","./src/tools/definitions/list-tests-and-projects.ts","./src/tools/definitions/merge-conflicts.ts","./src/tools/definitions/rename-file.ts","./src/tools/definitions/run-test.ts","./src/tools/definitions/safe-bash.ts","./src/tools/definitions/str_replace_editor.ts","./src/tools/definitions/test-gen-browser.ts","./src/tools/definitions/upgrade-packages.ts","./src/tools/definitions/utils.ts","./src/tools/delete-file/index.ts","./src/tools/download-build/index.ts","./src/tools/executor/base.ts","./src/tools/executor/index.ts","./src/tools/executor/types.ts","./src/tools/executor/utils/checkpoint.ts","./src/tools/executor/utils/git.ts","./src/tools/executor/utils/index.ts","./src/tools/executor/utils/pr-description.ts","./src/tools/fetch-file/index.ts","./src/tools/fetch-file/utils.ts","./src/tools/fetch-session-diff/index.ts","./src/tools/file-operations/create.ts","./src/tools/file-operations/index.ts","./src/tools/file-operations/insert.ts","./src/tools/file-operations/replace.ts","./src/tools/file-operations/shared/helpers.ts","./src/tools/file-operations/view/index.ts","./src/tools/firecrawl-scrape/index.ts","./src/tools/grep/index.ts","./src/tools/grep/types.ts","./src/tools/grep/ripgrep/index.ts","./src/tools/issues-v1/create-issue.ts","./src/tools/issues-v1/index.ts","./src/tools/issues-v1/list-issues.ts","./src/tools/issues-v1/update-issue.ts","./src/tools/issues-v1/utils.ts","./src/tools/issues-v2/create-issue.ts","./src/tools/issues-v2/set-issue-description.ts","./src/tools/issues-v2/update-issue.ts","./src/tools/list-tests-and-projects/index.ts","./src/tools/merge-conflicts/index.ts","./src/tools/rename-file/index.ts","./src/tools/safe-bash/index.ts","./src/tools/test-run-fetcher/index.ts","./src/tools/test-run-fetcher/types.ts","./src/tools/trace-dot-zip/index.ts","./src/tools/trace-dot-zip/types.ts","./src/tools/trace-dot-zip/utils/console-trace.ts","./src/tools/trace-dot-zip/utils/extract-zip.ts","./src/tools/trace-dot-zip/utils/network-trace.ts","./src/tools/triage-summary/index.ts","./src/tools/triage-summary/types.ts","./src/tools/triage-summary/utils.ts","./src/tools/upgrade-packages/index.ts","./src/tools/upgrade-packages/utils.ts","./src/tools/utils/queue.ts","./src/tools/utils/validate-schema.ts","./src/trace-utils/index.ts","./src/types/handlebars.d.ts","./src/types/index.ts","./src/utils/SQSClient.ts","./src/utils/env.ts","./src/utils/exec.ts","./src/utils/file.ts","./src/utils/hash.ts","./src/utils/html.ts","./src/utils/index.ts","./src/utils/json.ts","./src/utils/model.ts","./src/utils/playwright-report-parser.ts","./src/utils/playwright-test-id.ts","./src/utils/repo-tree.ts","./src/utils/slug.ts","./src/utils/string.ts","./src/utils/stripAnsi.ts","./src/utils/url-validation.ts","./src/utils/dedup/dedup-image.ts","./src/utils/dedup/find-threshold.ts","./src/video-core/index.ts","./src/video-core/model-limits.ts","./src/video-core/storage-manager.ts","./src/video-core/types.ts","./src/video-core/utils.ts"],"version":"5.8.3"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"review-pull-request.d.ts","sourceRoot":"","sources":["../../../src/tools/definitions/review-pull-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAO5E,eAAO,MAAM,qBAAqB,EAAE,cAQnC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reviewPullRequestTool = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const ReviewPullRequestInputSchema = zod_1.z.object({
|
|
6
|
-
sessionUrl: zod_1.z.string().describe("The URL of the chat session to review"),
|
|
7
|
-
});
|
|
8
|
-
exports.reviewPullRequestTool = {
|
|
9
|
-
schema: {
|
|
10
|
-
name: "reviewPullRequest",
|
|
11
|
-
description: `Reviews a pull request by using CodeReviewAgent to fetch session diff and analyse it. Returns a boolean result with an explanation.`,
|
|
12
|
-
parameters: ReviewPullRequestInputSchema,
|
|
13
|
-
},
|
|
14
|
-
needsBrowser: false,
|
|
15
|
-
isInlineTool: true,
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/review-pull-request/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAEL,MAAM,uCAAuC,CAAC;AAU/C,eAAO,MAAM,qBAAqB,EAAE,IA0FnC,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reviewPullRequestTool = void 0;
|
|
4
|
-
const code_review_1 = require("../../agent/code-review");
|
|
5
|
-
const executor_1 = require("../../agent/code-review/executor");
|
|
6
|
-
const file_info_1 = require("../../file-info");
|
|
7
|
-
const review_pull_request_1 = require("../definitions/review-pull-request");
|
|
8
|
-
const CODE_REVIEW_MODEL = "claude-sonnet-4-5-20250929";
|
|
9
|
-
exports.reviewPullRequestTool = {
|
|
10
|
-
...review_pull_request_1.reviewPullRequestTool,
|
|
11
|
-
execute: async ({ input, apiClient, environmentOverrides, trace, featureFlags, repoPath, }) => {
|
|
12
|
-
try {
|
|
13
|
-
const { sessionUrl } = input;
|
|
14
|
-
if (!sessionUrl) {
|
|
15
|
-
return {
|
|
16
|
-
isError: true,
|
|
17
|
-
result: "No chat session URL provided",
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
if (!apiClient)
|
|
21
|
-
return {
|
|
22
|
-
isError: true,
|
|
23
|
-
result: "API Client not available",
|
|
24
|
-
};
|
|
25
|
-
const span = trace?.span({
|
|
26
|
-
name: "code-review-agent",
|
|
27
|
-
input: {
|
|
28
|
-
sessionUrl,
|
|
29
|
-
model: CODE_REVIEW_MODEL,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
const codeReviewToolExecutor = new executor_1.CodeReviewToolExecutor({
|
|
33
|
-
chatSession: null,
|
|
34
|
-
repoPath,
|
|
35
|
-
apiClient,
|
|
36
|
-
trace: span,
|
|
37
|
-
featureFlags,
|
|
38
|
-
environmentOverrides: environmentOverrides || {},
|
|
39
|
-
});
|
|
40
|
-
const agentParams = {
|
|
41
|
-
featureFlags: [],
|
|
42
|
-
selectedModel: CODE_REVIEW_MODEL,
|
|
43
|
-
chatState: undefined,
|
|
44
|
-
toolExecutor: codeReviewToolExecutor,
|
|
45
|
-
trace: span,
|
|
46
|
-
repoInfoBuilder: () => (0, file_info_1.getFileInfoFromFS)(repoPath),
|
|
47
|
-
};
|
|
48
|
-
const agent = new code_review_1.CodeReviewAgent({ ...agentParams });
|
|
49
|
-
// Push the review prompt to the agent
|
|
50
|
-
const userPrompt = `Review this session: ${sessionUrl}`;
|
|
51
|
-
agent.pushUserMessage([{ text: userPrompt }]);
|
|
52
|
-
while (!agent.askUserForInput) {
|
|
53
|
-
await agent.runLoop({
|
|
54
|
-
reporter: async () => { },
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const agentResult = agent.getResult();
|
|
58
|
-
span?.end({
|
|
59
|
-
output: {
|
|
60
|
-
result: agentResult,
|
|
61
|
-
success: !!agentResult,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
if (!agentResult) {
|
|
65
|
-
return {
|
|
66
|
-
isError: true,
|
|
67
|
-
result: "Could not extract text response from agent",
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
isError: false,
|
|
72
|
-
result: JSON.stringify(agentResult),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.error("Error reviewing pull request", error);
|
|
77
|
-
return {
|
|
78
|
-
isError: true,
|
|
79
|
-
result: error instanceof Error ? error.message : String(error),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
};
|