@empiricalrun/test-gen 0.58.0 → 0.59.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/agent/browsing/run.d.ts +3 -1
  3. package/dist/agent/browsing/run.d.ts.map +1 -1
  4. package/dist/agent/browsing/run.js +23 -25
  5. package/dist/agent/browsing/utils.d.ts +1 -14
  6. package/dist/agent/browsing/utils.d.ts.map +1 -1
  7. package/dist/agent/browsing/utils.js +1 -58
  8. package/dist/agent/chat/agent-loop.d.ts +2 -1
  9. package/dist/agent/chat/agent-loop.d.ts.map +1 -1
  10. package/dist/agent/chat/agent-loop.js +41 -24
  11. package/dist/agent/chat/exports.d.ts +4 -5
  12. package/dist/agent/chat/exports.d.ts.map +1 -1
  13. package/dist/agent/chat/exports.js +12 -42
  14. package/dist/agent/chat/index.d.ts.map +1 -1
  15. package/dist/agent/chat/index.js +10 -4
  16. package/dist/agent/chat/models.d.ts +6 -0
  17. package/dist/agent/chat/models.d.ts.map +1 -0
  18. package/dist/agent/chat/models.js +37 -0
  19. package/dist/agent/chat/prompt.d.ts.map +1 -1
  20. package/dist/agent/chat/prompt.js +37 -8
  21. package/dist/agent/chat/state.d.ts +14 -5
  22. package/dist/agent/chat/state.d.ts.map +1 -1
  23. package/dist/agent/chat/state.js +88 -25
  24. package/dist/agent/chat/types.d.ts +0 -1
  25. package/dist/agent/chat/types.d.ts.map +1 -1
  26. package/dist/agent/master/browser-tests/index.spec.js +6 -6
  27. package/dist/bin/index.js +4 -0
  28. package/dist/bin/utils/index.d.ts +1 -0
  29. package/dist/bin/utils/index.d.ts.map +1 -1
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -0
  33. package/dist/test-build/index.js +1 -1
  34. package/dist/tool-call-service/index.d.ts +2 -1
  35. package/dist/tool-call-service/index.d.ts.map +1 -1
  36. package/dist/tool-call-service/index.js +51 -71
  37. package/dist/tool-call-service/utils.d.ts +10 -0
  38. package/dist/tool-call-service/utils.d.ts.map +1 -0
  39. package/dist/tool-call-service/utils.js +23 -0
  40. package/dist/tools/download-build.d.ts +9 -0
  41. package/dist/tools/download-build.d.ts.map +1 -1
  42. package/dist/tools/download-build.js +5 -4
  43. package/dist/tools/test-gen-browser.d.ts.map +1 -1
  44. package/dist/tools/test-gen-browser.js +8 -13
  45. package/dist/tools/test-run.d.ts.map +1 -1
  46. package/dist/tools/test-run.js +8 -13
  47. package/dist/utils/checkpoint.d.ts.map +1 -1
  48. package/dist/utils/checkpoint.js +3 -1
  49. package/dist/utils/exec.d.ts +2 -2
  50. package/dist/utils/exec.d.ts.map +1 -1
  51. package/dist/utils/exec.js +5 -4
  52. package/package.json +4 -4
  53. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.59.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e2b0318: feat: dashboard session migration from CLI working
