@empiricalrun/test-gen 0.75.0 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/agent/base/index.d.ts +32 -21
- package/dist/agent/base/index.d.ts.map +1 -1
- package/dist/agent/base/index.js +100 -57
- package/dist/agent/browsing/run.d.ts +1 -2
- package/dist/agent/browsing/run.d.ts.map +1 -1
- package/dist/agent/browsing/run.js +3 -9
- package/dist/agent/browsing/utils.d.ts +2 -9
- package/dist/agent/browsing/utils.d.ts.map +1 -1
- package/dist/agent/browsing/utils.js +5 -109
- package/dist/agent/chat/agent-loop.d.ts +8 -7
- package/dist/agent/chat/agent-loop.d.ts.map +1 -1
- package/dist/agent/chat/agent-loop.js +7 -18
- package/dist/agent/chat/exports.d.ts +9 -6
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +11 -13
- package/dist/agent/chat/index.d.ts +6 -10
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +117 -196
- package/dist/agent/chat/models.d.ts +0 -2
- package/dist/agent/chat/models.d.ts.map +1 -1
- package/dist/agent/chat/models.js +12 -26
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.d.ts.map +1 -1
- package/dist/agent/chat/prompt/pw-utils-docs.js +52 -0
- package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
- package/dist/agent/chat/prompt/repo.js +11 -22
- package/dist/agent/chat/prompt/test-case-def.d.ts +2 -0
- package/dist/agent/chat/prompt/test-case-def.d.ts.map +1 -0
- package/dist/agent/chat/prompt/test-case-def.js +44 -0
- package/dist/agent/chat/state.d.ts +8 -8
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/state.js +17 -47
- package/dist/agent/chat/utils.d.ts +4 -5
- package/dist/agent/chat/utils.d.ts.map +1 -1
- package/dist/agent/chat/utils.js +15 -9
- package/dist/agent/cli.d.ts +11 -0
- package/dist/agent/cli.d.ts.map +1 -0
- package/dist/agent/cli.js +213 -0
- package/dist/agent/code-review/executor/index.d.ts +5 -0
- package/dist/agent/code-review/executor/index.d.ts.map +1 -0
- package/dist/agent/code-review/executor/index.js +13 -0
- package/dist/agent/code-review/index.d.ts +12 -0
- package/dist/agent/code-review/index.d.ts.map +1 -0
- package/dist/agent/code-review/index.js +159 -0
- package/dist/agent/code-review/parser.d.ts +5 -0
- package/dist/agent/code-review/parser.d.ts.map +1 -0
- package/dist/agent/code-review/parser.js +70 -0
- package/dist/agent/code-review/types.d.ts +36 -0
- package/dist/agent/code-review/types.d.ts.map +1 -0
- package/dist/agent/code-review/types.js +13 -0
- package/dist/agent/cua/index.d.ts.map +1 -1
- package/dist/agent/cua/index.js +18 -2
- package/dist/agent/cua/model.d.ts.map +1 -1
- package/dist/agent/cua/model.js +4 -1
- package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +1 -1
- package/dist/agent/index.d.ts +10 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +19 -0
- package/dist/agent/triage/index.d.ts +7 -0
- package/dist/agent/triage/index.d.ts.map +1 -0
- package/dist/agent/triage/index.js +103 -0
- package/dist/agent/video-analysis/executor/index.d.ts +5 -0
- package/dist/agent/video-analysis/executor/index.d.ts.map +1 -0
- package/dist/agent/video-analysis/executor/index.js +10 -0
- package/dist/agent/video-analysis/index.d.ts +7 -0
- package/dist/agent/video-analysis/index.d.ts.map +1 -0
- package/dist/agent/video-analysis/index.js +60 -0
- package/dist/artifacts/index.d.ts +1 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +3 -1
- package/dist/artifacts/utils.d.ts.map +1 -1
- package/dist/bin/index.js +68 -23
- package/dist/constants/index.d.ts +14 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +33 -1
- package/dist/file/server.d.ts +1 -3
- package/dist/file/server.d.ts.map +1 -1
- package/dist/file/server.js +0 -13
- package/dist/file-info/adapters/file-system/index.d.ts.map +1 -1
- package/dist/file-info/adapters/file-system/reader.d.ts.map +1 -1
- package/dist/file-info/adapters/file-system/reader.js +8 -1
- package/dist/file-info/adapters/github/index.d.ts.map +1 -1
- package/dist/file-info/adapters/github/index.js +1 -2
- package/dist/file-info/adapters/github/reader.d.ts +4 -9
- package/dist/file-info/adapters/github/reader.d.ts.map +1 -1
- package/dist/file-info/adapters/github/reader.js +166 -134
- package/dist/index.d.ts.map +1 -1
- package/dist/tools/analyse-video/index.d.ts +5 -0
- package/dist/tools/analyse-video/index.d.ts.map +1 -0
- package/dist/tools/analyse-video/index.js +50 -0
- package/dist/tools/create-pull-request/index.d.ts.map +1 -0
- package/dist/tools/{definitions/commit-and-create-pr.js → create-pull-request/index.js} +28 -1
- package/dist/tools/create-pull-request/utils.d.ts +21 -0
- package/dist/tools/create-pull-request/utils.d.ts.map +1 -0
- package/dist/tools/create-pull-request/utils.js +83 -0
- package/dist/tools/definitions/{fetch-video-analysis.d.ts → analyse-video.d.ts} +17 -12
- package/dist/tools/definitions/analyse-video.d.ts.map +1 -0
- package/dist/tools/definitions/analyse-video.js +60 -0
- package/dist/tools/definitions/review-pull-request.d.ts +3 -0
- package/dist/tools/definitions/review-pull-request.d.ts.map +1 -0
- package/dist/tools/definitions/review-pull-request.js +16 -0
- package/dist/tools/definitions/str_replace_editor.d.ts +1 -0
- package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -1
- package/dist/tools/definitions/str_replace_editor.js +4 -1
- package/dist/tools/definitions/test-gen-browser.d.ts +0 -3
- package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/definitions/test-gen-browser.js +33 -8
- package/dist/tools/delete-file/index.d.ts.map +1 -1
- package/dist/tools/delete-file/index.js +1 -19
- package/dist/tools/executor/base.d.ts +32 -0
- package/dist/tools/executor/base.d.ts.map +1 -0
- package/dist/tools/executor/base.js +114 -0
- package/dist/tools/executor/index.d.ts +3 -22
- package/dist/tools/executor/index.d.ts.map +1 -1
- package/dist/tools/executor/index.js +13 -92
- package/dist/tools/executor/utils/checkpoint.d.ts +1 -1
- package/dist/tools/executor/utils/checkpoint.d.ts.map +1 -1
- package/dist/tools/executor/utils/checkpoint.js +6 -2
- package/dist/tools/executor/utils/git.d.ts +2 -2
- package/dist/tools/executor/utils/git.d.ts.map +1 -1
- package/dist/tools/executor/utils/git.js +7 -3
- package/dist/tools/executor/utils/index.d.ts.map +1 -1
- package/dist/tools/executor/utils/index.js +1 -1
- package/dist/tools/fetch-session-diff/index.d.ts +3 -0
- package/dist/tools/fetch-session-diff/index.d.ts.map +1 -0
- package/dist/tools/fetch-session-diff/index.js +46 -0
- package/dist/tools/file-operations/create.d.ts.map +1 -1
- package/dist/tools/file-operations/create.js +1 -4
- package/dist/tools/file-operations/index.d.ts +2 -1
- package/dist/tools/file-operations/index.d.ts.map +1 -1
- package/dist/tools/file-operations/index.js +4 -1
- package/dist/tools/file-operations/insert.d.ts +1 -2
- package/dist/tools/file-operations/insert.d.ts.map +1 -1
- package/dist/tools/file-operations/insert.js +1 -4
- package/dist/tools/file-operations/replace.d.ts.map +1 -1
- package/dist/tools/file-operations/replace.js +1 -4
- package/dist/tools/grep/index.d.ts.map +1 -1
- package/dist/tools/grep/index.js +18 -11
- package/dist/tools/index.d.ts +28 -2
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +52 -33
- package/dist/tools/merge-conflicts/index.d.ts.map +1 -1
- package/dist/tools/merge-conflicts/index.js +1 -1
- package/dist/tools/rename-file/index.js +1 -1
- package/dist/tools/review-pull-request/index.d.ts +3 -0
- package/dist/tools/review-pull-request/index.d.ts.map +1 -0
- package/dist/tools/review-pull-request/index.js +89 -0
- package/dist/tools/run-test.d.ts.map +1 -1
- package/dist/tools/run-test.js +25 -3
- package/dist/tools/test-gen-browser.d.ts.map +1 -1
- package/dist/tools/test-gen-browser.js +51 -47
- package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
- package/dist/tools/test-run-fetcher/index.js +4 -14
- package/dist/tools/utils/urls.d.ts +5 -0
- package/dist/tools/utils/urls.d.ts.map +1 -0
- package/dist/tools/utils/urls.js +19 -0
- package/dist/tools/view-failed-test-run-report/index.d.ts.map +1 -1
- package/dist/tools/view-failed-test-run-report/index.js +3 -15
- package/dist/utils/artifact-paths.d.ts +20 -0
- package/dist/utils/artifact-paths.d.ts.map +1 -0
- package/dist/utils/artifact-paths.js +16 -0
- package/dist/utils/dedup-image-fs.d.ts +2 -16
- package/dist/utils/dedup-image-fs.d.ts.map +1 -1
- package/dist/utils/dedup-image-fs.js +12 -16
- package/dist/utils/dedup-image.d.ts +1 -14
- package/dist/utils/dedup-image.d.ts.map +1 -1
- package/dist/utils/dedup-image.js +7 -62
- package/dist/{tools/fetch-video-analysis/local-ffmpeg-client.d.ts → utils/ffmpeg/index.d.ts} +9 -6
- package/dist/utils/ffmpeg/index.d.ts.map +1 -0
- package/dist/utils/ffmpeg/index.js +415 -0
- package/dist/utils/file.d.ts +1 -0
- package/dist/utils/file.d.ts.map +1 -1
- package/dist/utils/file.js +45 -1
- package/dist/utils/find-threshold.d.ts +8 -0
- package/dist/utils/find-threshold.d.ts.map +1 -0
- package/dist/utils/find-threshold.js +55 -0
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +24 -0
- package/dist/utils/model.d.ts +1 -1
- package/dist/utils/model.d.ts.map +1 -1
- package/dist/utils/model.js +7 -5
- package/dist/utils/repo-tree.d.ts +0 -1
- package/dist/utils/repo-tree.d.ts.map +1 -1
- package/dist/utils/repo-tree.js +2 -14
- package/dist/utils/slug.js +1 -1
- package/dist/video-core/agent-orchestrator.d.ts +14 -0
- package/dist/video-core/agent-orchestrator.d.ts.map +1 -0
- package/dist/video-core/agent-orchestrator.js +78 -0
- package/dist/video-core/analysis-server.d.ts +24 -0
- package/dist/video-core/analysis-server.d.ts.map +1 -0
- package/dist/video-core/analysis-server.js +398 -0
- package/dist/video-core/analysis-viewer.html +1374 -0
- package/dist/video-core/index.d.ts +44 -0
- package/dist/video-core/index.d.ts.map +1 -0
- package/dist/video-core/index.js +204 -0
- package/dist/video-core/model-limits.d.ts +4 -0
- package/dist/video-core/model-limits.d.ts.map +1 -0
- package/dist/video-core/model-limits.js +67 -0
- package/dist/video-core/storage-manager.d.ts +5 -0
- package/dist/video-core/storage-manager.d.ts.map +1 -0
- package/dist/video-core/storage-manager.js +55 -0
- package/dist/video-core/types.d.ts +13 -0
- package/dist/video-core/types.d.ts.map +1 -0
- package/dist/video-core/types.js +2 -0
- package/dist/video-core/utils.d.ts +25 -0
- package/dist/video-core/utils.d.ts.map +1 -0
- package/dist/video-core/utils.js +211 -0
- package/dist/video-core/xml-parser.d.ts +3 -0
- package/dist/video-core/xml-parser.d.ts.map +1 -0
- package/dist/video-core/xml-parser.js +27 -0
- package/package.json +5 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/agent/chat/prompt/index.d.ts +0 -5
- package/dist/agent/chat/prompt/index.d.ts.map +0 -1
- package/dist/agent/chat/prompt/index.js +0 -189
- package/dist/agent/chat/utils/tool-calls.d.ts +0 -21
- package/dist/agent/chat/utils/tool-calls.d.ts.map +0 -1
- package/dist/agent/chat/utils/tool-calls.js +0 -64
- package/dist/agent/code-review/prompt.d.ts +0 -2
- package/dist/agent/code-review/prompt.d.ts.map +0 -1
- package/dist/agent/code-review/prompt.js +0 -19
- package/dist/agent/diagnosis-agent/index.d.ts +0 -11
- package/dist/agent/diagnosis-agent/index.d.ts.map +0 -1
- package/dist/agent/diagnosis-agent/index.js +0 -88
- package/dist/agent/diagnosis-agent/strict-mode-violation.d.ts +0 -10
- package/dist/agent/diagnosis-agent/strict-mode-violation.d.ts.map +0 -1
- package/dist/agent/diagnosis-agent/strict-mode-violation.js +0 -30
- package/dist/tools/commit-and-create-pr/index.d.ts.map +0 -1
- package/dist/tools/commit-and-create-pr/index.js +0 -83
- package/dist/tools/definitions/commit-and-create-pr.d.ts +0 -3
- package/dist/tools/definitions/commit-and-create-pr.d.ts.map +0 -1
- package/dist/tools/definitions/fetch-video-analysis.d.ts.map +0 -1
- package/dist/tools/definitions/fetch-video-analysis.js +0 -61
- package/dist/tools/fetch-video-analysis/index.d.ts +0 -5
- package/dist/tools/fetch-video-analysis/index.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/index.js +0 -138
- package/dist/tools/fetch-video-analysis/local-ffmpeg-client.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/local-ffmpeg-client.js +0 -247
- package/dist/tools/fetch-video-analysis/open-ai.d.ts +0 -6
- package/dist/tools/fetch-video-analysis/open-ai.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/open-ai.js +0 -37
- package/dist/tools/fetch-video-analysis/utils.d.ts +0 -13
- package/dist/tools/fetch-video-analysis/utils.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/utils.js +0 -98
- package/dist/tools/fetch-video-analysis/video-analysis.d.ts +0 -7
- package/dist/tools/fetch-video-analysis/video-analysis.d.ts.map +0 -1
- package/dist/tools/fetch-video-analysis/video-analysis.js +0 -54
- package/dist/tools/file-operations/shared/git-helper.d.ts +0 -4
- package/dist/tools/file-operations/shared/git-helper.d.ts.map +0 -1
- package/dist/tools/file-operations/shared/git-helper.js +0 -29
- package/eslint.config.mjs +0 -43
- /package/dist/tools/{commit-and-create-pr → create-pull-request}/index.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.77.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bc38c65: feat: diff tab ui update with code review comments
|
|
8
|
+
- e5e45e0: feat: code review agent output format update to v2
|
|
9
|
+
- 44373a4: feat: code review agent system prompt and ui update
|
|
10
|
+
- 8a206cf: feat: optional line annotated diff on /diff endpoint for code review agent
|
|
11
|
+
- 151dc8f: feat: fetchVideoAnalysis uses VideoAnalysisAgent under the hood
|
|
12
|
+
- 49b44a6: feat: cr agent auto refresh ui with fresh code review data
|
|
13
|
+
- 82a6fe7: refactor: chat model update in base agent v2
|
|
14
|
+
- f9a7023: feat: tool exec v2 integration with base agent v2
|
|
15
|
+
- a25735a: feat: added trace in code review agent
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- a45714d: fix: updated prompt to ask agent to format code description in markdown
|
|
20
|
+
- ba65440: feat: convert image url to base64 uri before sending to llm
|
|
21
|
+
- cf991ee: chore: file view tool for code review agent
|
|
22
|
+
- eda0ccd: feat: support tool response image parts with urls
|
|
23
|
+
- 1f7e8b0: chore: diff endpoint now also returns pr metadata, code review agent receives pr metadata
|
|
24
|
+
- 42e19ee: fix: removed duplicate trigger on create pr tool for code review
|
|
25
|
+
- 02c3532: fix: graceful handling of missing verdict in xml - infer verdict from cr agent line comments
|
|
26
|
+
- 8f3a25f: feat: versioned code review responses
|
|
27
|
+
- bd61b13: feat: change default model to gpt-5
|
|
28
|
+
- Updated dependencies [8ff49e5]
|
|
29
|
+
- Updated dependencies [ba65440]
|
|
30
|
+
- Updated dependencies [eda0ccd]
|
|
31
|
+
- Updated dependencies [25bd9b6]
|
|
32
|
+
- Updated dependencies [d56954c]
|
|
33
|
+
- @empiricalrun/llm@0.23.0
|
|
34
|
+
- @empiricalrun/test-run@0.11.1
|
|
35
|
+
|
|
36
|
+
## 0.76.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- 9c9d6e5: feat: code review basic agent
|
|
41
|
+
- ee8ce00: feat: fetchVideoAnalysis multi modal tool response
|
|
42
|
+
- 86a1549: feat: code review agent v1 with workflow as an ad hoc tool call
|
|
43
|
+
- 5339d2c: feat: VideoAnalysisAgent working in CLI with extractFrames tool
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- a6aa6d8: fix: bug where video analysis was set to empty string
|
|
48
|
+
- @empiricalrun/llm@0.22.0
|
|
49
|
+
- @empiricalrun/test-run@0.11.1
|
|
50
|
+
|
|
3
51
|
## 0.75.0
|
|
4
52
|
|
|
5
53
|
### Minor Changes
|
|
@@ -1,36 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FileInfo, PendingToolCall, ReporterFunction, StreamingMessageReporterFunc, SupportedChatModels,
|
|
1
|
+
import { type IChatCanonicalModel } from "@empiricalrun/llm/chat";
|
|
2
|
+
import type { Attachment, CanonicalMessage, ChatState, FileInfo, MessageCheckpoint, PendingToolCall, ReporterFunction, StreamingMessageReporterFunc, SupportedChatModels, ToolResult, ToolsForLLM, TraceClient } from "@empiricalrun/shared-types";
|
|
3
|
+
import { BaseToolExecutor } from "../../tools/executor/base";
|
|
3
4
|
type RunLoopParams<T> = {
|
|
4
|
-
chatModel: IChatModel<T>;
|
|
5
5
|
reporter: ReporterFunction;
|
|
6
6
|
streamingMessageReporter?: StreamingMessageReporterFunc;
|
|
7
7
|
trace?: TraceClient;
|
|
8
8
|
signal?: AbortSignal;
|
|
9
|
-
onPendingToolCall
|
|
9
|
+
onPendingToolCall?: (toolCalls: PendingToolCall[]) => Promise<void>;
|
|
10
10
|
onLLMResponse?: (response: T, selectedModel: SupportedChatModels) => Promise<void>;
|
|
11
|
+
repoInfoBuilder?: () => Promise<FileInfo>;
|
|
11
12
|
};
|
|
12
|
-
export
|
|
13
|
-
type AgentParams = {
|
|
14
|
-
featureFlags: string[];
|
|
13
|
+
export type AgentParams = {
|
|
15
14
|
selectedModel: SupportedChatModels;
|
|
16
|
-
|
|
15
|
+
chatState: ChatState;
|
|
16
|
+
featureFlags?: string[];
|
|
17
|
+
workerEnv?: Record<string, string>;
|
|
18
|
+
toolExecutor?: BaseToolExecutor;
|
|
19
|
+
trace?: TraceClient;
|
|
17
20
|
};
|
|
18
|
-
export declare
|
|
19
|
-
export declare class ChatAgent {
|
|
21
|
+
export declare abstract class BaseAgent {
|
|
20
22
|
featureFlags: string[];
|
|
21
|
-
tools:
|
|
23
|
+
tools: ToolsForLLM;
|
|
22
24
|
selectedModel: SupportedChatModels;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
chatModel: IChatCanonicalModel;
|
|
26
|
+
workerEnv?: Record<string, string>;
|
|
27
|
+
toolExecutor?: BaseToolExecutor;
|
|
28
|
+
trace?: TraceClient;
|
|
29
|
+
constructor({ featureFlags, selectedModel, workerEnv, chatState, toolExecutor, trace, }: AgentParams);
|
|
30
|
+
protected abstract getTools(): ToolsForLLM;
|
|
31
|
+
protected abstract buildSystemPrompt(repoContext?: string): Promise<string>;
|
|
32
|
+
get messages(): CanonicalMessage[];
|
|
33
|
+
get askUserForInput(): boolean;
|
|
34
|
+
get chatState(): ChatState;
|
|
35
|
+
pushUserMessage(text: string, attachments: Attachment[]): void;
|
|
36
|
+
setChatState(chatState: ChatState): void;
|
|
37
|
+
stop(): ChatState;
|
|
38
|
+
processToolResults(toolCalls: PendingToolCall[], toolResults: ToolResult[], checkpoint: MessageCheckpoint | null): ChatState | undefined;
|
|
39
|
+
toolCallHandler(toolCalls: PendingToolCall[]): Promise<void>;
|
|
33
40
|
runLoop(params: RunLoopParams<any>): Promise<void>;
|
|
41
|
+
getHumanReadableLatestMessage(): {
|
|
42
|
+
role: string;
|
|
43
|
+
textMessage: string;
|
|
44
|
+
} | undefined;
|
|
34
45
|
}
|
|
35
46
|
export {};
|
|
36
47
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAO7D,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,wBAAwB,CAAC,EAAE,4BAA4B,CAAC;IACxD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,aAAa,CAAC,EAAE,CACd,QAAQ,EAAE,CAAC,EACX,aAAa,EAAE,mBAAmB,KAC/B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,EAAE,mBAAmB,CAAC;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,8BAAsB,SAAS;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAM;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,aAAa,EAAE,mBAAmB,CAAC;IACnC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;gBAER,EACV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,SAAS,EACT,YAAY,EACZ,KAAK,GACN,EAAE,WAAW;IAed,SAAS,CAAC,QAAQ,CAAC,QAAQ,IAAI,WAAW;IAC1C,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAE3E,IAAI,QAAQ,IAAI,gBAAgB,EAAE,CAEjC;IAED,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,IAAI,SAAS,IAAI,SAAS,CAQzB;IAED,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI;IAI9D,YAAY,CAAC,SAAS,EAAE,SAAS;IAQjC,IAAI,IAAI,SAAS;IA6BjB,kBAAkB,CAChB,SAAS,EAAE,eAAe,EAAE,EAC5B,WAAW,EAAE,UAAU,EAAE,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,GACnC,SAAS,GAAG,SAAS;IA4BlB,eAAe,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC;IAmBxC,6BAA6B,IACzB;QACE,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,GACD,SAAS;CAGd"}
|
package/dist/agent/base/index.js
CHANGED
|
@@ -1,74 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
const tools_1 = require("../../tools");
|
|
3
|
+
exports.BaseAgent = void 0;
|
|
4
|
+
const chat_1 = require("@empiricalrun/llm/chat");
|
|
6
5
|
const agent_loop_1 = require("../chat/agent-loop");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return "triage";
|
|
12
|
-
case "dashboard":
|
|
13
|
-
return "test_generation";
|
|
14
|
-
case "manual":
|
|
15
|
-
return "test_generation";
|
|
16
|
-
default:
|
|
17
|
-
return "test_generation";
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.getChatAgentMode = getChatAgentMode;
|
|
21
|
-
function getAgentForMode(isTriage, params) {
|
|
22
|
-
if (isTriage) {
|
|
23
|
-
return new TriageAgent(params);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return new ChatAgent(params);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
class ChatAgent {
|
|
6
|
+
const repo_1 = require("../chat/prompt/repo");
|
|
7
|
+
const state_1 = require("../chat/state");
|
|
8
|
+
const REJECTION_RESULT = "This tool call was rejected by the user.";
|
|
9
|
+
class BaseAgent {
|
|
30
10
|
featureFlags = [];
|
|
31
|
-
tools
|
|
11
|
+
tools;
|
|
32
12
|
selectedModel;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
chatModel;
|
|
14
|
+
workerEnv;
|
|
15
|
+
toolExecutor;
|
|
16
|
+
trace;
|
|
17
|
+
constructor({ featureFlags, selectedModel, workerEnv, chatState, toolExecutor, trace, }) {
|
|
18
|
+
this.featureFlags = featureFlags || [];
|
|
37
19
|
this.selectedModel = selectedModel;
|
|
38
|
-
this.
|
|
20
|
+
this.workerEnv = workerEnv;
|
|
21
|
+
this.tools = this.getTools();
|
|
22
|
+
this.toolExecutor = toolExecutor;
|
|
23
|
+
this.chatModel = (0, chat_1.createChatModel)(chatState.messages, this.selectedModel, this.workerEnv);
|
|
24
|
+
this.chatModel.validateEnvVarsForAuth();
|
|
25
|
+
this.trace = trace;
|
|
39
26
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
get messages() {
|
|
28
|
+
return this.chatModel.messages;
|
|
29
|
+
}
|
|
30
|
+
get askUserForInput() {
|
|
31
|
+
return this.chatModel.askUserForInput || false;
|
|
32
|
+
}
|
|
33
|
+
get chatState() {
|
|
34
|
+
return (0, state_1.createChatStateForMessages)({
|
|
35
|
+
messages: this.chatModel.messages,
|
|
45
36
|
selectedModel: this.selectedModel,
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
askUserForInput: this.chatModel.askUserForInput,
|
|
38
|
+
// TODO: Test out the error scenario
|
|
39
|
+
error: null,
|
|
48
40
|
});
|
|
49
41
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
pushUserMessage(text, attachments) {
|
|
43
|
+
this.chatModel.pushUserMessage(text, attachments);
|
|
44
|
+
}
|
|
45
|
+
setChatState(chatState) {
|
|
46
|
+
this.chatModel = (0, chat_1.createChatModel)(chatState.messages, this.selectedModel, this.workerEnv);
|
|
47
|
+
}
|
|
48
|
+
stop() {
|
|
49
|
+
const pendingToolCalls = this.chatModel.getPendingToolCalls();
|
|
50
|
+
let updatedChatState = {
|
|
51
|
+
...this.chatState,
|
|
52
|
+
messages: this.chatModel.messages,
|
|
53
|
+
askUserForInput: true,
|
|
54
|
+
};
|
|
55
|
+
if (pendingToolCalls.length > 0) {
|
|
56
|
+
const toolResults = pendingToolCalls.map(() => ({
|
|
57
|
+
isError: true,
|
|
58
|
+
result: REJECTION_RESULT,
|
|
59
|
+
artifacts: null,
|
|
60
|
+
}));
|
|
61
|
+
this.chatModel.pushToolResultsMessage(pendingToolCalls, toolResults, null);
|
|
62
|
+
updatedChatState = {
|
|
63
|
+
...updatedChatState,
|
|
64
|
+
messages: this.chatModel.messages,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return updatedChatState;
|
|
68
|
+
}
|
|
69
|
+
processToolResults(toolCalls, toolResults, checkpoint) {
|
|
70
|
+
const pendingToolCalls = this.chatModel.getPendingToolCalls() || [];
|
|
71
|
+
// Filter tool calls to only include pending ones
|
|
72
|
+
const filteredToolResults = [];
|
|
73
|
+
const filteredToolCalls = toolCalls.filter((call, index) => {
|
|
74
|
+
if (pendingToolCalls.some((p) => p.id === call.id)) {
|
|
75
|
+
filteredToolResults.push(toolResults[index]);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
});
|
|
80
|
+
if (filteredToolCalls.length > 0) {
|
|
81
|
+
this.chatModel.pushToolResultsMessage(filteredToolCalls, filteredToolResults, checkpoint);
|
|
82
|
+
return {
|
|
83
|
+
...this.chatState,
|
|
84
|
+
messages: this.chatModel.messages,
|
|
85
|
+
askUserForInput: this.chatModel.askUserForInput,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
async toolCallHandler(toolCalls) {
|
|
91
|
+
if (!this.toolExecutor) {
|
|
92
|
+
throw new Error("No toolExecutor available and no onPendingToolCall provided");
|
|
93
|
+
}
|
|
94
|
+
const { toolResults, checkpoint } = await this.toolExecutor.execute(toolCalls);
|
|
95
|
+
this.processToolResults(toolCalls, toolResults, checkpoint);
|
|
62
96
|
}
|
|
63
97
|
async runLoop(params) {
|
|
64
|
-
|
|
65
|
-
|
|
98
|
+
let repoContext;
|
|
99
|
+
if (params.repoInfoBuilder) {
|
|
100
|
+
const repoInfo = await params.repoInfoBuilder();
|
|
101
|
+
repoContext = await (0, repo_1.getRepoInfoPrompt)(repoInfo);
|
|
102
|
+
}
|
|
103
|
+
const systemPrompt = await this.buildSystemPrompt(repoContext);
|
|
104
|
+
await (0, agent_loop_1.chatAgentLoop)({
|
|
66
105
|
...params,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
106
|
+
onPendingToolCall: params.onPendingToolCall || this.toolCallHandler.bind(this),
|
|
107
|
+
chatModel: this.chatModel,
|
|
108
|
+
tools: this.getTools(),
|
|
109
|
+
systemPrompt,
|
|
70
110
|
featureFlags: this.featureFlags,
|
|
71
111
|
});
|
|
72
112
|
}
|
|
113
|
+
getHumanReadableLatestMessage() {
|
|
114
|
+
return this.chatModel.getHumanReadableLatestMessage();
|
|
115
|
+
}
|
|
73
116
|
}
|
|
74
|
-
exports.
|
|
117
|
+
exports.BaseAgent = BaseAgent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Usage } from "@empiricalrun/shared-types";
|
|
2
2
|
import { BrowserAgentResult } from "../cua";
|
|
3
3
|
type GenerateTestsType = {
|
|
4
4
|
testCaseName: string;
|
|
@@ -22,7 +22,6 @@ export declare function runBrowsingAgent({ testCaseName, testCaseSuites, testFil
|
|
|
22
22
|
error: string;
|
|
23
23
|
result: BrowserAgentResult | undefined;
|
|
24
24
|
usage: Usage | undefined;
|
|
25
|
-
artifacts: ArtifactInput[];
|
|
26
25
|
}>;
|
|
27
26
|
export {};
|
|
28
27
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAanD,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAG5C,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF,wBAAsB,8BAA8B,CAAC,EACnD,gBAAgB,EAChB,OAAO,EACP,YAAY,GACb,EAAE;IACD,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlB;AAED,wBAAsB,gBAAgB,CAAC,EACrC,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,OAAO,EACP,OAAO,EACP,yBAAyB,EACzB,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACvC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;CAC1B,CAAC,CA+FD"}
|
|
@@ -9,14 +9,13 @@ const test_run_1 = require("@empiricalrun/test-run");
|
|
|
9
9
|
const detect_port_1 = __importDefault(require("detect-port"));
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const utils_1 = require("../../artifacts/utils");
|
|
13
12
|
const web_1 = require("../../bin/utils/platform/web");
|
|
14
13
|
const server_1 = require("../../file/server");
|
|
15
14
|
const exec_1 = require("../../utils/exec");
|
|
16
|
-
const
|
|
15
|
+
const utils_1 = require("./utils");
|
|
17
16
|
async function convertProjectsFilterToProject({ pwProjectsFilter, repoDir, testFilePath, }) {
|
|
18
|
-
const playwrightConfig = await (0,
|
|
19
|
-
const project = await (0,
|
|
17
|
+
const playwrightConfig = await (0, utils_1.readPlaywrightConfig)(repoDir);
|
|
18
|
+
const project = await (0, utils_1.detectProjectName)(testFilePath, playwrightConfig, pwProjectsFilter);
|
|
20
19
|
return project;
|
|
21
20
|
}
|
|
22
21
|
async function runBrowsingAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, projectName, testGenToken, repoDir, traceId, editFileWithGeneratedCode, envOverrides, }) {
|
|
@@ -92,17 +91,12 @@ async function runBrowsingAgent({ testCaseName, testCaseSuites, testFilePath, fi
|
|
|
92
91
|
console.error(`[generateTestsUsingMasterAgent] Failed to remove extra scripts from files post test gen error:`, e);
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
|
-
const artifacts = [
|
|
96
|
-
...((0, utils_1.findPlaywrightArtifacts)(repoDir) || []),
|
|
97
|
-
...(fileServer.getArtifactInputsFromServer() || []),
|
|
98
|
-
];
|
|
99
94
|
await fileServer.stop();
|
|
100
95
|
const { result, usage } = fileServer.getResultAndUsage();
|
|
101
96
|
return {
|
|
102
97
|
isError: !!error,
|
|
103
98
|
error: error || "",
|
|
104
99
|
result,
|
|
105
|
-
artifacts,
|
|
106
100
|
usage,
|
|
107
101
|
};
|
|
108
102
|
}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import type { TestCase } from "@empiricalrun/shared-types";
|
|
3
1
|
import { Page } from "playwright";
|
|
4
2
|
import { PlaywrightTestConfig } from "playwright/test";
|
|
5
3
|
export declare function isRegExp(obj: any): obj is RegExp;
|
|
6
4
|
export declare function prepareBrowsingAgentTask(steps: string[]): string;
|
|
7
|
-
export declare function addImportForMethod(testFilePath: string, methodName: string):
|
|
8
|
-
export declare function replaceTodoWithCreateTest(testFilePath: string, repoDir: string):
|
|
5
|
+
export declare function addImportForMethod(testFilePath: string, methodName: string): void;
|
|
6
|
+
export declare function replaceTodoWithCreateTest(testFilePath: string, repoDir: string): string | undefined;
|
|
9
7
|
export declare function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }: {
|
|
10
8
|
testCaseName: string;
|
|
11
9
|
testCaseSuites: string[];
|
|
12
10
|
specPath: string;
|
|
13
11
|
}): Promise<void>;
|
|
14
|
-
export declare function prepareFileForMasterAgent({ testCase, specPath, trace, }: {
|
|
15
|
-
testCase: TestCase;
|
|
16
|
-
specPath: string;
|
|
17
|
-
trace?: TraceClient;
|
|
18
|
-
}): Promise<string>;
|
|
19
12
|
export declare function injectPwLocatorGenerator(page: Page): Promise<void>;
|
|
20
13
|
/**
|
|
21
14
|
* function to read playwright config from the source repo
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAYvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAe1E;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAsBpB;AAED,wBAAsB,cAAc,CAAC,EACnC,YAAY,EACZ,cAAc,EACd,QAAQ,GACT,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAoBA;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA6HxD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CA2B/B;AAWD,wBAAsB,oBAAoB,CACxC,gBAAgB,EAAE,oBAAoB,GACrC,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,gBAAgB,GAAE,MAAM,EAAU,GACjC,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
|
|
@@ -8,7 +8,6 @@ exports.prepareBrowsingAgentTask = prepareBrowsingAgentTask;
|
|
|
8
8
|
exports.addImportForMethod = addImportForMethod;
|
|
9
9
|
exports.replaceTodoWithCreateTest = replaceTodoWithCreateTest;
|
|
10
10
|
exports.markTestAsOnly = markTestAsOnly;
|
|
11
|
-
exports.prepareFileForMasterAgent = prepareFileForMasterAgent;
|
|
12
11
|
exports.injectPwLocatorGenerator = injectPwLocatorGenerator;
|
|
13
12
|
exports.readPlaywrightConfig = readPlaywrightConfig;
|
|
14
13
|
exports.getValidProjectNames = getValidProjectNames;
|
|
@@ -18,13 +17,7 @@ const minimatch_1 = require("minimatch");
|
|
|
18
17
|
const path_1 = __importDefault(require("path"));
|
|
19
18
|
// For TypeScript type safety
|
|
20
19
|
let tsxImport = null;
|
|
21
|
-
const logger_1 = require("../../bin/logger");
|
|
22
|
-
const context_1 = require("../../bin/utils/context");
|
|
23
20
|
const web_1 = require("../../bin/utils/platform/web");
|
|
24
|
-
const create_test_block_1 = require("../codegen/create-test-block");
|
|
25
|
-
const fix_ts_errors_1 = require("../codegen/fix-ts-errors");
|
|
26
|
-
const lexical_scoped_vars_1 = require("../codegen/lexical-scoped-vars");
|
|
27
|
-
const update_flow_1 = require("../codegen/update-flow");
|
|
28
21
|
function isRegExp(obj) {
|
|
29
22
|
return (obj instanceof RegExp ||
|
|
30
23
|
Object.prototype.toString.call(obj) === "[object RegExp]");
|
|
@@ -34,7 +27,7 @@ function prepareBrowsingAgentTask(steps) {
|
|
|
34
27
|
const task = `${sanitizedSteps.join("\n")}\n`;
|
|
35
28
|
return task;
|
|
36
29
|
}
|
|
37
|
-
|
|
30
|
+
function addImportForMethod(testFilePath, methodName) {
|
|
38
31
|
// Instead of using "@empiricalrun/test-gen", we use the local dist file
|
|
39
32
|
// This is to avoid assuming that the test-gen package is installed in the project
|
|
40
33
|
const importSource = path_1.default.join(__dirname, "../../../dist/index.js");
|
|
@@ -43,60 +36,7 @@ async function addImportForMethod(testFilePath, methodName) {
|
|
|
43
36
|
}
|
|
44
37
|
fs_1.default.writeFileSync(testFilePath, (0, web_1.addNewImport)(fs_1.default.readFileSync(testFilePath, "utf-8"), [methodName], importSource));
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
const { name, suites } = testCase;
|
|
48
|
-
await (0, web_1.addUserContextFixture)({
|
|
49
|
-
scenarioName: name,
|
|
50
|
-
filePath: specPath,
|
|
51
|
-
suites,
|
|
52
|
-
});
|
|
53
|
-
// update the test case with appropriate location for createTest
|
|
54
|
-
const [suggestion] = await (0, update_flow_1.appendCreateTestBlock)({
|
|
55
|
-
trace,
|
|
56
|
-
testCase,
|
|
57
|
-
file: specPath,
|
|
58
|
-
validateTypes: false,
|
|
59
|
-
});
|
|
60
|
-
const createTestFilePath = suggestion?.updatedFiles[0] || "";
|
|
61
|
-
console.log("appending to existing test block");
|
|
62
|
-
console.log("updated test file path", createTestFilePath);
|
|
63
|
-
const fetchScopeVariablesSpan = trace?.span({
|
|
64
|
-
name: "fetch-scope-variables",
|
|
65
|
-
input: {
|
|
66
|
-
createTestFilePath,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
const scopeVariables = await (0, lexical_scoped_vars_1.getLexicalScopedVars)({
|
|
70
|
-
file: fs_1.default.readFileSync(createTestFilePath, "utf-8"),
|
|
71
|
-
referencePoint: "await createTest",
|
|
72
|
-
trace: fetchScopeVariablesSpan,
|
|
73
|
-
});
|
|
74
|
-
fetchScopeVariablesSpan?.end({
|
|
75
|
-
name: "fetch-scope-variables",
|
|
76
|
-
output: {
|
|
77
|
-
variables: scopeVariables,
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
await (0, web_1.appendScopeToCreateTest)(createTestFilePath, scopeVariables);
|
|
81
|
-
await addImportForMethod(createTestFilePath, "createTest");
|
|
82
|
-
const { pomPrompt, nonSpecFilePrompt } = await (0, context_1.contextForGeneration)(createTestFilePath);
|
|
83
|
-
await (0, fix_ts_errors_1.validateAndFixTypescriptErrors)({
|
|
84
|
-
trace,
|
|
85
|
-
file: createTestFilePath,
|
|
86
|
-
pomCode: pomPrompt,
|
|
87
|
-
nonSpecFileCode: nonSpecFilePrompt,
|
|
88
|
-
testCase: testCase,
|
|
89
|
-
});
|
|
90
|
-
await markTestAsOnly({
|
|
91
|
-
testCaseName: name,
|
|
92
|
-
testCaseSuites: suites,
|
|
93
|
-
specPath,
|
|
94
|
-
});
|
|
95
|
-
return createTestFilePath;
|
|
96
|
-
}
|
|
97
|
-
async function replaceTodoWithCreateTest(testFilePath, repoDir) {
|
|
98
|
-
// This method is an alternative to prepareFileForUpdateScenario
|
|
99
|
-
// TODO: Does not support scoped variables and updates in POM files
|
|
39
|
+
function replaceTodoWithCreateTest(testFilePath, repoDir) {
|
|
100
40
|
const absoluteTestFilePath = path_1.default.join(repoDir, testFilePath);
|
|
101
41
|
const fileContent = fs_1.default.readFileSync(absoluteTestFilePath, "utf-8");
|
|
102
42
|
const todoRegex = /\/\/ TODO\(agent(?:\s+on\s+(\w+))?\):\s*(.*)/;
|
|
@@ -104,10 +44,11 @@ async function replaceTodoWithCreateTest(testFilePath, repoDir) {
|
|
|
104
44
|
if (!todoMatch) {
|
|
105
45
|
throw new Error(`No "// TODO(agent):" or "// TODO(agent on pageName):" comment found in file: ${testFilePath}`);
|
|
106
46
|
}
|
|
107
|
-
const [, pageVarName] = todoMatch;
|
|
47
|
+
const [, pageVarName, todoContent] = todoMatch;
|
|
108
48
|
const pageVariable = pageVarName || "page"; // Default to "page" if not specified
|
|
109
49
|
fs_1.default.writeFileSync(absoluteTestFilePath, fileContent.replace(todoRegex, (_, __, todoText) => `await createTest("${todoText.replace(/"/g, '\\"')}", ${pageVariable});`));
|
|
110
|
-
|
|
50
|
+
addImportForMethod(absoluteTestFilePath, "createTest");
|
|
51
|
+
return todoContent;
|
|
111
52
|
}
|
|
112
53
|
async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
|
|
113
54
|
const testFileContent = fs_1.default.readFileSync(specPath, "utf-8");
|
|
@@ -124,51 +65,6 @@ async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
|
|
|
124
65
|
fs_1.default.writeFileSync(specPath, updatedTestFileContent);
|
|
125
66
|
}
|
|
126
67
|
}
|
|
127
|
-
async function prepareFileForMasterAgent({ testCase, specPath, trace, }) {
|
|
128
|
-
const prepareFileSpan = trace?.span({
|
|
129
|
-
name: "prepare-file-for-master-agent",
|
|
130
|
-
});
|
|
131
|
-
new logger_1.CustomLogger({ useReporter: true }).log(`Preparing file for master agent. [view trace](${trace?.getTraceUrl()})`);
|
|
132
|
-
const { name, suites } = testCase;
|
|
133
|
-
// check if the spec file exists
|
|
134
|
-
// if no then create a new file with test and expect imports
|
|
135
|
-
if (!fs_1.default.existsSync(specPath)) {
|
|
136
|
-
const fileCreateSpan = prepareFileSpan?.span({
|
|
137
|
-
name: "create-file",
|
|
138
|
-
input: { specPath },
|
|
139
|
-
});
|
|
140
|
-
fs_1.default.writeFileSync(specPath, "");
|
|
141
|
-
const fileContentWithImports = (0, web_1.addNewImport)("", ["test", "expect"], (0, web_1.getFixtureImportPath)(specPath));
|
|
142
|
-
fs_1.default.writeFileSync(specPath, fileContentWithImports, "utf-8");
|
|
143
|
-
fileCreateSpan?.end({ output: { specPath, fileContentWithImports } });
|
|
144
|
-
}
|
|
145
|
-
const existingContents = fs_1.default.readFileSync(specPath, "utf-8");
|
|
146
|
-
const { testBlock } = (0, web_1.getTypescriptTestBlock)({
|
|
147
|
-
scenarioName: name,
|
|
148
|
-
suites,
|
|
149
|
-
content: existingContents,
|
|
150
|
-
});
|
|
151
|
-
if (!testBlock) {
|
|
152
|
-
const newTestBlock = await (0, create_test_block_1.createEmptyTestCaseBlock)({
|
|
153
|
-
trace: prepareFileSpan,
|
|
154
|
-
testCase,
|
|
155
|
-
file: specPath,
|
|
156
|
-
});
|
|
157
|
-
fs_1.default.writeFileSync(specPath, `${existingContents} \n\n ${newTestBlock}`, "utf-8");
|
|
158
|
-
const updatedContent = (0, web_1.injectCodeSnippetBySuiteChain)({
|
|
159
|
-
testFileContent: existingContents,
|
|
160
|
-
suites: testCase.suites,
|
|
161
|
-
codeSnippet: `\n\n${newTestBlock}`,
|
|
162
|
-
});
|
|
163
|
-
fs_1.default.writeFileSync(specPath, updatedContent, "utf-8");
|
|
164
|
-
}
|
|
165
|
-
const updatePath = await prepareFileForUpdateScenario({
|
|
166
|
-
testCase,
|
|
167
|
-
specPath,
|
|
168
|
-
trace,
|
|
169
|
-
});
|
|
170
|
-
return updatePath;
|
|
171
|
-
}
|
|
172
68
|
function newContentsWithTestOnly(existingContents, originalTestBlock, updatedTestBlock, parentDescribeBlock) {
|
|
173
69
|
if (!parentDescribeBlock) {
|
|
174
70
|
const testMarkedAsOnly = updatedTestBlock.replace("test(", "test.only(");
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { TraceClient } from "@empiricalrun/llm";
|
|
2
|
-
import { IChatModel } from "@empiricalrun/llm/chat";
|
|
3
|
-
import { CanonicalMessage, PendingToolCall, ReporterFunction, StreamingMessageReporterFunc, SupportedChatModels,
|
|
4
|
-
|
|
5
|
-
chatModel: IChatModel<T
|
|
6
|
-
selectedModel: SupportedChatModels;
|
|
2
|
+
import { IChatCanonicalModel, IChatModel } from "@empiricalrun/llm/chat";
|
|
3
|
+
import { CanonicalMessage, PendingToolCall, ReporterFunction, StreamingMessageReporterFunc, SupportedChatModels, ToolsForLLM } from "@empiricalrun/shared-types";
|
|
4
|
+
type AgentLoopParams<T> = {
|
|
5
|
+
chatModel: IChatModel<T> | IChatCanonicalModel;
|
|
7
6
|
reporter: ReporterFunction;
|
|
8
7
|
streamingMessageReporter?: StreamingMessageReporterFunc;
|
|
9
8
|
trace?: TraceClient;
|
|
10
9
|
signal?: AbortSignal;
|
|
11
10
|
featureFlags: string[];
|
|
12
|
-
tools:
|
|
11
|
+
tools: ToolsForLLM;
|
|
13
12
|
onPendingToolCall: (toolCalls: PendingToolCall[]) => Promise<void>;
|
|
14
13
|
onLLMResponse?: (response: T, selectedModel: SupportedChatModels) => Promise<void>;
|
|
15
14
|
systemPrompt: string;
|
|
16
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export declare function chatAgentLoop<T extends CanonicalMessage = CanonicalMessage>({ chatModel, reporter, streamingMessageReporter, trace, signal, featureFlags, tools, onPendingToolCall, onLLMResponse, systemPrompt, }: AgentLoopParams<T>): Promise<void>;
|
|
17
|
+
export {};
|
|
17
18
|
//# sourceMappingURL=agent-loop.d.ts.map
|
|
@@ -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;
|
|
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,mBAAmB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,4BAA4B,EAC5B,mBAAmB,EACnB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAKpC,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC;IAC/C,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,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,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,aAAa,CAAC,EAAE,CACd,QAAQ,EAAE,CAAC,EACX,aAAa,EAAE,mBAAmB,KAC/B,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAsB,aAAa,CACjC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB,EAC7C,EACA,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,CA2CpC"}
|