figranium 0.9.2 → 0.9.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,318 +1,336 @@
1
- <div align="center">
2
- <img src="https://raw.githubusercontent.com/figranium/figranium/main/figranium_banner.png" alt="Figranium Banner">
3
- </div>
4
-
5
- # Figranium — Deterministic Control for an Agentic World
6
-
7
- Figranium (formerly 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.
8
-
9
- <img src="https://raw.githubusercontent.com/figranium/figranium/main/figranium_screenshot.png" alt="Figranium Demo" width="100%">
10
-
11
- # What You Get
12
-
13
- - **Block‑based automation** — build flows with actions like click, type, wait, hover, and execute JavaScript against modern pages.
14
- - **Task API + CLI** — trigger saved tasks via HTTP (`/tasks/:id/api`) or `npx figranium` while passing variables and securing runs with the API key you control.
15
- - **Captures & storage** — automatically store screenshots/recordings and cookies; view them in the captures tab, reset storage, or download built assets.
16
- - **Proxy management** — host, rotate, or import HTTP/SOCKS proxies, flag a default, and toggle rotation per task.
17
- - **Security-first** — session authentication, IP allowlists, secret management, and audit trails live entirely inside your environment.
18
-
19
- # Architecture Snapshot
20
-
21
- 1. **Frontend**
22
- - Vite with React (TypeScript) drives `/dashboard`, `/tasks`, `/settings`, `/executions`, and `/captures`.
23
- - The Settings screen is tabbed (`System`, `Data`, `Proxies`) and houses panels for API keys, user agents, layout, storage, and version info.
24
- - Components call `/api/*` endpoints through the Vite dev proxy (see `vite.config.mts`), sharing `APP_VERSION` via `src/utils/appInfo.ts`.
25
-
26
- 2. **Backend**
27
- - `server.js` (Express) handles auth (`/api/auth`), task metadata, hooks into Playwright, and exposes `/api/settings/*` for runtime configuration.
28
- - Requirements: Node 18+ (LTS), Playwright bundled via `npm install`.
29
- - Storage is plain‑file: `data/` for proxies and allowlists, `public/captures` for visuals, `storage_state.json` for cookies.
30
-
31
- 3. **Scripts & automation**
32
- - `scripts/postinstall.js` runs when dependencies install (keep an eye if you customize).
33
- - `agent.js`, `headful.js`, `scrape.js` expose specialized runners; the CLI binary `bin/cli.js` wires them for `npx figranium`.
34
-
35
- 4. **Code layout highlights**
36
- - `src/App.tsx` glues together routing, alerts, and the sidebar that links dashboards, tasks, and settings.
37
- - `src/components` houses reusable panels (API keys, storage, captures, proxies) that map directly to backend endpoints.
38
- - `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.
39
-
40
- # Getting Started
41
-
42
- ## Docker (Recommended)
43
-
44
- ### Docker Compose (Multi-arch / ARM / Apple Silicon)
45
-
46
- The easiest way to run Figranium on any architecture (including M1/M2/M3 Macs) is via Docker Compose.
47
-
48
- 1. Clone the repository:
49
-
50
- ```bash
51
- git clone https://github.com/figranium/figranium.git
52
- cd figranium
53
- ```
54
-
55
- 2. Start the services:
56
-
57
- ```bash
58
- docker compose up --build -d
59
- ```
60
-
61
- This starts the app on `http://localhost:11345` and the VNC viewer on `http://localhost:54311`.
62
-
63
- ### Docker Run (Standard)
64
-
65
- ```bash
66
- docker pull figranium/figranium
67
- docker run -d \
68
- --name figranium \
69
- -p 11345:11345 \
70
- -p 54311:54311 \
71
- -e SESSION_SECRET=replace_with_long_random_value \
72
- -v $(pwd)/data:/app/data \
73
- -v $(pwd)/public:/app/public \
74
- -v $(pwd)/storage_state.json:/app/storage_state.json \
75
- figranium/figranium
76
- ```
77
-
78
- Visit `http://localhost:11345`. Stop/start with `docker stop/start figranium`.
79
-
80
- > The first visit loads the login/setup screen. After you create the admin account and sign in, the dashboard replaces the login view and stays visible for as long as the session remains valid; returning users are redirected straight to the dashboard until they explicitly log out or the session expires.
81
-
82
- ## Local Development (npm)
83
-
84
- 1. Install dependencies:
85
-
86
- ```bash
87
- npm install
88
- ```
89
-
90
- 2. Launch backend + frontend:
91
-
92
- ```bash
93
- npm run server
94
- npm run dev
95
- ```
96
-
97
- Frontend calls `/api` via the Vite proxy defined in `vite.config.mts`; the backend listens on `process.env.VITE_BACKEND_PORT` (default `11345`).
98
-
99
- ## Install Release via npm
100
-
101
- If you just want to run the packaged release (no source checkout), install the published npm package and run `figranium` directly.
102
-
103
- ```bash
104
- npm install -g figranium
105
- figranium
106
- ```
107
-
108
- Or use `npx`:
109
-
110
- ```bash
111
- npx figranium
112
- ```
113
-
114
- If you prefer not to install globally, clone the repo, run `npm install` to pull dependencies, and then run `npx figranium` inside that folder. This ensures `npx` can resolve the package from the local registry/cache while still shipping the same dashboard experience.
115
-
116
- 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`.
117
-
118
- ## Session Secret
119
-
120
- Set `SESSION_SECRET` before any run. A quick generator:
121
-
122
- ```bash
123
- node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
124
- ```
125
-
126
- # Configuration
127
-
128
- | Variable | Purpose | Default |
129
- |----------|---------|---------|
130
- | `SESSION_SECRET` | Signs session cookies. Required. | — |
131
- | `ALLOWED_IPS` | Comma list for basic IP allowlisting. | none (open) |
132
- | `TRUST_PROXY` | Honor `X-Forwarded-*` when behind a reverse proxy. | `0` |
133
- | `ALLOW_PRIVATE_NETWORKS` | Allow scraping local/private IPs (SSRF risk). | `true` |
134
- | `VITE_DEV_PORT` | Port for front-end dev server. | `5173` |
135
- | `VITE_BACKEND_PORT` | Backend port for proxying + scripts. | `11345` |
136
- | `DB_TYPE` | Optional database type overriding disk storage. Set to `postgres` to use PostgreSQL. | — |
137
- | `DB_POSTGRESDB_HOST` | Hostname for the PostgreSQL database (required if DB_TYPE is postgres). | — |
138
- | `DB_POSTGRESDB_PORT` | Port for the PostgreSQL database (required if DB_TYPE is postgres). | — |
139
- | `DB_POSTGRESDB_USER` | Username for the PostgreSQL database (required if DB_TYPE is postgres). | — |
140
- | `DB_POSTGRESDB_PASSWORD` | Password for the PostgreSQL database (required if DB_TYPE is postgres). | — |
141
-
142
- Proxy rotation also respects `data/proxies.json` (see below), and `data/allowed_ips.json` works as an alternate allowlist format.
143
-
144
- ## Advanced Configuration
145
-
146
- - `PLAYWRIGHT_BROWSERS_PATH` (or set `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH`) when using a shared Playwright installation.
147
- - `NODE_ENV=production` enables the bundled `dist/` client and reduces console verbosity.
148
- - `HOST=0.0.0.0` allows binding beyond localhost inside Docker containers, while `PORT` overrides the Express listen port (defaults to `11345`).
149
- - 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`.
150
- - **Headful mode:** the headful/visible browser binds to `54311`, so open that port alongside `11345` when running `headful.js` or other headful flows.
151
-
152
- # UI Walkthrough
153
-
154
- - **Dashboard** — quick stats, recent runs, and a “New Task” entry point (block or agent).
155
- - **Task Editor** — drag blocks (click, type, wait, scroll, press, JavaScript); toggle Rotate Proxies”; run/stop tasks; inspect results with pins & logs.
156
- - **Captures** — review screenshots/recordings stored under `public/captures`; delete individually or refresh.
157
- - **Executions** — historical runs with detail drill-down and the ability to re-run or download results.
158
- - **Settings**
159
- - **System tab**: regenerate or copy API key, select user agent, adjust layout ratio, view/copy version (`VersionPanel`), and clear storage.
160
- - **Data tab**: manage captures and cookies.
161
- - **Proxies tab**: add/import proxies, set defaults, toggle rotation, and inspect host vs saved entries.
162
-
163
- # CLI & Agent Mode
164
-
165
- - Use `npx figranium` (or `npm run cli`) to launch the interactive CLI that shows tasks, status, and logs.
166
- - Behind the scenes, `bin/cli.js` can invoke `agent.js`, `headful.js`, or `scrape.js` depending on the runtime mode (`--agent`, `--headful`, `--scrape`).
167
- - 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.
168
- - 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.
169
-
170
- ### Agent capabilities
171
-
172
- - Tasks use the JSON schema outlined in `AGENT_SPEC.md`, including mode/modes (`agent`/`block`), wait times, selectors, and stealth flags.
173
- - 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.
174
- - Variable templating ( `{$var}` ), structured conditions, and helper functions such as `exists()`, `text()`, and `block` output ensure reusable, data-driven tasks.
175
- - 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`.
176
-
177
- # Proxies
178
-
179
- Proxies can be defined via the UI or `data/proxies.json`:
180
-
181
- ```json
182
- [
183
- "http://user:pass@proxy1.example.com:8000",
184
- { "server": "socks5://proxy2.example.com:1080", "label": "data center" }
185
- ]
186
- ```
187
-
188
- - `host` is always available and represents your machine’s default IP.
189
- - Rotation settings (`round-robin` or `random`) live in the Settings screen and persist through the backend endpoints.
190
- - Import/export operations live behind `/api/settings/proxies/import`.
191
-
192
- # API Surface
193
-
194
- Figranium exposes a comprehensive REST API for integration with agents (like OpenClaw) or custom automation scripts. All endpoints are hosted locally, typically on port `11345`.
195
-
196
- **Authentication:**
197
- If enabled, provide the `x-api-key` header or `Authorization: Bearer <key>`. For internal network use, this may be optional depending on your settings.
198
-
199
-
200
- ### Task Management API
201
- * **`GET /api/tasks`**: List all saved automation profiles.
202
- * **`POST /api/tasks`**: Create a new task profile.
203
- * **`PUT /api/tasks/:id`**: Update an existing task profile.
204
- * **`POST /api/tasks/:id/api`**: Execute a predefined task. Pass `{"variables": {}}` in the body to override execution variables dynamically.
205
-
206
- ### Execution & Logging API
207
- * **`GET /api/executions`**: Retrieve paginated logs of all past runs.
208
- * **`GET /api/executions/:id`**: View the exact steps, result JSON, and configuration state of a specific run.
209
-
210
- ### Data Management API
211
- * **`GET /api/data/captures`**: List generated screenshots, videos, and downloads.
212
- * **`DELETE /api/data/captures/:name`**: Delete a specific capture.
213
- * **`POST /api/clear-screenshots`**: Removes all files in `public/captures`.
214
- * **`POST /api/clear-cookies`**: Deletes `storage_state.json`.
215
-
216
- # Task Scripting Tips
217
-
218
- - Use JavaScript blocks to scrape structured data:
219
- ```js
220
- return document.querySelectorAll('article').length;
221
- ```
222
- - Keep CSS selectors narrow; the block-based editor surfaces `#`, `.`, and attribute hints.
223
- - When running headlessly, toggle `headful.js` or `agent.js` depending on whether you need a visible browser for debugging.
224
- - Set `task.variables` via the API to re-use generic workflows across multiple domains.
225
-
226
- ## Workflow Recipe
227
-
228
- 1. Design a task in the editor starting with a `goto` block and a `wait` block to give pages time to render.
229
- 2. Add conditional `javascript` blocks to test for specific DOM elements; use the retry/timer controls per block.
230
- 3. Attach `extract` (JSON output) or `screenshot` actions before submitting so you can inspect results in the Captures tab.
231
- 4. Toggle “Rotate Proxies” if you need egress diversity and pick a default proxy on Settings → Proxies.
232
- 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.
233
-
234
- # Testing & Validation
235
-
236
- - Run `npm run build` before packaging for production; the `dist/` folder contains the compiled assets.
237
- - Backend logging writes to the console; capture output from `server.js` for debugging proxies, authentication, or Playwright failures.
238
- - Playwright logs are visible in the running Node process and under `node_modules/.cache` when using the CLI.
239
-
240
- # Troubleshooting
241
-
242
- - **“Session expired”** in the UI: confirm `SESSION_SECRET` is consistent and cookies aren’t blocked by your browser.
243
- - **Proxy import fails**: inspect `data/proxies.json` for valid URLs; the backend validates `server` as a string.
244
- - **API key lost**: copy from Settings System tab.
245
-
246
- # Data Lifecycle
247
-
248
- - Captures land in `public/captures`; regular cleanups can be scripted via `POST /api/clear-screenshots`.
249
- - Cookies live in `storage_state.json`. Back up this file before clearing cookies via the UI or `/api/clear-cookies`.
250
- - 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.
251
- - 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`.
252
-
253
- # Maintenance
254
-
255
- - The project is governed by the **[GNU General Public License v3.0](https://github.com/figranium/figranium/blob/main/LICENSE)**, which grants rights for distribution and modification as per the GPLv3 terms.
256
- - Keep `data/` and `storage_state.json` backed up if you rely on historical cookies or proxies.
257
- - Release updates by pulling `figranium/figranium` (Docker) or `npm i figranium` (npm). The Settings view always displays the current package version.
258
- - Contributions: follow `.github/` templates, respect `CONTRIBUTING.md`, and run available lint/test scripts if you touch critical areas.
259
-
260
- # Roadmap
261
-
262
- - [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.
263
- - [x] **Storage cleanup** — the Settings data tab lets you clear captures and cookies, and the backend exposes `/api/clear-screenshots` and `/api/clear-cookies`.
264
- - [x] **IP rotation tooling** — build a settings workflow for importing proxies and automatically rotating them.
265
- - [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.
266
- - [x] **Task proxy rotation toggle** the “Rotate Proxies” option in each task ties into the Settings rotation controls, enabling rotation per execution.
267
- - [x] **Spatial editor transition** transition to a spatial editor like that of activepieces (top priority).
268
- - [ ] **Action key combos** add modifier shortcuts (e.g., Ctrl+Click, Shift+Scroll) so tasks can more closely mirror real user interactions.
269
- - [ ] **Click-and-drag block** — add an action that does drag gestures (selecting text, moving items) so tasks can simulate click-and-drag flows.
270
- - [x] **Recording controls** — Task editor now exposes a “Disable automated recording” switch in the general settings panel so workflows can skip video capture on a per-task basis.
271
- - [x] **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.
272
- - [x] **Stateless mode** Tasks now have a “Stateless execution” toggle alongside the recording controls so each run can skip `storage_state.json`, ensuring no cookies or local storage persist between executions for that workflow.
273
- - [ ] **Adblocking filters** add controls so execution contexts can enable built-in ad/malware filtering (e.g., via hosts file overrides or request blocking) to reduce noise on sensitive sites.
274
- - [ ] **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.
275
- - [ ] **Folder organization** group tasks, assets, and captures into named folders so operators can browse, filter, and download collections per workflow.
276
- - [ ] **Stable capture retention** — add filtering, pinning, and archiving in captures tab so teams can keep compliance records.
277
- - [ ] **Workspace templates** — allow saving and sharing workspace presets (layout + default proxies/agents) so new team members can onboard with pre-configured setups.
278
- - [ ] **Geo-targeted exits** — allow choosing proxy regions for tasks so you can pin the apparent location before running a job.
279
- - [ ] **Complete anti-detection coverage** — follow browserscan.net's anti-detection checklist (fingerprints, headers, fonts, WebRTC, etc.) so automated runs mimic real browsers across task executions.
280
- - [ ] **Session recording redaction** — add toggles to redact sensitive fields (passwords, credit cards) from recordings/logs before storing them.
281
- - [ ] **Two-factor authentication** — add optional TOTP/second-factor support to Settings/Auth so operators can lock down the UI with 2FA.
282
- - [ ] **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.
283
- - [ ] **Companion app** — build a lightweight companion app that mirrors critical dashboard notifications (failures, capture completions, proxy issues) so operators can stay informed without opening the full UI.
284
- - [ ] **Community presets hub** — build a marketplace where users can publish task/workspace presets, browse and download others’ submissions, and choose to offer each preset either for free or as a paid template so creators can monetize standalone workflows while keeping the free option available.
285
- - [ ] **Database Tab / Local CRM** — add a built-in spreadsheet-like interface for viewing and managing extracted data (CRM-style) entirely within the app, without requiring external tools.
286
- - [ ] **iframe interaction support** — add the ability to target and interact with elements inside iframes in the task editor.
287
- - [x] **Autosave** — automatically persist task changes and editor state at regular intervals so operators don't lose work on long-running or complex workflow designs.
288
- - [ ] **Highlight tool** — add a feature to highlight elements on the page (similar to a browser's inspect tool) to easily pick selectors and build workflows.
289
-
290
- # Security Considerations
291
-
292
- - Never commit your `SESSION_SECRET`, API keys, or `storage_state.json` into shared repositories.
293
- - Use `ALLOWED_IPS`/`data/allowed_ips.json` to gate the UI when deploying to a network-exposed host.
294
- - Rotate API keys periodically via Settings, and log all automation runs through the Executions tab for audit purposes.
295
- - Playwright runs inside the same Node process; keep dependencies up to date and rebuild `node_modules` after significant OS patches.
296
-
297
- # Community
298
-
299
- - Report issues or request features via the GitHub repo issue tracker.
300
- - Follow the authors on `https://github.com/figranium` for releases.
301
- - Share automation recipes with other self-hosted users in your org, but respect the license for sharing infrastructure.
302
- - Join the community on [Discord](https://discord.gg/kPmfbgu9Xn).
303
-
304
- # Support the Project
305
-
306
- If you find this project helpful, please consider supporting its development. Your contributions help keep the project maintained and the lights on!
307
-
308
- <div align="center">
309
- <a href="https://ko-fi.com/asernasr" target="_blank">
310
- <img src="https://img.shields.io/badge/Support%20on-Ko--fi-FF5E5B?style=for-the-badge&logo=ko-fi&logoColor=white" alt="Support on Ko-fi" />
311
- </a>
312
- </div>
313
-
314
- ---
315
- **Other ways to help:**
316
- * **Star** the repository to help others find it.
317
- * **Share** the project with your network.
318
- * **Contribute** to the code or documentation.
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/figranium/figranium/main/figranium_banner.png" alt="Figranium Banner">
3
+ </div>
4
+
5
+ # Figranium — Deterministic Control for an Agentic World
6
+
7
+ Figranium (formerly 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.
8
+
9
+ <img src="https://raw.githubusercontent.com/figranium/figranium/main/figranium_screenshot.png" alt="Figranium Demo" width="100%">
10
+
11
+ # What You Get
12
+
13
+ - **Block‑based automation** — build flows with actions like click, type, wait, hover, and execute JavaScript against modern pages.
14
+ - **Task API + CLI** — trigger saved tasks via HTTP (`/tasks/:id/api`) or `npx figranium` while passing variables and securing runs with the API key you control.
15
+ - **Captures & storage** — automatically store screenshots/recordings and cookies; view them in the captures tab, reset storage, or download built assets.
16
+ - **Proxy management** — host, rotate, or import HTTP/SOCKS proxies, flag a default, and toggle rotation per task.
17
+ - **Task Scheduling** — run workflows automatically using visual interval/daily/weekly/monthly settings or advanced cron expressions.
18
+ - **Security-first** — session authentication, IP allowlists, secret management, and audit trails live entirely inside your environment.
19
+
20
+ # Architecture Snapshot
21
+
22
+ 1. **Frontend**
23
+ - Vite with React (TypeScript) drives `/dashboard`, `/tasks`, `/settings`, `/executions`, and `/captures`.
24
+ - The Settings screen is tabbed (`System`, `Data`, `Proxies`) and houses panels for API keys, user agents, layout, storage, and version info.
25
+ - Components call `/api/*` endpoints through the Vite dev proxy (see `vite.config.mts`), sharing `APP_VERSION` via `src/utils/appInfo.ts`.
26
+
27
+ 2. **Backend**
28
+ - `server.js` (Express) handles auth (`/api/auth`), task metadata, hooks into Playwright, and exposes `/api/settings/*` for runtime configuration.
29
+ - Requirements: Node 18+ (LTS), Playwright bundled via `npm install`.
30
+ - Storage is plain‑file: `data/` for proxies and allowlists, `public/captures` for visuals, `storage_state.json` for cookies.
31
+
32
+ 3. **Scripts & automation**
33
+ - `scripts/postinstall.js` runs when dependencies install (keep an eye if you customize).
34
+ - `agent.js`, `headful.js`, `scrape.js` expose specialized runners; the CLI binary `bin/cli.js` wires them for `npx figranium`.
35
+
36
+ 4. **Code layout highlights**
37
+ - `src/App.tsx` glues together routing, alerts, and the sidebar that links dashboards, tasks, and settings.
38
+ - `src/components` houses reusable panels (API keys, storage, captures, proxies) that map directly to backend endpoints.
39
+ - `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.
40
+
41
+ # Getting Started
42
+
43
+ ## Docker (Recommended)
44
+
45
+ ### Docker Compose (Multi-arch / ARM / Apple Silicon)
46
+
47
+ The easiest way to run Figranium on any architecture (including M1/M2/M3 Macs) is via Docker Compose.
48
+
49
+ 1. Clone the repository:
50
+
51
+ ```bash
52
+ git clone https://github.com/figranium/figranium.git
53
+ cd figranium
54
+ ```
55
+
56
+ 2. Start the services:
57
+
58
+ ```bash
59
+ docker compose up --build -d
60
+ ```
61
+
62
+ This starts the app on `http://localhost:11345` and the VNC viewer on `http://localhost:54311`.
63
+
64
+ ### Docker Run (Standard)
65
+
66
+ ```bash
67
+ docker pull ghcr.io/figranium/figranium
68
+ docker run -d \
69
+ --name figranium \
70
+ -p 11345:11345 \
71
+ -p 54311:54311 \
72
+ -e SESSION_SECRET=replace_with_long_random_value \
73
+ -v $(pwd)/data:/app/data \
74
+ -v $(pwd)/public:/app/public \
75
+ -v $(pwd)/storage_state.json:/app/storage_state.json \
76
+ figranium/figranium
77
+ ```
78
+
79
+ Visit `http://localhost:11345`. Stop/start with `docker stop/start figranium`.
80
+
81
+ > The first visit loads the login/setup screen. After you create the admin account and sign in, the dashboard replaces the login view and stays visible for as long as the session remains valid; returning users are redirected straight to the dashboard until they explicitly log out or the session expires.
82
+
83
+ ## Local Development (npm)
84
+
85
+ 1. Install dependencies:
86
+
87
+ ```bash
88
+ npm install
89
+ ```
90
+
91
+ 2. Launch backend + frontend:
92
+
93
+ ```bash
94
+ npm run server
95
+ npm run dev
96
+ ```
97
+
98
+ Frontend calls `/api` via the Vite proxy defined in `vite.config.mts`; the backend listens on `process.env.VITE_BACKEND_PORT` (default `11345`).
99
+
100
+ ## Install Release via npm
101
+
102
+ If you just want to run the packaged release (no source checkout), install the published npm package and run `figranium` directly.
103
+
104
+ ```bash
105
+ npm install -g figranium
106
+ figranium
107
+ ```
108
+
109
+ Or use `npx`:
110
+
111
+ ```bash
112
+ npx figranium
113
+ ```
114
+
115
+ If you prefer not to install globally, clone the repo, run `npm install` to pull dependencies, and then run `npx figranium` inside that folder. This ensures `npx` can resolve the package from the local registry/cache while still shipping the same dashboard experience.
116
+
117
+ 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`.
118
+
119
+ ## Session Secret
120
+
121
+ Set `SESSION_SECRET` before any run. A quick generator:
122
+
123
+ ```bash
124
+ node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
125
+ ```
126
+
127
+ # Configuration
128
+
129
+ | Variable | Purpose | Default |
130
+ |----------|---------|---------|
131
+ | `SESSION_SECRET` | Signs session cookies. Required. | |
132
+ | `ALLOWED_IPS` | Comma list for basic IP allowlisting. | none (open) |
133
+ | `TRUST_PROXY` | Honor `X-Forwarded-*` when behind a reverse proxy. | `0` |
134
+ | `ALLOW_PRIVATE_NETWORKS` | Allow scraping local/private IPs (SSRF risk). | `true` |
135
+ | `VITE_DEV_PORT` | Port for front-end dev server. | `5173` |
136
+ | `VITE_BACKEND_PORT` | Backend port for proxying + scripts. | `11345` |
137
+ | `DB_TYPE` | Optional database type overriding disk storage. Set to `postgres` to use PostgreSQL. | — |
138
+ | `DB_POSTGRESDB_HOST` | Hostname for the PostgreSQL database (required if DB_TYPE is postgres). | — |
139
+ | `DB_POSTGRESDB_PORT` | Port for the PostgreSQL database (required if DB_TYPE is postgres). | — |
140
+ | `DB_POSTGRESDB_USER` | Username for the PostgreSQL database (required if DB_TYPE is postgres). | — |
141
+ | `DB_POSTGRESDB_PASSWORD` | Password for the PostgreSQL database (required if DB_TYPE is postgres). | — |
142
+
143
+ Proxy rotation also respects `data/proxies.json` (see below), and `data/allowed_ips.json` works as an alternate allowlist format.
144
+
145
+ ## Advanced Configuration
146
+
147
+ - `PLAYWRIGHT_BROWSERS_PATH` (or set `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH`) when using a shared Playwright installation.
148
+ - `NODE_ENV=production` enables the bundled `dist/` client and reduces console verbosity.
149
+ - `HOST=0.0.0.0` allows binding beyond localhost inside Docker containers, while `PORT` overrides the Express listen port (defaults to `11345`).
150
+ - 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`.
151
+ - **Headful mode:** the headful/visible browser binds to `54311`, so open that port alongside `11345` when running `headful.js` or other headful flows.
152
+
153
+ # UI Walkthrough
154
+
155
+ - **Dashboard** — quick stats, recent runs, and aNew Task” entry point (block or agent).
156
+ - **Task Editor** — drag blocks (click, type, wait, scroll, press, JavaScript); toggle “Rotate Proxies”; schedule runs via the **Schedule** tab; run/stop tasks; inspect results with pins & logs.
157
+ - **Captures** — review screenshots/recordings stored under `public/captures`; delete individually or refresh.
158
+ - **Executions** — historical runs with detail drill-down and the ability to re-run or download results.
159
+ - **Settings**
160
+ - **System tab**: regenerate or copy API key, select user agent, adjust layout ratio, view/copy version (`VersionPanel`), and clear storage.
161
+ - **Data tab**: manage captures and cookies.
162
+ - **Proxies tab**: add/import proxies, set defaults, toggle rotation, and inspect host vs saved entries.
163
+
164
+ # CLI & Agent Mode
165
+
166
+ - Use `npx figranium` (or `npm run cli`) to launch the interactive CLI that shows tasks, status, and logs.
167
+ - Behind the scenes, `bin/cli.js` can invoke `agent.js`, `headful.js`, or `scrape.js` depending on the runtime mode (`--agent`, `--headful`, `--scrape`).
168
+ - 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.
169
+ - 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.
170
+
171
+ ### Agent capabilities
172
+
173
+ - Tasks use the JSON schema outlined in `AGENT_SPEC.md`, including mode/modes (`agent`/`block`), wait times, selectors, and stealth flags.
174
+ - 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.
175
+ - Variable templating ( `{$var}` ), structured conditions, and helper functions such as `exists()`, `text()`, and `block` output ensure reusable, data-driven tasks.
176
+ - 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`.
177
+
178
+ # Proxies
179
+
180
+ Proxies can be defined via the UI or `data/proxies.json`:
181
+
182
+ ```json
183
+ [
184
+ "http://user:pass@proxy1.example.com:8000",
185
+ { "server": "socks5://proxy2.example.com:1080", "label": "data center" }
186
+ ]
187
+ ```
188
+
189
+ - `host` is always available and represents your machine’s default IP.
190
+ - Rotation settings (`round-robin` or `random`) live in the Settings screen and persist through the backend endpoints.
191
+ - Import/export operations live behind `/api/settings/proxies/import`.
192
+
193
+ # API Surface
194
+
195
+ Figranium exposes a comprehensive REST API for integration with agents (like OpenClaw) or custom automation scripts. All endpoints are hosted locally, typically on port `11345`.
196
+
197
+ **Authentication:**
198
+ If enabled, provide the `x-api-key` header or `Authorization: Bearer <key>`. For internal network use, this may be optional depending on your settings.
199
+
200
+
201
+ ### Task Management API
202
+ * **`GET /api/tasks`**: List all saved automation profiles.
203
+ * **`POST /api/tasks`**: Create a new task profile.
204
+ * **`PUT /api/tasks/:id`**: Update an existing task profile.
205
+ * **`POST /api/tasks/:id/api`**: Execute a predefined task. Pass `{"variables": {}}` in the body to override execution variables dynamically.
206
+
207
+ ### Scheduling API
208
+ * **`GET /api/schedules`**: List all scheduled tasks and their status.
209
+ * **`POST /api/schedules/:taskId`**: Create or update a schedule (supports visual config or raw cron).
210
+ * **`DELETE /api/schedules/:taskId`**: Disable/remove a schedule.
211
+ * **`GET /api/schedules/status/all`**: Get an overview of all active scheduled jobs.
212
+
213
+ ### Execution & Logging API
214
+ * **`GET /api/executions`**: Retrieve paginated logs of all past runs.
215
+ * **`GET /api/executions/:id`**: View the exact steps, result JSON, and configuration state of a specific run.
216
+
217
+ ### Data Management API
218
+ * **`GET /api/data/captures`**: List generated screenshots, videos, and downloads.
219
+ * **`DELETE /api/data/captures/:name`**: Delete a specific capture.
220
+ * **`POST /api/clear-screenshots`**: Removes all files in `public/captures`.
221
+ * **`POST /api/clear-cookies`**: Deletes `storage_state.json`.
222
+
223
+ # Task Scripting Tips
224
+
225
+ - Use JavaScript blocks to scrape structured data:
226
+ ```js
227
+ return document.querySelectorAll('article').length;
228
+ ```
229
+ - Keep CSS selectors narrow; the block-based editor surfaces `#`, `.`, and attribute hints.
230
+ - When running headlessly, toggle `headful.js` or `agent.js` depending on whether you need a visible browser for debugging.
231
+ - Set `task.variables` via the API to re-use generic workflows across multiple domains.
232
+
233
+ ## Workflow Recipe
234
+
235
+ 1. Design a task in the editor starting with a `goto` block and a `wait` block to give pages time to render.
236
+ 2. Add conditional `javascript` blocks to test for specific DOM elements; use the retry/timer controls per block.
237
+ 3. Attach `extract` (JSON output) or `screenshot` actions before submitting so you can inspect results in the Captures tab.
238
+ 4. Toggle “Rotate Proxies” if you need egress diversity and pick a default proxy on Settings → Proxies.
239
+ 5. Use the **Schedule** tab to set up automated runs (e.g., every day at 9 AM or every 15 minutes).
240
+ 6. 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.
241
+
242
+ # Task Scheduling
243
+
244
+ Figranium includes a built-in scheduler that handles automated task execution without requiring external cron jobs or triggers.
245
+
246
+ - **Visual Mode**: Easily configure periodic runs (every X minutes), hourly, daily, weekly (select specific days), or monthly runs.
247
+ - **Advanced Mode**: Use standard 5-field cron expressions (`* * * * *`) for complex schedules.
248
+ - **Persistence**: Schedules are stored within the task metadata and persist across server restarts.
249
+ - **Monitoring**: The "Next Run" and "Last Run" status (including duration) are visible directly in the Task Editor's Schedule tab.
250
+
251
+ # Testing & Validation
252
+
253
+ - Run `npm run build` before packaging for production; the `dist/` folder contains the compiled assets.
254
+ - Backend logging writes to the console; capture output from `server.js` for debugging proxies, authentication, or Playwright failures.
255
+ - Playwright logs are visible in the running Node process and under `node_modules/.cache` when using the CLI.
256
+
257
+ # Troubleshooting
258
+
259
+ - **“Session expired”** in the UI: confirm `SESSION_SECRET` is consistent and cookies aren’t blocked by your browser.
260
+ - **Proxy import fails**: inspect `data/proxies.json` for valid URLs; the backend validates `server` as a string.
261
+ - **API key lost**: copy from Settings → System tab.
262
+
263
+ # Data Lifecycle
264
+
265
+ - Captures land in `public/captures`; regular cleanups can be scripted via `POST /api/clear-screenshots`.
266
+ - Cookies live in `storage_state.json`. Back up this file before clearing cookies via the UI or `/api/clear-cookies`.
267
+ - 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.
268
+ - 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`.
269
+
270
+ # Maintenance
271
+
272
+ - The project is governed by the **[GNU General Public License v3.0](https://github.com/figranium/figranium/blob/main/LICENSE)**, which grants rights for distribution and modification as per the GPLv3 terms.
273
+ - Keep `data/` and `storage_state.json` backed up if you rely on historical cookies or proxies.
274
+ - Release updates by pulling `figranium/figranium` (Docker) or `npm i figranium` (npm). The Settings view always displays the current package version.
275
+ - Contributions: follow `.github/` templates, respect `CONTRIBUTING.md`, and run available lint/test scripts if you touch critical areas.
276
+
277
+ # Roadmap
278
+
279
+ - [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.
280
+ - [x] **Storage cleanup** — the Settings data tab lets you clear captures and cookies, and the backend exposes `/api/clear-screenshots` and `/api/clear-cookies`.
281
+ - [x] **IP rotation tooling** — build a settings workflow for importing proxies and automatically rotating them.
282
+ - [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.
283
+ - [x] **Task proxy rotation toggle** — the “Rotate Proxies” option in each task ties into the Settings rotation controls, enabling rotation per execution.
284
+ - [x] **Spatial editor transition** — transition to a spatial editor like that of activepieces (top priority).
285
+ - [ ] **Action key combos** — add modifier shortcuts (e.g., Ctrl+Click, Shift+Scroll) so tasks can more closely mirror real user interactions.
286
+ - [ ] **Click-and-drag block** — add an action that does drag gestures (selecting text, moving items) so tasks can simulate click-and-drag flows.
287
+ - [x] **Recording controls** — Task editor now exposes a “Disable automated recording” switch in the general settings panel so workflows can skip video capture on a per-task basis.
288
+ - [x] **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.
289
+ - [x] **Stateless mode** — Tasks now have a “Stateless execution” toggle alongside the recording controls so each run can skip `storage_state.json`, ensuring no cookies or local storage persist between executions for that workflow.
290
+ - [ ] **Adblocking filters** — add controls so execution contexts can enable built-in ad/malware filtering (e.g., via hosts file overrides or request blocking) to reduce noise on sensitive sites.
291
+ - [ ] **Extraction response mode** — add a Settings switch so users can choose whether the API returns HTML+data (for debugging) or data-only payloads when extraction scripts run.
292
+ - [ ] **Folder organization** group tasks, assets, and captures into named folders so operators can browse, filter, and download collections per workflow.
293
+ - [ ] **Stable capture retention** add filtering, pinning, and archiving in captures tab so teams can keep compliance records.
294
+ - [ ] **Workspace templates** allow saving and sharing workspace presets (layout + default proxies/agents) so new team members can onboard with pre-configured setups.
295
+ - [ ] **Geo-targeted exits** allow choosing proxy regions for tasks so you can pin the apparent location before running a job.
296
+ - [ ] **Complete anti-detection coverage** — follow browserscan.net's anti-detection checklist (fingerprints, headers, fonts, WebRTC, etc.) so automated runs mimic real browsers across task executions.
297
+ - [ ] **Session recording redaction** — add toggles to redact sensitive fields (passwords, credit cards) from recordings/logs before storing them.
298
+ - [ ] **Two-factor authentication** — add optional TOTP/second-factor support to Settings/Auth so operators can lock down the UI with 2FA.
299
+ - [ ] **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.
300
+ - [ ] **Companion app** build a lightweight companion app that mirrors critical dashboard notifications (failures, capture completions, proxy issues) so operators can stay informed without opening the full UI.
301
+ - [x] **Community presets hub** build a marketplace where users can publish task/workspace presets, browse and download others’ submissions, and choose to offer each preset either for free or as a paid template so creators can monetize standalone workflows while keeping the free option available.
302
+ - [ ] **Database Tab / Local CRM** — add a built-in spreadsheet-like interface for viewing and managing extracted data (CRM-style) entirely within the app, without requiring external tools.
303
+ - [ ] **iframe interaction support** — add the ability to target and interact with elements inside iframes in the task editor.
304
+ - [x] **Autosave** — automatically persist task changes and editor state at regular intervals so operators don't lose work on long-running or complex workflow designs.
305
+ - [x] **Highlight tool** — add a feature to highlight elements on the page (similar to a browser's inspect tool) to easily pick selectors and build workflows.
306
+ - [x] **Cron triggers** add support for scheduling tasks with cron expressions so workflows can run automatically on defined intervals.
307
+
308
+ # Security Considerations
309
+
310
+ - Never commit your `SESSION_SECRET`, API keys, or `storage_state.json` into shared repositories.
311
+ - Use `ALLOWED_IPS`/`data/allowed_ips.json` to gate the UI when deploying to a network-exposed host.
312
+ - Rotate API keys periodically via Settings, and log all automation runs through the Executions tab for audit purposes.
313
+ - Playwright runs inside the same Node process; keep dependencies up to date and rebuild `node_modules` after significant OS patches.
314
+
315
+ # Community
316
+
317
+ - Report issues or request features via the GitHub repo issue tracker.
318
+ - Follow the authors on `https://github.com/figranium` for releases.
319
+ - Share automation recipes with other self-hosted users in your org, but respect the license for sharing infrastructure.
320
+ - Join the community on [Discord](https://discord.gg/kPmfbgu9Xn).
321
+
322
+ # Support the Project
323
+
324
+ If you find this project helpful, please consider supporting its development. Your contributions help keep the project maintained and the lights on!
325
+
326
+ <div align="center">
327
+ <a href="https://ko-fi.com/asernasr" target="_blank">
328
+ <img src="https://img.shields.io/badge/Support%20on-Ko--fi-FF5E5B?style=for-the-badge&logo=ko-fi&logoColor=white" alt="Support on Ko-fi" />
329
+ </a>
330
+ </div>
331
+
332
+ ---
333
+ **Other ways to help:**
334
+ * **Star** the repository to help others find it.
335
+ * **Share** the project with your network.
336
+ * **Contribute** to the code or documentation.