8
+ - 894c5b5: fix: stricter types for tool call args in canonical message
9
+ - 919e7df: fix: session create, duplicate user message, add Model Options
10
+ - 045e370: feat: stateless build download for tool execution
11
+ - f2d5859: feat: canonical migration for claude and openai
12
+ - e2b0318: feat: migrate dashboard chat sessions to canonical chat state
13
+ - 4d3b46a: feat: migrate to new chat state version in cli run
14
+
15
+ ### Patch Changes
16
+
17
+ - 72f4577: feat: stop marking files as only and move to cmd builder approach
18
+ - 82b3373: test: remove irrelevant or flaky tests
19
+ - 3dbd4ff: fix: remove teardown skip since we interrupt agent with SIGINT
20
+ - 7c77600: refactor: move test-gen file changes to prepare for removal
21
+ - 562c25d: fix: update chat agent system prompt for using try/catch
22
+ - 43656bf: refactor: split tool call execute into 2 methods
23
+ - 51a9975: fix: unit tests for test-gen tool call
24
+ - 772b93c: feat: gemini message transformer into canonical message type
25
+ - 0c935ce: chore: chat model types are moved to shared-types pkg
26
+ - 050fbd3: fix: model selection is ignored while creating a new session
27
+ - ddfd009: fix: refactor chat agent and session list UI
28
+ - 28682e2: feat: use test-run cmd builder in test-gen, remove test.only marking
29
+ - 6b2ed6d: chore: use function args to tell if tool execution is remote
30
+ - 511dbb1: test: skip tests for the old master agent
31
+ - 7145e34: test: add new agent-loop test for openai canonical model
32
+ - 43fb70f: feat: add retry functionality for chat sessions and update ChatAgent …
33
+ - d1d1055: feat: integrate askUserForInput state into session handling
34
+ - ef491c0: fix: incorrect build url getter
35
+ - Updated dependencies [72f4577]
36
+ - Updated dependencies [97cef16]
37
+ - Updated dependencies [e2b0318]
38
+ - Updated dependencies [772b93c]
39
+ - Updated dependencies [894c5b5]
40
+ - Updated dependencies [0c935ce]
41
+ - Updated dependencies [919e7df]
42
+ - Updated dependencies [045e370]
43
+ - Updated dependencies [f2d5859]
44
+ - Updated dependencies [919e7df]
45
+ - Updated dependencies [ddfd009]
46
+ - Updated dependencies [e2b0318]
47
+ - Updated dependencies [28682e2]
48
+ - Updated dependencies [b415e29]
49
+ - Updated dependencies [09291a8]
50
+ - Updated dependencies [aab69ae]
51
+ - Updated dependencies [4d3b46a]
52
+ - Updated dependencies [bc5996d]
53
+ - @empiricalrun/test-run@0.9.0
54
+ - @empiricalrun/llm@0.16.0
55
+
3
56
  ## 0.58.0
4
57
 
5
58
  ### Minor Changes
@@ -1,4 +1,6 @@
1
1
  type GenerateTestsType = {
2
+ testCaseName: string;
3
+ testCaseSuites: string[];
2
4
  testFilePath: string;
3
5
  filePathToUpdate: string;
4
6
  pwProjectsFilter: string[];
@@ -7,7 +9,7 @@ type GenerateTestsType = {
7
9
  traceId?: string;
8
10
  editFileWithGeneratedCode: boolean;
9
11
  };
10
- export declare function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }: GenerateTestsType): Promise<{
12
+ export declare function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }: GenerateTestsType): Promise<{
11
13
  isError: boolean;
12
14
  error: string;
13
15
  actionsSummary?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAiBA,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,OAAO,EACP,yBAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAuFD"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAcA,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,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAsB,6BAA6B,CAAC,EAClD,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,OAAO,EACP,yBAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC,CAsFD"}
@@ -4,13 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateTestsUsingMasterAgent = generateTestsUsingMasterAgent;
7
+ const test_run_1 = require("@empiricalrun/test-run");
7
8
  const detect_port_1 = __importDefault(require("detect-port"));
8
9
  const fs_1 = __importDefault(require("fs"));
9
10
  const web_1 = require("../../bin/utils/platform/web");
10
11
  const server_1 = require("../../file/server");
11
12
  const exec_1 = require("../../utils/exec");
12
13
  const utils_1 = require("./utils");
