@empiricalrun/test-gen 0.79.4 → 0.79.5

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 (79) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/agent/browsing/run.d.ts +1 -1
  3. package/dist/agent/browsing/run.d.ts.map +1 -1
  4. package/dist/agent/browsing/utils.d.ts +0 -7
  5. package/dist/agent/browsing/utils.d.ts.map +1 -1
  6. package/dist/agent/browsing/utils.js +1 -56
  7. package/dist/agent/master/run.d.ts +1 -1
  8. package/dist/agent/master/run.d.ts.map +1 -1
  9. package/dist/agent/master/run.js +1 -1
  10. package/dist/dashboard/client.d.ts +2 -45
  11. package/dist/dashboard/client.d.ts.map +1 -1
  12. package/dist/dashboard/client.js +4 -217
  13. package/dist/dashboard/index.d.ts +2 -4
  14. package/dist/dashboard/index.d.ts.map +1 -1
  15. package/dist/dashboard/index.js +10 -13
  16. package/dist/dashboard/tool-response-from-sandbox.d.ts +1 -4
  17. package/dist/dashboard/tool-response-from-sandbox.d.ts.map +1 -1
  18. package/dist/dashboard/tool-response-from-sandbox.js +4 -38
  19. package/dist/dashboard/tool-response.d.ts +1 -5
  20. package/dist/dashboard/tool-response.d.ts.map +1 -1
  21. package/dist/dashboard/tool-response.js +5 -87
  22. package/dist/dashboard/types.d.ts +1 -8
  23. package/dist/dashboard/types.d.ts.map +1 -1
  24. package/dist/dashboard/types.js +4 -14
  25. package/dist/file/server.d.ts +1 -1
  26. package/dist/file/server.d.ts.map +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -3
  29. package/dist/recorder/index.d.ts.map +1 -1
  30. package/dist/recorder/index.js +2 -2
  31. package/dist/tools/test-gen-browser.d.ts.map +1 -1
  32. package/dist/tools/test-gen-browser.js +3 -3
  33. package/package.json +3 -1
  34. package/tsconfig.tsbuildinfo +1 -1
  35. package/dist/agent/cua/computer.d.ts +0 -14
  36. package/dist/agent/cua/computer.d.ts.map +0 -1
  37. package/dist/agent/cua/computer.js +0 -191
  38. package/dist/agent/cua/index.d.ts +0 -22
  39. package/dist/agent/cua/index.d.ts.map +0 -1
  40. package/dist/agent/cua/index.js +0 -254
  41. package/dist/agent/cua/model.d.ts +0 -25
  42. package/dist/agent/cua/model.d.ts.map +0 -1
  43. package/dist/agent/cua/model.js +0 -66
  44. package/dist/agent/cua/pw-codegen/element-from-point.d.ts +0 -10
  45. package/dist/agent/cua/pw-codegen/element-from-point.d.ts.map +0 -1
  46. package/dist/agent/cua/pw-codegen/element-from-point.js +0 -135
  47. package/dist/agent/cua/pw-codegen/factory.d.ts +0 -15
  48. package/dist/agent/cua/pw-codegen/factory.d.ts.map +0 -1
  49. package/dist/agent/cua/pw-codegen/factory.js +0 -59
  50. package/dist/agent/cua/pw-codegen/index.d.ts +0 -7
  51. package/dist/agent/cua/pw-codegen/index.d.ts.map +0 -1
  52. package/dist/agent/cua/pw-codegen/index.js +0 -14
  53. package/dist/agent/cua/pw-codegen/pw-event-sink/index.d.ts +0 -43
  54. package/dist/agent/cua/pw-codegen/pw-event-sink/index.d.ts.map +0 -1
  55. package/dist/agent/cua/pw-codegen/pw-event-sink/index.js +0 -250
  56. package/dist/agent/cua/pw-codegen/pw-pause/for-recorder.d.ts +0 -14
  57. package/dist/agent/cua/pw-codegen/pw-pause/for-recorder.d.ts.map +0 -1
  58. package/dist/agent/cua/pw-codegen/pw-pause/for-recorder.js +0 -88
  59. package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts +0 -17
  60. package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +0 -1
  61. package/dist/agent/cua/pw-codegen/pw-pause/index.js +0 -117
  62. package/dist/agent/cua/pw-codegen/pw-pause/ipc.d.ts +0 -3
  63. package/dist/agent/cua/pw-codegen/pw-pause/ipc.d.ts.map +0 -1
  64. package/dist/agent/cua/pw-codegen/pw-pause/ipc.js +0 -13
  65. package/dist/agent/cua/pw-codegen/pw-pause/patch.d.ts +0 -24
  66. package/dist/agent/cua/pw-codegen/pw-pause/patch.d.ts.map +0 -1
  67. package/dist/agent/cua/pw-codegen/pw-pause/patch.js +0 -197
  68. package/dist/agent/cua/pw-codegen/pw-pause/types.d.ts +0 -14
  69. package/dist/agent/cua/pw-codegen/pw-pause/types.d.ts.map +0 -1
  70. package/dist/agent/cua/pw-codegen/pw-pause/types.js +0 -2
  71. package/dist/agent/cua/pw-codegen/pw-pause/utils.d.ts +0 -2
  72. package/dist/agent/cua/pw-codegen/pw-pause/utils.d.ts.map +0 -1
  73. package/dist/agent/cua/pw-codegen/pw-pause/utils.js +0 -6
  74. package/dist/agent/cua/pw-codegen/types.d.ts +0 -47
  75. package/dist/agent/cua/pw-codegen/types.d.ts.map +0 -1
  76. package/dist/agent/cua/pw-codegen/types.js +0 -2
  77. package/dist/agent/cua/pw-codegen/version.d.ts +0 -25
  78. package/dist/agent/cua/pw-codegen/version.d.ts.map +0 -1
  79. package/dist/agent/cua/pw-codegen/version.js +0 -86
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.79.5
4
+
5
+ ### Patch Changes
6
+
7
+ - b58777e: refactor: extract CUA agent into standalone @empiricalrun/cua package
8
+ - fda9bc3: feat: extract DashboardAPIClient into standalone @empiricalrun/dashboard-client package
9
+ - Updated dependencies [b58777e]
10
+ - Updated dependencies [fda9bc3]
11
+ - @empiricalrun/cua@0.2.0
12
+ - @empiricalrun/dashboard-client@0.2.0
13
+
3
14
  ## 0.79.4
