@empiricalrun/test-gen 0.67.0 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/agent/chat/exports.d.ts +8 -8
- package/dist/agent/chat/exports.d.ts.map +1 -1
- package/dist/agent/chat/exports.js +10 -7
- package/dist/agent/chat/index.d.ts.map +1 -1
- package/dist/agent/chat/index.js +5 -2
- package/dist/agent/chat/state.d.ts +4 -2
- package/dist/agent/chat/state.d.ts.map +1 -1
- package/dist/agent/chat/state.js +10 -2
- package/dist/agent/chat/utils.d.ts +5 -1
- package/dist/agent/chat/utils.d.ts.map +1 -1
- package/dist/agent/chat/utils.js +22 -0
- package/dist/agent/cua/pw-codegen/pw-pause/for-recorder.d.ts.map +1 -1
- package/dist/agent/cua/pw-codegen/pw-pause/for-recorder.js +24 -3
- package/dist/agent/cua/pw-codegen/pw-pause/patch.d.ts.map +1 -1
- package/dist/agent/cua/pw-codegen/pw-pause/patch.js +4 -6
- package/dist/auth/api-client.d.ts +1 -2
- package/dist/auth/api-client.d.ts.map +1 -1
- package/dist/auth/api-client.js +15 -45
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -4
- package/dist/bin/index.js +104 -108
- package/dist/bin/setup.d.ts +4 -0
- package/dist/bin/setup.d.ts.map +1 -0
- package/dist/bin/setup.js +86 -0
- package/dist/bin/utils/index.d.ts +2 -7
- package/dist/bin/utils/index.d.ts.map +1 -1
- package/dist/bin/utils/index.js +1 -9
- package/dist/file/server.js +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +11 -0
- package/dist/recorder/env-variables.d.ts +2 -0
- package/dist/recorder/env-variables.d.ts.map +1 -0
- package/dist/recorder/env-variables.js +29 -0
- package/dist/recorder/index.d.ts.map +1 -1
- package/dist/recorder/index.js +25 -34
- package/dist/recorder/request.d.ts +2 -1
- package/dist/recorder/request.d.ts.map +1 -1
- package/dist/recorder/request.js +15 -21
- package/dist/recorder/temp-files.d.ts.map +1 -1
- package/dist/recorder/temp-files.js +5 -4
- package/dist/recorder/upload.d.ts +1 -0
- package/dist/recorder/upload.d.ts.map +1 -1
- package/dist/recorder/upload.js +23 -11
- package/dist/recorder/validation.d.ts +1 -1
- package/dist/recorder/validation.d.ts.map +1 -1
- package/dist/recorder/validation.js +9 -4
- package/package.json +6 -4
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @empiricalrun/test-gen
|
|
2
2
|
|
|
3
|
+
## 0.69.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 64fa486: feat: user message can have video/webm attachments
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a2cb0ab: feat: support video attachments for recorder requests
|
|
12
|
+
- b533712: chore: remove verbose logs, hide pw glass pane
|
|
13
|
+
- b9571e9: feat: cli command to clone and setup repo
|
|
14
|
+
- Updated dependencies [a2cb0ab]
|
|
15
|
+
- Updated dependencies [64fa486]
|
|
16
|
+
- Updated dependencies [b533712]
|
|
17
|
+
- @empiricalrun/llm@0.19.0
|
|
18
|
+
- @empiricalrun/test-run@0.10.4
|
|
19
|
+
|
|
20
|
+
## 0.68.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- cb957ea: feat: use cli user auth to upload recorder output
|
|
25
|
+
|
|
3
26
|
## 0.67.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
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,
|
|
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.
|
|
4
|
-
|
|
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
|
-
|
|
6
|
+
var models_1 = require("./models");
|
|
10
7
|
Object.defineProperty(exports, "defaultModel", { enumerable: true, get: function () { return models_1.defaultModel; } });
|
|
11
|
-
|
|
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;
|
|
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"}
|
package/dist/agent/chat/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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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AAK,EAAE,cAAc,GAAG,IAAI,QAgB7B;AA2BD,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,MAAM,GAAG,IAAI,CAef;AAED,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,gBAAgB,EAAE;;;EAe7B"}
|
package/dist/agent/chat/state.js
CHANGED
|
@@ -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
|
|
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,
|
|
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"}
|
package/dist/agent/chat/utils.js
CHANGED
|
@@ -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;
|
|
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(
|
|
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
|
-
|
|
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.
|
|
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":"patch.d.ts","sourceRoot":"","sources":["../../../../../src/agent/cua/pw-codegen/pw-pause/patch.ts"],"names":[],"mappings":"
|
|
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
|
-
|
|
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
|
-
|
|
168
|
+
logger_1.logger.debug(`Patched Playwright recorder app at ${pathToRecorderApp}`);
|
|
171
169
|
}
|
|
@@ -7,6 +7,5 @@ declare class APIClient {
|
|
|
7
7
|
private refreshToken;
|
|
8
8
|
}
|
|
9
9
|
export declare const apiClient: APIClient;
|
|
10
|
-
export {
|
|
11
|
-
export declare function authenticatedFetch(endpoint: string, options?: RequestInit): Promise<any>;
|
|
10
|
+
export {};
|
|
12
11
|
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/auth/api-client.ts"],"names":[],"mappings":"
|
|
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;YAuBX,mBAAmB;YAiBnB,YAAY;CA4C3B;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
|
package/dist/auth/api-client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.apiClient = void 0;
|
|
4
|
+
const logger_1 = require("../logger");
|
|
5
5
|
const token_store_1 = require("./token-store");
|
|
6
6
|
class APIClient {
|
|
7
7
|
appUrl;
|
|
@@ -9,17 +9,14 @@ class APIClient {
|
|
|
9
9
|
this.appUrl = process.env.DASHBOARD_DOMAIN || "https://dash.empirical.run";
|
|
10
10
|
}
|
|
11
11
|
async request(endpoint, options = {}) {
|
|
12
|
-
// Ensure user is authenticated
|
|
13
12
|
await this.ensureAuthenticated();
|
|
14
13
|
const tokens = await (0, token_store_1.getStoredTokens)();
|
|
15
14
|
if (!tokens) {
|
|
16
15
|
throw new Error("Not authenticated. Please run the login command first.");
|
|
17
16
|
}
|
|
18
|
-
// Make the request with the access token
|
|
19
17
|
const response = await this.makeRequest(endpoint, options, tokens.access_token);
|
|
20
|
-
// If token is expired, try refreshing and retry once
|
|
21
18
|
if (response.status === 401) {
|
|
22
|
-
|
|
19
|
+
logger_1.logger.debug("Access token expired, attempting to refresh...");
|
|
23
20
|
const refreshed = await this.refreshToken();
|
|
24
21
|
if (refreshed) {
|
|
25
22
|
const newTokens = await (0, token_store_1.getStoredTokens)();
|
|
@@ -34,14 +31,19 @@ class APIClient {
|
|
|
34
31
|
async makeRequest(endpoint, options, accessToken) {
|
|
35
32
|
const url = endpoint.startsWith("http")
|
|
36
33
|
? endpoint
|
|
37
|
-
: `${this.appUrl}
|
|
34
|
+
: `${this.appUrl}${endpoint}`;
|
|
35
|
+
// Don't set Content-Type for FormData (let browser set it automatically)
|
|
36
|
+
const headers = {
|
|
37
|
+
Authorization: `Bearer ${accessToken}`,
|
|
38
|
+
...options.headers,
|
|
39
|
+
};
|
|
40
|
+
// Only set Content-Type to application/json if body is not FormData
|
|
41
|
+
if (!(options.body instanceof FormData)) {
|
|
42
|
+
headers["Content-Type"] = "application/json";
|
|
43
|
+
}
|
|
38
44
|
return fetch(url, {
|
|
39
45
|
...options,
|
|
40
|
-
headers
|
|
41
|
-
Authorization: `Bearer ${accessToken}`,
|
|
42
|
-
"Content-Type": "application/json",
|
|
43
|
-
...options.headers,
|
|
44
|
-
},
|
|
46
|
+
headers,
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
async ensureAuthenticated() {
|
|
@@ -88,7 +90,7 @@ class APIClient {
|
|
|
88
90
|
user_id: data.user?.id || tokens.user_id,
|
|
89
91
|
user_email: data.user?.email || tokens.user_email,
|
|
90
92
|
});
|
|
91
|
-
|
|
93
|
+
logger_1.logger.debug("Access token refreshed successfully via dashboard");
|
|
92
94
|
return true;
|
|
93
95
|
}
|
|
94
96
|
catch (error) {
|
|
@@ -98,36 +100,4 @@ class APIClient {
|
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
|
-
exports.APIClient = APIClient;
|
|
102
103
|
exports.apiClient = new APIClient();
|
|
103
|
-
async function authenticatedFetch(endpoint, options) {
|
|
104
|
-
try {
|
|
105
|
-
const response = await exports.apiClient.request(endpoint, options);
|
|
106
|
-
if (!response.ok) {
|
|
107
|
-
const errorText = await response.text();
|
|
108
|
-
let errorMessage;
|
|
109
|
-
try {
|
|
110
|
-
const errorJson = JSON.parse(errorText);
|
|
111
|
-
errorMessage =
|
|
112
|
-
errorJson.error || errorJson.message || "API request failed";
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
errorMessage =
|
|
116
|
-
errorText || `Request failed with status ${response.status}`;
|
|
117
|
-
}
|
|
118
|
-
throw new Error(errorMessage);
|
|
119
|
-
}
|
|
120
|
-
const contentType = response.headers.get("content-type");
|
|
121
|
-
if (contentType && contentType.includes("application/json")) {
|
|
122
|
-
return response.json();
|
|
123
|
-
}
|
|
124
|
-
return response.text();
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
if (error.message.includes("Not authenticated") ||
|
|
128
|
-
error.message.includes("Please run the login command")) {
|
|
129
|
-
throw new Error("Authentication required. Please run: npx @empiricalrun/test-gen login");
|
|
130
|
-
}
|
|
131
|
-
throw error;
|
|
132
|
-
}
|
|
133
|
-
}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { apiClient } from "./api-client";
|
|
2
2
|
export { authenticate, getAuthStatus, logout } from "./cli-auth";
|
|
3
3
|
export { clearTokens, getStoredTokens, isAuthenticated, type StoredTokens, storeTokens, } from "./token-store";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EACL,WAAW,EACX,eAAe,EACf,eAAe,EACf,KAAK,YAAY,EACjB,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
package/dist/auth/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storeTokens = exports.isAuthenticated = exports.getStoredTokens = exports.clearTokens = exports.logout = exports.getAuthStatus = exports.authenticate = exports.
|
|
4
|
-
// Export all auth-related functionality
|
|
3
|
+
exports.storeTokens = exports.isAuthenticated = exports.getStoredTokens = exports.clearTokens = exports.logout = exports.getAuthStatus = exports.authenticate = exports.apiClient = void 0;
|
|
5
4
|
var api_client_1 = require("./api-client");
|
|
6
|
-
Object.defineProperty(exports, "APIClient", { enumerable: true, get: function () { return api_client_1.APIClient; } });
|
|
7
5
|
Object.defineProperty(exports, "apiClient", { enumerable: true, get: function () { return api_client_1.apiClient; } });
|
|
8
|
-
Object.defineProperty(exports, "authenticatedFetch", { enumerable: true, get: function () { return api_client_1.authenticatedFetch; } });
|
|
9
6
|
var cli_auth_1 = require("./cli-auth");
|
|
10
7
|
Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return cli_auth_1.authenticate; } });
|
|
11
8
|
Object.defineProperty(exports, "getAuthStatus", { enumerable: true, get: function () { return cli_auth_1.getAuthStatus; } });
|