@doppelgangerdev/doppelganger 0.5.3 → 0.5.6

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/README.md CHANGED
@@ -1,179 +1,274 @@
1
- # Doppelganger - Browser Automation for Everyone
2
-
3
- [![Docker](https://img.shields.io/badge/docker-mnemosyneai%2Fdoppelganger-0db7ed)](https://hub.docker.com/r/mnemosyneai/doppelganger)
4
- [![Self-Hosted](https://img.shields.io/badge/self--hosted-local--first-2f855a)](#getting-started)
5
-
6
- Doppelganger is a self-hosted, developer-focused browser automation and extraction tool. It runs locally via Docker and provides a DIY workflow for building automation tasks with blocks and optional JavaScript customization.
7
-
8
- This project is designed for local, controlled use cases. It does not claim to bypass protections and does not encourage unlawful activity.
9
-
10
- <img src="demo-run.gif" alt="Dashboard task demo" style="max-width:100%;height:auto;border:1px solid #ccc;">
11
-
12
- ## Getting Started (Docker)
13
-
14
- ### Requirements
15
- - Docker Desktop or Docker Engine
16
- - x86_64 or ARM64 host
17
- - 4GB+ RAM recommended
18
-
19
- ### Pull the Image
20
- ```bash
21
- docker pull mnemosyneai/doppelganger
22
- ```
23
-
24
- ### Run the Container
1
+ ![Doppelganger Banner](banner.png)
2
+
3
+ # Doppelganger — Browser Automation for Everyone
4
+
5
+ <div align="center">
6
+ <a href="https://doppelgangerdev.com">
7
+ <img src="https://img.shields.io/badge/Website-doppelgangerdev.com-0056ff?style=for-the-badge&logo=googlechrome&rounded=true" alt="Website" />
8
+ </a>
9
+ <a href="https://doppelgangerdev.com/docs">
10
+ <img src="https://img.shields.io/badge/Docs-doppelgangerdev.com%2Fdocs-00c2ff?style=for-the-badge&logo=readthedocs&rounded=true" alt="Docs" />
11
+ </a>
12
+ <a href="https://forum.doppelgangerdev.com">
13
+ <img src="https://img.shields.io/badge/Forum-forum.doppelgangerdev.com-ff9900?style=for-the-badge&logo=discourse&rounded=true" alt="Forum" />
14
+ </a>
15
+ <a href="https://github.com/mnemosyne-artificial-intelligence/doppelganger/blob/main/LICENSE">
16
+ <img src="https://img.shields.io/badge/License-SUL%201.0-4caf50?style=for-the-badge&logo=github&rounded=true" alt="License" />
17
+ </a>
18
+ <a href="https://www.npmjs.com/package/@doppelgangerdev/doppelganger">
19
+ <img src="https://img.shields.io/badge/Version-0.5.5-6a8cff?style=for-the-badge&logo=npm&rounded=true" alt="Version" />
20
+ </a>
21
+ <a href="https://hub.docker.com/r/mnemosyneai/doppelganger">
22
+ <img src="https://img.shields.io/badge/Docker-mnemosyneai%2Fdoppelganger-0db7ed?style=for-the-badge&logo=docker&rounded=true" alt="Docker" />
23
+ </a>
24
+ </div>
25
+
26
+ Doppelganger is a self‑hosted, block-first automation control plane built for teams that want predictable, auditable browser workflows without pushing sensitive data to third‑party SaaS. It bundles a React/Vite frontend, an Express/Playwright backend, helper scripts, and optional CLI tooling so you can sketch blocks, inject JavaScript, rotate proxies, and run everything locally.
27
+
28
+ ![Demo run](demo-run.gif)
29
+
30
+ # What You Get
31
+
32
+ - **Block‑based automation** — build flows with actions like click, type, wait, hover, and execute JavaScript against modern pages.
33
+ - **Task API + CLI** — trigger saved tasks via HTTP (`/tasks/:id/api`) or `npx doppelganger` while passing variables and securing runs with the API key you control.
34
+ - **Captures & storage** — automatically store screenshots/recordings and cookies; view them in the captures tab, reset storage, or download built assets.
35
+ - **Proxy management** — host, rotate, or import HTTP/SOCKS proxies, flag a default, and toggle rotation per task.
36
+ - **Security-first** — session authentication, IP allowlists, secret management, and audit trails live entirely inside your environment.
37
+
38
+ # Architecture Snapshot
39
+
40
+ 1. **Frontend**
41
+ - Vite with React (TypeScript) drives `/dashboard`, `/tasks`, `/settings`, `/executions`, and `/captures`.
42
+ - The Settings screen is tabbed (`System`, `Data`, `Proxies`) and houses panels for API keys, user agents, layout, storage, and version info.
43
+ - Components call `/api/*` endpoints through the Vite dev proxy (see `vite.config.mts`), sharing `APP_VERSION` via `src/utils/appInfo.ts`.
44
+
45
+ 2. **Backend**
46
+ - `server.js` (Express) handles auth (`/api/auth`), task metadata, hooks into Playwright, and exposes `/api/settings/*` for runtime configuration.
47
+ - Requirements: Node 18+ (LTS), Playwright bundled via `npm install`.
48
+ - Storage is plain‑file: `data/` for proxies and allowlists, `public/captures` for visuals, `storage_state.json` for cookies.
49
+
50
+ 3. **Scripts & automation**
51
+ - `scripts/postinstall.js` runs when dependencies install (keep an eye if you customize).
52
+ - `agent.js`, `headful.js`, `scrape.js` expose specialized runners; the CLI binary `bin/cli.js` wires them for `npx doppelganger`.
53
+
54
+ 4. **Code layout highlights**
55
+ - `src/App.tsx` glues together routing, alerts, and the sidebar that links dashboards, tasks, and settings.
56
+ - `src/components` houses reusable panels (API keys, storage, captures, proxies) that map directly to backend endpoints.
57
+ - `server.js` embeds all HTTP handlers in one file; use the `data/` helpers for proxies, API keys, and user agent preferences if you customize behavior.
58
+
59
+ # Getting Started
60
+
61
+ ## Docker (Recommended)
62
+
25
63
  ```bash
64
+ docker pull mnemosyneai/doppelganger
26
65
  docker run -d \
27
66
  --name doppelganger \
28
67
  -p 11345:11345 \
29
- -e SESSION_SECRET=change_me_to_a_long_random_value \
68
+ -p 54311:54311 \
69
+ -e SESSION_SECRET=replace_with_long_random_value \
30
70
  -v $(pwd)/data:/app/data \
31
71
  -v $(pwd)/public:/app/public \
32
72
  -v $(pwd)/storage_state.json:/app/storage_state.json \
33
73
  mnemosyneai/doppelganger
34
74
  ```
35
-
36
- Open the dashboard at:
37
- ```
38
- http://localhost:11345
39
- ```
40
-
41
- ### Session Secret
42
- Set a strong, unique secret via `SESSION_SECRET` before starting the container.
43
-
44
- Example:
45
- ```bash
46
- export SESSION_SECRET="$(node -e 'console.log(require("crypto").randomBytes(32).toString("hex"))')"
47
- ```
48
-
49
- ### Update to Latest
75
+
76
+ Visit `http://localhost:11345`. Stop/start with `docker stop/start doppelganger`.
77
+
78
+ ## Local Development (npm)
79
+
80
+ 1. Install dependencies:
81
+
50
82
  ```bash
51
- docker pull mnemosyneai/doppelganger
52
- docker stop doppelganger
53
- docker rm doppelganger
54
- docker run -d \
55
- --name doppelganger \
56
- -p 11345:11345 \
57
- -e SESSION_SECRET=change_me_to_a_long_random_value \
58
- -v $(pwd)/data:/app/data \
59
- -v $(pwd)/public:/app/public \
60
- -v $(pwd)/storage_state.json:/app/storage_state.json \
61
- mnemosyneai/doppelganger
83
+ npm install
62
84
  ```
63
-
64
- ## Getting Started (npm)
65
-
66
- ### Install
67
- ```bash
68
- npm i @doppelgangerdev/doppelganger
69
- ```
70
-
71
- ### Run
72
- ```bash
73
- npx doppelganger
74
- ```
75
-
76
- ## Usage
77
-
78
- ### Open the Dashboard
79
- Navigate to:
80
- ```
81
- http://localhost:11345
82
- ```
83
-
84
- ### Create a Task (Block-Based)
85
- 1. Click **New Task**
86
- 2. Choose a mode (Scrape, Agent, Headful)
87
- 3. Add action blocks (click, type, hover, wait, scroll, press, javascript)
88
- 4. Configure variables and selectors
89
- 5. Save and run
90
-
91
- ### Example Workflow (Safe Demo)
92
- Goal: Load a public page, wait, and extract a title.
93
- 1. Create a new task
94
- 2. Set URL to `https://example.com`
95
- 3. Add a **wait** block (2 seconds)
96
- 4. Add a **javascript** block:
97
- ```js
98
- return document.title;
99
- ```
100
- 5. Run the task and view the output
101
-
102
- ### JSON Export
103
- In the task editor, open the JSON view and copy the task definition for reuse.
104
-
105
- ### JavaScript Blocks
106
- JavaScript blocks allow custom extraction or page logic. Use them for:
107
- - Parsing DOM elements
108
- - Returning structured data
109
- - Adding custom logic to actions
110
-
111
- ### Secure API Access
112
- Tasks can be executed via HTTP requests using the API key. This enables secure, automated access from other services.
113
-
114
- Key details:
115
- - Endpoint: `POST /tasks/:id/api`
116
- - Auth headers: `x-api-key: <key>` or `Authorization: Bearer <key>`
117
- - Variables: send `variables` (or `taskVariables`) in the JSON body to override task variables
118
- - API key: generate or set one in **Settings** **API Key** (stored locally)
119
-
120
- Example:
121
- ```bash
122
- curl -X POST http://localhost:11345/tasks/task_123/api \
123
- -H "Content-Type: application/json" \
124
- -H "x-api-key: YOUR_API_KEY" \
125
- -d "{\"variables\":{\"query\":\"example.com\"}}"
126
- ```
127
-
128
- ### Egress Proxy Rotation
129
- Doppelganger can rotate outbound browser traffic using a `proxies.json` file or via the UI.
130
-
131
- Supported locations:
132
- - `data/proxies.json`
133
-
134
- Example format:
135
- ```json
136
- [
137
- "http://user:pass@proxy1.example.com:8000",
138
- { "server": "http://proxy2.example.com:8000" },
139
- { "server": "socks5://proxy3.example.com:1080", "username": "user", "password": "pass" }
140
- ]
141
- ```
142
-
143
- You can also manage proxies in the **Settings Proxies** tab. Set a default proxy (or use host IP), and enable rotation per task via the **Rotate Proxies** toggle in the task editor.
144
-
145
- ### IP Allowlist (Basic IP Auth)
146
- Set `ALLOWED_IPS` (comma-separated) or create `data/allowed_ips.json` to restrict access by client IP.
147
-
148
- Example:
149
- ```bash
150
- export ALLOWED_IPS="127.0.0.1,192.168.1.10"
151
- ```
152
-
153
- JSON format:
154
- ```json
155
- ["127.0.0.1", "192.168.1.10"]
156
- ```
157
-
158
- If you're running behind a reverse proxy, set `TRUST_PROXY=1` so `X-Forwarded-For` is respected.
159
-
160
- ## Community and Presets
161
- Community-contributed presets or examples may be shared in the future.
162
- - Use community content at your own risk
163
- - The author is not responsible for community content
164
- - Always use the tool safely and legally
165
-
166
- ## License
167
- This project uses a Sustainable Use License (SUL). See `LICENSE`.
168
-
169
- ## Disclaimer
170
- The software is provided "as-is" without warranty. You are solely responsible for:
171
- - Your scripts and automation behavior
172
- - The data you access or collect
173
- - Any consequences of use
174
-
175
- Do not use this tool in ways that violate laws or third-party terms.
176
-
177
- ## Links
178
- - Homepage/Docs: https://doppelgangerdev.com
179
- - Docker Hub: https://hub.docker.com/r/mnemosyneai/doppelganger
85
+
86
+ 2. Launch backend + frontend:
87
+
88
+ ```bash
89
+ npm run server
90
+ npm run dev
91
+ ```
92
+
93
+ Frontend calls `/api` via the Vite proxy defined in `vite.config.mts`; the backend listens on `process.env.VITE_BACKEND_PORT` (default `11345`).
94
+
95
+ ## Install Release via npm
96
+
97
+ If you just want to run the packaged release (no source checkout), install the published npm package and run `doppelganger` directly.
98
+
99
+ ```bash
100
+ npm install -g @doppelgangerdev/doppelganger
101
+ doppelganger
102
+ ```
103
+
104
+ Or use `npx`:
105
+
106
+ ```bash
107
+ npx @doppelgangerdev/doppelganger
108
+ ```
109
+
110
+ If you prefer not to install globally, clone the repo, run `npm install` to pull dependencies, and then run `npx @doppelgangerdev/doppelganger` inside that folder. This ensures `npx` can resolve the package from the local registry/cache while still shipping the same dashboard experience.
111
+
112
+ Set `SESSION_SECRET` and optionally mount `data/`, `public/`, and `storage_state.json` (match the Docker volume layout). The CLI spins up the same Express/Playwright stack and opens the browser-based dashboard at `http://localhost:11345` unless you override `PORT`.
113
+
114
+ ## Session Secret
115
+
116
+ Set `SESSION_SECRET` before any run. A quick generator:
117
+
118
+ ```bash
119
+ node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
120
+ ```
121
+
122
+ # Configuration
123
+
124
+ | Variable | Purpose | Default |
125
+ |----------|---------|---------|
126
+ | `SESSION_SECRET` | Signs session cookies. Required. | — |
127
+ | `ALLOWED_IPS` | Comma list for basic IP allowlisting. | none (open) |
128
+ | `TRUST_PROXY` | Honor `X-Forwarded-*` when behind a reverse proxy. | `0` |
129
+ | `VITE_DEV_PORT` | Port for front-end dev server. | `5173` |
130
+ | `VITE_BACKEND_PORT` | Backend port for proxying + scripts. | `11345` |
131
+
132
+ Proxy rotation also respects `data/proxies.json` (see below), and `data/allowed_ips.json` works as an alternate allowlist format.
133
+
134
+ ## Advanced Configuration
135
+
136
+ - `PLAYWRIGHT_BROWSERS_PATH` (or set `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH`) when using a shared Playwright installation.
137
+ - `NODE_ENV=production` enables the bundled `dist/` client and reduces console verbosity.
138
+ - `HOST=0.0.0.0` allows binding beyond localhost inside Docker containers, while `PORT` overrides the Express listen port (defaults to `11345`).
139
+ - Set `LOG_LEVEL` to `debug` if you need more Playwright or proxy diagnostics; this can also be a custom wrapper when running `node server.js`.
140
+ - **Headful mode:** the headful/visible browser binds to `54311`, so open that port alongside `11345` when running `headful.js` or other headful flows.
141
+
142
+ # UI Walkthrough
143
+
144
+ - **Dashboard** quick stats, recent runs, and a “New Task” entry point (block or agent).
145
+ - **Task Editor** — drag blocks (click, type, wait, scroll, press, JavaScript); toggle “Rotate Proxies”; run/stop tasks; inspect results with pins & logs.
146
+ - **Captures** — review screenshots/recordings stored under `public/captures`; delete individually or refresh.
147
+ - **Executions** — historical runs with detail drill-down and the ability to re-run or download results.
148
+ - **Settings**
149
+ - **System tab**: regenerate or copy API key, select user agent, adjust layout ratio, view/copy version (`VersionPanel`), and clear storage.
150
+ - **Data tab**: manage captures and cookies.
151
+ - **Proxies tab**: add/import proxies, set defaults, toggle rotation, and inspect host vs saved entries.
152
+
153
+ # CLI & Agent Mode
154
+
155
+ - Use `npx doppelganger` (or `npm run cli`) to launch the interactive CLI that shows tasks, status, and logs.
156
+ - Behind the scenes, `bin/cli.js` can invoke `agent.js`, `headful.js`, or `scrape.js` depending on the runtime mode (`--agent`, `--headful`, `--scrape`).
157
+ - Run `node agent.js --help` to see flags like `--task`, `--browser`, or `--version`. These runners share the same settings (API key, proxies, storage) as the web UI.
158
+ - When connecting via the API key, prefer `Authorization: Bearer <key>` so reverse proxies can normalize headers; the CLI also accepts a `--api-key` flag for scripted runs.
159
+
160
+ ### Agent capabilities
161
+
162
+ - Tasks use the JSON schema outlined in `AGENT_SPEC.md`, including mode/modes (`agent`/`block`), wait times, selectors, and stealth flags.
163
+ - Support for all action types in the spec (`click`, `type`, `wait`, `press`, `scroll`, `javascript`, `csv`, `hover`, `merge`, `screenshot`, `if/else/end`, loops, `foreach`, `stop`, `set`, `on_error`, `start`), so you can encode complex flows.
164
+ - Variable templating ( `{$var}` ), structured conditions, and helper functions such as `exists()`, `text()`, and `block` output ensure reusable, data-driven tasks.
165
+ - Extraction scripts run in the browser context after the page renders; you can return JSON/CSV by reading DOM nodes directly as documented in `AGENT_SPEC.md`.
166
+
167
+ # Proxies
168
+
169
+ Proxies can be defined via the UI or `data/proxies.json`:
170
+
171
+ ```json
172
+ [
173
+ "http://user:pass@proxy1.example.com:8000",
174
+ { "server": "socks5://proxy2.example.com:1080", "label": "data center" }
175
+ ]
176
+ ```
177
+
178
+ - `host` is always available and represents your machine’s default IP.
179
+ - Rotation settings (`round-robin` or `random`) live in the Settings screen and persist through the backend endpoints.
180
+ - Import/export operations live behind `/api/settings/proxies/import`.
181
+
182
+ # API Surface
183
+
184
+ - **Task execution** (`POST /tasks/:id/api`)
185
+ - Headers: `x-api-key` or `Authorization: Bearer <key>`.
186
+ - Body: `{ "variables": { ... } }` to override task variables or provide runtime data.
187
+ - **Settings**:
188
+ - `/api/settings/api-key` — GET current, POST regen.
189
+ - `/api/settings/user-agent` toggle system vs custom list.
190
+ - `/api/settings/proxies*` — GET/POST/PUT/DELETE plus rotation toggles.
191
+ - **Clear data**:
192
+ - `POST /api/clear-screenshots` removes files in `public/captures`.
193
+ - `POST /api/clear-cookies` deletes `storage_state.json`.
194
+
195
+ Authentication enforces sessions (`/api/auth/login`, `/api/auth/logout`, `/api/auth/me`); read `server.js` to see the guard/middleware logic.
196
+
197
+ # Task Scripting Tips
198
+
199
+ - Use JavaScript blocks to scrape structured data:
200
+ ```js
201
+ return document.querySelectorAll('article').length;
202
+ ```
203
+ - Keep CSS selectors narrow; the block-based editor surfaces `#`, `.`, and attribute hints.
204
+ - When running headlessly, toggle `headful.js` or `agent.js` depending on whether you need a visible browser for debugging.
205
+ - Set `task.variables` via the API to re-use generic workflows across multiple domains.
206
+
207
+ ## Workflow Recipe
208
+
209
+ 1. Design a task in the editor starting with a `goto` block and a `wait` block to give pages time to render.
210
+ 2. Add conditional `javascript` blocks to test for specific DOM elements; use the retry/timer controls per block.
211
+ 3. Attach `extract` (JSON output) or `screenshot` actions before submitting so you can inspect results in the Captures tab.
212
+ 4. Toggle “Rotate Proxies” if you need egress diversity and pick a default proxy on Settings → Proxies.
213
+ 5. Save the task, pin results you care about, and use the `POST /tasks/:id/api` endpoint with variables like `{"variables":{"query":"books"}}` to run it from automation tools.
214
+
215
+ # Testing & Validation
216
+
217
+ - Run `npm run build` before packaging for production; the `dist/` folder contains the compiled assets.
218
+ - Backend logging writes to the console; capture output from `server.js` for debugging proxies, authentication, or Playwright failures.
219
+ - Playwright logs are visible in the running Node process and under `node_modules/.cache` when using the CLI.
220
+
221
+ # Troubleshooting
222
+
223
+ - **“Session expired”** in the UI: confirm `SESSION_SECRET` is consistent and cookies aren’t blocked by your browser.
224
+ - **Tasks hang**: ensure the target site isn’t blocking automated browsers; try toggling `headful`/`headless` modes or adding delays.
225
+ - **Proxy import fails**: inspect `data/proxies.json` for valid URLs; the backend validates `server` as a string.
226
+ - **API key lost**: regenerate from Settings → System tab; the UI copies it automatically.
227
+
228
+ # Data Lifecycle
229
+
230
+ - Captures land in `public/captures`; regular cleanups can be scripted via `POST /api/clear-screenshots`.
231
+ - Cookies live in `storage_state.json`. Back up this file before clearing cookies via the UI or `/api/clear-cookies`.
232
+ - Proxy lists, user-agent preferences, and settings persist under `data/` (look for `proxies.json`, `allowed_ips.json`, etc.) — treat this directory as your config source control.
233
+ - Use `Storage` controls in Settings to clear data after experimentation cycles, and keep `layouts` or `version` info tracked via `localStorage` as shown in `src/components/SettingsScreen.tsx`.
234
+
235
+ # Maintenance
236
+
237
+ - The project is governed by the **[Sustainable Use License (SUL 1.0)](https://github.com/mnemosyne-artificial-intelligence/doppelganger/blob/main/LICENSE)**; hosting it as a competing service is prohibited.
238
+ - Keep `data/` and `storage_state.json` backed up if you rely on historical cookies or proxies.
239
+ - Release updates by pulling `mnemosyneai/doppelganger` (Docker) or `npm i @doppelgangerdev/doppelganger` (npm). The Settings view always displays the current package version.
240
+ - Contributions: follow `.github/` templates, respect `CONTRIBUTING.md`, and run available lint/test scripts if you touch critical areas.
241
+
242
+ # Roadmap
243
+
244
+ - [x] **Settings shortcuts** — the System tab already exposes API key regeneration, user agent selection, and layout preferences so operators can tune them without leaving the UI.
245
+ - [x] **Storage cleanup** — the Settings data tab lets you clear captures and cookies, and the backend exposes `/api/clear-screenshots` and `/api/clear-cookies`.
246
+ - [x] **IP rotation tooling** — build a settings workflow for importing proxies and automatically rotating them.
247
+ - [x] **API key workflow** — the API key panel already supports regenerating and copying keys via `/api/settings/api-key`, so secure API access is ready without extra setup.
248
+ - [x] **Task proxy rotation toggle** — the “Rotate Proxies” option in each task ties into the Settings rotation controls, enabling rotation per execution.
249
+ - [ ] **Action key combos** — add modifier shortcuts (e.g., Ctrl+Click, Shift+Scroll) so tasks can more closely mirror real user interactions.
250
+ - [ ] **Click-and-drag block** — add an action that does drag gestures (selecting text, moving items) so tasks can simulate click-and-drag flows.
251
+ - [ ] **Recording controls** — Add a toggle for disabling automated recording when needed.
252
+ - [ ] **File downloads** — add explicit support for agent tasks to download files (PDFs, CSVs, etc.) directly from target pages, then surface those downloads in the UI so users can preview or export them without sifting through captures.
253
+ - [ ] **Stateless mode** — add a lightweight “stateless” execution path that spins up browsers without touching the shared `storage_state.json`, ideal for sensitive workflows that should never persist cookies or local storage between runs.
254
+ - [ ] **Extraction response mode** — add a Settings switch so users can choose whether the UI returns HTML+data (for debugging) or data-only payloads when extraction scripts run.
255
+ - [ ] **Folder organization** — group tasks, assets, and captures into named folders so operators can browse, filter, and download collections per workflow.
256
+ - [ ] **Stable capture retention** — add filtering, pinning, and archiving in captures tab so teams can keep compliance records.
257
+ - [ ] **Workspace templates** — allow saving and sharing workspace presets (layout + default proxies/agents) so new team members can onboard with pre-configured setups.
258
+ - [ ] **Geo-targeted exits** — allow choosing proxy regions for tasks so you can pin the apparent location before running a job.
259
+ - [ ] **Session recording redaction** — add toggles to redact sensitive fields (passwords, credit cards) from recordings/logs before storing them.
260
+ - [ ] **Two-factor authentication** — add optional TOTP/second-factor support to Settings/Auth so operators can lock down the UI with 2FA.
261
+ - [ ] **AI-assisted fixing** — add an “AI auto-fix” helper that suggests layout, selector, and proxy tweaks after failed runs, letting teams approve or discard the proposed changes without switching contexts.
262
+
263
+ # Security Considerations
264
+
265
+ - Never commit your `SESSION_SECRET`, API keys, or `storage_state.json` into shared repositories.
266
+ - Use `ALLOWED_IPS`/`data/allowed_ips.json` to gate the UI when deploying to a network-exposed host.
267
+ - Rotate API keys periodically via Settings, and log all automation runs through the Executions tab for audit purposes.
268
+ - Playwright runs inside the same Node process; keep dependencies up to date and rebuild `node_modules` after significant OS patches.
269
+
270
+ # Community & Support
271
+
272
+ - Report issues or request features via the GitHub repo issue tracker.
273
+ - Follow the authors on `https://github.com/mnemosyne-artificial-intelligence` for releases.
274
+ - Share automation recipes with other self-hosted users in your org, but respect SUL limits on sharing infrastructure.
package/agent.js CHANGED
@@ -194,9 +194,10 @@ async function handleAgent(req, res) {
194
194
  });
195
195
  }
196
196
 
197
- const localPort = req.socket && req.socket.localPort;
198
- const localHost = localPort ? `127.0.0.1:${localPort}` : req.get('host');
199
- const baseUrl = `${req.protocol || 'http'}://${localHost}`;
197
+ const localPort = req.socket && req.socket.localPort;
198
+ const configuredPort = process.env.PORT || process.env.VITE_BACKEND_PORT;
199
+ const basePort = localPort || configuredPort || '11345';
200
+ const baseUrl = `${req.protocol || 'http'}://127.0.0.1:${basePort}`;
200
201
  const runtimeVars = { ...(data.taskVariables || data.variables || {}) };
201
202
  let lastBlockOutput = null;
202
203
  runtimeVars['block.output'] = lastBlockOutput;
@@ -1349,7 +1350,9 @@ async function handleAgent(req, res) {
1349
1350
  return { shadowQueryAll, shadowText };
1350
1351
  })();
1351
1352
 
1352
- const executor = new Function(
1353
+ // CodeQL alerts on dynamic eval, but extraction scripts intentionally run inside the browser sandbox,
1354
+ // so we expose only the helpers needed (window, document, DOMParser, console) and keep the evaluation confined there.
1355
+ const executor = new Function(
1353
1356
  '$$data',
1354
1357
  'window',
1355
1358
  'document',