ff-automationv2 1.0.0 → 2.0.1-beta.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 (60) hide show
  1. package/bitbucket-pipelines.yml +20 -0
  2. package/eslint.config.ts +29 -29
  3. package/package.json +51 -51
  4. package/src/ai/llmcalls/decodeApiKey.ts +14 -14
  5. package/src/ai/llmcalls/llmAction.ts +89 -89
  6. package/src/ai/llmcalls/parseLlmOputput.ts +69 -69
  7. package/src/ai/llmprompts/systemPrompts/actionExtractorPrompt.ts +70 -70
  8. package/src/ai/llmprompts/systemPrompts/errorDescriptionPrompt.ts +23 -23
  9. package/src/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.ts +198 -198
  10. package/src/ai/llmprompts/systemPrompts/userStoryToListPrompt.ts +24 -24
  11. package/src/ai/llmprompts/systemPrompts/visionPrompt.ts +28 -28
  12. package/src/automation/actions/executor.ts +74 -74
  13. package/src/automation/actions/interaction/enterInput.ts +27 -27
  14. package/src/automation/actions/interface/interactionActionInterface.ts +26 -26
  15. package/src/automation/actions/interface/navigationActionInterface.ts +21 -21
  16. package/src/automation/actions/interface/waitActionInterface.ts +5 -5
  17. package/src/automation/actions/navigation/getTitle.ts +8 -8
  18. package/src/automation/actions/navigation/goBack.ts +8 -8
  19. package/src/automation/actions/navigation/navigate.ts +9 -9
  20. package/src/automation/actions/navigation/refresh.ts +8 -8
  21. package/src/automation/actions/wait/wait.ts +9 -9
  22. package/src/automation/browserSession/initiateBrowserSession.ts +81 -81
  23. package/src/core/constants/supportedActions.ts +7 -7
  24. package/src/core/interfaces/StableDomInterface.ts +5 -5
  25. package/src/core/interfaces/actionInterface.ts +13 -13
  26. package/src/core/interfaces/automationRunnerInterface.ts +2 -2
  27. package/src/core/interfaces/browserCapabilitiesInterface.ts +4 -4
  28. package/src/core/interfaces/browserConfigurationInterface.ts +2 -2
  29. package/src/core/interfaces/domAnalysisInterface.ts +34 -34
  30. package/src/core/interfaces/executionDetails.ts +29 -29
  31. package/src/core/interfaces/fireflinkScriptPayloadInterface.ts +39 -39
  32. package/src/core/interfaces/llmConfigurationInterface.ts +2 -2
  33. package/src/core/interfaces/llmResponseInterface.ts +38 -38
  34. package/src/core/interfaces/promptInterface.ts +21 -21
  35. package/src/core/interfaces/scriptGenrationDataInterface.ts +16 -16
  36. package/src/core/interfaces/toolsInterface.ts +5 -5
  37. package/src/core/main/actionHandlerFactory.ts +86 -86
  38. package/src/core/main/executionContext.ts +18 -18
  39. package/src/core/main/runAutomationScript.ts +177 -177
  40. package/src/core/main/stepProcessor.ts +28 -28
  41. package/src/core/types/llmResponseType.ts +10 -10
  42. package/src/core/types/visionllmInputType.ts +4 -4
  43. package/src/domAnalysis/getRelaventElements.ts +24 -24
  44. package/src/domAnalysis/relativeElementsFromDom.ts +94 -94
  45. package/src/domAnalysis/searchBest.ts +159 -159
  46. package/src/domAnalysis/simplifyAndFlatten.ts +118 -118
  47. package/src/fireflinkData/fireflinkLocators/elementsFromHTML.ts +656 -656
  48. package/src/fireflinkData/fireflinkLocators/getListOfLocators.ts +31 -31
  49. package/src/fireflinkData/fireflinkLocators/typeList.ts +36 -36
  50. package/src/fireflinkData/fireflinkScript/scriptGenrationData.ts +30 -30
  51. package/src/index.ts +5 -5
  52. package/src/llmConfig/llmConfiguration.ts +26 -26
  53. package/src/service/fireflinkApi.service.ts +46 -46
  54. package/src/service/scriptRunner.service.ts +83 -83
  55. package/src/utils/DomExtraction/jsForAttributeInjection.ts +254 -254
  56. package/src/utils/javascript/jsFindElement.ts +161 -161
  57. package/src/utils/javascript/jsForShadowRoot.ts +216 -216
  58. package/src/utils/javascript/jsForToaster.ts +60 -60
  59. package/src/utils/logger/logData.ts +36 -36
  60. package/tsconfig.json +26 -26
