@empiricalrun/test-gen 0.77.0 → 0.78.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 (87) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/agent/base/index.d.ts +3 -3
  3. package/dist/agent/base/index.d.ts.map +1 -1
  4. package/dist/agent/base/index.js +5 -3
  5. package/dist/agent/chat/exports.d.ts +1 -1
  6. package/dist/agent/chat/exports.d.ts.map +1 -1
  7. package/dist/agent/chat/exports.js +1 -3
  8. package/dist/agent/chat/models.d.ts.map +1 -1
  9. package/dist/agent/chat/models.js +1 -1
  10. package/dist/agent/chat/state.d.ts +1 -8
  11. package/dist/agent/chat/state.d.ts.map +1 -1
  12. package/dist/agent/chat/state.js +0 -15
  13. package/dist/agent/cli.d.ts.map +1 -1
  14. package/dist/agent/cli.js +12 -25
  15. package/dist/agent/code-review/index.d.ts +1 -1
  16. package/dist/agent/code-review/index.d.ts.map +1 -1
  17. package/dist/agent/code-review/index.js +3 -0
  18. package/dist/agent/code-review/types.d.ts +9 -9
  19. package/dist/agent/code-review/types.d.ts.map +1 -1
  20. package/dist/agent/triage/index.d.ts +1 -1
  21. package/dist/agent/triage/index.d.ts.map +1 -1
  22. package/dist/agent/triage/index.js +9 -14
  23. package/dist/bin/index.js +0 -55
  24. package/dist/tools/analyse-video/index.d.ts.map +1 -1
  25. package/dist/tools/analyse-video/index.js +8 -2
  26. package/dist/tools/definitions/analyse-video.d.ts +4 -4
  27. package/dist/tools/definitions/analyse-video.js +2 -2
  28. package/dist/tools/executor/base.d.ts +1 -1
  29. package/dist/tools/executor/base.d.ts.map +1 -1
  30. package/dist/tools/executor/base.js +19 -2
  31. package/dist/tools/executor/utils/index.d.ts +5 -3
  32. package/dist/tools/executor/utils/index.d.ts.map +1 -1
  33. package/dist/tools/executor/utils/index.js +22 -1
  34. package/dist/tools/file-operations/replace.d.ts.map +1 -1
  35. package/dist/tools/file-operations/replace.js +20 -21
  36. package/dist/tools/file-operations/shared/helpers.d.ts +3 -5
  37. package/dist/tools/file-operations/shared/helpers.d.ts.map +1 -1
  38. package/dist/tools/file-operations/shared/helpers.js +1 -5
  39. package/dist/tools/review-pull-request/index.d.ts.map +1 -1
  40. package/dist/tools/review-pull-request/index.js +4 -11
  41. package/dist/tools/upgrade-packages/index.d.ts.map +1 -1
  42. package/dist/tools/upgrade-packages/index.js +4 -0
  43. package/dist/tools/upgrade-packages/utils.d.ts +1 -0
  44. package/dist/tools/upgrade-packages/utils.d.ts.map +1 -1
  45. package/dist/tools/upgrade-packages/utils.js +1 -0
  46. package/dist/trace-utils/index.d.ts +1 -1
  47. package/dist/trace-utils/index.d.ts.map +1 -1
  48. package/dist/trace-utils/index.js +1 -1
  49. package/dist/utils/dedup/dedup-image.d.ts +22 -0
  50. package/dist/utils/dedup/dedup-image.d.ts.map +1 -0
  51. package/dist/utils/dedup/dedup-image.js +26 -0
  52. package/dist/utils/dedup/find-threshold.d.ts +2 -0
  53. package/dist/utils/dedup/find-threshold.d.ts.map +1 -0
  54. package/dist/utils/{find-threshold.js → dedup/find-threshold.js} +0 -13
  55. package/dist/video-core/agent-orchestrator.d.ts +1 -2
  56. package/dist/video-core/agent-orchestrator.d.ts.map +1 -1
  57. package/dist/video-core/agent-orchestrator.js +11 -30
  58. package/dist/video-core/index.d.ts +11 -16
  59. package/dist/video-core/index.d.ts.map +1 -1
  60. package/dist/video-core/index.js +110 -180
  61. package/dist/video-core/model-limits.d.ts.map +1 -1
  62. package/dist/video-core/model-limits.js +8 -2
  63. package/dist/video-core/storage-manager.d.ts.map +1 -1
  64. package/dist/video-core/storage-manager.js +13 -6
  65. package/dist/video-core/utils.d.ts +0 -10
  66. package/dist/video-core/utils.d.ts.map +1 -1
  67. package/dist/video-core/utils.js +1 -18
  68. package/package.json +5 -4
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/dist/utils/artifact-paths.d.ts +0 -20
  71. package/dist/utils/artifact-paths.d.ts.map +0 -1
  72. package/dist/utils/artifact-paths.js +0 -16
  73. package/dist/utils/dedup-image-fs.d.ts +0 -13
  74. package/dist/utils/dedup-image-fs.d.ts.map +0 -1
  75. package/dist/utils/dedup-image-fs.js +0 -84
  76. package/dist/utils/dedup-image.d.ts +0 -12
  77. package/dist/utils/dedup-image.d.ts.map +0 -1
  78. package/dist/utils/dedup-image.js +0 -25
  79. package/dist/utils/ffmpeg/index.d.ts +0 -26
  80. package/dist/utils/ffmpeg/index.d.ts.map +0 -1
  81. package/dist/utils/ffmpeg/index.js +0 -415
  82. package/dist/utils/find-threshold.d.ts +0 -8
  83. package/dist/utils/find-threshold.d.ts.map +0 -1
  84. package/dist/video-core/analysis-server.d.ts +0 -24
  85. package/dist/video-core/analysis-server.d.ts.map +0 -1
  86. package/dist/video-core/analysis-server.js +0 -398
  87. package/dist/video-core/analysis-viewer.html +0 -1374