4
15
 
5
16
  ### Patch Changes
@@ -1,5 +1,5 @@
1
+ import { BrowserAgentResult } from "@empiricalrun/cua";
1
2
  import { Usage } from "@empiricalrun/shared-types/chat-agent";
2
- import { BrowserAgentResult } from "../cua";
3
3
  type GenerateTestsType = {
4
4
  testCaseName: string;
5
5
  testCaseSuites: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uCAAuC,CAAC;AAa9D,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"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/browsing/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,uCAAuC,CAAC;AAc9D,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"}
@@ -1,21 +1,14 @@
1
1
  import { Page } from "playwright";
2
2
  import { PlaywrightTestConfig } from "playwright/test";
3
3
  export declare function isRegExp(obj: any): obj is RegExp;
4
- export declare function prepareBrowsingAgentTask(steps: string[]): string;
5
4
  export declare function addImportForMethod(testFilePath: string, methodName: string): void;
6
5
  export declare function replaceTodoWithCreateTest(testFilePath: string, repoDir: string): string | undefined;
7
- export declare function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }: {
8
- testCaseName: string;
9
- testCaseSuites: string[];
10
- specPath: string;
11
- }): Promise<void>;
12
6
  export declare function injectPwLocatorGenerator(page: Page): Promise<void>;
13
7
  /**
14
8
  * function to read playwright config from the source repo
15
9
  * @return {*} {Promise<PlaywrightTestConfig>}
16
10
  */
17
11
  export declare function readPlaywrightConfig(repoDir: string): Promise<PlaywrightTestConfig>;
