@empiricalrun/test-gen 0.68.0 → 0.69.1

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 (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/agent/chat/exports.d.ts +8 -8
  3. package/dist/agent/chat/exports.d.ts.map +1 -1
  4. package/dist/agent/chat/exports.js +10 -7
  5. package/dist/agent/chat/index.d.ts.map +1 -1
  6. package/dist/agent/chat/index.js +5 -2
  7. package/dist/agent/chat/state.d.ts +4 -2
  8. package/dist/agent/chat/state.d.ts.map +1 -1
  9. package/dist/agent/chat/state.js +10 -2
  10. package/dist/agent/chat/utils.d.ts +5 -1
  11. package/dist/agent/chat/utils.d.ts.map +1 -1
  12. package/dist/agent/chat/utils.js +22 -0
  13. package/dist/agent/cua/pw-codegen/pw-pause/for-recorder.d.ts.map +1 -1
  14. package/dist/agent/cua/pw-codegen/pw-pause/for-recorder.js +24 -3
  15. package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +1 -1
  16. package/dist/agent/cua/pw-codegen/pw-pause/index.js +5 -4
  17. package/dist/agent/cua/pw-codegen/pw-pause/patch.d.ts.map +1 -1
  18. package/dist/agent/cua/pw-codegen/pw-pause/patch.js +4 -6
  19. package/dist/auth/api-client.d.ts +1 -1
  20. package/dist/auth/api-client.d.ts.map +1 -1
  21. package/dist/auth/api-client.js +3 -2
  22. package/dist/auth/cli-auth.js +1 -1
  23. package/dist/bin/index.js +10 -2
  24. package/dist/bin/setup.d.ts +4 -0
  25. package/dist/bin/setup.d.ts.map +1 -0
  26. package/dist/bin/setup.js +86 -0
  27. package/dist/bin/utils/index.d.ts +1 -0
  28. package/dist/bin/utils/index.d.ts.map +1 -1
  29. package/dist/bin/utils/index.js +1 -1
  30. package/dist/file/server.d.ts.map +1 -1
  31. package/dist/file/server.js +60 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +3 -2
  34. package/dist/logger.d.ts +3 -0
  35. package/dist/logger.d.ts.map +1 -0
  36. package/dist/logger.js +11 -0
  37. package/dist/recorder/index.d.ts.map +1 -1
  38. package/dist/recorder/index.js +31 -11
  39. package/dist/recorder/request.d.ts.map +1 -1
  40. package/dist/recorder/request.js +158 -8
  41. package/dist/recorder/temp-files.d.ts +1 -1
  42. package/dist/recorder/temp-files.d.ts.map +1 -1
  43. package/dist/recorder/temp-files.js +7 -7
  44. package/dist/recorder/upload.d.ts.map +1 -1
  45. package/dist/recorder/upload.js +0 -1
  46. package/package.json +6 -4
  47. package/tsconfig.tsbuildinfo +1 -1
  48. package/dist/recorder/display.d.ts +0 -2
  49. package/dist/recorder/display.d.ts.map +0 -1
  50. package/dist/recorder/display.js +0 -50
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @empiricalrun/test-gen
2
2
 
3
+ ## 0.69.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ff84083: feat: request verification for recording, more logs clean up
8
+ - Updated dependencies [ff84083]
9
+ - @empiricalrun/test-run@0.10.5
10
+
11
+ ## 0.69.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 64fa486: feat: user message can have video/webm attachments
16
+
17
+ ### Patch Changes
18
+
19
+ - a2cb0ab: feat: support video attachments for recorder requests
20
+ - b533712: chore: remove verbose logs, hide pw glass pane
21
+ - b9571e9: feat: cli command to clone and setup repo
22
+ - Updated dependencies [a2cb0ab]
23
+ - Updated dependencies [64fa486]
24
+ - Updated dependencies [b533712]
25
+ - @empiricalrun/llm@0.19.0
26
+ - @empiricalrun/test-run@0.10.4
27
+
3
28
  ## 0.68.0
4
29
 
5
30
  ### Minor Changes
@@ -1,9 +1,9 @@
1
- import { createChatModel, IChatModel, SUPPORTED_CHAT_MODELS } from "@empiricalrun/llm/chat";
2
- import { FileInfo } from "../../types";
3
- import { chatAgentLoop } from "./agent-loop";
4
- import { defaultModel } from "./models";
5
- import { CHAT_STATE_VERSIONS_MIGRATIONS_MAP, chatStateFromModel, createChatState, createChatStateForMessages, fetchToolCallAvailability, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, migrateChatState } from "./state";
6
- import { ReporterFunction } from "./types";
7
- export { CHAT_STATE_VERSIONS_MIGRATIONS_MAP, chatAgentLoop, chatStateFromModel, createChatModel, createChatState, createChatStateForMessages, defaultModel, fetchToolCallAvailability, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, migrateChatState, SUPPORTED_CHAT_MODELS, };
8
- export type { FileInfo, IChatModel, ReporterFunction };
1
+ export type { FileInfo } from "../../types";
2
+ export { chatAgentLoop } from "./agent-loop";
3
+ export { defaultModel } from "./models";
4
+ export { CHAT_STATE_VERSIONS_MIGRATIONS_MAP, chatStateFromModel, createChatState, createChatStateForMessages, fetchToolCallAvailability, getLatestDownloadBuildUrl, LATEST_CHAT_STATE_VERSION, migrateChatState, processAttachments, } from "./state";
5
+ export type { ReporterFunction } from "./types";
6
+ export { extractAttachments } from "./utils";
7
+ export type { IChatModel } from "@empiricalrun/llm/chat";
8
+ export { createChatModel, SUPPORTED_CHAT_MODELS } from "@empiricalrun/llm/chat";
9
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,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,kCAAkC,EAClC,kBAAkB,EAClB,eAAe,EACf,0BAA0B,EAC1B,yBAAyB,EACzB,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,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,GACtB,CAAC;AAEF,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/exports.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,kCAAkC,EAClC,kBAAkB,EAClB,eAAe,EACf,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUPPORTED_CHAT_MODELS = exports.migrateChatState = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.fetchToolCallAvailability = exports.defaultModel = exports.createChatStateForMessages = exports.createChatState = exports.createChatModel = exports.chatStateFromModel = exports.chatAgentLoop = exports.CHAT_STATE_VERSIONS_MIGRATIONS_MAP = void 0;
4
- const chat_1 = require("@empiricalrun/llm/chat");
5
- Object.defineProperty(exports, "createChatModel", { enumerable: true, get: function () { return chat_1.createChatModel; } });
6
- Object.defineProperty(exports, "SUPPORTED_CHAT_MODELS", { enumerable: true, get: function () { return chat_1.SUPPORTED_CHAT_MODELS; } });
7
- const agent_loop_1 = require("./agent-loop");
3
+ exports.SUPPORTED_CHAT_MODELS = exports.createChatModel = exports.extractAttachments = exports.processAttachments = exports.migrateChatState = exports.LATEST_CHAT_STATE_VERSION = exports.getLatestDownloadBuildUrl = exports.fetchToolCallAvailability = exports.createChatStateForMessages = exports.createChatState = exports.chatStateFromModel = exports.CHAT_STATE_VERSIONS_MIGRATIONS_MAP = exports.defaultModel = exports.chatAgentLoop = void 0;
4
+ var agent_loop_1 = require("./agent-loop");
8
5
  Object.defineProperty(exports, "chatAgentLoop", { enumerable: true, get: function () { return agent_loop_1.chatAgentLoop; } });
9
- const models_1 = require("./models");
6
+ var models_1 = require("./models");
10
7
  Object.defineProperty(exports, "defaultModel", { enumerable: true, get: function () { return models_1.defaultModel; } });
11
- const state_1 = require("./state");
8
+ var state_1 = require("./state");
12
9
  Object.defineProperty(exports, "CHAT_STATE_VERSIONS_MIGRATIONS_MAP", { enumerable: true, get: function () { return state_1.CHAT_STATE_VERSIONS_MIGRATIONS_MAP; } });
13
10
  Object.defineProperty(exports, "chatStateFromModel", { enumerable: true, get: function () { return state_1.chatStateFromModel; } });
14
11
  Object.defineProperty(exports, "createChatState", { enumerable: true, get: function () { return state_1.createChatState; } });
@@ -17,3 +14,9 @@ Object.defineProperty(exports, "fetchToolCallAvailability", { enumerable: true,
17
14
  Object.defineProperty(exports, "getLatestDownloadBuildUrl", { enumerable: true, get: function () { return state_1.getLatestDownloadBuildUrl; } });
18
15
  Object.defineProperty(exports, "LATEST_CHAT_STATE_VERSION", { enumerable: true, get: function () { return state_1.LATEST_CHAT_STATE_VERSION; } });
19
16
  Object.defineProperty(exports, "migrateChatState", { enumerable: true, get: function () { return state_1.migrateChatState; } });
17
+ Object.defineProperty(exports, "processAttachments", { enumerable: true, get: function () { return state_1.processAttachments; } });
18
+ var utils_1 = require("./utils");
19
+ Object.defineProperty(exports, "extractAttachments", { enumerable: true, get: function () { return utils_1.extractAttachments; } });
20
+ var chat_1 = require("@empiricalrun/llm/chat");
21
+ Object.defineProperty(exports, "createChatModel", { enumerable: true, get: function () { return chat_1.createChatModel; } });
22
+ Object.defineProperty(exports, "SUPPORTED_CHAT_MODELS", { enumerable: true, get: function () { return chat_1.SUPPORTED_CHAT_MODELS; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAwCpC,wBAAsB,yBAAyB,IAAI,OAAO,CACxD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACvB,CAwBA;AAED,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,iBA6HA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA6DA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAyCpC,wBAAsB,yBAAyB,IAAI,OAAO,CACxD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACvB,CAwBA;AAED,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,iBA+HA;AAuBD,wBAAsB,wBAAwB,CAAC,EAC7C,aAAa,EACb,aAAa,GACd,EAAE;IACD,aAAa,EAAE,mBAAmB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,iBA6DA"}
@@ -12,6 +12,7 @@ const file_tree_1 = require("../../utils/file-tree");
12
12
  const git_1 = require("../../utils/git");
13
13
  const agent_loop_1 = require("./agent-loop");
14
14
  const state_1 = require("./state");
15
+ const utils_1 = require("./utils");
15
16
  const DASHBOARD_DOMAIN = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
16
17
  function stopCriteria(userPrompt) {
17
18
  return userPrompt?.toLowerCase() === "stop";
@@ -54,7 +55,7 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
54
55
  let chatModel = (0, chat_1.createChatModel)(messagesLoadedFromDisk, selectedModel);
55
56
  chatModel.validateEnvVarsForAuth();
56
57
  if (initialPromptContent && chatModel.messages.length === 0) {
57
- chatModel.pushUserMessage(initialPromptContent);
58
+ chatModel.pushUserMessage(initialPromptContent, []);
58
59
  chatModel.askUserForInput = false;
59
60
  }
60
61
  else if (initialPromptContent && chatModel.messages.length > 0) {
@@ -116,7 +117,9 @@ async function runChatAgentForCLI({ useDiskForChatState, selectedModel, initialP
116
117
  throw e;
117
118
  }
118
119
  if (!stopCriteria(userPrompt)) {
119
- chatModel.pushUserMessage(userPrompt);
120
+ const { text, attachments } = (0, utils_1.extractAttachments)(userPrompt);
121
+ const processed = await chatModel.processAttachments(attachments);
122
+ chatModel.pushUserMessage(text, processed);
120
123
  }
121
124
  }
122
125
  else {
@@ -1,10 +1,12 @@
1
1
  import { IChatModel } from "@empiricalrun/llm/chat";
2
- import { CanonicalMessage, ChatState, ChatStateError, SupportedChatModels } from "@empiricalrun/shared-types";
2
+ import { Attachment, CanonicalMessage, ChatState, ChatStateError, ProcessedAttachment, SupportedChatModels } from "@empiricalrun/shared-types";
3
3
  export declare const CHAT_STATE_VERSIONS_MIGRATIONS_MAP: Record<string, (state: any) => any>;
4
4
  export declare const LATEST_CHAT_STATE_VERSION = "0.1";
5
5
  export declare const CHAT_STATE_PATH: string;
6
- export declare function createChatState({ userPrompt, existingState, selectedModel, error, }: {
6
+ export declare function processAttachments(attachments: Attachment[], selectedModel: SupportedChatModels): Promise<ProcessedAttachment[]>;
7
+ export declare function createChatState({ userPrompt, attachments, existingState, selectedModel, error, }: {
7
8
  userPrompt: string | undefined;
9
+ attachments: ProcessedAttachment[];
8
10
  existingState: ChatState | undefined;
9
11
  selectedModel: SupportedChatModels;
10
12
  error: ChatStateError | null;
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,cAAc,EACd,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AA+BpC,eAAO,MAAM,kCAAkC,EAAE,MAAM,CACrD,MAAM,EACN,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAIpB,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAQ,CAAC;AAE/C,eAAO,MAAM,eAAe,QAI3B,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,aAAa,EACb,aAAa,EACb,KAAK,GACN,EAAE;IACD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,aAAa,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,aAAa,EAAE,mBAAmB,CAAC;IACnC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CAC9B,aAYA;AAED,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,aAAa,EACb,eAAe,EACf,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,GAAG,CAAC;IACd,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,OAAO,CAAC;IAC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;AAED,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,gBAAgB,EAAE;;;EAe7B"}
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CHAT_STATE_PATH = exports.LATEST_CHAT_STATE_VERSION = exports.CHAT_STATE_VERSIONS_MIGRATIONS_MAP = void 0;
7
+ exports.processAttachments = processAttachments;
7
8
  exports.createChatState = createChatState;
8
9
  exports.createChatStateForMessages = createChatStateForMessages;
9
10
  exports.chatStateFromModel = chatStateFromModel;
@@ -42,11 +43,18 @@ exports.CHAT_STATE_VERSIONS_MIGRATIONS_MAP = {
42
43
  };
43
44
  exports.LATEST_CHAT_STATE_VERSION = "0.1";
44
45
  exports.CHAT_STATE_PATH = path_1.default.join(process.cwd(), ".empiricalrun", "last-chat.json");
45
- function createChatState({ userPrompt, existingState, selectedModel, error, }) {
46
+ async function processAttachments(attachments, selectedModel) {
47
+ const chatModel = (0, chat_1.createChatModel)([], selectedModel);
48
+ if (attachments.length === 0) {
49
+ return [];
50
+ }
51
+ return chatModel.processAttachments(attachments);
52
+ }
53
+ function createChatState({ userPrompt, attachments, existingState, selectedModel, error, }) {
46
54
  const messages = existingState?.messages || [];
47
55
  const chatModel = (0, chat_1.createChatModel)(messages, selectedModel);
48
56
  if (userPrompt) {
49
- chatModel.pushUserMessage(userPrompt);
57
+ chatModel.pushUserMessage(userPrompt, attachments);
50
58
  }
51
59
  return createChatStateForMessages({
52
60
  messages: chatModel.messages,
@@ -1,6 +1,6 @@
1
1
  import { TraceClient } from "@empiricalrun/llm";
2
2
  import { IChatModel } from "@empiricalrun/llm/chat";
3
- import { SupportedChatModels } from "@empiricalrun/shared-types";
3
+ import { Attachment, SupportedChatModels } from "@empiricalrun/shared-types";
4
4
  import { ReporterFunction } from "./types";
5
5
  export declare const log: (...args: any[]) => void;
6
6
  export declare function getModelName(model: string): string;
@@ -12,4 +12,8 @@ export declare function handleAgentError({ context, error, chatModel, selectedMo
12
12
  reporter: ReporterFunction;
13
13
  trace?: TraceClient;
14
14
  }): Promise<void>;
15
+ export declare function extractAttachments(userPrompt: string): {
16
+ text: string;
17
+ attachments: Attachment[];
18
+ };
15
19
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAuB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAEL,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,GAAG,EAAE,SAEjC,CAAC;AAcF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,wBAAsB,gBAAgB,CAAC,EACrC,OAAO,EACP,KAAK,EACL,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,GACN,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC3B,aAAa,EAAE,mBAAmB,CAAC;IACnC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,iBAsBA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/agent/chat/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAuB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EACL,UAAU,EAEV,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,GAAG,EAAE,SAEjC,CAAC;AAcF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED,wBAAsB,gBAAgB,CAAC,EACrC,OAAO,EACP,KAAK,EACL,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,GACN,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC3B,aAAa,EAAE,mBAAmB,CAAC;IACnC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,iBAsBA;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAsBA"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.log = void 0;
4
4
  exports.getModelName = getModelName;
5
5
  exports.handleAgentError = handleAgentError;
6
+ exports.extractAttachments = extractAttachments;
6
7
  const chat_1 = require("@empiricalrun/llm/chat");
7
8
  const picocolors_1 = require("picocolors");
8
9
  const state_1 = require("./state");
@@ -48,3 +49,24 @@ async function handleAgentError({ context, error, chatModel, selectedModel, repo
48
49
  logError(context, error, trace);
49
50
  }
50
51
  }
52
+ function extractAttachments(userPrompt) {
53
+ const attachments = [];
54
+ const urlPattern = /\[\[(https?:\/\/[^\]]+)\]\]/g;
55
+ let match;
56
+ while ((match = urlPattern.exec(userPrompt)) !== null) {
57
+ const name = match[1].split("/").pop();
58
+ if (!name || !name.endsWith(".webm")) {
59
+ throw new Error(`Invalid attachment name: ${name}. Only .webm files are supported.`);
60
+ }
61
+ attachments.push({
62
+ contentType: "video/webm",
63
+ name,
64
+ url: match[1],
65
+ });
66
+ }
67
+ const text = userPrompt.replace(urlPattern, "").trim();
68
+ return {
69
+ text,
70
+ attachments,
71
+ };
72
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"for-recorder.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/for-recorder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,iCAAiC;IAO1C,OAAO,CAAC,eAAe;IANzB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,iBAAiB,CAAqB;gBAGpC,eAAe,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;YAKtD,QAAQ;IAWhB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrC,sBAAsB,CAAC,IAAI,EAAE,IAAI;CAiBxC"}
1
+ {"version":3,"file":"for-recorder.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/for-recorder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,iCAAiC;IAO1C,OAAO,CAAC,eAAe;IANzB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,iBAAiB,CAAqB;gBAGpC,eAAe,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;YAKtD,QAAQ;IAWhB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrC,sBAAsB,CAAC,IAAI,EAAE,IAAI;CAmCxC"}
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PlaywrightPauseCodegenForRecorder = void 0;
7
7
  const express_1 = __importDefault(require("express"));
8
+ const logger_1 = require("../../../../logger");
8
9
  const ipc_1 = require("./ipc");
9
10
  class PlaywrightPauseCodegenForRecorder {
10
11
  sourcesCallback;
@@ -19,7 +20,9 @@ class PlaywrightPauseCodegenForRecorder {
19
20
  async saveCode(code) {
20
21
  const generatedCode = code.map((c) => c.actions.join("\n")).join("\n");
21
22
  if (generatedCode) {
22
- console.log(`[PlaywrightPauseCodegen] Received code from Playwright: ${generatedCode}`);
23
+ // console.log(
24
+ // `[PlaywrightPauseCodegen] Received code from Playwright: ${generatedCode}`,
25
+ // );
23
26
  this.codeForLastAction = generatedCode;
24
27
  await this.sourcesCallback(code);
25
28
  }
@@ -36,13 +39,20 @@ class PlaywrightPauseCodegenForRecorder {
36
39
  await new Promise((resolve) => {
37
40
  this.server = app.listen(this.port, () => resolve());
38
41
  });
39
- console.log(`Server started on port ${this.port}`);
42
+ logger_1.logger.debug(`Server started on port ${this.port}`);
40
43
  // Start page.pause experience in the page
41
44
  this.page = page;
42
45
  await this.startPlaywrightCodegen(page);
43
46
  }
44
47
  async startPlaywrightCodegen(page) {
45
48
  // Similar to the same name method in the main codegen
49
+ /**
50
+ * x-pw-glass
51
+ * # inside shadow DOM (closed)
52
+ * |----> x-pw-overlay (controls)
53
+ * |----> x-pw-highlight (red highlight)
54
+ * |----> x-pw-tooltip
55
+ */
46
56
  const timerPromise = new Promise((resolve) => {
47
57
  setTimeout(resolve, 1000);
48
58
  });
@@ -51,11 +61,22 @@ class PlaywrightPauseCodegenForRecorder {
51
61
  const evaluatePromise = page.evaluate(() => {
52
62
  // @ts-ignore
53
63
  console.log(window["__pw_recorderSetMode"]("recording"));
64
+ // Remove playwright's glass pane
54
65
  const glassPane = document.querySelector("x-pw-glass");
55
66
  if (glassPane) {
56
- glassPane.remove();
67
+ const styles = glassPane.getAttribute("style") || "";
68
+ glassPane.setAttribute("style", styles + "; display: none;");
57
69
  }
58
70
  });
71
+ await page.addInitScript(() => {
72
+ setInterval(() => {
73
+ const glassPane = document.querySelector("x-pw-glass");
74
+ if (glassPane) {
75
+ const styles = glassPane.getAttribute("style") || "";
76
+ glassPane.setAttribute("style", styles + "; display: none;");
77
+ }
78
+ }, 300);
79
+ });
59
80
  await Promise.all([pausePromise, evaluatePromise]);
60
81
  }
61
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAKjD,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE9E,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,oBAuCvD;AAED,qBAAa,sBAAuB,YAAW,qBAAqB;IAClE,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,iBAAiB,CAAqB;;YAMhC,QAAQ;IAUhB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrC,sBAAsB,CAAC,IAAI,EAAE,IAAI;IAyBjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAU9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAKjD,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE9E,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,oBAyCvD;AAED,qBAAa,sBAAuB,YAAW,qBAAqB;IAClE,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,iBAAiB,CAAqB;;YAMhC,QAAQ;IAUhB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrC,sBAAsB,CAAC,IAAI,EAAE,IAAI;IAyBjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;CAU9C"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PlaywrightPauseCodegen = exports.revertToOriginalPwCode = exports.preparePlaywrightForCodegen = void 0;
7
7
  exports.canUsePauseCodegen = canUsePauseCodegen;
8
8
  const express_1 = __importDefault(require("express"));
9
+ const logger_1 = require("../../../../logger");
9
10
  const ipc_1 = require("./ipc");
10
11
  const patch_1 = require("./patch");
11
12
  var patch_2 = require("./patch");
@@ -16,12 +17,12 @@ async function canUsePauseCodegen(repoDir) {
16
17
  if (!hasPatchedPwCode) {
17
18
  // This codegen approach requires patching the playwright code to setup an
18
19
  // IPC server <> client that passes generated code from Playwright to @empiricalrun/test-gen
19
- console.log("Cannot use pause codegen because recorder app is not patched");
20
+ logger_1.logger.error("Cannot use pause codegen because recorder app is not patched");
20
21
  return false;
21
22
  }
22
23
  if (!(await (0, ipc_1.isIPCPortAvailable)())) {
23
24
  // The IPC port is hardcoded, and it should be available for IPC to work
24
- console.log("Cannot use pause codegen because IPC port is not available");
25
+ logger_1.logger.error("Cannot use pause codegen because IPC port is not available");
25
26
  return false;
26
27
  }
27
28
  const isRunningHeaded = process.env.RUN_PLAYWRIGHT_HEADED &&
@@ -29,7 +30,7 @@ async function canUsePauseCodegen(repoDir) {
29
30
  if (!isRunningHeaded) {
30
31
  // This codegen approach requires running Playwright in headed mode because
31
32
  // it depends on the page.pause() API, which is no-op in headless mode
32
- console.log("Cannot use pause codegen because RUN_PLAYWRIGHT_HEADED is not true");
33
+ logger_1.logger.error("Cannot use pause codegen because RUN_PLAYWRIGHT_HEADED is not true");
33
34
  return false;
34
35
  }
35
36
  // eslint-disable-next-line turbo/no-undeclared-env-vars
@@ -37,7 +38,7 @@ async function canUsePauseCodegen(repoDir) {
37
38
  // PW_CODEGEN_NO_INSPECTOR should be set to true, so that Playwright runs the
38
39
  // EmptyRecorderApp() -- which is the entrypoint to our patched code
39
40
  // Ref: https://github.com/microsoft/playwright/blob/c96558d0691c0377dbc0c772a1bd8120d546e6d7/packages/playwright-core/src/server/recorder/recorderApp.ts#L98
40
- console.log("Cannot use pause codegen because PW_CODEGEN_NO_INSPECTOR is not set");
41
+ logger_1.logger.error("Cannot use pause codegen because PW_CODEGEN_NO_INSPECTOR is not set");
41
42
  return false;
42
43
  }
43
44
  // Need all conditions to be met to use pause codegen
@@ -1 +1 @@
1
- {"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/patch.ts"],"names":[],"mappings":"AAmBA,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,MAAM,iBAehE;AAED,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,mBAgB5D;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,+BAiB/C;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B,CA8BA;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,gCAkB1D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,iBAoB3D;AAED,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,iBAGxD;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,MAAM,iBA2Bb"}
1
+ {"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/patch.ts"],"names":[],"mappings":"AAoBA,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,MAAM,iBAehE;AAED,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,mBAgB5D;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,+BAgB/C;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B,CA8BA;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,gCAkB1D;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,iBAoB3D;AAED,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,iBAGxD;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,MAAM,iBA2Bb"}
@@ -14,6 +14,7 @@ exports.patchPwCode = patchPwCode;
14
14
  const child_process_1 = require("child_process");
15
15
  const fs_1 = __importDefault(require("fs"));
16
16
  const path_1 = __importDefault(require("path"));
17
+ const logger_1 = require("../../../../logger");
17
18
  const ipc_1 = require("./ipc");
18
19
  /**
19
20
  * Helpful commands for debugging:
@@ -59,15 +60,12 @@ async function runNpmList(repoDir) {
59
60
  const output = (0, child_process_1.execSync)("npm ls playwright-core --json --long --production=false", {
60
61
  cwd: repoDir,
61
62
  encoding: "utf-8",
63
+ stdio: ["pipe", "pipe", "pipe"],
62
64
  });
63
65
  return output;
64
66
  }
65
67
  catch (error) {
66
- console.error("Command failed:", error.message);
67
- console.error("Error code:", error.status);
68
- console.error("Signal:", error.signal);
69
- console.error("Stdout:", error.stdout?.toString());
70
- console.error("Stderr:", error.stderr?.toString());
68
+ logger_1.logger.error(`npm ls failed with error: ${error.message} and status: ${error.status}`);
71
69
  }
72
70
  }
73
71
  function getPlaywrightCoreFromNpmList(output) {
@@ -167,5 +165,5 @@ async function patchPwCode(pwVersion, pathToRecorderApp, port) {
167
165
  }`;
168
166
  const newCode = currentFileContents.replace(original, replacement);
169
167
  fs_1.default.writeFileSync(pathToRecorderApp, newCode);
170
- console.log(`Patched Playwright recorder app at ${pathToRecorderApp}`);
168
+ logger_1.logger.debug(`Patched Playwright recorder app at ${pathToRecorderApp}`);
171
169
  }
@@ -3,7 +3,7 @@ declare class APIClient {
3
3
  constructor();
4
4
  request(endpoint: string, options?: RequestInit): Promise<Response>;
5
5
  private makeRequest;
6
- private ensureAuthenticated;
6
+ ensureAuthenticated(): Promise<void>;
7
7
  private refreshToken;
8
8
  }
9
9
  export declare const apiClient: APIClient;
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/auth/api-client.ts"],"names":[],"mappings":"AAOA,cAAM,SAAS;IACb,OAAO,CAAC,MAAM,CAAS;;IAMjB,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,QAAQ,CAAC;YA2BN,WAAW;YAuBX,mBAAmB;YAiBnB,YAAY;CA4C3B;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
1
+ {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/auth/api-client.ts"],"names":[],"mappings":"AAQA,cAAM,SAAS;IACb,OAAO,CAAC,MAAM,CAAS;;IAMjB,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,QAAQ,CAAC;YA2BN,WAAW;IAuBnB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;YAiB5B,YAAY;CA4C3B;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiClient = void 0;
4
+ const logger_1 = require("../logger");
4
5
  const token_store_1 = require("./token-store");
5
6
  class APIClient {
6
7
  appUrl;
@@ -15,7 +16,7 @@ class APIClient {
15
16
  }
16
17
  const response = await this.makeRequest(endpoint, options, tokens.access_token);
17
18
  if (response.status === 401) {
18
- // console.log("Access token expired, attempting to refresh...");
19
+ logger_1.logger.debug("Access token expired, attempting to refresh...");
19
20
  const refreshed = await this.refreshToken();
20
21
  if (refreshed) {
21
22
  const newTokens = await (0, token_store_1.getStoredTokens)();
@@ -89,7 +90,7 @@ class APIClient {
89
90
  user_id: data.user?.id || tokens.user_id,
90
91
  user_email: data.user?.email || tokens.user_email,
91
92
  });
92
- console.log("Access token refreshed successfully via dashboard");
93
+ logger_1.logger.debug("Access token refreshed successfully via dashboard");
93
94
  return true;
94
95
  }
95
96
  catch (error) {
@@ -147,7 +147,7 @@ async function authenticate() {
147
147
  server.listen(clientPort, () => {
148
148
  // Open browser to your Next.js auth page
149
149
  const authUrl = `${appUrl}/auth/cli?redirect_uri=${encodeURIComponent(redirectUri)}`;
150
- console.log("Opening browser for authentication...");
150
+ console.log("šŸ” Opening browser for authentication...\n");
151
151
  console.log(`If the browser doesn't open automatically, visit: ${authUrl}`);
152
152
  (0, open_1.default)(authUrl).catch((err) => {
153
153
  console.warn("Could not open browser automatically:", err.message);
package/dist/bin/index.js CHANGED
@@ -23,6 +23,7 @@ const reporter_1 = require("../reporter");
23
23
  const session_1 = require("../session");
24
24
  const test_build_1 = require("../test-build");
25
25
  const logger_1 = require("./logger");
26
+ const setup_1 = require("./setup");
26
27
  const utils_2 = require("./utils");
27
28
  const scenarios_1 = require("./utils/scenarios");
28
29
  dotenv_1.default.config({
@@ -198,7 +199,6 @@ async function main() {
198
199
  .command("login")
199
200
  .description("Authenticate with your Empirical account")
200
201
  .action(async () => {
201
- console.log("šŸ” Starting authentication...\n");
202
202
  try {
203
203
  const result = await (0, auth_1.authenticate)();
204
204
  if (result.success) {
@@ -206,7 +206,6 @@ async function main() {
206
206
  if (result.user) {
207
207
  console.log(`šŸ‘¤ Logged in as: ${result.user.email}`);
208
208
  }
209
- console.log("\nYou can now use authenticated CLI commands.\n");
210
209
  }
211
210
  else {
212
211
  console.error("āŒ Authentication failed:", result.error);
@@ -302,6 +301,15 @@ async function main() {
302
301
  });
303
302
  process.exit(0);
304
303
  });
304
+ program
305
+ .command("setup")
306
+ .description("Clone a repository from your projects")
307
+ .option("--repo-name <string>", "Name of the repository to clone")
308
+ .action(async (opts) => {
309
+ const options = await (0, utils_2.validateAndCompleteCliOptions)(opts, ["repoName"]);
310
+ await (0, setup_1.runSetup)({ repoName: options.repoName });
311
+ process.exit(0);
312
+ });
305
313
  program
306
314
  .command("legacy")
307
315
  .description("Run the legacy workflows")
@@ -0,0 +1,4 @@
1
+ export declare function runSetup({ repoName }: {
2
+ repoName: string;
3
+ }): Promise<void>;
4
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/bin/setup.ts"],"names":[],"mappings":"AA+EA,wBAAsB,QAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,iBA2BhE"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runSetup = runSetup;
7
+ const child_process_1 = require("child_process");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const util_1 = require("util");
11
+ const api_client_1 = require("../auth/api-client");
12
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
13
+ async function cloneRepository(cloneUrl, repoName) {
14
+ const targetDir = path_1.default.join(process.cwd(), repoName);
15
+ if (fs_1.default.existsSync(targetDir)) {
16
+ console.error(`Directory '${repoName}' already exists in current location`);
17
+ process.exit(1);
18
+ }
19
+ console.log(`šŸ“„ Cloning repository to ./${repoName}...`);
20
+ const { stderr } = await execAsync(`git clone ${cloneUrl} ${repoName}`, {
21
+ cwd: process.cwd(),
22
+ });
23
+ if (stderr && !stderr.includes("Cloning into")) {
24
+ console.error(`Git clone error: ${stderr}`);
25
+ process.exit(1);
26
+ }
27
+ console.log(`āœ… Repository cloned successfully to ./${repoName}`);
28
+ return targetDir;
29
+ }
30
+ async function installDependencies(targetDir) {
31
+ console.log(`šŸ“¦ Installing dependencies...`);
32
+ try {
33
+ const { stderr: installStderr } = await execAsync(`npm install`, {
34
+ cwd: targetDir,
35
+ });
36
+ if (installStderr && !installStderr.toLowerCase().includes("npm warn")) {
37
+ console.error(`npm install error: ${installStderr}`);
38
+ process.exit(1);
39
+ }
40
+ console.log(`āœ… Dependencies installed successfully`);
41
+ }
42
+ catch (installError) {
43
+ console.error(`āŒ Failed to install dependencies: ${installError.message}`);
44
+ process.exit(1);
45
+ }
46
+ }
47
+ async function installPlaywrightBrowser(targetDir) {
48
+ console.log(`šŸŽ­ Installing Playwright browser...`);
49
+ try {
50
+ const { stderr: playwrightStderr } = await execAsync(`npx playwright install chromium --with-deps`, {
51
+ cwd: targetDir,
52
+ });
53
+ if (playwrightStderr && !playwrightStderr.includes("Installing")) {
54
+ console.error(`Playwright install error: ${playwrightStderr}`);
55
+ process.exit(1);
56
+ }
57
+ console.log(`āœ… Playwright browser installed successfully`);
58
+ }
59
+ catch (playwrightError) {
60
+ console.error(`āŒ Failed to install Playwright browser: ${playwrightError.message}`);
61
+ process.exit(1);
62
+ }
63
+ }
64
+ async function runSetup({ repoName }) {
65
+ try {
66
+ console.log(`šŸ” Fetching details for repository: ${repoName}`);
67
+ const response = await api_client_1.apiClient.request(`/api/projects/clone?project_repo_name=${repoName}`);
68
+ if (!response.ok) {
69
+ if (response.status === 404) {
70
+ throw new Error(`Repository '${repoName}' not found in your projects`);
71
+ }
72
+ throw new Error(`Failed to fetch repository details: ${response.statusText}`);
73
+ }
74
+ const { data: repoDetails } = await response.json();
75
+ const { clone_url } = repoDetails;
76
+ console.log(`šŸ“‚ Clone URL: ${clone_url}`);
77
+ const targetDir = await cloneRepository(clone_url, repoName);
78
+ await installDependencies(targetDir);
79
+ await installPlaywrightBrowser(targetDir);
80
+ console.log(`\nšŸŽ‰ Setup complete! Repository is ready at ./${repoName}`);
81
+ }
82
+ catch (error) {
83
+ console.error(`āŒ Setup failed: ${error.message}`);
84
+ process.exit(1);
85
+ }
86
+ }
@@ -6,6 +6,7 @@ export interface CLIOptions {
6
6
  file?: string;
7
7
  prompt?: string;
8
8
  suites?: string;
9
+ repoName?: string;
9
10
  }
10
11
  export declare function validateAndCompleteCliOptions(options: CLIOptions, requiredFields?: string[]): Promise<CLIOptions>;
11
12
  export declare function printBanner(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAgBjE,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAQD,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,UAAU,EACnB,cAAc,GAAE,MAAM,EAA+B,GACpD,OAAO,CAAC,UAAU,CAAC,CAqDrB;AAeD,wBAAsB,WAAW,kBAgDhC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAgBjE,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,UAAU,EACnB,cAAc,GAAE,MAAM,EAA+B,GACpD,OAAO,CAAC,UAAU,CAAC,CAqDrB;AAeD,wBAAsB,WAAW,kBAgDhC"}
@@ -100,7 +100,7 @@ async function printBanner() {
100
100
  versionSuffix = ` (latest)`;
101
101
  }
102
102
  else {
103
- versionSuffix = ` ${reset}(latest is ${latestVersion})`;
103
+ versionSuffix = ` ${reset}(latest is v${latestVersion})`;
104
104
  }
105
105
  }
106
106
  const logLine1 = `Running ${PACKAGE_NAME} v${version}${versionSuffix}`;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/file/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAKlE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASlD,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,kBAAkB,CAAC;IAC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