@@ -1,4 +1,4 @@
1
- import { IDashboardAPIClient } from "@empiricalrun/shared-types";
1
+ import { IDashboardAPIClient, PendingToolCall, ToolResult } from "@empiricalrun/shared-types";
2
2
  export interface GitHubRepoInfo {
3
3
  owner: string;
4
4
  repo: string;
@@ -50,7 +50,7 @@ export declare function createPullRequest({ owner, repo, title, head, base, body
50
50
  repo: string;
51
51
  title: string;
52
52
  head: string;
53
- base?: string;
53
+ base: string;
54
54
  body: string;
55
55
  labels?: string[];
56
56
  apiClient: IDashboardAPIClient;
@@ -62,16 +62,18 @@ export declare function updatePullRequest({ owner, repo, prNumber, body, apiClie
62
62
  body?: string;
63
63
  apiClient: IDashboardAPIClient;
64
64
  }): Promise<PullRequestInfo>;
65
- export declare function findOrCreatePullRequest({ owner, repo, branchName, title, body, labels, apiClient, }: {
65
+ export declare function findOrCreatePullRequest({ owner, repo, branchName, title, body, base, labels, apiClient, }: {
66
66
  owner: string;
67
67
  repo: string;
68
68
  branchName: string;
69
69
  title: string;
70
70
  body: string;
71
+ base: string;
71
72
  labels?: string[];
72
73
  apiClient: IDashboardAPIClient;
73
74
  }): Promise<{
74
75
  pr: PullRequestInfo;
75
76
  isNew: boolean;
76
77
  }>;
78
+ export declare function validateToolInput<T>(toolCall: PendingToolCall, schema: T): ToolResult | null;
77
79
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/executor/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,eAAe,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;CAC7D;AAED,wBAAsB,aAAa,CAAC,EAClC,KAAK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IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,mBAAmB,CAAC;CAChC,GAAG,OAAO,CAAC,eAAe,CAAC,CAS3B;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,IAAI,EACJ,UAAU,EACV,KAAK,EACL,IAAI,EACJ,MAAM,EACN,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,mBAAmB,CAAC;CAChC,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAoBnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/executor/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,UAAU,EACX,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAiB1D;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM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AK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,mBAAmB,CAAC;CAChC,GAAG,OAAO,CAAC,eAAe,CAAC,CAoB3B;AAED,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,mBAAmB,CAAC;CAChC,GAAG,OAAO,CAAC,eAAe,CAAC,CAS3B;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,IAAI,EACJ,UAAU,EACV,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,mBAAmB,CAAC;CAChC,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAqBnD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,CAAC,GACR,UAAU,GAAG,IAAI,CAwBnB"}
@@ -7,6 +7,7 @@ exports.getMergeableStateDescription = getMergeableStateDescription;
7
7
  exports.createPullRequest = createPullRequest;
8
8
  exports.updatePullRequest = updatePullRequest;
9
9
  exports.findOrCreatePullRequest = findOrCreatePullRequest;
10
+ exports.validateToolInput = validateToolInput;
10
11
  function parseGitHubUrl(url) {
11
12
  const githubIndex = url.indexOf("github.com");
12
13
  if (githubIndex === -1) {
@@ -98,7 +99,7 @@ async function updatePullRequest({ owner, repo, prNumber, body, apiClient, }) {
98
99
  body: updateBody,
99
100
  });
100
101
  }
101
- async function findOrCreatePullRequest({ owner, repo, branchName, title, body, labels, apiClient, }) {
102
+ async function findOrCreatePullRequest({ owner, repo, branchName, title, body, base, labels, apiClient, }) {
102
103
  const existingPR = await getExistingPR({
103
104
  owner,
104
105
  repo,
@@ -113,9 +114,29 @@ async function findOrCreatePullRequest({ owner, repo, branchName, title, body, l
113
114
  repo,
114
115
  title,
115
116
  head: branchName,
117
+ base,
116
118
  body,
117
119
  labels,
118
120
  apiClient,
119
121
  });
120
122
  return { pr: newPR, isNew: true };
121
123
  }
124
+ function validateToolInput(toolCall, schema) {
125
+ const { name: toolName, input } = toolCall;
126
+ const strictSchema = schema._def?.typeName === "ZodObject"
127
+ ? schema.strict()
128
+ : schema;
129
+ const validation = strictSchema.safeParse(input);
130
+ if (!validation.success) {
131
+ const errorMessage = [
132
+ `Schema validation failed for tool "${toolName}".`,
133
+ `\nValidation errors: ${JSON.stringify(validation.error.issues, null, 2)}`,
134
+ ].join("\n");
135
+ return {
136
+ isError: true,
137
+ result: errorMessage,
138
+ artifacts: null,
139
+ };
140
+ }
141
+ return null;
142
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../../src/tools/file-operations/replace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAM1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG9D,iBAAe,sBAAsB,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,gBAAgB,GACjB,EAAE;IACD,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,GAAG,OAAO,CAAC,UAAU,CAAC,CA4EtB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../../src/tools/file-operations/replace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAM1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG9D,iBAAe,sBAAsB,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,gBAAgB,GACjB,EAAE;IACD,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,GAAG,OAAO,CAAC,UAAU,CAAC,CAwEtB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -29,37 +29,36 @@ async function fileStrReplaceExecutor({ input, filePath, absoluteFilePath, repoD
29
29
  };
30
30
  }
31
31
  const content = fs_1.default.readFileSync(absoluteFilePath, "utf8");
32
- // Normalize newlines in both the content and search string
32
+ // Normalize newlines in file content only
33
33
  const normalizedContent = content.replace(/\r\n/g, "\n");
34
- const normalizedOldStr = input.old_str
35
- .replace(/\\n/g, "\n")
36
- .replace(/\r\n/g, "\n");
37
- if (!normalizedContent.includes(normalizedOldStr)) {
34
+ const oldStr = input.old_str;
35
+ // Use literal split/join for replacement to avoid regex and escape sequence issues
36
+ const parts = normalizedContent.split(oldStr);
37
+ const occurrences = parts.length - 1;
38
+ if (occurrences === 0) {
38
39
  return {
39
40
  result: `old_str not found in file: ${filePath}`,
40
41
  isError: true,
41
42
  };
42
43
  }
43
- else {
44
- const escapedOldStr = (0, helpers_1.escapeRegExp)(normalizedOldStr);
45
- const occurences = normalizedContent.match(new RegExp(escapedOldStr, "g"));
46
- if (occurences && occurences.length > 1) {
47
- const uniqueContexts = (0, helpers_1.getUniqueOccurences)(content, input.old_str);
48
- if (uniqueContexts.length === 0) {
49
- return {
50
- result: `Error: old_str found ${occurences.length} times in file: ${filePath}, but no unique contexts could be identified. Try using a more specific string.`,
51
- isError: true,
52
- };
53
- }
54
- const uniqueContextsString = uniqueContexts
55
- .map(({ uniqueContext, lineNumber }, idx) => `${idx + 1}. For occurence at line number ${lineNumber}, unique context is:\n\`\`\`\n${uniqueContext}\n\`\`\`\n`)
56
- .join("\n");
44
+ else if (occurrences > 1) {
45
+ const uniqueContexts = (0, helpers_1.getUniqueOccurences)(content, input.old_str);
46
+ if (uniqueContexts.length === 0) {
57
47
  return {
58
- result: `Error: old_str found ${occurences.length} times in file: ${filePath}. Please use one of these unique contexts instead:\n\n${uniqueContextsString}`,
48
+ result: `Error: old_str found ${occurrences} times in file: ${filePath}. Try using a more specific string.`,
59
49
  isError: true,
60
50
  };
61
51
  }
62
- const newContent = normalizedContent.replace(normalizedOldStr, input.new_str);
52
+ const uniqueContextsString = uniqueContexts
53
+ .map(({ uniqueContext, lineNumber }, idx) => `${idx + 1}. For occurence at line number ${lineNumber}, unique context is:\n\`\`\`\n${uniqueContext}\n\`\`\`\n`)
54
+ .join("\n");
55
+ return {
56
+ result: `Error: old_str found ${occurrences} times in file: ${filePath}. Please use one of these unique contexts instead:\n\n${uniqueContextsString}`,
57
+ isError: true,
58
+ };
59
+ }
60
+ else {
61
+ const newContent = parts.join(input.new_str);
63
62
  fs_1.default.writeFileSync(absoluteFilePath, newContent);
64
63
  // Stage the file
65
64
  (0, child_process_1.execSync)(`git add "${filePath}"`, { cwd: repoDir });
@@ -8,12 +8,10 @@ export interface StrReplaceInputParams {
8
8
  insert_line?: number;
9
9
  insert_text?: string;
10
10
  }
11
- declare function formatLinesWithNumbers(content: string, viewRange?: [number, number]): string;
12
- declare function isBinaryFile(filePath: string): boolean;
13
- declare function getUniqueOccurences(contents: string, old_str: string): {
11
+ export declare function formatLinesWithNumbers(content: string, viewRange?: [number, number]): string;
12
+ export declare function isBinaryFile(filePath: string): boolean;
13
+ export declare function getUniqueOccurences(contents: string, old_str: string): {
14
14
  uniqueContext: string;
15
15
  lineNumber: number;
16
16
  }[];
17
- declare function escapeRegExp(text: string): string;
18
- export { escapeRegExp, formatLinesWithNumbers, getUniqueOccurences, isBinaryFile, };
19
17
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/tools/file-operations/shared/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IAGb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAG9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,iBAAS,sBAAsB,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,MAAM,CAaR;AAED,iBAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA2D/C;AAED,iBAAS,mBAAmB,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,CAyDjD;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,UAEjC;AAED,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,GACb,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/tools/file-operations/shared/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IAGb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAG9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,MAAM,CAaR;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA2DtD;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,CAyDjD"}
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.escapeRegExp = escapeRegExp;
4
3
  exports.formatLinesWithNumbers = formatLinesWithNumbers;
5
- exports.getUniqueOccurences = getUniqueOccurences;
6
4
  exports.isBinaryFile = isBinaryFile;
5
+ exports.getUniqueOccurences = getUniqueOccurences;
7
6
  function formatLinesWithNumbers(content, viewRange) {
8
7
  const lines = content.split("\n");
9
8
  if (viewRange) {
@@ -128,6 +127,3 @@ function getUniqueOccurences(contents, old_str) {
128
127
  }
129
128
  return uniqueContexts;
130
129
  }
131
- function escapeRegExp(text) {
132
- return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
133
- }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/review-pull-request/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAU9D,eAAO,MAAM,qBAAqB,EAAE,IAiGnC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/review-pull-request/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AAS9D,eAAO,MAAM,qBAAqB,EAAE,IA2FnC,CAAC"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reviewPullRequestTool = void 0;
4
- const state_1 = require("../../agent/chat/state");
5
4
  const code_review_1 = require("../../agent/code-review");
6
5
  const executor_1 = require("../../agent/code-review/executor");
7
6
  const review_pull_request_1 = require("../definitions/review-pull-request");
@@ -22,15 +21,6 @@ exports.reviewPullRequestTool = {
22
21
  isError: true,
23
22
  result: "API Client not available",
24
23
  };
25
- // creating chat state to pass to model
26
- const userPrompt = `Review this session: ${sessionUrl}`;
27
- const chatState = (0, state_1.createChatState)({
28
- userPrompt,
29
- attachments: [],
30
- existingState: undefined,
31
- selectedModel: CODE_REVIEW_MODEL,
32
- error: null,
33
- });
34
24
  const span = trace?.span({
35
25
  name: "code-review-agent",
36
26
  input: {
@@ -49,11 +39,14 @@ exports.reviewPullRequestTool = {
49
39
  const agentParams = {
50
40
  featureFlags: [],
51
41
  selectedModel: CODE_REVIEW_MODEL,
52
- chatState,
42
+ chatState: undefined,
53
43
  toolExecutor: codeReviewToolExecutor,
54
44
  trace: span,
55
45
  };
56
46
  const agent = new code_review_1.CodeReviewAgent({ ...agentParams });
47
+ // Push the review prompt to the agent
48
+ const userPrompt = `Review this session: ${sessionUrl}`;
49
+ agent.pushUserMessage([{ text: userPrompt }]);
57
50
  while (!agent.askUserForInput) {
58
51
  await agent.runLoop({
59
52
  reporter: async () => { },
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/upgrade-packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAoBvD,eAAO,MAAM,mBAAmB,EAAE,IAyHjC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/upgrade-packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAoBvD,eAAO,MAAM,mBAAmB,EAAE,IA8HjC,CAAC"}
@@ -62,6 +62,9 @@ exports.upgradePackagesTool = {
62
62
  let shouldMerge = false;
63
63
  let prNumber = null;
64
64
  let merged = false;
65
+ if (!chatSession) {
66
+ throw new Error("Chat session is not available.");
67
+ }
65
68
  if (!apiClient) {
66
69
  throw new Error("Dashboard API client is not available.");
67
70
  }
@@ -71,6 +74,7 @@ exports.upgradePackagesTool = {
71
74
  repo: repoName,
72
75
  apiClient,
73
76
  branchName,
77
+ base: chatSession?.baseBranchName,
74
78
  title: prTitle,
75
79
  body: (0, pr_description_1.addMetadataToPRDescription)(prBody, chatSession),
76
80
  labels: ["automated"],
@@ -1,4 +1,5 @@
1
1
  import { IDashboardAPIClient } from "@empiricalrun/shared-types";
2
+ export declare function isPatchUpdate(currentVersion: string | undefined, newVersion: string | undefined): boolean;
2
3
  export declare function getLatestVersion(packageName: string): Promise<any>;
3
4
  export declare function parsePackageJsonDiff({ diff, }: {
4
5
  diff: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/upgrade-packages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BA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AClC,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,mBAAmB,CAAC;CAChC,oBA8BA;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB;;;GAcA"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPatchUpdate = isPatchUpdate;
3
4
  exports.getLatestVersion = getLatestVersion;
4
5
  exports.parsePackageJsonDiff = parsePackageJsonDiff;
5
6
  exports.shouldMergePR = shouldMergePR;
@@ -1,4 +1,4 @@
1
1
  export { extractFileFromZipFromUrl, getFilenamesInZip, } from "../tools/trace-dot-zip/utils/extract-zip";
2
2
  export { generateNetworkTrace } from "../tools/trace-dot-zip/utils/network-trace";
3
- export { deduplicateImages } from "../utils/dedup-image";
3
+ export { deduplicateImages } from "../utils/dedup/dedup-image";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trace-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trace-utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "extractFileFromZipFromUrl", { enumerable: true,
6
6
  Object.defineProperty(exports, "getFilenamesInZip", { enumerable: true, get: function () { return extract_zip_1.getFilenamesInZip; } });
7
7
  var network_trace_1 = require("../tools/trace-dot-zip/utils/network-trace");
8
8
  Object.defineProperty(exports, "generateNetworkTrace", { enumerable: true, get: function () { return network_trace_1.generateNetworkTrace; } });
9
- var dedup_image_1 = require("../utils/dedup-image");
9
+ var dedup_image_1 = require("../utils/dedup/dedup-image");
10
10
  Object.defineProperty(exports, "deduplicateImages", { enumerable: true, get: function () { return dedup_image_1.deduplicateImages; } });
@@ -0,0 +1,22 @@
1
+ type ImageMetadata = {
2
+ base64: string;
3
+ type: string;
4
+ pageId: string;
5
+ sha1: string;
6
+ width: number;
7
+ height: number;
8
+ timestamp: number;
9
+ };
10
+ export declare function deduplicateImages({ base64Images, threshold, logPrefix, }: {
11
+ base64Images: {
12
+ metadata: ImageMetadata;
13
+ image: string;
14
+ }[];
15
+ threshold: number;
16
+ logPrefix?: string;
17
+ }): Promise<{
18
+ metadata: ImageMetadata;
19
+ image: string;
20
+ }[]>;
21
+ export {};
22
+ //# sourceMappingURL=dedup-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedup-image.d.ts","sourceRoot":"","sources":["../../../src/utils/dedup/dedup-image.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,GAAG;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,EACtC,YAAY,EACZ,SAAS,EACT,SAAyB,GAC1B,EAAE;IACD,YAAY,EAAE;QAAE,QAAQ,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAkCxD"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deduplicateImages = deduplicateImages;
4
+ const find_threshold_1 = require("./find-threshold");
5
+ async function deduplicateImages({ base64Images, threshold, logPrefix = "dedup-image", }) {
6
+ console.log(`[${logPrefix}] Starting deduplication with sequential comparison`);
7
+ console.log(`[${logPrefix}] Input: ${base64Images.length} images, Threshold: ${threshold}`);
8
+ if (base64Images.length === 0) {
9
+ return [];
10
+ }
11
+ const uniqueImages = [];
12
+ let previousImage = null;
13
+ for (const currentImage of base64Images) {
14
+ if (previousImage === null) {
15
+ uniqueImages.push(currentImage);
16
+ previousImage = currentImage.image;
17
+ continue;
18
+ }
19
+ const similarity = await (0, find_threshold_1.findSimilarityPercentage)(previousImage, currentImage.image);
20
+ if (similarity < threshold) {
21
+ uniqueImages.push(currentImage);
22
+ previousImage = currentImage.image;
23
+ }
24
+ }
25
+ return uniqueImages;
26
+ }
@@ -0,0 +1,2 @@
1
+ export declare function findSimilarityPercentage(base64Image1: string, base64Image2: string): Promise<number>;
2
+ //# sourceMappingURL=find-threshold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-threshold.d.ts","sourceRoot":"","sources":["../../../src/utils/dedup/find-threshold.ts"],"names":[],"mappings":"AAsCA,wBAAsB,wBAAwB,CAC5C,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CASjB"}
@@ -3,12 +3,9 @@ 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.compareImageBuffers = compareImageBuffers;
7
6
  exports.findSimilarityPercentage = findSimilarityPercentage;
8
- exports.areImagesDuplicate = areImagesDuplicate;
9
7
  const pixelmatch_1 = __importDefault(require("pixelmatch"));
10
8
  const sharp_1 = __importDefault(require("sharp"));
11
- const PIXELMATCH_THRESHOLD = 0.1;
12
9
  async function compareImageBuffers(buffer1, buffer2, pixelmatchThreshold) {
13
10
  const metadata1 = await (0, sharp_1.default)(buffer1).metadata();
14
11
  const metadata2 = await (0, sharp_1.default)(buffer2).metadata();
@@ -43,13 +40,3 @@ async function findSimilarityPercentage(base64Image1, base64Image2) {
43
40
  throw new Error(`Error calculating similarity: ${error}`);
44
41
  }
45
42
  }
46
- async function areImagesDuplicate(buffer1, buffer2, threshold) {
47
- try {
48
- const { diffFraction } = await compareImageBuffers(buffer1, buffer2, PIXELMATCH_THRESHOLD);
49
- return diffFraction <= threshold;
50
- }
51
- catch (error) {
52
- console.error("Error comparing images for duplication:", error);
53
- return false;
54
- }
55
- }
@@ -1,7 +1,6 @@
1
- import type { Attachment, CanonicalMessage, ChatState, SupportedChatModels } from "@empiricalrun/shared-types";
1
+ import type { Attachment, CanonicalMessage, SupportedChatModels } from "@empiricalrun/shared-types";
2
2
  import { ProcessedAnalysis } from "./types";
3
3
  export declare function extractTextPartFromLastMessage(messages: CanonicalMessage[]): string | null;
4
- export declare function getChatStateWithFrameIdAttachmentParts(attachments: Attachment[], selectedModel: SupportedChatModels): ChatState;
5
4
  export declare function orchestrateVideoAnalysis({ selectedModel, featureFlags, workingDirectory, frameBatch, }: {
6
5
  selectedModel: SupportedChatModels;
7
6
  featureFlags: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"agent-orchestrator.d.ts","sourceRoot":"","sources":["../../src/video-core/agent-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EAEpB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,MAAM,GAAG,IAAI,CAgBf;AAED,wBAAgB,sCAAsC,CACpD,WAAW,EAAE,UAAU,EAAE,EACzB,aAAa,EAAE,mBAAmB,GACjC,SAAS,CAqBX;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,UAAU,EAAE,CAAC;CAC1B,GAAG,OAAO,CACT;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAAE,GAAG,iBAAiB,CAC1E,CAoDA"}
1
+ {"version":3,"file":"agent-orchestrator.d.ts","sourceRoot":"","sources":["../../src/video-core/agent-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EAEpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,MAAM,GAAG,IAAI,CAgBf;AAED,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,UAAU,EAAE,CAAC;CAC1B,GAAG,OAAO,CACT;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAAE,GAAG,iBAAiB,CAC1E,CAgDA"}
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractTextPartFromLastMessage = extractTextPartFromLastMessage;
4
- exports.getChatStateWithFrameIdAttachmentParts = getChatStateWithFrameIdAttachmentParts;
5
4
  exports.orchestrateVideoAnalysis = orchestrateVideoAnalysis;
6
5
  const agent_1 = require("../agent");
7
- const state_1 = require("../agent/chat/state");
8
6
  const executor_1 = require("../agent/video-analysis/executor");
9
7
  const xml_parser_1 = require("./xml-parser");
10
8
  function extractTextPartFromLastMessage(messages) {
@@ -19,33 +17,7 @@ function extractTextPartFromLastMessage(messages) {
19
17
  .map((p) => p.text)
20
18
  .join("\\n");
21
19
  }
22
- function getChatStateWithFrameIdAttachmentParts(attachments, selectedModel) {
23
- const chatState = (0, state_1.createChatState)({
24
- userPrompt: `Analyse the frames and give me a summary at the end.`,
25
- attachments: [],
26
- existingState: undefined,
27
- selectedModel,
28
- error: null,
29
- });
30
- const userMessageWithAttachment = attachments.map((attachment) => ({
31
- text: `Frame ID: ${attachment.name.split(".")[0]}`,
32
- attachments: [attachment],
33
- }));
34
- chatState.messages[0].parts = [
35
- ...chatState.messages[0].parts,
36
- ...userMessageWithAttachment,
37
- ];
38
- return chatState;
39
- }
40
20
  async function orchestrateVideoAnalysis({ selectedModel, featureFlags, workingDirectory, frameBatch, }) {
41
- const frameIds = frameBatch
42
- .map((attachment) => {
43
- const filename = attachment.name || "";
44
- // Remove .png extension if present
45
- return filename.replace(/\.png$/, "");
46
- })
47
- .filter(Boolean)
48
- .join(", ");
49
21
  const allMessages = [];
50
22
  const toolExecutor = new executor_1.VideoAnalysisToolExecutor({
51
23
  chatSession: null,
@@ -53,13 +25,22 @@ async function orchestrateVideoAnalysis({ selectedModel, featureFlags, workingDi
53
25
  featureFlags,
54
26
  environmentOverrides: {},
55
27
  });
56
- const chatState = getChatStateWithFrameIdAttachmentParts(frameBatch, selectedModel);
57
28
  const agent = new agent_1.VideoAnalysisAgent({
58
29
  featureFlags: featureFlags,
59
30
  selectedModel,
60
- chatState,
31
+ chatState: undefined,
61
32
  toolExecutor,
62
33
  });
34
+ const attachmentsWithLabels = frameBatch.map((attachment) => ({
35
+ text: `Frame ID: ${attachment.name.split(".")[0]}`,
36
+ attachments: [attachment],
37
+ }));
38
+ agent.pushUserMessage([
39
+ {
40
+ text: "Analyse the frames and give me a summary at the end.",
41
+ },
42
+ ...attachmentsWithLabels,
43
+ ]);
63
44
  while (!agent.askUserForInput) {
64
45
  await agent.runLoop({
65
46
  reporter: async () => { },
@@ -1,17 +1,12 @@
1
- import { VideoAnalysisParams } from "@empiricalrun/shared-types";
2
- export declare function parseVideoAnalysisParams(paramsString: string): VideoAnalysisParams;
3
- export declare function runVideoAnalysisForCli({ url, params, startServer, }: {
4
- url: string;
5
- params: string;
6
- startServer?: boolean;
7
- }): Promise<import("./analysis-server").AnalysisServerHandle>;
8
- export declare function runVideoAnalysis({ videoUrl, videoUrlHash, params, featureFlags, workingDirectory, skipUpload, }: {
1
+ import { CanonicalMessage, ToolResultPart, UniqueFrameInfos, VideoAnalysisParams } from "@empiricalrun/shared-types";
2
+ export declare function runVideoAnalysis({ videoUrl, videoUrlHash, params, featureFlags, workingDirectory, skipUpload, algo, }: {
9
3
  videoUrl: string;
10
4
  videoUrlHash: string;
11
5
  params: VideoAnalysisParams;
12
6
  featureFlags: string[];
13
7
  workingDirectory: string;
14
8
  skipUpload?: boolean;
9
+ algo?: string;
15
10
  }): Promise<{
16
11
  result: {
17
12
  total_extracted_frames: number;
@@ -22,10 +17,10 @@ export declare function runVideoAnalysis({ videoUrl, videoUrlHash, params, featu
22
17
  analysis_id: string;
23
18
  params: VideoAnalysisParams;
24
19
  };
25
- unique_frames: import("@empiricalrun/shared-types").UniqueFrameInfos[];
26
- interleaved_tool_result: import("@empiricalrun/shared-types").ToolResultPart[];
27
- chat_messages: import("@empiricalrun/shared-types").CanonicalMessage[];
28
- isError: boolean;
20
+ unique_frames: UniqueFrameInfos[];
21
+ interleaved_tool_result: ToolResultPart[];
22
+ chat_messages: CanonicalMessage[];
23
+ error: null;
29
24
  } | {
30
25
  result: {
31
26
  total_extracted_frames: number;
@@ -36,9 +31,9 @@ export declare function runVideoAnalysis({ videoUrl, videoUrlHash, params, featu
36
31
  analysis_id: string;
37
32
  params: VideoAnalysisParams;
38
33
  };
39
- interleaved_tool_result: never[];
40
- chat_messages: never[];
41
- isError: boolean;
42
- unique_frames?: undefined;
34
+ unique_frames: UniqueFrameInfos[];
35
+ interleaved_tool_result: ToolResultPart[];
36
+ chat_messages: CanonicalMessage[];
37
+ error: string;
43
38
  }>;
44
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/video-core/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAa7E,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,GACnB,mBAAmB,CAoCrB;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,GAAG,EACH,MAAM,EACN,WAAkB,GACnB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,6DAuFA;AAED,wBAAsB,gBAAgB,CAAC,EACrC,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,C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