recordful-mcp 0.0.0-stage → 0.4.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 (62) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/LICENSE +21 -0
  3. package/README.md +170 -2
  4. package/SECURITY.md +36 -0
  5. package/dist/args.d.ts +6 -0
  6. package/dist/args.js +44 -0
  7. package/dist/args.js.map +1 -0
  8. package/dist/auth/handshake.d.ts +4 -0
  9. package/dist/auth/handshake.js +16 -0
  10. package/dist/auth/handshake.js.map +1 -0
  11. package/dist/auth/pairings.d.ts +30 -0
  12. package/dist/auth/pairings.js +163 -0
  13. package/dist/auth/pairings.js.map +1 -0
  14. package/dist/bridge/BridgeAgent.d.ts +44 -0
  15. package/dist/bridge/BridgeAgent.js +182 -0
  16. package/dist/bridge/BridgeAgent.js.map +1 -0
  17. package/dist/bridge/BridgeServer.d.ts +100 -0
  18. package/dist/bridge/BridgeServer.js +586 -0
  19. package/dist/bridge/BridgeServer.js.map +1 -0
  20. package/dist/bridge/PeerClient.d.ts +30 -0
  21. package/dist/bridge/PeerClient.js +169 -0
  22. package/dist/bridge/PeerClient.js.map +1 -0
  23. package/dist/cli.d.ts +2 -0
  24. package/dist/cli.js +419 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/clientNames.d.ts +4 -0
  27. package/dist/clientNames.js +39 -0
  28. package/dist/clientNames.js.map +1 -0
  29. package/dist/config.d.ts +17 -0
  30. package/dist/config.js +53 -0
  31. package/dist/config.js.map +1 -0
  32. package/dist/logger.d.ts +11 -0
  33. package/dist/logger.js +39 -0
  34. package/dist/logger.js.map +1 -0
  35. package/dist/mcp/createMcpServer.d.ts +12 -0
  36. package/dist/mcp/createMcpServer.js +260 -0
  37. package/dist/mcp/createMcpServer.js.map +1 -0
  38. package/dist/mcp/videoTools.d.ts +6 -0
  39. package/dist/mcp/videoTools.js +74 -0
  40. package/dist/mcp/videoTools.js.map +1 -0
  41. package/dist/protocol/errors.d.ts +45 -0
  42. package/dist/protocol/errors.js +56 -0
  43. package/dist/protocol/errors.js.map +1 -0
  44. package/dist/protocol/messages.d.ts +208 -0
  45. package/dist/protocol/messages.js +153 -0
  46. package/dist/protocol/messages.js.map +1 -0
  47. package/dist/protocol/methods.d.ts +25 -0
  48. package/dist/protocol/methods.js +30 -0
  49. package/dist/protocol/methods.js.map +1 -0
  50. package/dist/protocol/page.d.ts +51 -0
  51. package/dist/protocol/page.js +173 -0
  52. package/dist/protocol/page.js.map +1 -0
  53. package/dist/protocol/video.d.ts +28 -0
  54. package/dist/protocol/video.js +42 -0
  55. package/dist/protocol/video.js.map +1 -0
  56. package/dist/setupGuide.d.ts +1 -0
  57. package/dist/setupGuide.js +48 -0
  58. package/dist/setupGuide.js.map +1 -0
  59. package/dist/workflows.d.ts +34 -0
  60. package/dist/workflows.js +99 -0
  61. package/dist/workflows.js.map +1 -0
  62. package/package.json +62 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,53 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0 (2026-10-22)
