endorphin-ai 0.1.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 (35) hide show
  1. package/LICENSE.md +209 -0
  2. package/README.md +474 -0
  3. package/bin/endorphin.js +256 -0
  4. package/examples/endorphin.config.js +22 -0
  5. package/examples/tests/QE-001-basic-login-test.js +18 -0
  6. package/examples/tests/sample-test.js +9 -0
  7. package/examples/tools/.gitkeep +0 -0
  8. package/framework/config/agent-config.js +53 -0
  9. package/framework/config/browser-config.js +53 -0
  10. package/framework/config/paths.js +40 -0
  11. package/framework/core/agent-setup.js +75 -0
  12. package/framework/core/browser-framework.js +766 -0
  13. package/framework/core/config-loader.js +309 -0
  14. package/framework/core/test-discovery.js +402 -0
  15. package/framework/core/test-manager.js +343 -0
  16. package/framework/core/test-recorder.js +302 -0
  17. package/framework/core/test-runner.js +133 -0
  18. package/framework/core/test-session.js +98 -0
  19. package/framework/index.js +44 -0
  20. package/framework/interactive/enhanced-interactive-recorder.js +223 -0
  21. package/framework/interactive/index.js +18 -0
  22. package/framework/interactive/interactive-test-clean.js +33 -0
  23. package/framework/interactive/interactive-test.js +33 -0
  24. package/framework/test-framework.js +29 -0
  25. package/framework/testing/index.js +15 -0
  26. package/framework/testing/test-interactive-recorder.js +83 -0
  27. package/framework/testing/test-modular-framework.js +47 -0
  28. package/framework/testing/verify-test-format.js +58 -0
  29. package/framework/tools/content.js +67 -0
  30. package/framework/tools/index.js +52 -0
  31. package/framework/tools/interaction.js +180 -0
  32. package/framework/tools/navigation.js +43 -0
  33. package/framework/tools/utilities.js +99 -0
  34. package/framework/tools/verification.js +84 -0
  35. package/package.json +84 -0