13
- async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }) {
14
+ async function generateTestsUsingMasterAgent({ testCaseName, testCaseSuites, testFilePath, filePathToUpdate, pwProjectsFilter, testGenToken, repoDir, traceId, editFileWithGeneratedCode, }) {
14
15
  if (!fs_1.default.existsSync(testFilePath)) {
15
16
  throw new Error(`File for master agent to run not found: ${testFilePath}`);
16
17
  }
@@ -32,24 +33,27 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
32
33
  const project = await (0, utils_1.detectProjectName)(testFilePath, playwrightConfig, pwProjectsFilter);
33
34
  const pageVar = await (0, web_1.getPageVariableNameFromCreateTest)(filePathToUpdate);
34
35
  console.log(`Detected playwright project name: ${project}`);
35
- // run playwright test which will internally run the master agent
36
- const teardownFileRegex = /.*\.teardown\.ts/;
37
- const testsDirectory = `${repoDir}/tests`;
38
- const isTestRunTriggeredForTeardown = teardownFileRegex.test(testFilePath);
39
- const teardowns = new utils_1.TeardownManager(testsDirectory);
40
- let removeListeners;
41
- const command = `npx playwright test ${testFilePath} --retries 0 --project ${project} --timeout 0`;
42
- let isError = false;
43
- let error = "";
36
+ const testsDir = "tests";
37
+ const cmd = await (0, test_run_1.runSpecificTestsCmd)({
38
+ tests: [
39
+ {
40
+ name: testCaseName,
41
+ dir: testsDir,
42
+ filePath: testFilePath,
43
+ suites: testCaseSuites,
44
+ },
45
+ ],
46
+ projects: [project],
47
+ passthroughArgs: "--retries 0 --timeout 0",
48
+ //@ts-ignore
49
+ platform: "web",
50
+ });
51
+ let error = undefined;
44
52
  try {
45
- if (!isTestRunTriggeredForTeardown) {
46
- removeListeners = await teardowns.skipAll();
47
- }
48
- await pm.execute(command.split(" "), {
53
+ await pm.execute(cmd.command, cmd.args, {
49
54
  env: {
50
55
  IPC_FILE_SERVICE_PORT: availablePort.toString(),
51
56
  PW_TEST_HTML_REPORT_OPEN: "never",
52
- // pass the test gen token so that the agent has the same configuration as cli
53
57
  TEST_GEN_TOKEN: testGenToken,
54
58
  PAGE_VAR_NAME: pageVar || "page",
55
59
  DISPLAY: ":99",
@@ -60,15 +64,9 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
60
64
  catch (e) {
61
65
  error = `Failed to generate test using master agent ${e}`;
62
66
  console.error(error);
63
- isError = true;
64
- }
65
- finally {
66
- // Remove process listeners before unskipping files
67
- removeListeners?.();
68
- teardowns.unskipAll();
69
67
  }
70
- // clean up the file if there is any error
71
- if (isError) {
68
+ if (error) {
69
+ // clean up the file if there is any error
72
70
  try {
73
71
  const fileContent = fs_1.default.readFileSync(filePathToUpdate, "utf-8");
74
72
  const updatedContent = (0, web_1.replaceCreateTestWithNewCode)(filePathToUpdate, fileContent, "");
@@ -83,8 +81,8 @@ async function generateTestsUsingMasterAgent({ testFilePath, filePathToUpdate, p
83
81
  await (0, web_1.removeTestOnly)(testFilePath);
84
82
  await fileServer.stop();
85
83
  return {
86
- isError,
87
- error,
84
+ isError: !!error,
85
+ error: error || "",
88
86
  actionsSummary: fileServer.getActionsSummary(),
89
87
  };
90
88
  }
@@ -4,11 +4,7 @@ import { Page } from "playwright";
4
4
  import { PlaywrightTestConfig } from "playwright/test";
5
5
  export declare function isRegExp(obj: any): obj is RegExp;
6
6
  export declare function prepareBrowsingAgentTask(steps: string[]): string;
7
- export declare function replaceTodoWithCreateTest({ testFilePath, testCaseName, testCaseSuites, }: {
8
- testFilePath: string;
9
- testCaseName: string;
10
- testCaseSuites: string[];
11
- }): Promise<void>;
7
+ export declare function replaceTodoWithCreateTest(testFilePath: string): Promise<void>;
12
8
  export declare function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }: {
13
9
  testCaseName: string;
14
10
  testCaseSuites: string[];
@@ -33,13 +29,4 @@ export declare function getValidProjectNames(playwrightConfig: PlaywrightTestCon
33
29
  * @returns
34
30
  */
35
31
  export declare function detectProjectName(testFilePath: string, playwrightConfig: PlaywrightTestConfig, pwProjectsFilter?: string[]): Promise<string>;
36
- export declare class TeardownManager {
37
- private directory;
38
- constructor(directory: string);
39
- private teardownFiles;
40
- private getAllTeardownFiles;
41
- private skipTeardownFile;
42
- skipAll(): Promise<() => void>;
43
- unskipAll(): void;
44
- }
45
32
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAIxE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAwBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAiFD,wBAAsB,yBAAyB,CAAC,EAC9C,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,iBA2BA;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;AAED,wBAAsB,yBAAyB,CAAC,EAC9C,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDlB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA2HxD;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;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,MAAM;IACrC,OAAO,CAAC,aAAa,CAAqB;YAE5B,mBAAmB;YAUnB,gBAAgB;IAsBjB,OAAO;IAoBb,SAAS;CAKjB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAsBvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAIvD;AAiFD,wBAAsB,yBAAyB,CAAC,YAAY,EAAE,MAAM,iBAsBnE;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;AAED,wBAAsB,yBAAyB,CAAC,EAC9C,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDlB;AAyBD,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA2HxD;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"}
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TeardownManager = void 0;
7
6
  exports.isRegExp = isRegExp;
8
7
  exports.prepareBrowsingAgentTask = prepareBrowsingAgentTask;
9
8
  exports.replaceTodoWithCreateTest = replaceTodoWithCreateTest;
@@ -16,12 +15,10 @@ exports.detectProjectName = detectProjectName;
16
15
  const fs_1 = __importDefault(require("fs"));
17
16
  const minimatch_1 = require("minimatch");
18
17
  const path_1 = __importDefault(require("path"));
19
- const ts_morph_1 = require("ts-morph");
20
18
  // For TypeScript type safety
21
19
  let tsxImport = null;
22
20
  const logger_1 = require("../../bin/logger");
23
21
  const context_1 = require("../../bin/utils/context");
24
- const fs_2 = require("../../bin/utils/fs");
25
22
  const web_1 = require("../../bin/utils/platform/web");
26
23
  const create_test_block_1 = require("../codegen/create-test-block");
27
24
  const fix_ts_errors_1 = require("../codegen/fix-ts-errors");
@@ -96,7 +93,7 @@ async function prepareFileForUpdateScenario({ testCase, specPath, trace, }) {
96
93
  });
97
94
  return createTestFilePath;
98
95
  }
99
- async function replaceTodoWithCreateTest({ testFilePath, testCaseName, testCaseSuites, }) {
96
+ async function replaceTodoWithCreateTest(testFilePath) {
100
97
  // This method is an alternative to prepareFileForUpdateScenario
101
98
  // TODO: Does not support scoped variables and updates in POM files
102
99
  const fileContent = fs_1.default.readFileSync(testFilePath, "utf-8");
@@ -109,11 +106,6 @@ async function replaceTodoWithCreateTest({ testFilePath, testCaseName, testCaseS
109
106
  const pageVariable = pageVarName || "page"; // Default to "page" if not specified
110
107
  fs_1.default.writeFileSync(testFilePath, fileContent.replace(todoRegex, (_, __, todoText) => `await createTest("${todoText.replace(/"/g, '\\"')}", ${pageVariable});`));
111
108
  await addImportForCreateTest(testFilePath);
112
- await markTestAsOnly({
113
- testCaseName,
114
- testCaseSuites,
115
- specPath: testFilePath,
116
- });
117
109
  }
118
110
  async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
119
111
  const testFileContent = fs_1.default.readFileSync(specPath, "utf-8");
@@ -388,52 +380,3 @@ async function detectProjectName(testFilePath, playwrightConfig, pwProjectsFilte
388
380
  }
389
381
  return filteredProjectNames[0];
390
382
  }
391
- class TeardownManager {
392
- directory;
393
- constructor(directory) {
394
- this.directory = directory;
395
- }
396
- teardownFiles = [];
397
- async getAllTeardownFiles() {
398
- const teardownFileRegex = /.*\.teardown\.ts/;
399
- const teardownFiles = await (0, fs_2.readFilesInDirectory)(this.directory, (fileName) => teardownFileRegex.test(fileName));
400
- return teardownFiles;
401
- }
402
- async skipTeardownFile(filePath) {
403
- const project = new ts_morph_1.Project();
404
- const sourceFile = project.addSourceFileAtPath(filePath);
405
- sourceFile
406
- .getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression)
407
- .forEach((callExpression) => {
408
- const expression = callExpression.getExpression();
409
- if (expression.getText() === "teardown") {
410
- expression.replaceWithText("teardown.skip");
411
- }
412
- else if (expression.getText() === "test") {
413
- expression.replaceWithText("test.skip");
414
- }
415
- });
416
- // Save the modified file
417
- sourceFile.save().catch((error) => {
418
- console.error(`Error updating the file: ${filePath}`, error);
419
- });
420
- }
421
- async skipAll() {
422
- this.teardownFiles = await this.getAllTeardownFiles();
423
- await Promise.all(this.teardownFiles.map(async ({ filePath }) => await this.skipTeardownFile(filePath)));
424
- const setupProcessListeners = (cleanup) => {
425
- const events = ["beforeExit", "exit", "SIGINT", "SIGTERM"];
426
- events.forEach((event) => process.on(event, cleanup));
427
- return () => {
428
- events.forEach((event) => process.removeListener(event, cleanup));
429
- };
430
- };
431
- return setupProcessListeners(this.unskipAll.bind(this));
432
- }
433
- unskipAll() {
434
- this.teardownFiles.forEach(({ filePath, content }) => {
435
- fs_1.default.writeFileSync(filePath, content, "utf-8");
436
- });
437
- }
438
- }
439
- exports.TeardownManager = TeardownManager;
@@ -3,12 +3,13 @@ import { IChatModel, SupportedChatModels } from "@empiricalrun/llm/chat";
3
3
  import { ToolCallService } from "../../tool-call-service";
4
4
  import { FileInfo } from "../../types";
5
5
  import { ReporterFunction } from "./types";
6
- export declare function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, }: {
6
+ export declare function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, isToolExecutionRemote, }: {
7
7
  chatModel: IChatModel<any>;
8
8
  selectedModel: SupportedChatModels;
9
9
  toolCallService: ToolCallService;
10
10
  reporter: ReporterFunction;
11
11
  trace?: TraceClient;
12
12
  fileInfo: FileInfo;
13
+ isToolExecutionRemote: boolean;
13
14
  }): Promise<void>;
14
15
  //# 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,EACL,UAAU,EACV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAgB3C,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC3B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;CACpB,iBAoCA"}
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,EAEL,UAAU,EACV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA0B3C,wBAAsB,aAAa,CAAC,EAClC,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,EACR,qBAAqB,GACtB,EAAE;IACD,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC3B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,qBAAqB,EAAE,OAAO,CAAC;CAChC,iBAuCA"}
@@ -6,44 +6,61 @@ const picocolors_1 = require("picocolors");
6
6
  const prompt_1 = require("./prompt");
7
7
  const state_1 = require("./state");
8
8
  function getModelName(model) {
9
- if (model.startsWith("claude"))
9
+ const provider = (0, chat_1.getProviderForModel)(model);
10
+ if (provider === "claude")
10
11
  return "Claude";
11
- if (model.startsWith("gemini"))
12
+ if (provider === "google")
12
13
  return "Gemini";
13
- if (model.startsWith("o4"))
14
+ if (provider === "openai")
14
15
  return "o4";
15
16
  return "AI";
16
17
  }
17
18
  const log = (...args) => {
18
19
  console.log((0, picocolors_1.gray)(args.join(" ")));
19
20
  };
20
- const isRemote = process.env.TOOL_EXECUTION_IS_REMOTE === "true" || false;
21
- async function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, }) {
21
+ function logError(context, error, trace) {
22
+ console.error((0, picocolors_1.gray)(`[Error in ${context}]:`), error instanceof Error ? error.stack || error.message : error);
23
+ trace?.update({
24
+ output: {
25
+ error: error instanceof Error ? error.message : String(error),
26
+ },
27
+ });
28
+ }
29
+ async function chatAgentLoop({ chatModel, selectedModel, reporter, trace, toolCallService, fileInfo, isToolExecutionRemote, }) {
22
30
  const systemPrompt = await (0, prompt_1.buildSystemPrompt)(fileInfo);
23
31
  trace?.update({ input: { systemPrompt } });
24
32
  const { tools } = await toolCallService.getTools();
25
33
  while (!chatModel.askUserForInput) {
26
- const toolCalls = chatModel.getPendingToolCalls();
27
- if (toolCalls.length) {
28
- const toolResults = await toolCallService.execute(toolCalls, isRemote, trace);
29
- if (isRemote) {
30
- log(`Tool call remote execution in progress`);
31
- break;
34
+ try {
35
+ const toolCalls = chatModel.getPendingToolCalls();
36
+ if (toolCalls.length) {
37
+ if (isToolExecutionRemote) {
38
+ await toolCallService.sendToQueue(toolCalls);
39
+ log(`Tool call remote execution in progress`);
40
+ break;
41
+ }
42
+ else {
43
+ const toolResults = await toolCallService.execute(toolCalls, trace);
44
+ chatModel.pushToolResultsMessage(toolCalls, toolResults);
45
+ }
46
+ }
47
+ log(`${getModelName(selectedModel)} is working...`);
48
+ const response = await chatModel.getLLMResponse({
49
+ systemPrompt,
50
+ tools: tools.map((tool) => (0, chat_1.zodToOpenAITool)(tool.schema)),
51
+ selectedModel,
52
+ trace,
53
+ });
54
+ if (!response) {
55
+ throw new Error("No response from LLM");
32
56
  }
33
- chatModel.pushToolResultsMessage(toolCalls, toolResults);
57
+ chatModel.pushMessage(response);
58
+ const latest = chatModel.getHumanReadableLatestMessage();
59
+ await reporter((0, state_1.chatStateFromModel)(chatModel, selectedModel), latest);
34
60
  }
35
- log(`${getModelName(selectedModel)} is working...`);
36
- const response = await chatModel.getLLMResponse({
37
- systemPrompt,
38
- tools: tools.map((tool) => (0, chat_1.zodToOpenAITool)(tool.schema)),
39
- selectedModel,
40
- trace,
41
- });
42
- if (!response) {
43
- throw new Error("No response from LLM");
61
+ catch (error) {
62
+ logError("chatAgentLoop", error, trace);
63
+ throw error;
44
64
  }
45
- chatModel.pushMessage(response);
46
- const latest = chatModel.getHumanReadableLatestMessage();
47
- await reporter((0, state_1.chatStateFromModel)(chatModel, selectedModel), latest);
48
65
  }
49
66
  }
@@ -1,10 +1,9 @@
1
- import { createChatModel, IChatModel, SupportedChatModels } from "@empiricalrun/llm/chat";
1
+ import { createChatModel, IChatModel } from "@empiricalrun/llm/chat";
2
2
  import { FileInfo } from "../../types";
3
3
  import { chatAgentLoop } from "./agent-loop";
4
- import * as State from "./state";
5
- import { ChatStateOnDisk } from "./state";
4
+ import { defaultModel, SUPPORTED_CHAT_MODELS, SupportedChatModels } from "./models";
5
+ import { CHAT_STATE_VERSIONS_MIGRATIONS_MAP, chatStateFromModel, ChatStateOnDisk, createChatState, createChatStateForMessages, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, migrateChatState } from "./state";
6
6
  import { ReporterFunction } from "./types";
7
- declare const createChatState: typeof State.createChatState, createChatStateForMessages: typeof State.createChatStateForMessages, chatStateFromModel: typeof State.chatStateFromModel, loadChatState: typeof State.loadChatState, saveToDisk: typeof State.saveToDisk, CURRENT_CHAT_STATE_VERSION: string;
8
- export { chatAgentLoop, chatStateFromModel, createChatModel, createChatState, createChatStateForMessages, CURRENT_CHAT_STATE_VERSION, loadChatState, saveToDisk, };
7
+ export { CHAT_STATE_VERSIONS_MIGRATIONS_MAP, chatAgentLoop, chatStateFromModel, createChatModel, createChatState, createChatStateForMessages, defaultModel, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, migrateChatState, SUPPORTED_CHAT_MODELS, };
9
8
  export type { ChatStateOnDisk, FileInfo, IChatModel, ReporterFunction, SupportedChatModels, };
10
9
  //# sourceMappingURL=exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,QAAA,MACE,eAAe,gCACf,0BAA0B,2CAC1B,kBAAkB,mCAClB,aAAa,8BACb,UAAU,2BACV,0BAA0B,QACnB,CAAC;AAEV,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,0BAA0B,EAC1B,aAAa,EACb,UAAU,GACX,CAAC;AAEF,YAAY,EACV,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,mBAAmB,GACpB,CAAC"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,kCAAkC,EAClC,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACL,kCAAkC,EAClC,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,GACtB,CAAC;AAEF,YAAY,EACV,eAAe,EACf,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,mBAAmB,GACpB,CAAC"}
@@ -1,48 +1,18 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.saveToDisk = exports.loadChatState = exports.CURRENT_CHAT_STATE_VERSION = exports.createChatStateForMessages = exports.createChatState = exports.createChatModel = exports.chatStateFromModel = exports.chatAgentLoop = void 0;
3
+ exports.SUPPORTED_CHAT_MODELS = exports.migrateChatState = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.defaultModel = exports.createChatStateForMessages = exports.createChatState = exports.createChatModel = exports.chatStateFromModel = exports.chatAgentLoop = exports.CHAT_STATE_VERSIONS_MIGRATIONS_MAP = void 0;
37
4
  const chat_1 = require("@empiricalrun/llm/chat");
38
5
  Object.defineProperty(exports, "createChatModel", { enumerable: true, get: function () { return chat_1.createChatModel; } });
39
6
  const agent_loop_1 = require("./agent-loop");
40
7
  Object.defineProperty(exports, "chatAgentLoop", { enumerable: true, get: function () { return agent_loop_1.chatAgentLoop; } });
41
- const State = __importStar(require("./state"));
42
- const { createChatState, createChatStateForMessages, chatStateFromModel, loadChatState, saveToDisk, CURRENT_CHAT_STATE_VERSION, } = State;
43
- exports.createChatState = createChatState;
44
- exports.createChatStateForMessages = createChatStateForMessages;
45
- exports.chatStateFromModel = chatStateFromModel;
46
- exports.loadChatState = loadChatState;
47
- exports.saveToDisk = saveToDisk;
48
- exports.CURRENT_CHAT_STATE_VERSION = CURRENT_CHAT_STATE_VERSION;
8
+ const models_1 = require("./models");
9
+ Object.defineProperty(exports, "defaultModel", { enumerable: true, get: function () { return models_1.defaultModel; } });
10
+ Object.defineProperty(exports, "SUPPORTED_CHAT_MODELS", { enumerable: true, get: function () { return models_1.SUPPORTED_CHAT_MODELS; } });
11
+ const state_1 = require("./state");
12
+ Object.defineProperty(exports, "CHAT_STATE_VERSIONS_MIGRATIONS_MAP", { enumerable: true, get: function () { return state_1.CHAT_STATE_VERSIONS_MIGRATIONS_MAP; } });
13
+ Object.defineProperty(exports, "chatStateFromModel", { enumerable: true, get: function () { return state_1.chatStateFromModel; } });
14
+ Object.defineProperty(exports, "createChatState", { enumerable: true, get: function () { return state_1.createChatState; } });
15
+ Object.defineProperty(exports, "createChatStateForMessages", { enumerable: true, get: function () { return state_1.createChatStateForMessages; } });
16
+ Object.defineProperty(exports, "getLatestDownloadBuildUrl", { enumerable: true, get: function () { return state_1.getLatestDownloadBuildUrl; } });
17
+ Object.defineProperty(exports, "LATEST_CHAT_STATE_VERSION", { enumerable: true, get: function () { return state_1.LATEST_CHAT_STATE_VERSION; } });
18
+ Object.defineProperty(exports, "migrateChatState", { enumerable: true, get: function () { return state_1.migrateChatState; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AA0BhC,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,iBAgGA;AA0BD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBAkDA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAmChC,wBAAsB,kBAAkB,CAAC,EACvC,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,iBAiGA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBAsDA"}
@@ -11,13 +11,14 @@ const file_tree_1 = require("../../utils/file-tree");
11
11
  const git_1 = require("../../utils/git");
12
12
  const agent_loop_1 = require("./agent-loop");
13
13
  const state_1 = require("./state");
14
+ const DASHBOARD_DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
14
15
  function stopCriteria(userPrompt) {
15
16
  return userPrompt?.toLowerCase() === "stop";
16
17
  }
17
18
  function concludeAgent(chatModel, useDiskForChatState, selectedModel) {
18
19
  console.log(`\n${(0, picocolors_1.gray)("Usage summary -> " + chatModel.getUsageSummary())}`);
19
20
  if (useDiskForChatState) {
20
- (0, state_1.saveToDisk)(chatModel.messages, selectedModel);
21
+ (0, state_1.saveToDisk)(chatModel.messages, selectedModel, chatModel.askUserForInput);
21
22
  }
22
23
  }
23
24
  async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialPromptContent, }) {
@@ -54,7 +55,7 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
54
55
  let userPrompt;
55
56
  let reporterFunc = async (chatState, latest) => {
56
57
  if (useDiskForChatState) {
57
- (0, state_1.saveToDisk)(chatState.messages, selectedModel);
58
+ (0, state_1.saveToDisk)(chatState.messages, selectedModel, chatState.askUserForInput);
58
59
  }
59
60
  if (latest) {
60
61
  console.log(`${(0, picocolors_1.blue)(latest.role)}: ${latest.textMessage}`);
@@ -99,6 +100,7 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
99
100
  trace,
100
101
  toolCallService,
101
102
  fileInfo,
103
+ isToolExecutionRemote: false,
102
104
  });
103
105
  }
104
106
  }
@@ -111,7 +113,6 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
111
113
  const usageSummary = chatModel.getUsageSummary();
112
114
  console.log(`\n${(0, picocolors_1.gray)("Usage summary -> " + usageSummary)}`);
113
115
  }
114
- const DASHBOARD_DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
115
116
  async function getChatSessionFromDashboard(chatSessionId) {
116
117
  const response = await fetch(`${DASHBOARD_DOMAIN}/api/chat-sessions/${chatSessionId}`, {
117
118
  headers: {
@@ -127,7 +128,11 @@ async function getChatSessionFromDashboard(chatSessionId) {
127
128
  }
128
129
  async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
129
130
  const chatSession = await getChatSessionFromDashboard(chatSessionId);
130
- const chatState = chatSession.chat_state;
131
+ let chatState = chatSession.chat_state;
132
+ // If not already canonical, migrate to canonical format
133
+ if (!chatState.version || chatState.version !== state_1.LATEST_CHAT_STATE_VERSION) {
134
+ chatState = (0, state_1.migrateChatState)(chatState);
135
+ }
131
136
  const branchName = chatSession.branch_name;
132
137
  const trace = llm_1.langfuseInstance?.trace({
133
138
  id: chatSession.langfuse_trace_id,
@@ -164,5 +169,6 @@ async function runChatAgentForDashboard({ chatSessionId, selectedModel, }) {
164
169
  trace,
165
170
  toolCallService,
166
171
  fileInfo,
172
+ isToolExecutionRemote: false,
167
173
  });
168
174
  }
@@ -0,0 +1,6 @@
1
+ import type { ModelInfo } from "@empiricalrun/shared-types";
2
+ export declare const SUPPORTED_CHAT_MODELS: readonly ModelInfo[];
3
+ export type SupportedChatModels = (typeof SUPPORTED_CHAT_MODELS)[number]["id"];
4
+ export declare const defaultModel: SupportedChatModels;
5
+ export declare const modelLabels: Record<SupportedChatModels, string>;
6
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,eAAO,MAAM,qBAAqB,EAAE,SAAS,SAAS,EAqB5C,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAW/E,eAAO,MAAM,YAAY,EAAE,mBAA6C,CAAC;AAEzE,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAOzD,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelLabels = exports.defaultModel = exports.SUPPORTED_CHAT_MODELS = void 0;
4
+ exports.SUPPORTED_CHAT_MODELS = [
5
+ {
6
+ id: "gemini-2.5-pro-preview-03-25",
7
+ label: "Gemini 2.5 Pro",
8
+ provider: "google",
9
+ },
10
+ {
11
+ id: "o4-mini-2025-04-16",
12
+ label: "OpenAI O4 Mini",
13
+ provider: "openai",
14
+ },
15
+ {
16
+ id: "claude-3-7-sonnet-20250219",
17
+ label: "Claude 3.7 Sonnet",
18
+ provider: "claude",
19
+ },
20
+ {
21
+ id: "claude-3-5-sonnet-20241022",
22
+ label: "Claude 3.5 Sonnet",
23
+ provider: "claude",
24
+ },
25
+ ];
26
+ const DEFAULT_CHAT_MODEL_ID = "gemini-2.5-pro-preview-03-25";
27
+ function getDefaultChatModelId() {
28
+ if (!exports.SUPPORTED_CHAT_MODELS.some((m) => m.id === DEFAULT_CHAT_MODEL_ID)) {
29
+ throw new Error("Default chat model is not in SUPPORTED_CHAT_MODELS");
30
+ }
31
+ return DEFAULT_CHAT_MODEL_ID;
32
+ }
33
+ exports.defaultModel = getDefaultChatModelId();
34
+ exports.modelLabels = exports.SUPPORTED_CHAT_MODELS.reduce((acc, model) => ({
35
+ ...acc,
36
+ [model.id]: model.label,
37
+ }), {});
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,mBAoEzD"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,mBAiGzD"}