@cogniqa-app/recorder

中文文档
0.3.5发布于 2026/11/04UNLICENSEDES Module近 30 天下载 2559

Local recorder for CogniQA — launches a real browser on your own machine so 'Record' can capture your clicks as test steps, without a browser ever running on CogniQA's servers.

原始使用文档
文档目录21 节
  1. Table of Contents
  2. What is this?
  3. Features
  4. Prerequisites
  5. Installation
  6. Usage
  7. Start the recorder
  8. Disable autostart
  9. Configuration
  10. Changing the local port
  11. Self-hosted / development setups
  12. How It Works
  13. Security
  14. System Requirements
  15. Troubleshooting
  16. "Could not register to start automatically at login"
  17. "Port 51820 is already in use"
  18. Browser does not open
  19. "Ticket is invalid, expired, or already used"
  20. Origin mismatch errors
  21. License

@cogniqa-app/recorder

npm version License

Local browser recorder for CogniQA — launches a real browser on your own machine so you can record test steps by simply clicking through your application. No browser ever runs on CogniQA's servers during recording.

Table of Contents

What is this?

@cogniqa-app/recorder is a companion CLI for CogniQA users. When you click "Record" inside the CogniQA web app, this locally-running service:

  1. Receives a secure, one-time ticket from CogniQA
  2. Launches a real Chromium browser window on your machine
  3. Replays any existing precondition steps so you start from the right page
  4. Captures every click, fill, and navigation as a structured test step
  5. Streams those steps back to CogniQA in real time

Because the browser runs locally, you can interact with internal sites, VPN-protected apps, or anything behind your corporate firewall — none of your application traffic leaves your machine.

Features

  • Local-first recording — Browser runs on your machine, not in the cloud
  • Warm-start replay — Automatically replays existing login/precondition steps before recording starts
  • Playwright-powered — Built on the same recording engine as npx playwright codegen
  • Electron overlay — Clean floating toolbar for Run / Done / Delete controls
  • Auto-launch — Optionally registers itself to start automatically when you log in
  • Single-session safety — Only one recording session at a time; accidental double-starts are rejected
  • Origin-locked — Only accepts commands from the CogniQA web origin

Prerequisites

  • Node.js >= 18.0.0 (LTS recommended)
  • npm or npx (comes with Node.js)

The recording window runs on Electron, which is downloaded automatically during install — no separate browser install is needed.

Installation

You do not need to clone this repository. Install directly from npm:

npm install -g @cogniqa-app/recorder

Or run on-demand without installing:

npx @cogniqa-app/recorder listen

After global installation, the binary is available as:

cogniqa-recorder listen

Usage

Start the recorder

Leave this running in a terminal while you use CogniQA:

cogniqa-recorder listen

You will see:

[recorder] Listening on http://127.0.0.1:51820 — leave this running, then click
[recorder] "Record" in CogniQA. Press Ctrl+C to stop.

On the very first successful run, the recorder will also register itself to start automatically at login (you can disable this later).

Disable autostart

If you no longer want the recorder to start automatically when you log in:

cogniqa-recorder disable

Configuration

No configuration is required for normal use with the hosted CogniQA instance.

Changing the local port

If the default port is already taken, you can override it:

# macOS / Linux
COGNIQA_RECORDER_PORT=51900 cogniqa-recorder listen

# Windows (PowerShell)
$env:COGNIQA_RECORDER_PORT=51900; cogniqa-recorder listen

The recorder only ever binds to 127.0.0.1 (localhost). It is never reachable from another machine on your network, regardless of which port it uses.

Self-hosted / development setups

By default the recorder talks to the hosted CogniQA for its release channel: latest builds accept only https://cogniqa.fissionlabs.com, and @beta / @stage builds accept only https://dev-cogniqa.fissionlabs.com.

If you are running your own CogniQA backend and web app locally, set these before starting the recorder:

# macOS / Linux
COGNIQA_API_URL=http://localhost:3001 COGNIQA_WEB_ORIGIN=http://localhost:3000 cogniqa-recorder listen

# Windows (PowerShell)
$env:COGNIQA_API_URL="http://localhost:3001"; $env:COGNIQA_WEB_ORIGIN="http://localhost:3000"; cogniqa-recorder listen

How It Works