4
+
5
+ Record, upload and read back: coding assistants can now share a demo and check what was said, on their own, from MCP or a shell.
6
+
7
+ - **Uploads** (`upload_recording`, Recordful Pro): uploads a local recording to recordful.app with the same steps as the web editor, signed in as the user through the extension (no credential ever reaches the agent), and waits until it's up. Never uploads the same recording twice unless `force`. Cloud recordings are recognised and returned as already uploading.
8
+ - **Transcripts** (`get_transcript`, Recordful Pro): starts transcription on first use and waits for it, including for an upload still in progress; returns `text`, `vtt` or both.
9
+ - **Videos**: `get_video` (links and upload stage, optionally waiting until ready), `list_videos`, `list_recordings` (local recordings). `stop_recording` now says where the recording went: a cloud video with its links, or a local recording to upload.
10
+ - **Clear about plans**: `get_status` reports `plan` (`pro`, `free`, `signed-out`, `unavailable`). On other plans, uploads and transcripts fail at once with `PRO_REQUIRED` or `NOT_SIGNED_IN`, saying what still works (recording, page tools, the editor) and linking the upgrade page; the agent instructions, prompt and skill tell agents to check first and not retry.
11
+ - **A real CLI**: `start`, `pause`, `resume`, `stop`, `recordings`, `upload`, `videos`, `video`, `transcript`, `status`, each with readable output or `--json`. The first command starts a small background helper that holds Recordful's connection, so the user clicks the Recordful icon once.
12
+ - **Any number of AI apps at once**: a second recordful-mcp (another AI app, or the CLI) shares the first one's connection over an authenticated local peer channel, and takes the port over when the owner exits. `BRIDGE_UNAVAILABLE` now only means something else holds the port.
13
+ - MCP progress notifications while uploads and transcripts wait.
14
+ - Fixed: two recordful-mcp processes creating the pairing file at the same moment could disagree on the server's identity.
15
+ - Tests: 112, including the real CLI end to end and peer takeover. Verified live against recordful.app's stack: a spoken recording uploaded, transcribed and read back through both the CLI and MCP; free and signed-out accounts get clear answers.
16
+ - Needs Recordful 4.6.19 or newer (with the upload and transcript methods) and recordful.app with `GET /videos/:id/transcript?text=1`.
17
+
18
+ ## 0.3.0 (2026-10-17)
19
+
20
+ Ready for everyone: install with one line in any AI app, pair with one click, no tokens or builds.
21
+
22
+ - **Pairing replaces tokens.** The first time an AI app connects, Recordful opens a window naming the app with a 4-digit code; the agent gets `PAIRING_PENDING` with the same code to show in chat. On Allow, both sides keep a fresh per-pairing secret. Pairing happens once per computer, shared by every AI app (protocol v2, new path `/recordful-agent-bridge/v2`).
23
+ - **Ships in Recordful itself**, off until the user turns on AI agents (Recordful popup → More → AI agents). That page has the switch, connection status, the setup command and paired apps with Forget. The toolbar icon shows an "AI" badge while an app is connected.
24
+ - **Only the official extension by default.** The Chrome Web Store build is allowed out of the box; `RECORDFUL_BRIDGE_ALLOWED_EXTENSION_IDS` adds development builds (`*` allows any).
25
+ - **`record_feature` prompt**: the whole plan-and-record workflow, available in every MCP client that supports prompts.
26
+ - **Fail-fast starts**: in tab capture modes, `start_recording` on a tab the user hasn't handed over returns `NOT_ARMED` at once instead of stalling, and targets the handed-over tab by default. A healthy start is no longer misreported as `START_FAILED` when it takes ~5 s.
27
+ - **One-step installs**: Claude Code plugin (MCP server, `record-demo` skill, `/record-demo` command) via `/plugin marketplace add iKislay/recordful-mcp`; Claude Desktop extension (`recordful.mcpb`, `npm run pack:mcpb`); MCP Registry entry (`server.json`).
28
+ - CLI: `setup` prints the configuration for each AI app, `status` shows the pairing state, `unpair` forgets pairings. `token` is gone.
29
+ - Agent instructions and errors cover first-run setup (`NOT_CONNECTED`, `PAIRING_PENDING`, `PAIRING_DENIED`, `NOT_ARMED`).
30
+ - Live test `scripts/live-pairing.mjs`: switch on, pairing window, code match, Allow, reconnect without prompting, fail-fast start, Deny, switch off. All 15 checks pass in Edge 155.
31
+ - Needs Recordful with the AI agents page (iKislay/recordful after 4.6.15).
32
+
33
+ ## 0.2.0 (2026-10-17)
34
+
35
+ Phase 1: page tools, so an agent with no browser tool of its own can record a feature end to end.
36
+
37
+ - MCP tools `navigate`, `snapshot`, `click`, `type`, `press`, `scroll`, `wait_for` and `screenshot` (image content), over new protocol methods `page.*`. Inputs are validated with zod before they reach the extension, and the `call` CLI validates page methods the same way. Protocol version unchanged (methods were added, nothing changed shape).
38
+ - They act only on the tab the user handed over by clicking the Recordful icon, or the tab being recorded. The extension draws its own cursor, glides it to each target, highlights clicks and types at a human pace.
39
+ - New error codes: `NOT_ARMED`, `TAB_NOT_ACTIVE`, `PAGE_NOT_SCRIPTABLE`, `STALE_REF`, `ELEMENT_NOT_INTERACTABLE`, `ELEMENT_OBSCURED`, `NAVIGATION_FAILED`, `WAIT_TIMEOUT`. An extension build without page tools gets a hint to rebuild.
40
+ - Agent instructions now cover the whole flow: plan, ask for the click on the Recordful icon, navigate, start, act with page tools, pause while thinking, stop.
41
+ - `scripts/live-spike.mjs --pages` exercises every page tool live; `--port` runs alongside an MCP client's bridge.
42
+ - Verified live in Edge 155: every page tool, tab targeting, stale refs and navigations, including during a live tab recording. See `docs/phase-1-findings.md`.
43
+ - Needs a Recordful development build (`npm run build:agent`) that includes the page tools: iKislay/recordful after 4.6.15.
44
+
45
+ ## 0.1.0 (2026-10-17)
46
+
47
+ First release: Phase 0 of letting AI agents drive the Recordful recorder.
48
+
49
+ - MCP server on stdio (`recordful-mcp`), built on the official SDK, with tools `get_status`, `start_recording`, `pause_recording`, `resume_recording`, `stop_recording` and `probe_capture`, plus agent instructions for the record-a-feature workflow.
50
+ - Loopback WebSocket bridge to the Recordful extension: mutual HMAC-SHA256 challenge-response over a per-user pairing token, Origin and extension-ID allowlist, a single superseding session, heartbeat, request timeouts and port supervision.
51
+ - CLI: `serve` (the default), `token [--rotate]`, `call <method> [json]`.
52
+ - Verified in Chrome: after one click on the Recordful icon, the agent started, paused, resumed and stopped recordings, and the web editor opened on stop. Chrome requires that click before tab capture; see `docs/phase-0-findings.md`.
53
+ - 34 unit and integration tests, CI on Linux, macOS and Windows (Node 20 and 22), and a live end-to-end script (`scripts/live-spike.mjs`).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kislay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,171 @@
1
- # Temporary Holding Version
1
+ # Recordful MCP
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Let any AI app record, upload and read back product demos with [Recordful](https://recordful.app).**
4
+
5
+ Ask your AI to *"record how the new sign-up flow works"*. It plans a short walkthrough, asks you to click the Recordful icon on the tab, then navigates, clicks and types with a smooth on-screen cursor while Recordful records. When it stops, Recordful's editor opens with the video. With Recordful Pro, it can also upload the video, hand you the link, and read the transcript back.
6
+
7
+ It ships as an **MCP server** for AI apps and a **CLI** for anything with a shell.
8
+
9
+ Works with Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, opencode, Codex, Gemini CLI and any other app that supports the [Model Context Protocol](https://modelcontextprotocol.io). The AI doesn't need a browser of its own. Everything runs on your computer: nothing to host, no account, no API key.
10
+
11
+ ## Install
12
+
13
+ You need Chrome and [Node.js](https://nodejs.org) 20.10 or newer. The Claude Desktop bundle includes everything, so it doesn't need Node.
14
+
15
+ **1. Install [Recordful from the Chrome Web Store](https://chromewebstore.google.com/detail/hkcgjbkibidgbefehehenlmhjanjaopc).**
16
+
17
+ **2. Add the server to your AI app:**
18
+
19
+ <details open>
20
+ <summary><b>Claude Code</b></summary>
21
+
22
+ The plugin adds the server, a `record-demo` skill and a `/record-demo` command:
23
+
24
+ ```text
25
+ /plugin marketplace add iKislay/recordful-mcp
26
+ /plugin install recordful@recordful
27
+ ```
28
+
29
+ Or add just the server: `claude mcp add --scope user recordful -- npx -y recordful-mcp` (on native Windows, use `cmd /c npx -y recordful-mcp`).
30
+ </details>
31
+
32
+ <details>
33
+ <summary><b>Claude Desktop</b></summary>
34
+
35
+ Download `recordful.mcpb` from the [latest release](https://github.com/iKislay/recordful-mcp/releases/latest) and double-click it. Or add this to `claude_desktop_config.json` (Settings → Developer → Edit Config) and restart Claude:
36
+
37
+ ```json
38
+ { "mcpServers": { "recordful": { "command": "npx", "args": ["-y", "recordful-mcp"] } } }
39
+ ```
40
+ </details>
41
+
42
+ <details>
43
+ <summary><b>Cursor, Windsurf, Gemini CLI and most others</b></summary>
44
+
45
+ Add to the app's MCP config: `~/.cursor/mcp.json`, `~/.codeium/windsurf/mcp_config.json`, `~/.gemini/settings.json`, and so on:
46
+
47
+ ```json
48
+ { "mcpServers": { "recordful": { "command": "npx", "args": ["-y", "recordful-mcp"] } } }
49
+ ```
50
+ </details>
51
+
52
+ <details>
53
+ <summary><b>VS Code</b></summary>
54
+
55
+ Run **MCP: Add Server**, or add to `.vscode/mcp.json`:
56
+
57
+ ```json
58
+ { "servers": { "recordful": { "type": "stdio", "command": "npx", "args": ["-y", "recordful-mcp"] } } }
59
+ ```
60
+ </details>
61
+
62
+ <details>
63
+ <summary><b>opencode</b></summary>
64
+
65
+ Add to `opencode.json`:
66
+
67
+ ```json
68
+ { "mcp": { "recordful": { "type": "local", "command": ["npx", "-y", "recordful-mcp"], "enabled": true } } }
69
+ ```
70
+ </details>
71
+
72
+ <details>
73
+ <summary><b>Codex CLI</b></summary>
74
+
75
+ Add to `~/.codex/config.toml`:
76
+
77
+ ```toml
78
+ [mcp_servers.recordful]
79
+ command = "npx"
80
+ args = ["-y", "recordful-mcp"]
81
+ ```
82
+ </details>
83
+
84
+ `npx -y recordful-mcp setup` prints all of these.
85
+
86
+ **3. First recording (one-time setup):**
87
+
88
+ 1. In Recordful's popup, click **More → AI agents** and turn it on.
89
+ 2. Ask your AI to record something. When it asks, click the **Recordful icon** on the tab.
90
+ 3. Recordful asks you to approve the app. If the 4-digit code matches the one your AI shows, click **Allow**.
91
+
92
+ After that, you only click the Recordful icon on the tab you want recorded.
93
+
94
+ ## Use it
95
+
96
+ Ask in plain words:
97
+
98
+ - "Record a demo of signing up and signing in on localhost:3000."
99
+ - "I just built the billing page. Record a short video of how it works."
100
+
101
+ - "Upload that and give me the link." / "What did I say in the last recording?" (Recordful Pro)
102
+
103
+ The AI works out the flow, uses test data (never your real accounts), records with pauses while it thinks, and stops so the editor opens. Apps that support MCP prompts also offer **record_feature**, a guided version of this workflow. While an app is connected, Recordful's icon shows an **AI** badge.
104
+
105
+ ### Free and Pro
106
+
107
+ | | Free | Pro |
108
+ | --- | --- | --- |
109
+ | Record, drive the page, open in Recordful's editor | ✓ | ✓ |
110
+ | Upload to recordful.app and get a link | | ✓ |
111
+ | Read back the transcript | | ✓ |
112
+
113
+ The AI checks your plan first. On the free plan it records as usual and tells you once that links and transcripts come with Pro, instead of failing. Recordings made while signed in to Pro go to the cloud as they record.
114
+
115
+ ### From the command line
116
+
117
+ The same things work from a terminal, for agents with a shell or for you:
118
+
119
+ ```bash
120
+ npx -y recordful-mcp start # click the Recordful icon on the tab first
121
+ npx -y recordful-mcp stop
122
+ npx -y recordful-mcp upload --title "Sign-up demo"
123
+ npx -y recordful-mcp transcript > transcript.txt
124
+ npx -y recordful-mcp videos
125
+ ```
126
+
127
+ The first command asks you to click the Recordful icon once; a small helper keeps the connection for later commands and exits after 30 idle minutes. Add `--json` for machine-readable output. All commands: `npx -y recordful-mcp --help`.
128
+
129
+ **Why the click?** Chrome only lets an extension record a tab after you click it there, and no app can click for you. The click also marks the only tab the AI may act in.
130
+
131
+ ## Do I need to host anything?
132
+
133
+ No. The server runs on your computer and talks to Recordful over `127.0.0.1`. Recordings stay on your computer unless you, or your AI with Recordful Pro, upload them to recordful.app.
134
+
135
+ Only cloud-only chat apps (claude.ai or ChatGPT in a browser or on a phone) would need a hosted connector, because they can't run programs on your computer. That's [planned](https://github.com/iKislay/recordful-mcp/blob/main/docs/remote-mcp.md).
136
+
137
+ ## Privacy and security
138
+
139
+ - **Off until you turn it on**, and off again with one switch.
140
+ - **Local only**: the server can't be reached from other devices or from web pages.
141
+ - **Paired once per computer** after you approve a matching code. Every connection proves the pairing, and the secret is never resent.
142
+ - **Only the official Recordful extension** can connect by default.
143
+ - **One tab**: the AI acts only in the tab you handed over.
144
+ - **Revocable**: Paired AI apps → Forget on the AI agents page, or `npx -y recordful-mcp unpair --all`.
145
+
146
+ Details: [SECURITY.md](https://github.com/iKislay/recordful-mcp/blob/main/SECURITY.md).
147
+
148
+ ## Troubleshooting
149
+
150
+ | Problem | Fix |
151
+ | --- | --- |
152
+ | "Recordful isn't connected" | Click the Recordful icon on the tab. Still nothing? Check **More → AI agents** is on |
153
+ | The AI shows a code | Check it matches in Recordful's window, click **Allow**, tell the AI to continue |
154
+ | Recording won't start | Click the Recordful icon on the exact tab to record, then retry |
155
+ | Recording waits forever | Recordful may be asking something (microphone access, or the screen picker in screen mode). Answer it |
156
+ | `PRO_REQUIRED` or `NOT_SIGNED_IN` | Uploads and transcripts need a Recordful Pro account, signed in in Recordful. Recording works on every plan |
157
+ | `BRIDGE_UNAVAILABLE` | Something other than recordful-mcp is using port 47823, or an older recordful-mcp is running. Update or close it |
158
+ | No Recordful tools in the AI app | Check `node -v` is 20.10+, then restart the app |
159
+
160
+ Run `npx -y recordful-mcp status` to see the pairing state.
161
+
162
+ ## More
163
+
164
+ - [Tools, CLI and configuration](https://github.com/iKislay/recordful-mcp/blob/main/docs/reference.md)
165
+ - [How it works: protocol and pairing](https://github.com/iKislay/recordful-mcp/blob/main/docs/protocol.md)
166
+ - [Development and releasing](https://github.com/iKislay/recordful-mcp/blob/main/docs/development.md)
167
+ - [Changelog](https://github.com/iKislay/recordful-mcp/blob/main/CHANGELOG.md)
168
+
169
+ ## License
170
+
171
+ [MIT](https://github.com/iKislay/recordful-mcp/blob/main/LICENSE)
package/SECURITY.md ADDED
@@ -0,0 +1,36 @@
1
+ # Security model
2
+
3
+ recordful-mcp lets a local program start screen and tab recordings and click and type in a browser tab. The design assumes that any process, web page or other extension on the machine may try to abuse it.
4
+
5
+ ## Threats and mitigations
6
+
7
+ | Threat | Mitigation |
8
+ | --- | --- |
9
+ | Someone who never asked for AI control gets it | The extension makes no connection at all until the user turns on AI agents (Recordful popup → More → AI agents). Turning it off disconnects at once |
10
+ | A remote machine connects | The server binds `127.0.0.1` only, and this isn't configurable |
11
+ | A web page (including via DNS rebinding) connects to the port | Browsers always send `Origin` on WebSocket upgrades, and the upgrade is refused unless it's an allowed `chrome-extension://` origin |
12
+ | Another extension connects | Only the Chrome Web Store build of Recordful is allowed by default; other IDs must be added explicitly (`RECORDFUL_BRIDGE_ALLOWED_EXTENSION_IDS`) |
13
+ | An app the user didn't mean to approve gets paired | Pairing needs a click on Allow in Recordful's own window, which names the app and shows a 4-digit code; the agent shows the same code in chat, and the user is told to allow only if they match. Pairing is only ever started by a user gesture, never by an automatic reconnect |
14
+ | A local process pretends to be the extension | HMAC challenge-response over a per-pairing secret; the secret is never sent after pairing |
15
+ | **A rogue local process grabs the port first and tries to control Recordful** | The extension verifies the server's proof and refuses all requests until it passes. An unpaired rogue server can only ask to pair, which shows a window with a code that won't match the agent's |
16
+ | Replaying a captured handshake | Fresh 32-byte nonces from both sides on every connection; proofs are bound to role and both nonces |
17
+ | The agent acts outside the intended tab | Page tools act only on the tab the user handed over by clicking the Recordful icon, or the tab being recorded |
18
+ | Silent control | The Recordful icon shows an "AI" badge, and the AI agents page names the connected app, while a session is live |
19
+ | Secret leakage through logs | Logs go to stderr only, and fields named `token`, `proof`, `secret` or `authorization` are redacted |
20
+ | The pairing file readable by other users | Written with mode `0600` in a `0700` directory on POSIX, atomically (write, then rename); on Windows it inherits the user-profile ACL |
21
+ | Memory exhaustion | 1 MiB frame limit, handshake and pairing deadlines, a single session, and heartbeat eviction |
22
+ | Test shortcuts reaching users | A baked-in shared secret and port override exist for scripted tests only, and are compiled out of every non-development build |
23
+
24
+ ## Out of scope
25
+
26
+ - Malware running as the same OS user. It can read the pairing file and could already capture the screen itself.
27
+ - A user who approves a pairing without checking the code.
28
+
29
+ ## Revoking access
30
+
31
+ - In Chrome: Recordful popup → More → AI agents → Paired AI apps → **Forget**, or turn AI agents off.
32
+ - On the computer: `npx -y recordful-mcp unpair --all` (or `unpair <extension-id>`). Recordful asks to pair again the next time it's needed.
33
+
34
+ ## Reporting
35
+
36
+ Report vulnerabilities privately through [GitHub security advisories](https://github.com/iKislay/recordful-mcp/security/advisories/new). Please don't open a public issue.
package/dist/args.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export interface Parsed {
2
+ positional: string[];
3
+ flags: Record<string, string | boolean>;
4
+ }
5
+ export declare const parseArgs: (argv: string[]) => Parsed;
6
+ export declare const intFlag: (flags: Parsed["flags"], name: string) => number | undefined;
package/dist/args.js ADDED
@@ -0,0 +1,44 @@
1
+ // The CLI's argument parser: positional words and --flags, where some flags
2
+ // take a value (--title "Demo" or --title=Demo) and the rest are switches.
3
+ import { BridgeError, ErrorCode } from "./protocol/errors.js";
4
+ const FLAGS_WITH_VALUES = new Set(["tab", "title", "visibility", "limit", "query", "format", "timeout"]);
5
+ export const parseArgs = (argv) => {
6
+ const positional = [];
7
+ const flags = {};
8
+ for (let i = 0; i < argv.length; i += 1) {
9
+ const arg = argv[i];
10
+ if (!arg.startsWith("--") || arg === "--") {
11
+ positional.push(arg);
12
+ continue;
13
+ }
14
+ const eq = arg.indexOf("=");
15
+ const name = eq === -1 ? arg.slice(2) : arg.slice(2, eq);
16
+ const inline = eq === -1 ? undefined : arg.slice(eq + 1);
17
+ if (FLAGS_WITH_VALUES.has(name)) {
18
+ const value = inline ?? argv[i + 1];
19
+ if (value === undefined || (inline === undefined && value.startsWith("--"))) {
20
+ throw new BridgeError(ErrorCode.InvalidParams, `--${name} needs a value`);
21
+ }
22
+ if (inline === undefined)
23
+ i += 1;
24
+ flags[name] = value;
25
+ }
26
+ else {
27
+ if (inline !== undefined)
28
+ throw new BridgeError(ErrorCode.InvalidParams, `--${name} doesn't take a value`);
29
+ flags[name] = true;
30
+ }
31
+ }
32
+ return { positional, flags };
33
+ };
34
+ export const intFlag = (flags, name) => {
35
+ const value = flags[name];
36
+ if (value === undefined)
37
+ return undefined;
38
+ const n = Number(value);
39
+ if (typeof value !== "string" || !Number.isInteger(n) || n <= 0) {
40
+ throw new BridgeError(ErrorCode.InvalidParams, `--${name} must be a positive whole number`);
41
+ }
42
+ return n;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+1,4 @@
1
+ export type ProofRole = "client" | "server" | "peer" | "peer-server";
2
+ export declare const newNonce: () => string;
3
+ export declare const computeProof: (token: string, role: ProofRole, serverNonce: string, clientNonce: string) => string;
4
+ export declare const verifyProof: (expected: string, actual: string) => boolean;
@@ -0,0 +1,16 @@
1
+ // Mutual challenge-response over a shared token. Neither side ever sends the
2
+ // token itself, so a rogue process that grabs the port first learns nothing,
3
+ // and the extension refuses to take orders from a server that can't prove it
4
+ // holds the token (otherwise anything on 127.0.0.1 could start a recording).
5
+ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
6
+ export const newNonce = () => randomBytes(32).toString("hex");
7
+ // The role prefix stops a proof from one direction being replayed as the other.
8
+ export const computeProof = (token, role, serverNonce, clientNonce) => createHmac("sha256", token)
9
+ .update(`recordful-agent-bridge:${role}:${serverNonce}:${clientNonce}`)
10
+ .digest("hex");
11
+ export const verifyProof = (expected, actual) => {
12
+ const a = Buffer.from(expected, "hex");
13
+ const b = Buffer.from(actual, "hex");
14
+ return a.length === b.length && a.length > 0 && timingSafeEqual(a, b);
15
+ };
16
+ //# sourceMappingURL=handshake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake.js","sourceRoot":"","sources":["../../src/auth/handshake.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAMvE,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAW,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAEtE,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAa,EACb,IAAe,EACf,WAAmB,EACnB,WAAmB,EACX,EAAE,CACV,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC;KACxB,MAAM,CAAC,0BAA0B,IAAI,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;KACtE,MAAM,CAAC,KAAK,CAAC,CAAC;AAEnB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,MAAc,EAAW,EAAE;IACvE,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxE,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ export declare const MIN_STATIC_SECRET_LENGTH = 32;
3
+ declare const PairingRecord: z.ZodObject<{
4
+ secret: z.ZodString;
5
+ pairedAt: z.ZodString;
6
+ app: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export type PairingRecord = z.infer<typeof PairingRecord>;
9
+ export declare const defaultStatePath: () => string;
10
+ export interface PairingSummary {
11
+ extensionId: string;
12
+ app: string;
13
+ pairedAt: string;
14
+ }
15
+ export declare class PairingStore {
16
+ readonly path: string;
17
+ readonly serverId: string;
18
+ private readonly staticSecrets;
19
+ private constructor();
20
+ static open(opts?: {
21
+ path?: string;
22
+ envSecret?: string | undefined;
23
+ }): Promise<PairingStore>;
24
+ peerSecret(): Promise<string>;
25
+ secretsFor(extensionId: string): Promise<string[]>;
26
+ save(extensionId: string, secret: string, app: string): Promise<void>;
27
+ remove(extensionId?: string): Promise<number>;
28
+ list(): Promise<PairingSummary[]>;
29
+ }
30
+ export {};
@@ -0,0 +1,163 @@
1
+ // Machine-wide bridge state: one server identity plus the extensions that
2
+ // paired with it. Every recordful-mcp process the user's AI apps start shares
3
+ // this file, so the user pairs once per machine, not once per app.
4
+ import { randomBytes, randomUUID } from "node:crypto";
5
+ import { chmod, mkdir, readFile, rename, writeFile } from "node:fs/promises";
6
+ import { homedir } from "node:os";
7
+ import { dirname, join } from "node:path";
8
+ import { z } from "zod";
9
+ import { PairingSecret } from "../protocol/messages.js";
10
+ export const MIN_STATIC_SECRET_LENGTH = 32;
11
+ const PairingRecord = z.object({
12
+ secret: PairingSecret,
13
+ pairedAt: z.string(),
14
+ app: z.string(),
15
+ });
16
+ const StateFileV2 = z.object({
17
+ version: z.literal(2),
18
+ serverId: z.string().uuid(),
19
+ createdAt: z.string(),
20
+ pairings: z.record(z.string(), PairingRecord),
21
+ // A v0.1 token, kept so development builds that baked it in still connect.
22
+ legacyToken: z.string().min(MIN_STATIC_SECRET_LENGTH).optional(),
23
+ // Shared by this user's recordful-mcp processes: a second one (another AI
24
+ // app, the CLI) proves it with this to use the first one's connection.
25
+ peerSecret: z.string().min(MIN_STATIC_SECRET_LENGTH).optional(),
26
+ });
27
+ const StateFileV1 = z.object({
28
+ version: z.literal(1),
29
+ token: z.string().min(MIN_STATIC_SECRET_LENGTH),
30
+ createdAt: z.string(),
31
+ });
32
+ export const defaultStatePath = () => join(homedir(), ".recordful", "agent-bridge.json");
33
+ export class PairingStore {
34
+ path;
35
+ serverId;
36
+ staticSecrets;
37
+ constructor(path, serverId, staticSecrets) {
38
+ this.path = path;
39
+ this.serverId = serverId;
40
+ this.staticSecrets = staticSecrets;
41
+ }
42
+ // envSecret (RECORDFUL_BRIDGE_TOKEN) is a shared secret any allowed
43
+ // extension may use instead of pairing: for CI and scripted test runs.
44
+ static async open(opts = {}) {
45
+ const path = opts.path ?? defaultStatePath();
46
+ if (opts.envSecret && opts.envSecret.length < MIN_STATIC_SECRET_LENGTH) {
47
+ throw new Error(`RECORDFUL_BRIDGE_TOKEN must be at least ${MIN_STATIC_SECRET_LENGTH} characters`);
48
+ }
49
+ let state = await loadOrCreate(path);
50
+ if (!state.peerSecret) {
51
+ await writeState(path, { ...state, peerSecret: randomBytes(32).toString("base64url") });
52
+ // Another process may have written at the same moment: the file wins.
53
+ state = (await readState(path)) ?? state;
54
+ }
55
+ const staticSecrets = [opts.envSecret, state.legacyToken].filter((s) => typeof s === "string" && s.length > 0);
56
+ return new PairingStore(path, state.serverId, staticSecrets);
57
+ }
58
+ // The secret recordful-mcp processes prove to each other. Re-read each
59
+ // time, so every process agrees even if two created it at once.
60
+ async peerSecret() {
61
+ const state = await readState(this.path);
62
+ if (!state?.peerSecret)
63
+ throw new Error(`${this.path} has no peer secret; delete it and restart`);
64
+ return state.peerSecret;
65
+ }
66
+ // Secrets this extension may sign with. Re-read on every call: another
67
+ // recordful-mcp process may have paired since this one started.
68
+ async secretsFor(extensionId) {
69
+ const state = await readState(this.path);
70
+ const paired = state?.pairings[extensionId]?.secret;
71
+ return paired ? [paired, ...this.staticSecrets] : [...this.staticSecrets];
72
+ }
73
+ async save(extensionId, secret, app) {
74
+ PairingSecret.parse(secret);
75
+ const state = (await readState(this.path)) ?? (await loadOrCreate(this.path));
76
+ state.pairings[extensionId] = { secret, app, pairedAt: new Date().toISOString() };
77
+ await writeState(this.path, state);
78
+ }
79
+ // Forgets one extension, or every pairing when extensionId is omitted.
80
+ async remove(extensionId) {
81
+ const state = await readState(this.path);
82
+ if (!state)
83
+ return 0;
84
+ const before = Object.keys(state.pairings).length;
85
+ if (extensionId)
86
+ delete state.pairings[extensionId];
87
+ else
88
+ state.pairings = {};
89
+ await writeState(this.path, state);
90
+ return before - Object.keys(state.pairings).length;
91
+ }
92
+ async list() {
93
+ const state = await readState(this.path);
94
+ return Object.entries(state?.pairings ?? {}).map(([extensionId, p]) => ({
95
+ extensionId,
96
+ app: p.app,
97
+ pairedAt: p.pairedAt,
98
+ }));
99
+ }
100
+ }
101
+ const readState = async (path) => {
102
+ let raw;
103
+ try {
104
+ raw = await readFile(path, "utf8");
105
+ }
106
+ catch (err) {
107
+ if (err.code === "ENOENT")
108
+ return null;
109
+ throw err;
110
+ }
111
+ let json;
112
+ try {
113
+ json = JSON.parse(raw);
114
+ }
115
+ catch (err) {
116
+ throw new Error(`${path} is not valid JSON; fix or delete it (${err.message})`);
117
+ }
118
+ const v2 = StateFileV2.safeParse(json);
119
+ if (v2.success)
120
+ return v2.data;
121
+ const v1 = StateFileV1.safeParse(json);
122
+ if (v1.success) {
123
+ return {
124
+ version: 2,
125
+ serverId: randomUUID(),
126
+ createdAt: v1.data.createdAt,
127
+ pairings: {},
128
+ legacyToken: v1.data.token,
129
+ };
130
+ }
131
+ throw new Error(`${path} has an unknown format; fix or delete it`);
132
+ };
133
+ const loadOrCreate = async (path) => {
134
+ const existing = await readState(path);
135
+ if (existing) {
136
+ // Persist a v1 migration so every process agrees on the new serverId.
137
+ const onDisk = JSON.parse(await readFile(path, "utf8"));
138
+ if (onDisk.version !== 2)
139
+ await writeState(path, existing);
140
+ return existing;
141
+ }
142
+ const fresh = {
143
+ version: 2,
144
+ serverId: randomUUID(),
145
+ createdAt: new Date().toISOString(),
146
+ pairings: {},
147
+ peerSecret: randomBytes(32).toString("base64url"),
148
+ };
149
+ await writeState(path, fresh);
150
+ // Two processes starting together each write one: adopt whichever landed.
151
+ return (await readState(path)) ?? fresh;
152
+ };
153
+ // Write-then-rename so a crash or a concurrent reader never sees half a file.
154
+ const writeState = async (path, state) => {
155
+ await mkdir(dirname(path), { recursive: true, mode: 0o700 });
156
+ const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
157
+ // mode is honoured on POSIX; on Windows the file inherits the profile ACL,
158
+ // which already limits it to the user.
159
+ await writeFile(tmp, `${JSON.stringify(state, null, 2)}\n`, { mode: 0o600 });
160
+ await rename(tmp, path);
161
+ await chmod(path, 0o600).catch(() => { });
162
+ };
163
+ //# sourceMappingURL=pairings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairings.js","sourceRoot":"","sources":["../../src/auth/pairings.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8EAA8E;AAC9E,mEAAmE;AACnE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM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config.js";
3
+ import type { Logger } from "../logger.js";
4
+ import { BridgeServer, type Bridge, type PairingInfo, type SessionInfo } from "./BridgeServer.js";
5
+ export interface BridgeAgentOptions {
6
+ config: BridgeConfig;
7
+ pairings: PairingStore;
8
+ logger: Logger;
9
+ mayOwn?: boolean;
10
+ app?: string;
11
+ }
12
+ export declare class BridgeAgent implements Bridge {
13
+ private readonly opts;
14
+ private readonly log;
15
+ private owner;
16
+ private peer;
17
+ private lastError;
18
+ private retryTimer;
19
+ private stopped;
20
+ private settling;
21
+ private app;
22
+ private readonly settledWaiters;
23
+ constructor(opts: BridgeAgentOptions);
24
+ get connection(): {
25
+ mode: "owner" | "peer" | "none";
26
+ error: string | null;
27
+ };
28
+ get lastErrorCode(): string | null;
29
+ get server(): BridgeServer | null;
30
+ start(): Promise<void>;
31
+ stop(): Promise<void>;
32
+ setAppName(name: string): void;
33
+ private ready;
34
+ waitForSession(timeoutMs: number): Promise<SessionInfo>;
35
+ request(method: string, params: Record<string, unknown>, timeoutMs: number): Promise<unknown>;
36
+ state(): Promise<{
37
+ session: SessionInfo | null;
38
+ pairing: PairingInfo | null;
39
+ }>;
40
+ private settle;
41
+ private fail;
42
+ private schedule;
43
+ private notifySettled;
44
+ }