@@ -1,6 +1,6 @@
1
- export interface StableDOM {
2
- browser: WebdriverIO.Browser | null,
3
- timeout: number,
4
- idleMs: number
5
-
1
+ export interface StableDOM {
2
+ browser: WebdriverIO.Browser | null,
3
+ timeout: number,
4
+ idleMs: number
5
+
6
6
  }
@@ -1,13 +1,13 @@
1
-
2
-
3
- // Main action executor interface
4
- export interface IActionExecutor {
5
- navigate(url: string): Promise<void>;
6
- goBack(): Promise<void>;
7
- refresh(): Promise<void>;
8
- wait(time: string): Promise<void>;
9
- click(pageDOM: string, selector: string, fireflinkIndex: string, elementName: string, elementType: string): Promise<void>;
10
- enterInput(selector: string, value: string, fireflinkIndex: string, pageDOM: string, elementName: string, elementType: string, platform: string): Promise<void>;
11
- }
12
-
13
-
1
+
2
+
3
+ // Main action executor interface
4
+ export interface IActionExecutor {
5
+ navigate(url: string): Promise<void>;
6
+ goBack(): Promise<void>;
7
+ refresh(): Promise<void>;
8
+ wait(time: string): Promise<void>;
9
+ click(pageDOM: string, selector: string, fireflinkIndex: string, elementName: string, elementType: string): Promise<void>;
10
+ enterInput(selector: string, value: string, fireflinkIndex: string, pageDOM: string, elementName: string, elementType: string, platform: string): Promise<void>;
11
+ }
12
+
13
+
@@ -1,3 +1,3 @@
1
- export interface IAutomationRunner {
2
- run(): Promise<void>;
1
+ export interface IAutomationRunner {
2
+ run(): Promise<void>;
3
3
  }
@@ -1,5 +1,5 @@
1
- export interface browserCapabilities {
2
- browserName: string;
3
- pageLoad: number;
4
- implicit: number;
1
+ export interface browserCapabilities {
2
+ browserName: string;
3
+ pageLoad: number;
4
+ implicit: number;
5
5
  }
@@ -1,3 +1,3 @@
1
- export interface BrowserConfig {
2
- browserName: string;
1
+ export interface BrowserConfig {
2
+ browserName: string;
3
3
  }
@@ -1,34 +1,34 @@
1
- export interface DomProcessingRequest {
2
- keywords: string[] | string;
3
- rawDom: any;
4
- stepIndex: number;
5
- }
6
-
7
-
8
- export interface SimplifiedNode {
9
- tag?: string;
10
- "FF-inspecter"?: string;
11
- "ff-xpath"?: string;
12
- text?: string;
13
- id?: string;
14
- name?: string;
15
- placeholder?: string;
16
- "aria-label"?: string;
17
- title?: string;
18
- class?: string;
19
- type?: string;
20
- search?: string;
21
- }
22
-
23
- export interface StructuredNode extends SimplifiedNode {
24
- relationship?: {
25
- parent?: Partial<SimplifiedNode>;
26
- children?: Partial<SimplifiedNode>[];
27
- siblings?: Partial<SimplifiedNode>[];
28
- };
29
- }
30
-
31
-
32
- export interface DomProcessingResult {
33
- results: StructuredNode[];
34
- }
1
+ export interface DomProcessingRequest {
2
+ keywords: string[] | string;
3
+ rawDom: any;
4
+ stepIndex: number;
5
+ }
6
+
7
+
8
+ export interface SimplifiedNode {
9
+ tag?: string;
10
+ "FF-inspecter"?: string;
11
+ "ff-xpath"?: string;
12
+ text?: string;
13
+ id?: string;
14
+ name?: string;
15
+ placeholder?: string;
16
+ "aria-label"?: string;
17
+ title?: string;
18
+ class?: string;
19
+ type?: string;
20
+ search?: string;
21
+ }
22
+
23
+ export interface StructuredNode extends SimplifiedNode {
24
+ relationship?: {
25
+ parent?: Partial<SimplifiedNode>;
26
+ children?: Partial<SimplifiedNode>[];
27
+ siblings?: Partial<SimplifiedNode>[];
28
+ };
29
+ }
30
+
31
+
32
+ export interface DomProcessingResult {
33
+ results: StructuredNode[];
34
+ }
@@ -1,29 +1,29 @@
1
- import { BrowserConfig } from "./browserConfigurationInterface.js";
2
- export interface AutomationRequest {
3
- userStory: string;
4
- scriptName: string;
5
- scriptType: string;
6
- projectId: string;
7
- testCaseId: string;
8
- promptId: string;
9
- pageDetails: any;
10
- generatedBy: string;
11
- webSocketId: string;
12
- licenseType: string;
13
- licenseId: string;
14
- userId: string;
15
- topic: string;
16
- projectType: string;
17
- serverData: any;
18
- serviceProvider: string;
19
- model: string;
20
- apiKey: string; // base64 encoded
21
- userName: string;
22
- service_accounts: any;
23
- serverHost: string;
24
- browser: BrowserConfig;
25
- platform: string;
26
- token: string;
27
- visionApikey: string;
28
- }
29
-
1
+ import { BrowserConfig } from "./browserConfigurationInterface.js";
2
+ export interface AutomationRequest {
3
+ userStory: string;
4
+ scriptName: string;
5
+ scriptType: string;
6
+ projectId: string;
7
+ testCaseId: string;
8
+ promptId: string;
9
+ pageDetails: any;
10
+ generatedBy: string;
11
+ webSocketId: string;
12
+ licenseType: string;
13
+ licenseId: string;
14
+ userId: string;
15
+ topic: string;
16
+ projectType: string;
17
+ serverData: any;
18
+ serviceProvider: string;
19
+ model: string;
20
+ apiKey: string; // base64 encoded
21
+ userName: string;
22
+ service_accounts: any;
23
+ serverHost: string;
24
+ browser: BrowserConfig;
25
+ platform: string;
26
+ token: string;
27
+ visionApikey: string;
28
+ }
29
+
@@ -1,39 +1,39 @@
1
- export interface IStep {
2
- nlpName: string;
3
- elementsData: any[];
4
- stepInputs: any[];
5
- }
6
-
7
- export interface IPayload {
8
- scriptName: string,
9
- scriptType: string,
10
- projectId: string,
11
- testCaseId: string,
12
- promptId: string,
13
- pageDetails: any,
14
- generatedBy: string,
15
- webSocketId: string,
16
- licenseType: string,
17
- licenseId: string,
18
- userId: string,
19
- topic: string,
20
- projectType: string,
21
- tokensConsumed: number,
22
- }
23
-
24
- export interface IFireFlinkApiService {
25
- callFireFlinkApi(
26
- headers: Record<string, string>,
27
- body: any,
28
- url: string
29
- ): Promise<any>;
30
- }
31
-
32
- export interface IScriptRunner {
33
- runScriptFromPayload(
34
- result: any[] | [],
35
- payload: IPayload,
36
- token: string,
37
- serverHost: string
38
- ): Promise<any>;
39
- }
1
+ export interface IStep {
2
+ nlpName: string;
3
+ elementsData: any[];
4
+ stepInputs: any[];
5
+ }
6
+
7
+ export interface IPayload {
8
+ scriptName: string,
9
+ scriptType: string,
10
+ projectId: string,
11
+ testCaseId: string,
12
+ promptId: string,
13
+ pageDetails: any,
14
+ generatedBy: string,
15
+ webSocketId: string,
16
+ licenseType: string,
17
+ licenseId: string,
18
+ userId: string,
19
+ topic: string,
20
+ projectType: string,
21
+ tokensConsumed: number,
22
+ }
23
+
24
+ export interface IFireFlinkApiService {
25
+ callFireFlinkApi(
26
+ headers: Record<string, string>,
27
+ body: any,
28
+ url: string
29
+ ): Promise<any>;
30
+ }
31
+
32
+ export interface IScriptRunner {
33
+ runScriptFromPayload(
34
+ result: any[] | [],
35
+ payload: IPayload,
36
+ token: string,
37
+ serverHost: string
38
+ ): Promise<any>;
39
+ }
@@ -1,3 +1,3 @@
1
- export interface IServiceProviderBaseUrlConfiguration {
2
- getBaseUrl(provider: string): string;
1
+ export interface IServiceProviderBaseUrlConfiguration {
2
+ getBaseUrl(provider: string): string;
3
3
  }
@@ -1,38 +1,38 @@
1
-
2
- export interface IKeywordAction {
3
- keywords: string[];
4
- elementName: string;
5
- action: string;
6
- }
7
-
8
- export interface IDragDropAction {
9
- drag: string;
10
- drop: string;
11
- action: string | "Builtin_DragAndDropToElement";
12
- drag_element_name: string;
13
- drop_element_name: string;
14
- }
15
-
16
- export interface IInputAction {
17
- action: string;
18
- input_text: string | "None";
19
- }
20
-
21
-
22
- export interface IScrollOrAttributeAction {
23
- attribute_value: string;
24
- action: string;
25
- input_text: string;
26
- keyword: string[];
27
- num_of_scrolls: number;
28
- direction: "up" | "down";
29
- elementType: string;
30
- }
31
-
32
- export interface IManualSteps {
33
- manualSteps: string[];
34
- }
35
-
36
- export interface IFireFlinkIndex {
37
- fireflinkIndex: string;
38
- }
1
+
2
+ export interface IKeywordAction {
3
+ keywords: string[];
4
+ elementName: string;
5
+ action: string;
6
+ }
7
+
8
+ export interface IDragDropAction {
9
+ drag: string;
10
+ drop: string;
11
+ action: string | "Builtin_DragAndDropToElement";
12
+ drag_element_name: string;
13
+ drop_element_name: string;
14
+ }
15
+
16
+ export interface IInputAction {
17
+ action: string;
18
+ input_text: string | "None";
19
+ }
20
+
21
+
22
+ export interface IScrollOrAttributeAction {
23
+ attribute_value: string;
24
+ action: string;
25
+ input_text: string;
26
+ keyword: string[];
27
+ num_of_scrolls: number;
28
+ direction: "up" | "down";
29
+ elementType: string;
30
+ }
31
+
32
+ export interface IManualSteps {
33
+ manualSteps: string[];
34
+ }
35
+
36
+ export interface IFireFlinkIndex {
37
+ fireflinkIndex: string;
38
+ }
@@ -1,21 +1,21 @@
1
- import { PromptType } from "../types/promptType.js";
2
- export interface PromptArgsMap {
3
- [PromptType.USER_STORY_TO_LIST]: Record<string, any>;
4
- [PromptType.KEYWORD_EXTRACTOR]: {
5
- priorAndNextSteps: string[];
6
- };
7
- [PromptType.ERROR_DESCRIPTION]: Record<string, any>;
8
- [PromptType.FF_INSPECTOR]: {
9
- stepAction: string;
10
- extractedDomJson: any;
11
- priorAndNextSteps: string[];
12
- isAlert?: boolean;
13
- isDrag?: boolean;
14
- };
15
- [PromptType.VISION_PROMPT]: {
16
- currentStep: string;
17
- priorAndNextSteps: string[];
18
- };
19
- }
20
-
21
-
1
+ import { PromptType } from "../types/promptType.js";
2
+ export interface PromptArgsMap {
3
+ [PromptType.USER_STORY_TO_LIST]: Record<string, any>;
4
+ [PromptType.KEYWORD_EXTRACTOR]: {
5
+ priorAndNextSteps: string[];
6
+ };
7
+ [PromptType.ERROR_DESCRIPTION]: Record<string, any>;
8
+ [PromptType.FF_INSPECTOR]: {
9
+ stepAction: string;
10
+ extractedDomJson: any;
11
+ priorAndNextSteps: string[];
12
+ isAlert?: boolean;
13
+ isDrag?: boolean;
14
+ };
15
+ [PromptType.VISION_PROMPT]: {
16
+ currentStep: string;
17
+ priorAndNextSteps: string[];
18
+ };
19
+ }
20
+
21
+
@@ -1,16 +1,16 @@
1
-
2
- export interface IElementData {
3
- elementName: string;
4
- type: string;
5
- locators: any[];
6
- platform: string;
7
- }
8
-
9
-
10
- export interface IScriptGenerationData {
11
- nlpName: string;
12
- elementsData: IElementData[] | [];
13
- stepInputs: string[] | [];
14
- }
15
-
16
-
1
+
2
+ export interface IElementData {
3
+ elementName: string;
4
+ type: string;
5
+ locators: any[];
6
+ platform: string;
7
+ }
8
+
9
+
10
+ export interface IScriptGenerationData {
11
+ nlpName: string;
12
+ elementsData: IElementData[] | [];
13
+ stepInputs: string[] | [];
14
+ }
15
+
16
+
@@ -1,5 +1,5 @@
1
- export interface ITool {
2
- name: string;
3
- description: string;
4
- execute(input: any): Promise<any>;
5
- }
1
+ export interface ITool {
2
+ name: string;
3
+ description: string;
4
+ execute(input: any): Promise<any>;
5
+ }
@@ -1,86 +1,86 @@
1
- import { ExecutionContext } from "../main/executionContext.js";
2
- import { ActionExecutor } from "../../automation/actions/executor.js";
3
-
4
- export function createActionHandlers(
5
- context: ExecutionContext,
6
- pageLoad: number,
7
- implicit: number
8
- ): Record<string, (result: any) => Promise<void>> {
9
-
10
- return {
11
-
12
- open: async () => {
13
- await context.session.open({
14
- browserName: "chrome",
15
- pageLoad,
16
- implicit
17
- });
18
-
19
- context.executor = new ActionExecutor(
20
- await context.session.getCurrentBrowser(),
21
- context.scriptAppender,
22
- context.locator,
23
- context.request.platform
24
- );
25
-
26
- context.scriptAppender.add({
27
- nlpName: "OpenBrowser",
28
- elementsData: [],
29
- stepInputs: []
30
- });
31
- },
32
-
33
- navigate: async (result: any) => {
34
- if (!context.executor) {
35
- throw new Error("Browser not initialized.");
36
- }
37
-
38
- await context.executor.navigate(result.response.keywords[0]);
39
- },
40
- goBack: async () => {
41
- if (!context.executor) {
42
- throw new Error("Browser not initialized.");
43
- }
44
- await context.executor.goBack();
45
- },
46
- refresh: async () => {
47
- if (!context.executor) {
48
- throw new Error("Browser not initialized.");
49
- }
50
- await context.executor.refresh();
51
- },
52
- wait: async (result: any) => {
53
- if (!context.executor) {
54
- throw new Error("Browser not initialized.");
55
- }
56
- await context.executor.wait(result.value);
57
- },
58
- click: async (result: any) => {
59
- if (!context.executor) {
60
- throw new Error("Browser not initialized.");
61
- }
62
- await context.executor.click(
63
- result.pageDOM,
64
- result.selector,
65
- result.fireflinkIndex,
66
- result.elementName,
67
- result.elementType
68
- );
69
- },
70
-
71
- enter: async (result: any) => {
72
- if (!context.executor) {
73
- throw new Error("Browser not initialized.");
74
- }
75
- await context.executor.enterInput(
76
- result.selector,
77
- result.value,
78
- result.fireflinkIndex,
79
- result.pageDOM,
80
- result.elementName,
81
- result.elementType
82
- );
83
- }
84
-
85
- };
86
- }
1
+ import { ExecutionContext } from "../main/executionContext.js";
2
+ import { ActionExecutor } from "../../automation/actions/executor.js";
3
+
4
+ export function createActionHandlers(
5
+ context: ExecutionContext,
6
+ pageLoad: number,
7
+ implicit: number
8
+ ): Record<string, (result: any) => Promise<void>> {
9
+
10
+ return {
11
+
12
+ open: async () => {
13
+ await context.session.open({
14
+ browserName: "chrome",
15
+ pageLoad,
16
+ implicit
17
+ });
18
+
19
+ context.executor = new ActionExecutor(
20
+ await context.session.getCurrentBrowser(),
21
+ context.scriptAppender,
22
+ context.locator,
23
+ context.request.platform
24
+ );
25
+
26
+ context.scriptAppender.add({
27
+ nlpName: "OpenBrowser",
28
+ elementsData: [],
29
+ stepInputs: []
30
+ });
31
+ },
32
+
33
+ navigate: async (result: any) => {
34
+ if (!context.executor) {
35
+ throw new Error("Browser not initialized.");
36
+ }
37
+
38
+ await context.executor.navigate(result.response.keywords[0]);
39
+ },
40
+ goBack: async () => {
41
+ if (!context.executor) {
42
+ throw new Error("Browser not initialized.");
43
+ }
44
+ await context.executor.goBack();
45
+ },
46
+ refresh: async () => {
47
+ if (!context.executor) {
48
+ throw new Error("Browser not initialized.");
49
+ }
50
+ await context.executor.refresh();
51
+ },
52
+ wait: async (result: any) => {
53
+ if (!context.executor) {
54
+ throw new Error("Browser not initialized.");
55
+ }
56
+ await context.executor.wait(result.value);
57
+ },
58
+ click: async (result: any) => {
59
+ if (!context.executor) {
60
+ throw new Error("Browser not initialized.");
61
+ }
62
+ await context.executor.click(
63
+ result.pageDOM,
64
+ result.selector,
65
+ result.fireflinkIndex,
66
+ result.elementName,
67
+ result.elementType
68
+ );
69
+ },
70
+
71
+ enter: async (result: any) => {
72
+ if (!context.executor) {
73
+ throw new Error("Browser not initialized.");
74
+ }
75
+ await context.executor.enterInput(
76
+ result.selector,
77
+ result.value,
78
+ result.fireflinkIndex,
79
+ result.pageDOM,
80
+ result.elementName,
81
+ result.elementType
82
+ );
83
+ }
84
+
85
+ };
86
+ }
@@ -1,18 +1,18 @@
1
- import { BrowserSession } from "../../automation/browserSession/initiateBrowserSession.js";
2
- import { ActionExecutor } from "../../automation/actions/executor.js";
3
- import { ElementGetter } from "../../fireflinkData/fireflinkLocators/getListOfLocators.js";
4
- import { ScriptDataAppender } from "../../fireflinkData/fireflinkScript/scriptGenrationData.js";
5
- import { AutomationRequest } from "../interfaces/executionDetails.js";
6
-
7
- export class ExecutionContext {
8
- public session: BrowserSession;
9
- public executor: ActionExecutor | null = null;
10
- public locator: ElementGetter;
11
- public scriptAppender: ScriptDataAppender;
12
-
13
- constructor(public request: AutomationRequest) {
14
- this.session = new BrowserSession();
15
- this.locator = new ElementGetter();
16
- this.scriptAppender = new ScriptDataAppender();
17
- }
18
- }
1
+ import { BrowserSession } from "../../automation/browserSession/initiateBrowserSession.js";
2
+ import { ActionExecutor } from "../../automation/actions/executor.js";
3
+ import { ElementGetter } from "../../fireflinkData/fireflinkLocators/getListOfLocators.js";
4
+ import { ScriptDataAppender } from "../../fireflinkData/fireflinkScript/scriptGenrationData.js";
5
+ import { AutomationRequest } from "../interfaces/executionDetails.js";
6
+
7
+ export class ExecutionContext {
8
+ public session: BrowserSession;
9
+ public executor: ActionExecutor | null = null;
10
+ public locator: ElementGetter;
11
+ public scriptAppender: ScriptDataAppender;
12
+
13
+ constructor(public request: AutomationRequest) {
14
+ this.session = new BrowserSession();
15
+ this.locator = new ElementGetter();
16
+ this.scriptAppender = new ScriptDataAppender();
17
+ }
18
+ }