┌─────────────────┐         ┌──────────────────────────┐         ┌─────────────────┐
│  CogniQA Web    │ ──────► │  @cogniqa-app/recorder   │ ──────► │  Chromium       │
│  (your browser) │  ticket │  (localhost :51820)      │  CDP    │  (your machine) │
└─────────────────┘         └──────────────────────────┘         └─────────────────┘
                                   │                                    │
                                   │  Playwright recorder API           │
                                   │  (clicks, fills, navigations)      │
                                   │                                    │
                                   ▼                                    ▼
                         ┌──────────────────────────┐         ┌─────────────────┐
                         │  Electron overlay window │         │  CogniQA API    │
                         │  (Run / Done / Delete)   │         │  (step stream)  │
                         └──────────────────────────┘         └─────────────────┘
  1. Ticket handshake — When you click "Record" in CogniQA, the web app generates a single-use ticket and POSTs it to the local recorder's /start endpoint.
  2. Validation — The recorder immediately redeems the ticket with the CogniQA API. Invalid, expired, or already-used tickets are rejected.
  3. Browser launch — A headed Chromium window opens via Playwright. Any existing precondition steps are replayed first so you land on the correct page.
  4. Recording — Playwright's internal recorder engine captures every actionable event.
  5. Real-time sync — Each captured step is sent back to the CogniQA web tab via polling on /status.
  6. Finish — Click Done in the floating Electron toolbar (or close the browser window) to end the session.

Security

  • Origin validation — Every incoming request is checked against the allowed-origin list. Cross-origin requests are rejected before they reach any handler.
  • One-time tickets — Recording sessions can only be initiated with a cryptographically random, single-use ticket minted by the CogniQA backend.
  • Local-only binding — The HTTP server binds exclusively to 127.0.0.1; it never accepts connections from other devices on your network.
  • No persistent credentials — The recorder does not store API keys, passwords, or session tokens. The only network call it ever makes is ticket redemption.
  • Private Network Access — CORS headers include Access-Control-Allow-Private-Network so modern Chrome versions allow the hosted CogniQA app to reach your localhost recorder.

System Requirements

OSStatusNotes
Windows 10/11✅ SupportedPowerShell or Command Prompt
macOS 12+✅ SupportedIntel and Apple Silicon
Linux (Ubuntu 20.04+, Fedora, Debian)✅ SupportedX11 or Wayland with a display server

A local graphical display is required because the recorder launches a headed browser window. It will not work in a headless SSH session without X11 forwarding.

Troubleshooting

"Could not register to start automatically at login"

Corporate-managed machines may block login-item registration. This is a non-fatal warning — just run cogniqa-recorder listen again after reboot.

"Port 51820 is already in use"

The recorder automatically tries ports 51820 through 51825. If all are taken, set a different base port:

COGNIQA_RECORDER_PORT=51900 cogniqa-recorder listen

Browser does not open

If the Electron window can't start (e.g. the Electron binary wasn't downloaded because install ran with --ignore-scripts or behind a proxy), the recorder falls back to a standalone Chromium window. That fallback needs Playwright's Chromium:

npx playwright install chromium

"Ticket is invalid, expired, or already used"

Tickets are single-use and time-bounded. Refresh the CogniQA page and click Record again to get a fresh ticket.

Origin mismatch errors

If you are self-hosting CogniQA, see the Self-hosted / development setups section above to point the recorder at your local web origin.

License

UNLICENSED — see package.json for details.


Repository: github.com/flabdev/CogniQA
Issues: github.com/flabdev/CogniQA/issues
Homepage: github.com/flabdev/CogniQA/tree/main/apps/recorder-cli#readme

版本与发布记录

@cogniqa-app/recorder 共发布 23 个版本,首次发布于 2026/08/18;过去 12 个月发布了 23 个版本。

版本发布日期距今
0.3.5latest2026/11/045 天前
0.3.4-beta.8beta2026/11/046 天前
0.3.4-beta.72026/11/046 天前
0.3.4-beta.62026/10/2912 天前
0.3.4-beta.22026/10/2912 天前
0.3.4-beta.02026/10/2813 天前

关于 @cogniqa-app/recorder 的常见问题

@cogniqa-app/recorder 是什么?

Local recorder for CogniQA — launches a real browser on your own machine so 'Record' can capture your clicks as test steps, without a browser ever running on CogniQA's servers.

如何安装 @cogniqa-app/recorder?

在项目目录运行 npm install @cogniqa-app/recorder,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 cogniqa-recorder,可以用 npx cogniqa-recorder 直接运行。

@cogniqa-app/recorder 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cogniqa-app__recorder 是否存在。

@cogniqa-app/recorder 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cogniqa-app/recorder 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cogniqa-app/recorder 可以商用吗?

@cogniqa-app/recorder 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@cogniqa-app/recorder 的下载量有多少?

根据 npm 官方下载统计,@cogniqa-app/recorder 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,559 次,日均约 85 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cogniqa-app/recorder 还在维护吗?

最新版本 0.3.5 发布于 2026/11/04(5 天前);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/08/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。