@@ -0,0 +1,84 @@
1
+ // Endorphin e2e AI test framework>
2
+ // Copyright (C) 2025 Redstudio Agency
3
+
4
+ // This program is free software: you can redistribute it and/or modify
5
+ // it under the terms of the GNU Affero General Public License as
6
+ // published by the Free Software Foundation, either version 3 of the
7
+ // License, or (at your option) any later version.
8
+
9
+ // This program is distributed in the hope that it will be useful,
10
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ // GNU Affero General Public License for more details.
13
+
14
+ // You should have received a copy of the GNU Affero General Public License
15
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ import { tool } from '@langchain/core/tools';
18
+ import { z } from 'zod';
19
+
20
+ export function createVerifyElementTool(framework) {
21
+ return tool(async ({ selector, state = 'visible', timeout = 10000 }) => {
22
+ const stepDesc = `Verify ${selector} is ${state}`;
23
+ console.log(`🔍 ${stepDesc}`);
24
+
25
+ try {
26
+ await framework.page.waitForSelector(selector, { state, timeout });
27
+ await framework.takeStepScreenshot(`Verified ${selector} is ${state}`);
28
+
29
+ const result = `Element ${selector} is ${state} on the page`;
30
+ framework.logTestStep(stepDesc, 'verifyElement', { selector, state, timeout }, result, true);
31
+ return `✅ ${result}`;
32
+ } catch (error) {
33
+ await framework.takeStepScreenshot(`Failed to verify ${selector}`);
34
+ framework.logTestStep(stepDesc, 'verifyElement', { selector, state, timeout }, error.message, false);
35
+ return `❌ Could not verify element ${selector} as ${state}: ${error.message}`;
36
+ }
37
+ }, {
38
+ name: 'verifyElement',
39
+ description: 'Verify element exists and is in specified state.',
40
+ schema: z.object({
41
+ selector: z.string(),
42
+ state: z.enum(['visible', 'hidden', 'attached', 'detached']).optional(),
43
+ timeout: z.number().optional(),
44
+ })
45
+ });
46
+ }
47
+
48
+ export function createGetElementInfoTool(framework) {
49
+ return tool(async ({ selector }) => {
50
+ const stepDesc = `Get element info: ${selector}`;
51
+ console.log(`🔍 ${stepDesc}`);
52
+
53
+ try {
54
+ await framework.page.waitForSelector(selector, { timeout: 5000 });
55
+
56
+ const elementInfo = await framework.page.locator(selector).evaluate(el => ({
57
+ tagName: el.tagName,
58
+ id: el.id,
59
+ className: el.className,
60
+ textContent: el.textContent?.trim(),
61
+ value: el.value,
62
+ placeholder: el.placeholder,
63
+ type: el.type,
64
+ disabled: el.disabled,
65
+ visible: el.offsetParent !== null,
66
+ href: el.href,
67
+ src: el.src
68
+ }));
69
+
70
+ const result = `Element info: ${JSON.stringify(elementInfo, null, 2)}`;
71
+ framework.logTestStep(stepDesc, 'getElementInfo', { selector }, result, true);
72
+ return result;
73
+ } catch (error) {
74
+ framework.logTestStep(stepDesc, 'getElementInfo', { selector }, error.message, false);
75
+ return `❌ Could not get info for ${selector}: ${error.message}`;
76
+ }
77
+ }, {
78
+ name: 'getElementInfo',
79
+ description: 'Get detailed information about any element.',
80
+ schema: z.object({
81
+ selector: z.string(),
82
+ })
83
+ });
84
+ }
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "endorphin-ai",
3
+ "version": "0.1.0",
4
+ "description": "E2E Testing Reinvented with AI - A powerful browser automation framework using AI-powered testing with LangChain, OpenAI GPT-4o, and Playwright",
5
+ "main": "framework/index.js",
6
+ "bin": {
7
+ "endorphin": "bin/endorphin.js"
8
+ },
9
+ "type": "module",
10
+ "scripts": {
11
+ "start": "node framework/test-framework.js",
12
+ "test": "vitest",
13
+ "test:watch": "vitest --watch",
14
+ "test:ui": "vitest --ui",
15
+ "test:coverage": "vitest run --coverage",
16
+ "framework:test": "node framework/test-framework.js --test",
17
+ "framework:demo": "node framework/test-framework.js",
18
+ "framework:all": "node framework/test-framework.js --all",
19
+ "framework:list": "node framework/test-framework.js --list",
20
+ "framework:comprehensive": "node framework/test-framework.js --comprehensive",
21
+ "framework:QE-001": "node framework/test-framework.js --test QE-001",
22
+ "framework:QE-002": "node framework/test-framework.js --test QE-002",
23
+ "framework:auth": "node framework/test-framework.js --tag authentication",
24
+ "framework:smoke": "node framework/test-framework.js --tag smoke",
25
+ "framework:high": "node framework/test-framework.js --priority High",
26
+ "verify-format": "node framework/testing/verify-test-format.js",
27
+ "test-recorder": "node framework/interactive/enhanced-interactive-recorder.js",
28
+ "test-recorder-demo": "node framework/demos/interactive-demo.js",
29
+ "test-framework": "node framework/testing/test-modular-framework.js"
30
+ },
31
+ "keywords": [
32
+ "ai",
33
+ "testing",
34
+ "e2e",
35
+ "automation",
36
+ "browser",
37
+ "playwright",
38
+ "langchain",
39
+ "openai",
40
+ "gpt-4",
41
+ "test-framework"
42
+ ],
43
+ "author": "Andrew Novykov <iam@andrewnovykov.com>",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/andrewnovykov/endorphin-ai.git"
47
+ },
48
+ "homepage": "https://github.com/andrewnovykov/endorphin-ai#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/andrewnovykov/endorphin-ai/issues"
51
+ },
52
+ "engines": {
53
+ "node": ">=16.0.0"
54
+ },
55
+ "files": [
56
+ "framework/",
57
+ "bin/",
58
+ "examples/",
59
+ "README.md",
60
+ "LICENSE.md",
61
+ "MIGRATION-GUIDE.md"
62
+ ],
63
+ "license": "AGPL-3.0-or-later",
64
+ "dependencies": {
65
+ "@langchain/community": "^0.3.31",
66
+ "@langchain/core": "^0.3.40",
67
+ "@langchain/langgraph": "^0.2.46",
68
+ "@modelcontextprotocol/sdk": "^1.13.0",
69
+ "@playwright/mcp": "^0.0.29",
70
+ "dotenv": "^16.4.7",
71
+ "langchain": "^0.3.19",
72
+ "openai": "^4.85.3",
73
+ "playwright": "^1.50.1",
74
+ "zod": "^3.25.67"
75
+ },
76
+ "directories": {
77
+ "doc": "doc",
78
+ "test": "tests"
79
+ },
80
+ "devDependencies": {
81
+ "vitest": "^2.1.8",
82
+ "@vitest/ui": "^2.1.8"
83
+ }
84
+ }