18
- export declare function getValidProjectNames(playwrightConfig: PlaywrightTestConfig): Promise<string[]>;
19
12
  /**
20
13
  * detect the project name for the given file in playwright test repo
21
14
  * if project and test file path for running test don't match, then playwright throws error
@@ -1 +1 @@
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"}
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;AAOvD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,CAKhD;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,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBA0GxD;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CA2B/B;AAWD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,gBAAgB,GAAE,MAAM,EAAU,GACjC,OAAO,CAAC,MAAM,CAAC,CA+CjB"}
@@ -4,13 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.isRegExp = isRegExp;
7
- exports.prepareBrowsingAgentTask = prepareBrowsingAgentTask;
8
7
  exports.addImportForMethod = addImportForMethod;
9
8
  exports.replaceTodoWithCreateTest = replaceTodoWithCreateTest;
10
- exports.markTestAsOnly = markTestAsOnly;
11
9
  exports.injectPwLocatorGenerator = injectPwLocatorGenerator;
12
10
  exports.readPlaywrightConfig = readPlaywrightConfig;
13
- exports.getValidProjectNames = getValidProjectNames;
14
11
  exports.detectProjectName = detectProjectName;
15
12
  const fs_1 = __importDefault(require("fs"));
16
13
  const minimatch_1 = require("minimatch");
@@ -22,11 +19,6 @@ function isRegExp(obj) {
22
19
  return (obj instanceof RegExp ||
23
20
  Object.prototype.toString.call(obj) === "[object RegExp]");
24
21
  }
25
- function prepareBrowsingAgentTask(steps) {
26
- const sanitizedSteps = steps.map((step) => step.replace(/`/g, "\\`"));
27
- const task = `${sanitizedSteps.join("\n")}\n`;
28
- return task;
29
- }
30
22
  function addImportForMethod(testFilePath, methodName) {
31
23
  // Instead of using "@empiricalrun/test-gen", we use the local dist file
32
24
  // This is to avoid assuming that the test-gen package is installed in the project
@@ -50,50 +42,12 @@ function replaceTodoWithCreateTest(testFilePath, repoDir) {
50
42
  addImportForMethod(absoluteTestFilePath, "createTest");
51
43
  return todoContent;
52
44
  }
53
- async function markTestAsOnly({ testCaseName, testCaseSuites, specPath, }) {
54
- const testFileContent = fs_1.default.readFileSync(specPath, "utf-8");
55
- const { testBlock, testNode } = (0, web_1.getTypescriptTestBlock)({
56
- scenarioName: testCaseName,
57
- content: testFileContent,
58
- suites: testCaseSuites,
59
- });
60
- const parentDescribe = (0, web_1.findFirstSerialDescribeBlock)(testNode);
61
- const isFileMarkedSerial = await (0, web_1.hasTopLevelDescribeConfigureWithSerialMode)(specPath);
62
- // add test.only / describe.only to the spec file so that only that block is executed
63
- if (!isFileMarkedSerial) {
64
- const updatedTestFileContent = newContentsWithTestOnly(testFileContent, testBlock, testBlock, parentDescribe?.getText() || "");
65
- fs_1.default.writeFileSync(specPath, updatedTestFileContent);
66
- }
67
- }
68
- function newContentsWithTestOnly(existingContents, originalTestBlock, updatedTestBlock, parentDescribeBlock) {
69
- if (!parentDescribeBlock) {
70
- const testMarkedAsOnly = updatedTestBlock.replace("test(", "test.only(");
71
- return existingContents.replace(originalTestBlock, testMarkedAsOnly);
72
- }
73
- else {
74
- const updatedDescribeBlock = parentDescribeBlock.replace(originalTestBlock, updatedTestBlock);
75
- // TODO: this should only happen when the describe block has "serial" execution
76
- const describeMarkedAsOnly = updatedDescribeBlock.replace("test.describe(", "test.describe.only(");
77
- return existingContents.replace(parentDescribeBlock, describeMarkedAsOnly);
78
- }
79
- }
80
45
  async function injectPwLocatorGenerator(page) {
81
- let pathToInstalledTestGen = require.resolve(".").split("dist")[0];
82
- if (process.env.RUNNING_BROWSER_TESTS_FOR_TEST_GEN) {
83
- pathToInstalledTestGen = process.cwd();
84
- }
85
- const annotateElementPath = path_1.default.join(pathToInstalledTestGen, "dist", "browser-injected-scripts", "annotate-elements.js");
86
- if (!fs_1.default.existsSync(annotateElementPath)) {
87
- throw new Error(`annotate-elements.js not found at path: ${annotateElementPath}`);
88
- }
89
46
  const remoteScriptResponses = await Promise.all([
90
47
  "https://assets-test.empirical.run/pw-selector.js",
91
48
  "https://code.jquery.com/jquery-3.7.1.min.js",
92
49
  ].map((url) => fetch(url)));
93
- const scripts = await Promise.all([
94
- ...remoteScriptResponses.map((r) => r.text()),
95
- fs_1.default.readFileSync(annotateElementPath, "utf-8"),
96
- ]);
50
+ const scripts = await Promise.all(remoteScriptResponses.map((r) => r.text()));
97
51
  page.on("load", async () => {
98
52
  try {
99
53
  await Promise.all(scripts.map((s) => page.addScriptTag({ content: s })));
@@ -219,15 +173,6 @@ function matchAgainstPattern(pattern, filePathToTest) {
219
173
  return (0, minimatch_1.minimatch)(filePathToTest, pattern);
220
174
  }
221
175
  }
222
- async function getValidProjectNames(playwrightConfig) {
223
- if (!playwrightConfig.projects) {
224
- return [];
225
- }
226
- const filteredProjectNames = playwrightConfig.projects
227
- .map((p) => p.name)
228
- .filter((p) => !!p);
229
- return filteredProjectNames;
230
- }
231
176
  /**
232
177
  * detect the project name for the given file in playwright test repo
233
178
  * if project and test file path for running test don't match, then playwright throws error
@@ -2,7 +2,7 @@ import type { TestGenConfigOptions } from "@empiricalrun/shared-types/agent-work
2
2
  import type { TestCaseWithSuitesAsArray } from "@empiricalrun/shared-types/api/test-cases";
3
3
  import { Page } from "playwright";
4
4
  import { ScopeVars } from "../../types";
5
- export { createTestUsingComputerUseAgent } from "../cua";
5
+ export { createTestUsingComputerUseAgent } from "@empiricalrun/cua";
6
6
  export declare const IS_ALLOWED_TO_USE_SKILLS = false;
7
7
  export declare function createTestUsingMasterAgent({ task, page, testCase, specPath, options, scopeVars, }: {
8
8
  task: string;
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAYlC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,QAAQ,CAAC;AAKzD,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAqB9C,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAwJA"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/master/run.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAYlC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAKpE,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAqB9C,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;;;GAwJA"}
@@ -15,7 +15,7 @@ const run_time_planner_1 = require("../planner/run-time-planner");
15
15
  const action_tool_calls_1 = require("./action-tool-calls");
16
16
  const execute_browser_action_1 = require("./execute-browser-action");
17
17
  const next_action_1 = require("./next-action");
18
- var cua_1 = require("../cua");
18
+ var cua_1 = require("@empiricalrun/cua");
19
19
  Object.defineProperty(exports, "createTestUsingComputerUseAgent", { enumerable: true, get: function () { return cua_1.createTestUsingComputerUseAgent; } });
20
20
  const MAX_ERROR_COUNT = 2;
21
21
  // Disabling skills as we're seeing false usage with chat agent
@@ -1,46 +1,3 @@
1
- import { IDashboardAPIClient, RequestOptions } from "@empiricalrun/shared-types/api/base";
2
- export type AuthenticationType = "user-access-token" | "project-api-key" | "admin-totp";
3
- export type TokenProvider = () => Promise<{
4
- access_token: string;
5
- refresh_token: string;
6
- expires_at: number;
7
- user_id?: string;
8
- user_email?: string;
9
- } | null>;
10
- export declare class DashboardAPIClient implements IDashboardAPIClient {
11
- private baseUrl;
12
- private authType;
13
- private projectApiKey?;
14
- private secretKey?;
15
- private tokenProvider?;
16
- constructor({ authType, projectApiKey, secretKey, baseUrl, tokenProvider, }: {
17
- authType: AuthenticationType;
18
- projectApiKey?: string;
19
- secretKey?: string;
20
- baseUrl?: string;
21
- tokenProvider?: TokenProvider;
22
- });
23
- private getTokens;
24
- request<T>(endpoint: string, options: RequestOptions): Promise<T>;
25
- callGitHubProxy<T>({ method, url, body, }: {
26
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
27
- url: string;
28
- body?: any;
29
- }): Promise<T>;
30
- callMailosaurProxy<T>({ method, path, body, }: {
31
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
32
- path: string;
33
- body?: any;
34
- }): Promise<T>;
35
- callWebhookSiteProxy<T>({ method, path, body, }: {
36
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
37
- path: string;
38
- body?: any;
39
- }): Promise<T>;
40
- getBaseUrl(): string;
41
- ensureUserIsAuthenticated(): Promise<void>;
42
- private _makeRequest;
43
- private refreshUserToken;
44
- }
45
- export declare const apiClient: DashboardAPIClient;
1
+ export type { AuthenticationType, TokenProvider, } from "@empiricalrun/dashboard-client";
2
+ export { apiClient, DashboardAPIClient } from "@empiricalrun/dashboard-client";
46
3
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/dashboard/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,cAAc,EACf,MAAM,qCAAqC,CAAC;AAY7C,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,GACnB,iBAAiB,GACjB,YAAY,CAAC;AAEjB,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,IAAI,CAAC,CAAC;AAEV,qBAAa,kBAAmB,YAAW,mBAAmB;IAC5D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAC,CAAgB;gBAE1B,EACV,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,aAAa,GACd,EAAE;QACD,QAAQ,EAAE,kBAAkB,CAAC;QAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,aAAa,CAAC;KAC/B;YAwBa,SAAS;IAOjB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IA+CjE,eAAe,CAAC,CAAC,EAAE,EACvB,MAAM,EACN,GAAG,EACH,IAAI,GACL,EAAE;QACD,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;QACpD,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,GAAG,OAAO,CAAC,CAAC,CAAC;IAYR,kBAAkB,CAAC,CAAC,EAAE,EAC1B,MAAM,EACN,IAAI,EACJ,IAAI,GACL,EAAE;QACD,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;QACpD,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,GAAG,OAAO,CAAC,CAAC,CAAC;IAYR,oBAAoB,CAAC,CAAC,EAAE,EAC5B,MAAM,EACN,IAAI,EACJ,IAAI,GACL,EAAE;QACD,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;QACpD,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,GAAG,OAAO,CAAC,CAAC,CAAC;IAYd,UAAU,IAAI,MAAM;IAKd,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC;YAmBlC,YAAY;YAoDZ,gBAAgB;CAyC/B;AAED,eAAO,MAAM,SAAS,oBAEpB,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/dashboard/client.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,aAAa,GACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,219 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.apiClient = exports.DashboardAPIClient = void 0;
7
- const async_retry_1 = __importDefault(require("async-retry"));
8
- const token_store_1 = require("../auth/token-store");
9
- const logger_1 = require("../logger");
10
- const totp_1 = require("./totp");
11
- const types_1 = require("./types");
12
- class DashboardAPIClient {
13
- baseUrl;
14
- authType;
15
- projectApiKey;
16
- secretKey;
17
- tokenProvider;
18
- constructor({ authType, projectApiKey, secretKey, baseUrl, tokenProvider, }) {
19
- this.baseUrl =
20
- baseUrl || process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
21
- this.authType = authType;
22
- if (this.authType === "project-api-key") {
23
- if (!projectApiKey && !process.env.EMPIRICALRUN_API_KEY) {
24
- throw new Error("Project API key is required when authentication type is 'project-api-key'");
25
- }
26
- this.projectApiKey = projectApiKey || process.env.EMPIRICALRUN_API_KEY;
27
- }
28
- else if (this.authType === "admin-totp") {
29
- if (!secretKey && !process.env.EMPIRICAL_TOTP_SK) {
30
- throw new Error("Secret key is required when authentication type is 'admin-totp'");
31
- }
32
- this.secretKey = secretKey || process.env.EMPIRICAL_TOTP_SK;
33
- }
34
- this.tokenProvider = tokenProvider;
35
- }
36
- async getTokens() {
37
- if (this.tokenProvider) {
38
- return this.tokenProvider();
39
- }
40
- return (0, token_store_1.getStoredUserTokens)();
41
- }
42
- async request(endpoint, options) {
43
- let response;
44
- if (this.secretKey) {
45
- const secretKey = this.secretKey;
46
- response = await this._makeRequest(endpoint, options, async () => ({
47
- "X-Empirical-Auth-TOTP": await (0, totp_1.getTOTP)(secretKey),
48
- }));
49
- }
50
- else if (this.projectApiKey) {
51
- response = await this._makeRequest(endpoint, options, async () => ({
52
- Authorization: `Bearer ${this.projectApiKey}`,
53
- }));
54
- }
55
- else {
56
- await this.ensureUserIsAuthenticated();
57
- const tokens = await this.getTokens();
58
- if (!tokens) {
59
- throw new Error("Not authenticated. Please run the login command first.");
60
- }
61
- response = await this._makeRequest(endpoint, options, async () => ({
62
- Authorization: `Bearer ${tokens.access_token}`,
63
- }));
64
- if (response && response.status === 401) {
65
- logger_1.logger.debug("Access token expired, attempting to refresh...");
66
- const refreshed = await this.refreshUserToken();
67
- if (refreshed) {
68
- const newTokens = await this.getTokens();
69
- if (newTokens) {
70
- response = this._makeRequest(endpoint, options, async () => ({
71
- Authorization: `Bearer ${newTokens.access_token}`,
72
- }));
73
- }
74
- }
75
- throw new Error("Authentication failed. Please run the login command again.");
76
- }
77
- }
78
- if (!response) {
79
- throw new Error("No response received from the API");
80
- }
81
- return response.json();
82
- }
83
- async callGitHubProxy({ method, url, body, }) {
84
- const requestBody = {
85
- method,
86
- url,
87
- body,
88
- };
89
- return await this.request(`/api/github/proxy`, {
90
- method: "POST",
91
- body: requestBody,
92
- });
93
- }
94
- async callMailosaurProxy({ method, path, body, }) {
95
- const requestBody = {
96
- method,
97
- path,
98
- body,
99
- };
100
- return await this.request(`/api/mailosaur/proxy`, {
101
- method: "POST",
102
- body: requestBody,
103
- });
104
- }
105
- async callWebhookSiteProxy({ method, path, body, }) {
106
- const requestBody = {
107
- method,
108
- path,
109
- body,
110
- };
111
- return await this.request(`/api/webhook-site/proxy`, {
112
- method: "POST",
113
- body: requestBody,
114
- });
115
- }
116
- getBaseUrl() {
117
- return this.baseUrl;
118
- }
119
- async ensureUserIsAuthenticated() {
120
- const tokens = await this.getTokens();
121
- if (!tokens) {
122
- throw new Error("Not authenticated. Please run the login command first.");
123
- }
124
- // Check if token is expired (with 5 minute buffer)
125
- const expirationBuffer = 5 * 60;
126
- const now = Math.floor(Date.now() / 1000);
127
- const isExpired = tokens.expires_at <= now + expirationBuffer;
128
- if (isExpired && !this.tokenProvider) {
129
- // Only attempt refresh if using file-based token store
130
- const refreshed = await this.refreshUserToken();
131
- if (!refreshed) {
132
- throw new Error("Session expired. Please run the login command again.");
133
- }
134
- }
135
- }
136
- async _makeRequest(endpoint, options, getAuthHeader) {
137
- const method = options.method || "GET";
138
- const url = new URL(endpoint, this.baseUrl);
139
- if (options.params) {
140
- Object.entries(options.params).forEach(([key, value]) => {
141
- url.searchParams.append(key, value);
142
- });
143
- }
144
- return await (0, async_retry_1.default)(async (bail) => {
145
- const authHeader = await getAuthHeader();
146
- const headers = {
147
- ...authHeader,
148
- "Content-Type": "application/json",
149
- "User-Agent": "@empiricalrun/test-gen",
150
- };
151
- const response = await fetch(url, {
152
- headers,
153
- method: method,
154
- body: options.body ? JSON.stringify(options.body) : undefined,
155
- });
156
- if (!response.ok) {
157
- let error;
158
- const msg = `HTTP error in ${method} request to ${url}! Status code: ${response.status}. Response: ${await response.text()}`;
159
- if (response.status < 500) {
160
- error = new types_1.NonRetryableHTTPError(msg, response.status);
161
- bail(error);
162
- return;
163
- }
164
- else {
165
- error = new types_1.RetryableHTTPError(msg, response.status);
166
- }
167
- throw error;
168
- }
169
- return response;
170
- }, {
171
- retries: 3,
172
- factor: 2,
173
- minTimeout: 1_000,
174
- maxTimeout: 5_000,
175
- });
176
- }
177
- async refreshUserToken() {
178
- const tokens = await this.getTokens();
179
- if (!tokens || !tokens.refresh_token) {
180
- return false;
181
- }
182
- try {
183
- const response = await fetch(`${this.baseUrl}/api/cli/refresh`, {
184
- method: "POST",
185
- headers: {
186
- "Content-Type": "application/json",
187
- },
188
- body: JSON.stringify({
189
- refresh_token: tokens.refresh_token,
190
- }),
191
- });
192
- if (!response.ok) {
193
- const errorText = await response.text();
194
- console.error("Token refresh failed:", errorText);
195
- await (0, token_store_1.clearTokens)();
196
- return false;
197
- }
198
- const data = await response.json();
199
- await (0, token_store_1.storeTokens)({
200
- access_token: data.access_token,
201
- refresh_token: data.refresh_token,
202
- expires_at: data.expires_at,
203
- user_id: data.user?.id || tokens.user_id,
204
- user_email: data.user?.email || tokens.user_email,
205
- });
206
- logger_1.logger.debug("Access token refreshed successfully via dashboard");
207
- return true;
208
- }
209
- catch (error) {
210
- console.error("Token refresh error:", error);
211
- await (0, token_store_1.clearTokens)();
212
- return false;
213
- }
214
- }
215
- }
216
- exports.DashboardAPIClient = DashboardAPIClient;
217
- exports.apiClient = new DashboardAPIClient({
218
- authType: "user-access-token",
219
- });
3
+ exports.DashboardAPIClient = exports.apiClient = void 0;
4
+ var dashboard_client_1 = require("@empiricalrun/dashboard-client");
5
+ Object.defineProperty(exports, "apiClient", { enumerable: true, get: function () { return dashboard_client_1.apiClient; } });
6
+ Object.defineProperty(exports, "DashboardAPIClient", { enumerable: true, get: function () { return dashboard_client_1.DashboardAPIClient; } });
@@ -1,5 +1,3 @@
1
- export { DashboardAPIClient } from "./client";
2
- export { sendErrorToolResponse, sendToolResponse } from "./tool-response";
3
- export { sendErrorToolResponseFromSandbox, sendToolResponseFromSandbox, } from "./tool-response-from-sandbox";
4
- export { HTTPError, NonRetryableHTTPError, RetryableHTTPError } from "./types";
1
+ export type { AuthenticationType, TokenProvider, } from "@empiricalrun/dashboard-client";
2
+ export { DashboardAPIClient, HTTPError, NonRetryableHTTPError, RetryableHTTPError, sendErrorToolResponse, sendErrorToolResponseFromSandbox, sendToolResponse, sendToolResponseFromSandbox, } from "@empiricalrun/dashboard-client";
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EACL,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,aAAa,GACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,gCAAgC,EAChC,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,gCAAgC,CAAC"}
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RetryableHTTPError = exports.NonRetryableHTTPError = exports.HTTPError = exports.sendToolResponseFromSandbox = exports.sendErrorToolResponseFromSandbox = exports.sendToolResponse = exports.sendErrorToolResponse = exports.DashboardAPIClient = void 0;
4
- var client_1 = require("./client");
5
- Object.defineProperty(exports, "DashboardAPIClient", { enumerable: true, get: function () { return client_1.DashboardAPIClient; } });
6
- var tool_response_1 = require("./tool-response");
7
- Object.defineProperty(exports, "sendErrorToolResponse", { enumerable: true, get: function () { return tool_response_1.sendErrorToolResponse; } });
8
- Object.defineProperty(exports, "sendToolResponse", { enumerable: true, get: function () { return tool_response_1.sendToolResponse; } });
9
- var tool_response_from_sandbox_1 = require("./tool-response-from-sandbox");
10
- Object.defineProperty(exports, "sendErrorToolResponseFromSandbox", { enumerable: true, get: function () { return tool_response_from_sandbox_1.sendErrorToolResponseFromSandbox; } });
11
- Object.defineProperty(exports, "sendToolResponseFromSandbox", { enumerable: true, get: function () { return tool_response_from_sandbox_1.sendToolResponseFromSandbox; } });
12
- var types_1 = require("./types");
13
- Object.defineProperty(exports, "HTTPError", { enumerable: true, get: function () { return types_1.HTTPError; } });
14
- Object.defineProperty(exports, "NonRetryableHTTPError", { enumerable: true, get: function () { return types_1.NonRetryableHTTPError; } });
15
- Object.defineProperty(exports, "RetryableHTTPError", { enumerable: true, get: function () { return types_1.RetryableHTTPError; } });
3
+ exports.sendToolResponseFromSandbox = exports.sendToolResponse = exports.sendErrorToolResponseFromSandbox = exports.sendErrorToolResponse = exports.RetryableHTTPError = exports.NonRetryableHTTPError = exports.HTTPError = exports.DashboardAPIClient = void 0;
4
+ var dashboard_client_1 = require("@empiricalrun/dashboard-client");
5
+ Object.defineProperty(exports, "DashboardAPIClient", { enumerable: true, get: function () { return dashboard_client_1.DashboardAPIClient; } });
6
+ Object.defineProperty(exports, "HTTPError", { enumerable: true, get: function () { return dashboard_client_1.HTTPError; } });
7
+ Object.defineProperty(exports, "NonRetryableHTTPError", { enumerable: true, get: function () { return dashboard_client_1.NonRetryableHTTPError; } });
8
+ Object.defineProperty(exports, "RetryableHTTPError", { enumerable: true, get: function () { return dashboard_client_1.RetryableHTTPError; } });
9
+ Object.defineProperty(exports, "sendErrorToolResponse", { enumerable: true, get: function () { return dashboard_client_1.sendErrorToolResponse; } });
10
+ Object.defineProperty(exports, "sendErrorToolResponseFromSandbox", { enumerable: true, get: function () { return dashboard_client_1.sendErrorToolResponseFromSandbox; } });
11
+ Object.defineProperty(exports, "sendToolResponse", { enumerable: true, get: function () { return dashboard_client_1.sendToolResponse; } });
12
+ Object.defineProperty(exports, "sendToolResponseFromSandbox", { enumerable: true, get: function () { return dashboard_client_1.sendToolResponseFromSandbox; } });
@@ -1,5 +1,2 @@
1
- import type { IDashboardAPIClient } from "@empiricalrun/shared-types/api/base";
2
- import type { Logger, MessageCheckpoint, PendingToolCall, ToolResult } from "@empiricalrun/shared-types/chat-agent";
3
- export declare function sendErrorToolResponseFromSandbox(apiClient: IDashboardAPIClient, apiPath: string, toolCalls: PendingToolCall[], errorMessage: string, logger: Logger): Promise<boolean>;
4
- export declare function sendToolResponseFromSandbox(apiClient: IDashboardAPIClient, apiPath: string, toolCalls: PendingToolCall[], toolResults: ToolResult[], checkpoint: MessageCheckpoint | null, logger: Logger): Promise<boolean>;
1
+ export { sendErrorToolResponseFromSandbox, sendToolResponseFromSandbox, } from "@empiricalrun/dashboard-client";
5
2
  //# sourceMappingURL=tool-response-from-sandbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-response-from-sandbox.d.ts","sourceRoot":"","sources":["../../src/dashboard/tool-response-from-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,UAAU,EACX,MAAM,uCAAuC,CAAC;AAI/C,wBAAsB,gCAAgC,CACpD,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,eAAe,EAAE,EAC5B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,oBAcf;AAED,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,eAAe,EAAE,EAC5B,WAAW,EAAE,UAAU,EAAE,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACpC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CA2BlB"}
1
+ {"version":3,"file":"tool-response-from-sandbox.d.ts","sourceRoot":"","sources":["../../src/dashboard/tool-response-from-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,gCAAgC,CAAC"}
@@ -1,40 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendErrorToolResponseFromSandbox = sendErrorToolResponseFromSandbox;
4
- exports.sendToolResponseFromSandbox = sendToolResponseFromSandbox;
5
- const tool_response_1 = require("./tool-response");
6
- const types_1 = require("./types");
7
- async function sendErrorToolResponseFromSandbox(apiClient, apiPath, toolCalls, errorMessage, logger) {
8
- const toolResults = toolCalls.map(() => ({
9
- isError: true,
10
- result: errorMessage,
11
- }));
12
- return sendToolResponseFromSandbox(apiClient, apiPath, toolCalls, toolResults, null, logger);
13
- }
14
- async function sendToolResponseFromSandbox(apiClient, apiPath, toolCalls, toolResults, checkpoint, logger) {
15
- const machineId = (0, tool_response_1.getDefaultMachineId)();
16
- try {
17
- await apiClient.request(apiPath, {
18
- method: "POST",
19
- body: {
20
- toolResults,
21
- toolCalls,
22
- checkpoint,
23
- machineId,
24
- },
25
- });
26
- return true;
27
- }
28
- catch (error) {
29
- // Check if it's a 409 Conflict (tool calls were rejected by user)
30
- if (error instanceof types_1.NonRetryableHTTPError && error.status === 409) {
31
- logger.info("Tool calls were rejected by user (409 Conflict), skipping git push");
32
- return false;
33
- }
34
- logger.error("Failed to send tool response to", {
35
- apiPath,
36
- error,
37
- });
38
- throw error;
39
- }
40
- }
3
+ exports.sendToolResponseFromSandbox = exports.sendErrorToolResponseFromSandbox = void 0;
4
+ var dashboard_client_1 = require("@empiricalrun/dashboard-client");
5
+ Object.defineProperty(exports, "sendErrorToolResponseFromSandbox", { enumerable: true, get: function () { return dashboard_client_1.sendErrorToolResponseFromSandbox; } });
6
+ Object.defineProperty(exports, "sendToolResponseFromSandbox", { enumerable: true, get: function () { return dashboard_client_1.sendToolResponseFromSandbox; } });
@@ -1,6 +1,2 @@
1
- import type { IDashboardAPIClient } from "@empiricalrun/shared-types/api/base";
2
- import type { Logger, MessageCheckpoint, PendingToolCall, ToolResult } from "@empiricalrun/shared-types/chat-agent";
3
- export declare function getDefaultMachineId(): string;
4
- export declare function sendToolResponse(apiClient: IDashboardAPIClient, chatSessionId: number | undefined, requestId: string, toolCalls: PendingToolCall[], toolResults: ToolResult[], checkpoint: MessageCheckpoint | null, logger: Logger, machineId?: string): Promise<boolean>;
5
- export declare function sendErrorToolResponse(apiClient: IDashboardAPIClient, chatSessionId: number | undefined, requestId: string, toolCalls: PendingToolCall[], errorMessage: string, logger: Logger, machineId?: string): Promise<void>;
1
+ export { getDefaultMachineId, sendErrorToolResponse, sendToolResponse, } from "@empiricalrun/dashboard-client";
6
2
  //# sourceMappingURL=tool-response.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-response.d.ts","sourceRoot":"","sources":["../../src/dashboard/tool-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,UAAU,EACX,MAAM,uCAAuC,CAAC;AAI/C,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,eAAe,EAAE,EAC5B,WAAW,EAAE,UAAU,EAAE,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACpC,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,CAoClB;AAED,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,mBAAmB,EAC9B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,eAAe,EAAE,EAC5B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
1
+ {"version":3,"file":"tool-response.d.ts","sourceRoot":"","sources":["../../src/dashboard/tool-response.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC"}