@peekdev/mcp 0.1.0-alpha.2 → 0.1.0-alpha.20
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 +163 -0
- package/dist/db/open.d.ts +19 -1
- package/dist/db/open.d.ts.map +1 -1
- package/dist/db/open.js +25 -1
- package/dist/db/open.js.map +1 -1
- package/dist/entrypoint.d.ts +8 -0
- package/dist/entrypoint.d.ts.map +1 -0
- package/dist/entrypoint.js +33 -0
- package/dist/entrypoint.js.map +1 -0
- package/dist/mcp/action-schema.d.ts +156 -0
- package/dist/mcp/action-schema.d.ts.map +1 -1
- package/dist/mcp/action-schema.js +69 -0
- package/dist/mcp/action-schema.js.map +1 -1
- package/dist/mcp/event-blobs.d.ts +12 -2
- package/dist/mcp/event-blobs.d.ts.map +1 -1
- package/dist/mcp/event-blobs.js +55 -6
- package/dist/mcp/event-blobs.js.map +1 -1
- package/dist/mcp/event-walker.d.ts +30 -0
- package/dist/mcp/event-walker.d.ts.map +1 -1
- package/dist/mcp/event-walker.js +67 -1
- package/dist/mcp/event-walker.js.map +1 -1
- package/dist/mcp/host-bridge.d.ts +50 -1
- package/dist/mcp/host-bridge.d.ts.map +1 -1
- package/dist/mcp/host-bridge.js +133 -0
- package/dist/mcp/host-bridge.js.map +1 -1
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +11 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/playwright-repro.d.ts.map +1 -1
- package/dist/mcp/playwright-repro.js +58 -9
- package/dist/mcp/playwright-repro.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +292 -58
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/summary.d.ts +7 -0
- package/dist/mcp/summary.d.ts.map +1 -1
- package/dist/mcp/summary.js +7 -1
- package/dist/mcp/summary.js.map +1 -1
- package/dist/native-host/action-protocol.d.ts +15 -2
- package/dist/native-host/action-protocol.d.ts.map +1 -1
- package/dist/native-host/audit.d.ts +1 -1
- package/dist/native-host/audit.d.ts.map +1 -1
- package/dist/native-host/audit.js +1 -1
- package/dist/native-host/audit.js.map +1 -1
- package/dist/native-host/host-socket.d.ts +125 -0
- package/dist/native-host/host-socket.d.ts.map +1 -0
- package/dist/native-host/host-socket.js +338 -0
- package/dist/native-host/host-socket.js.map +1 -0
- package/dist/native-host/host.d.ts +11 -0
- package/dist/native-host/host.d.ts.map +1 -1
- package/dist/native-host/host.js +54 -0
- package/dist/native-host/host.js.map +1 -1
- package/dist/native-host/ingest.js +4 -4
- package/dist/native-host/ingest.js.map +1 -1
- package/dist/native-host/installer.d.ts +21 -0
- package/dist/native-host/installer.d.ts.map +1 -1
- package/dist/native-host/installer.js +64 -2
- package/dist/native-host/installer.js.map +1 -1
- package/dist/native-host/manifest.d.ts +7 -2
- package/dist/native-host/manifest.d.ts.map +1 -1
- package/dist/native-host/manifest.js +29 -15
- package/dist/native-host/manifest.js.map +1 -1
- package/dist/native-host/socket-path.d.ts +10 -0
- package/dist/native-host/socket-path.d.ts.map +1 -0
- package/dist/native-host/socket-path.js +31 -0
- package/dist/native-host/socket-path.js.map +1 -0
- package/dist/postinstall.d.ts.map +1 -1
- package/dist/postinstall.js +15 -15
- package/dist/postinstall.js.map +1 -1
- package/package.json +34 -4
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<img src="https://raw.githubusercontent.com/Cubenest/rrweb-stack/main/assets/brand/sub-peek.svg" height="40" alt="peek">
|
|
2
|
+
|
|
3
|
+
# @peekdev/mcp
|
|
4
|
+
|
|
5
|
+
> Your real browser, exposed to your AI coding agent over MCP — capture once, query forever, never leaves your machine.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@peekdev/mcp)
|
|
8
|
+
[](https://www.npmjs.com/package/@peekdev/mcp)
|
|
9
|
+
[](https://github.com/Cubenest/rrweb-stack/blob/main/LICENSE)
|
|
10
|
+
[](https://github.com/Cubenest/rrweb-stack/actions/workflows/ci.yml)
|
|
11
|
+
[](https://glama.ai/mcp/servers/Cubenest/rrweb-stack)
|
|
12
|
+
|
|
13
|
+
Docs: <https://peek.cubenest.in>
|
|
14
|
+
|
|
15
|
+
`@peekdev/mcp` is **two things in one binary**:
|
|
16
|
+
|
|
17
|
+
1. The **stdio MCP server** that AI coding agents (Claude Code, Cursor, Cline, Windsurf, Continue, Zed) speak to when querying your captured browser sessions.
|
|
18
|
+
2. The **native messaging host** that Chrome's MV3 extension speaks to when writing into `~/.peek/sessions.db`.
|
|
19
|
+
|
|
20
|
+
The same binary handles both roles — chosen by argv. You don't install this package directly in normal use; the [`@peekdev/cli`](https://www.npmjs.com/package/@peekdev/cli) `peek init` wizard wires it into your AI client's MCP config and into Chrome's `NativeMessagingHosts/`.
|
|
21
|
+
|
|
22
|
+
> **Requires Node.js ≥ 22.** The native `better-sqlite3` dependency only ships
|
|
23
|
+
> prebuilt binaries for Node 22+ — on Node 20 (notably Windows, which has no
|
|
24
|
+
> C/C++ toolchain by default) the install falls back to compiling from source
|
|
25
|
+
> and fails. Use Node 22 or newer.
|
|
26
|
+
|
|
27
|
+
## You probably want `@peekdev/cli` instead
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm install -g @peekdev/cli
|
|
31
|
+
peek init
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Read on if you're configuring the MCP server manually, building tooling against it, or want the protocol/tool reference.
|
|
35
|
+
|
|
36
|
+
## What this is NOT
|
|
37
|
+
|
|
38
|
+
- Not a remote MCP server. Peek is **local-only**: stdio transport over a child-process pipe. There is no HTTP listener, no SSE endpoint, no remote auth. The MCP transport spec's Streamable HTTP variant is out of scope by design.
|
|
39
|
+
- Not a write-by-default tool. Read tools are unauthenticated. The write tools (`execute_action`, `request_authorization`) are gated by the per-origin permission model (off by default) + the destructive blocklist + the audit-log writer. The cross-process IPC that delivers them to the browser native host (`LocalSocketHostBridge` ↔ `HostSocketServer` over `~/.peek/host.sock`) is now wired: at **Level 3** every action prompts the side-panel confirm banner before it runs. The real-browser MAIN-world dispatch + banner UX are covered by the Playwright E2E (`e2e/smoke.spec.ts`); the bridge, relay, dispatcher, and confirm logic are unit-tested.
|
|
40
|
+
- Not a wrapper around Chrome DevTools Protocol. The server reads recorded events from SQLite; the extension owns capture. No live `chrome.debugger` access from the MCP server.
|
|
41
|
+
|
|
42
|
+
## Manual MCP-client config
|
|
43
|
+
|
|
44
|
+
If `peek init` doesn't recognize your client, paste this into your client's MCP server registry:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"mcpServers": {
|
|
49
|
+
"peek": {
|
|
50
|
+
"command": "npx",
|
|
51
|
+
"args": ["-y", "@peekdev/mcp@latest"]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The `@latest` tag is required while peek is in alpha: every published version is a
|
|
58
|
+
prerelease (`0.1.0-alpha.*`), and a bare `npx -y @peekdev/mcp` resolves the
|
|
59
|
+
implicit `*` range, which doesn't match prereleases (`ETARGET: No matching
|
|
60
|
+
version found for @peekdev/mcp@*`). Pinning `@latest` forces the newest published
|
|
61
|
+
build.
|
|
62
|
+
|
|
63
|
+
`PEEK_HOME` defaults to `~/.peek`; set it via `env` only if you want a non-default capture directory.
|
|
64
|
+
|
|
65
|
+
The per-user config paths `peek init` writes to (canonical, see `packages/peek-cli/src/lib/init-config.ts`):
|
|
66
|
+
|
|
67
|
+
| Client | Path |
|
|
68
|
+
|---|---|
|
|
69
|
+
| Claude Code | `~/.claude.json` (or `claude mcp add`) |
|
|
70
|
+
| Cursor | `~/.cursor/mcp.json` |
|
|
71
|
+
| VS Code (MCP) | `~/.vscode/mcp.json` |
|
|
72
|
+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` |
|
|
73
|
+
| Cline | `~/cline_mcp_settings.json` |
|
|
74
|
+
|
|
75
|
+
## What the AI agent can do
|
|
76
|
+
|
|
77
|
+
| Tool | Action | Authorization |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `list_recent_sessions` | List recently recorded sessions, newest first (id, origin, ts, event count) | none |
|
|
80
|
+
| `get_session_summary` | LLM-readable narrative summary of a session | none |
|
|
81
|
+
| `get_session_console_errors` | List console errors recorded in a session | none |
|
|
82
|
+
| `get_session_network_errors` | List failed/notable network requests in a session | none |
|
|
83
|
+
| `get_user_action_before_error` | Last N user actions before a console error | none |
|
|
84
|
+
| `generate_playwright_repro` | Generate a runnable Playwright test from a session | none |
|
|
85
|
+
| `get_dom_snapshot` | Reconstruct the DOM at a given timestamp | none |
|
|
86
|
+
| `query_dom_history` | Timeline of attribute/text changes for a selector | none |
|
|
87
|
+
| `request_authorization` | Side-panel consent for write actions (Level 3) | per-action user prompt |
|
|
88
|
+
| `execute_action` | Dispatch a UI action (gated by permission level + destructive blocklist) | permission level + destructive blocklist |
|
|
89
|
+
|
|
90
|
+
The full tool list is exposed via the MCP `tools/list` request (spec 2025-11-25 + back-compat for 2025-03-26). Tool docs ship with the binary via `tools/list` response `description` fields.
|
|
91
|
+
|
|
92
|
+
## Permission model (the five levels)
|
|
93
|
+
|
|
94
|
+
Per-origin, 5 levels (0–4). Default is **Level 1 — Read-only**. Higher levels are opt-in per origin.
|
|
95
|
+
|
|
96
|
+
| Level | Name | What it allows | Default |
|
|
97
|
+
|---|---|---|---|
|
|
98
|
+
| 0 | Off | Recording suppressed, tool surface disabled for the origin | |
|
|
99
|
+
| 1 | Read-only | Read recorded sessions; no action execution | enabled |
|
|
100
|
+
| 2 | Suggest-only | Read + highlight DOM via overlay; no DOM mutation | |
|
|
101
|
+
| 3 | Act-with-confirm | Read + execute actions, each prompting Allow once / Always for this site / Deny | |
|
|
102
|
+
| 4 | YOLO this session | Read + execute non-destructive actions with no prompt (auto-expires on tab close or 60 min) | |
|
|
103
|
+
|
|
104
|
+
At **Level 3** every `execute_action` call prompts the user via the side-panel banner (unless a one-shot `confirmToken` from a prior `request_authorization` is passed). At **Level 4 (YOLO)** non-destructive actions are auto-allowed with no prompt. Levels 0–2 deny `execute_action`.
|
|
105
|
+
|
|
106
|
+
**Destructive-action blocklist (cross-level override)** — independent of the level, any action whose resolved target text/label matches a destructive term (`delete`, `remove`, `transfer`, `send`, `pay`, `withdraw`, etc. — full base list in `permissions/destructive.ts`, extensible via `~/.peek/policy.json`) **always** prompts for confirmation. This overrides all levels, including Level 4 YOLO — it is not a separate "Level 5".
|
|
107
|
+
|
|
108
|
+
Every `execute_action` and `request_authorization` call is appended to `~/.peek/audit.log` (JSONL, mode 0600 — `peek audit log --json` prints it), including denied ones.
|
|
109
|
+
|
|
110
|
+
**The write-path is wired end to end:** the five-level model, the destructive blocklist, and the audit-log writer are enforced inside `peek-mcp` (observable via `~/.peek/audit.log`), and the cross-process IPC that lets `execute_action` fire a click in the browser now lands — a `LocalSocketHostBridge` (MCP process) ↔ `HostSocketServer` (native host) over `~/.peek/host.sock`, a MAIN-world action dispatcher (click/type/navigate/scroll), and a side-panel confirm banner. Both write levels are implemented: **Level 3** (act-with-confirm — every action prompts the banner) and **Level 4** (YOLO — non-destructive actions auto-allow, destructive ones still prompt via the blocklist override). Both are opt-in per origin; the default stays Level 1 (read-only). Level 2 highlight and the remaining action types are queued. The real-browser dispatch + banner are covered by the Playwright E2E (`e2e/smoke.spec.ts`).
|
|
111
|
+
|
|
112
|
+
## Database
|
|
113
|
+
|
|
114
|
+
`~/.peek/sessions.db` — SQLite (better-sqlite3, WAL mode). Schema in `src/db/migrations/`. The CLI opens this DB read-mostly; the native host writes it during extension capture; the MCP server reads it for tool calls.
|
|
115
|
+
|
|
116
|
+
The native host is the **only writer**. The CLI and MCP server only read (except for the audit log, which is append-only JSONL on disk, not in the DB).
|
|
117
|
+
|
|
118
|
+
## Subpath exports
|
|
119
|
+
|
|
120
|
+
For consumers building tooling on top of peek:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { generatePlaywrightRepro } from '@peekdev/mcp/mcp/playwright-repro';
|
|
124
|
+
import { loadSessionEvents } from '@peekdev/mcp/mcp/event-blobs';
|
|
125
|
+
import { openDb, peekHomeDir } from '@peekdev/mcp/db';
|
|
126
|
+
import { buildManifest, installManifests } from '@peekdev/mcp/native-host';
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
These are the subpath exports the `@peekdev/cli` package uses. API surface is small but stable.
|
|
130
|
+
|
|
131
|
+
## Versioning & compatibility
|
|
132
|
+
|
|
133
|
+
Semantic Versioning. Currently `0.1.0-alpha.x` — pre-release; tool schemas are stable in spirit but new tools may land in patch releases. See [SUPPORTED.md](https://github.com/Cubenest/rrweb-stack/blob/main/SUPPORTED.md) for the compatibility matrix (MCP protocol versions, Chrome stable channels, Node versions).
|
|
134
|
+
|
|
135
|
+
## Privacy
|
|
136
|
+
|
|
137
|
+
Local-only. No network destinations. No telemetry. The MCP transport is stdio over a child-process pipe — your AI client launches `peek-mcp`, talks to it over stdin/stdout, and kills it when done. The binary holds no persistent state outside `~/.peek/`.
|
|
138
|
+
|
|
139
|
+
Full data-handling policy: [`docs/peek/PRIVACY_POLICY.md`](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/PRIVACY_POLICY.md). Threat model: [`docs/peek/THREATMODEL.md`](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/THREATMODEL.md).
|
|
140
|
+
|
|
141
|
+
## Distribution (maintainer-facing)
|
|
142
|
+
|
|
143
|
+
> This section is for the maintainer's submission workflow at Phase 5 launch.
|
|
144
|
+
> If you're a user, you don't need any of this — just `npx @peekdev/cli init`.
|
|
145
|
+
|
|
146
|
+
peek is listed (or queued for listing) on the discovery surfaces below.
|
|
147
|
+
Each linked file is a **submission scaffold** with pre-filled metadata
|
|
148
|
+
audited against the registry's current schema as of 2026-05-30 — not a
|
|
149
|
+
user-facing install guide.
|
|
150
|
+
|
|
151
|
+
- [Official MCP Registry submission](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/distribution/modelcontextprotocol-servers.md) — `server.json` for `registry.modelcontextprotocol.io` via `mcp-publisher` CLI. Downstream registries (PulseMCP, others) ingest from here.
|
|
152
|
+
- [PulseMCP submission](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/distribution/pulsemcp.json) — URL-only form + auto-ingest from the MCP Registry.
|
|
153
|
+
- [Smithery submission](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/distribution/smithery.json) — MCPB bundle uploaded via `smithery mcp publish`.
|
|
154
|
+
- [mcp.so submission](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/distribution/mcp-so.md) — web-form submission with the source content paste-ready.
|
|
155
|
+
- [Claude Code skill standalone install](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/distribution/claude-code-skill.md) — curl recipe for users who want the Claude Code skill without running `peek init`.
|
|
156
|
+
|
|
157
|
+
Launch order is documented in [`docs/peek/distribution/README.md`](https://github.com/Cubenest/rrweb-stack/blob/main/docs/peek/distribution/README.md) (CWS first, then the MCP-registry fan-out).
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
Apache 2.0. The bundled rrweb engine remains MIT-licensed; see `NOTICE`.
|
|
162
|
+
|
|
163
|
+
Contributions are accepted under the [Developer Certificate of Origin (DCO)](https://developercertificate.org/) — sign your commits with `git commit -s`. See [CONTRIBUTING.md](https://github.com/Cubenest/rrweb-stack/blob/main/CONTRIBUTING.md) + [SECURITY.md](https://github.com/Cubenest/rrweb-stack/blob/main/SECURITY.md).
|
package/dist/db/open.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import Database from 'better-sqlite3';
|
|
1
|
+
import type Database from 'better-sqlite3';
|
|
2
2
|
import { schemaVersion } from './migrate.js';
|
|
3
|
+
/** Constructor signature of better-sqlite3's default export (value-erased import above). */
|
|
4
|
+
type BetterSqlite3Ctor = new (filename?: string, options?: Database.Options) => Database.Database;
|
|
5
|
+
/**
|
|
6
|
+
* Lazily load better-sqlite3's native constructor, wrapping a native-module
|
|
7
|
+
* load failure in an actionable error.
|
|
8
|
+
*
|
|
9
|
+
* WHY (P-Windows): the import was previously `import Database from
|
|
10
|
+
* 'better-sqlite3'` at top-level module scope, so the `.node` binding loaded at
|
|
11
|
+
* module-EVALUATION time. A missing / ABI-mismatched (Node < 22) / AV-locked
|
|
12
|
+
* prebuilt binary therefore threw before `main()` ran — and on stock Windows
|
|
13
|
+
* there is no compile-from-source fallback — so the native host process simply
|
|
14
|
+
* died and the browser saw a silently-closed stdio pipe with no message. Making
|
|
15
|
+
* this a type-only import + a lazy `require` defers the load to the first
|
|
16
|
+
* {@link openDb} call (inside `main()`, where it is caught) and lets us emit a
|
|
17
|
+
* message the user can act on. Node's own require cache makes repeat calls cheap,
|
|
18
|
+
* so no module-level memo is needed. `requireFn` is injectable for tests.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadBetterSqlite3(requireFn?: (id: string) => unknown): BetterSqlite3Ctor;
|
|
3
21
|
/**
|
|
4
22
|
* The native host's data directory (ADR-0007). Defaults to `~/.peek`; the
|
|
5
23
|
* `PEEK_HOME` environment variable overrides it (used by tests and by users who
|
package/dist/db/open.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../src/db/open.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../src/db/open.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAiB,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5D,4FAA4F;AAC5F,KAAK,iBAAiB,GAAG,KAAK,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,QAAQ,CAAC;AAElG;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,GAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAwC,GAClE,iBAAiB,CASnB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAIpC;AAED,iDAAiD;AACjD,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,QAAQ,CAAC,QAAQ,CA2BrE;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAA;CAAE,CAAC;AAEvD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAE,MAAwB,GAAG,gBAAgB,CAQ/E;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/db/open.js
CHANGED
|
@@ -2,10 +2,33 @@
|
|
|
2
2
|
// same ~/.peek/sessions.db through here so the pragmas (WAL, foreign keys) and
|
|
3
3
|
// the migration state stay consistent across the three thin clients (ADR-0007).
|
|
4
4
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
5
6
|
import { homedir } from 'node:os';
|
|
6
7
|
import { dirname, join } from 'node:path';
|
|
7
|
-
import Database from 'better-sqlite3';
|
|
8
8
|
import { runMigrations, schemaVersion } from './migrate.js';
|
|
9
|
+
/**
|
|
10
|
+
* Lazily load better-sqlite3's native constructor, wrapping a native-module
|
|
11
|
+
* load failure in an actionable error.
|
|
12
|
+
*
|
|
13
|
+
* WHY (P-Windows): the import was previously `import Database from
|
|
14
|
+
* 'better-sqlite3'` at top-level module scope, so the `.node` binding loaded at
|
|
15
|
+
* module-EVALUATION time. A missing / ABI-mismatched (Node < 22) / AV-locked
|
|
16
|
+
* prebuilt binary therefore threw before `main()` ran — and on stock Windows
|
|
17
|
+
* there is no compile-from-source fallback — so the native host process simply
|
|
18
|
+
* died and the browser saw a silently-closed stdio pipe with no message. Making
|
|
19
|
+
* this a type-only import + a lazy `require` defers the load to the first
|
|
20
|
+
* {@link openDb} call (inside `main()`, where it is caught) and lets us emit a
|
|
21
|
+
* message the user can act on. Node's own require cache makes repeat calls cheap,
|
|
22
|
+
* so no module-level memo is needed. `requireFn` is injectable for tests.
|
|
23
|
+
*/
|
|
24
|
+
export function loadBetterSqlite3(requireFn = createRequire(import.meta.url)) {
|
|
25
|
+
try {
|
|
26
|
+
return requireFn('better-sqlite3');
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new Error(`peek: the better-sqlite3 native module failed to load, so the session database cannot be opened. peek requires Node.js 22+ and a prebuilt binary for your platform (${process.platform}/${process.arch}); this usually means the prebuild is missing/incompatible (e.g. Node < 22) or an antivirus has locked the .node file. Original error: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
9
32
|
/**
|
|
10
33
|
* The native host's data directory (ADR-0007). Defaults to `~/.peek`; the
|
|
11
34
|
* `PEEK_HOME` environment variable overrides it (used by tests and by users who
|
|
@@ -37,6 +60,7 @@ export function openDb(options = {}) {
|
|
|
37
60
|
if (path !== ':memory:' && !readonly) {
|
|
38
61
|
mkdirSync(dirname(path), { recursive: true });
|
|
39
62
|
}
|
|
63
|
+
const Database = loadBetterSqlite3();
|
|
40
64
|
const db = new Database(path, readonly ? { readonly: true } : {});
|
|
41
65
|
if (readonly) {
|
|
42
66
|
// Read-only handles can't enable WAL (a DDL/pragma write); the writer (the
|
package/dist/db/open.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/db/open.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAEhF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/db/open.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAEhF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK5D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iBAAiB,CAC/B,YAAqC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAEnE,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,gBAAgB,CAAsB,CAAC;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,uKAAuK,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,0IAA0I,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAC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AAC,CAAC;IACjC,CAAC;IAED,2EAA2E;IAC3E,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzC,aAAa,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAWD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,aAAa,EAAE;IAC3D,yEAAyE;IACzE,2EAA2E;IAC3E,4BAA4B;IAC5B,IAAI,IAAI,KAAK,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when `metaUrl` (`import.meta.url`) refers to the same file as `argv1`
|
|
3
|
+
* (`process.argv[1]`). Compares via {@link pathToFileURL} (Windows-safe, encoded)
|
|
4
|
+
* and falls back to the realpath-resolved argv (bin shims / symlinks). A
|
|
5
|
+
* realpath failure resolves to `false`. `realpath` is injectable for tests.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isDirectInvocation(metaUrl: string, argv1: string | undefined, realpath?: (p: string) => string): boolean;
|
|
8
|
+
//# sourceMappingURL=entrypoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAqB,GAC7C,OAAO,CAQT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Decide whether this module is the process entry point (`node thisfile`, or an
|
|
2
|
+
// npm-generated bin shim) versus merely imported. Bin / postinstall entries
|
|
3
|
+
// guard their side effect on this so an ESM `import` (tests, consumers) is inert.
|
|
4
|
+
//
|
|
5
|
+
// WHY pathToFileURL (P-Windows): comparing `import.meta.url` against the
|
|
6
|
+
// string-concatenated `` `file://${process.argv[1]}` `` produced an INVALID url
|
|
7
|
+
// on Windows — `process.argv[1]` is a backslash path (`C:\…\x.js`), so the
|
|
8
|
+
// concat yields `file://C:\…\x.js`, which never equals `import.meta.url`'s
|
|
9
|
+
// RFC-8089 form (`file:///C:/…/x.js`). It also skipped percent-encoding for
|
|
10
|
+
// space/unicode paths on POSIX. pathToFileURL produces the correct encoded
|
|
11
|
+
// `file:` url on every platform. (Local copy of @peekdev/cli's helper — kept
|
|
12
|
+
// per-package so neither bin's entry guard depends on the other's public API.)
|
|
13
|
+
import { realpathSync } from 'node:fs';
|
|
14
|
+
import { pathToFileURL } from 'node:url';
|
|
15
|
+
/**
|
|
16
|
+
* True when `metaUrl` (`import.meta.url`) refers to the same file as `argv1`
|
|
17
|
+
* (`process.argv[1]`). Compares via {@link pathToFileURL} (Windows-safe, encoded)
|
|
18
|
+
* and falls back to the realpath-resolved argv (bin shims / symlinks). A
|
|
19
|
+
* realpath failure resolves to `false`. `realpath` is injectable for tests.
|
|
20
|
+
*/
|
|
21
|
+
export function isDirectInvocation(metaUrl, argv1, realpath = realpathSync) {
|
|
22
|
+
if (argv1 === undefined)
|
|
23
|
+
return false;
|
|
24
|
+
if (metaUrl === pathToFileURL(argv1).href)
|
|
25
|
+
return true;
|
|
26
|
+
try {
|
|
27
|
+
return metaUrl === pathToFileURL(realpath(argv1)).href;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=entrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,kFAAkF;AAClF,EAAE;AACF,yEAAyE;AACzE,gFAAgF;AAChF,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAe,EACf,KAAyB,EACzB,WAAkC,YAAY;IAE9C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,OAAO,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,CAAC;QACH,OAAO,OAAO,KAAK,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -117,6 +117,93 @@ export declare const WaitForActionSchema: z.ZodObject<{
|
|
|
117
117
|
timeoutMs?: number | undefined;
|
|
118
118
|
}>;
|
|
119
119
|
export type WaitForAction = z.infer<typeof WaitForActionSchema>;
|
|
120
|
+
/** Press Enter on the active element or a specific selector (focus → keydown/keypress/keyup). */
|
|
121
|
+
export declare const EnterActionSchema: z.ZodObject<{
|
|
122
|
+
type: z.ZodLiteral<"enter">;
|
|
123
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
type: "enter";
|
|
126
|
+
selector?: string | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
type: "enter";
|
|
129
|
+
selector?: string | undefined;
|
|
130
|
+
}>;
|
|
131
|
+
export type EnterAction = z.infer<typeof EnterActionSchema>;
|
|
132
|
+
/** Double-click a target element. */
|
|
133
|
+
export declare const DblClickActionSchema: z.ZodObject<{
|
|
134
|
+
type: z.ZodLiteral<"dblclick">;
|
|
135
|
+
selector: z.ZodString;
|
|
136
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
type: "dblclick";
|
|
139
|
+
selector: string;
|
|
140
|
+
nth?: number | undefined;
|
|
141
|
+
}, {
|
|
142
|
+
type: "dblclick";
|
|
143
|
+
selector: string;
|
|
144
|
+
nth?: number | undefined;
|
|
145
|
+
}>;
|
|
146
|
+
export type DblClickAction = z.infer<typeof DblClickActionSchema>;
|
|
147
|
+
/** Agent-set banner string (Part 2). Rides execute_action rails; no DOM target. */
|
|
148
|
+
export declare const SetIntentActionSchema: z.ZodObject<{
|
|
149
|
+
type: z.ZodLiteral<"set_intent">;
|
|
150
|
+
text: z.ZodString;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
type: "set_intent";
|
|
153
|
+
text: string;
|
|
154
|
+
}, {
|
|
155
|
+
type: "set_intent";
|
|
156
|
+
text: string;
|
|
157
|
+
}>;
|
|
158
|
+
export type SetIntentAction = z.infer<typeof SetIntentActionSchema>;
|
|
159
|
+
/** Draw a non-destructive highlight overlay on a target, with an optional label. */
|
|
160
|
+
export declare const HighlightActionSchema: z.ZodObject<{
|
|
161
|
+
type: z.ZodLiteral<"highlight">;
|
|
162
|
+
selector: z.ZodString;
|
|
163
|
+
label: z.ZodOptional<z.ZodString>;
|
|
164
|
+
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
type: "highlight";
|
|
166
|
+
selector: string;
|
|
167
|
+
label?: string | undefined;
|
|
168
|
+
}, {
|
|
169
|
+
type: "highlight";
|
|
170
|
+
selector: string;
|
|
171
|
+
label?: string | undefined;
|
|
172
|
+
}>;
|
|
173
|
+
export type HighlightAction = z.infer<typeof HighlightActionSchema>;
|
|
174
|
+
/** Remove the active highlight overlay — no DOM target. */
|
|
175
|
+
export declare const ClearHighlightActionSchema: z.ZodObject<{
|
|
176
|
+
type: z.ZodLiteral<"clear_highlight">;
|
|
177
|
+
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
type: "clear_highlight";
|
|
179
|
+
}, {
|
|
180
|
+
type: "clear_highlight";
|
|
181
|
+
}>;
|
|
182
|
+
export type ClearHighlightAction = z.infer<typeof ClearHighlightActionSchema>;
|
|
183
|
+
/** Plan B — input handoff. Rides the execute_action rails (wire tool='execute_action'). */
|
|
184
|
+
export declare const RequestUserInputActionSchema: z.ZodObject<{
|
|
185
|
+
type: z.ZodLiteral<"request_user_input">;
|
|
186
|
+
prompt: z.ZodString;
|
|
187
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
188
|
+
scope: z.ZodDefault<z.ZodEnum<["field", "page"]>>;
|
|
189
|
+
readBack: z.ZodDefault<z.ZodBoolean>;
|
|
190
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
type: "request_user_input";
|
|
193
|
+
timeoutMs: number;
|
|
194
|
+
prompt: string;
|
|
195
|
+
scope: "field" | "page";
|
|
196
|
+
readBack: boolean;
|
|
197
|
+
selector?: string | undefined;
|
|
198
|
+
}, {
|
|
199
|
+
type: "request_user_input";
|
|
200
|
+
prompt: string;
|
|
201
|
+
selector?: string | undefined;
|
|
202
|
+
timeoutMs?: number | undefined;
|
|
203
|
+
scope?: "field" | "page" | undefined;
|
|
204
|
+
readBack?: boolean | undefined;
|
|
205
|
+
}>;
|
|
206
|
+
export type RequestUserInputAction = z.infer<typeof RequestUserInputActionSchema>;
|
|
120
207
|
/** The full Action discriminated union (P2 PRD §E.4). */
|
|
121
208
|
export declare const ActionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
122
209
|
type: z.ZodLiteral<"click">;
|
|
@@ -211,6 +298,75 @@ export declare const ActionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
211
298
|
type: "waitFor";
|
|
212
299
|
selector?: string | undefined;
|
|
213
300
|
timeoutMs?: number | undefined;
|
|
301
|
+
}>, z.ZodObject<{
|
|
302
|
+
type: z.ZodLiteral<"enter">;
|
|
303
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
304
|
+
}, "strip", z.ZodTypeAny, {
|
|
305
|
+
type: "enter";
|
|
306
|
+
selector?: string | undefined;
|
|
307
|
+
}, {
|
|
308
|
+
type: "enter";
|
|
309
|
+
selector?: string | undefined;
|
|
310
|
+
}>, z.ZodObject<{
|
|
311
|
+
type: z.ZodLiteral<"dblclick">;
|
|
312
|
+
selector: z.ZodString;
|
|
313
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
314
|
+
}, "strip", z.ZodTypeAny, {
|
|
315
|
+
type: "dblclick";
|
|
316
|
+
selector: string;
|
|
317
|
+
nth?: number | undefined;
|
|
318
|
+
}, {
|
|
319
|
+
type: "dblclick";
|
|
320
|
+
selector: string;
|
|
321
|
+
nth?: number | undefined;
|
|
322
|
+
}>, z.ZodObject<{
|
|
323
|
+
type: z.ZodLiteral<"highlight">;
|
|
324
|
+
selector: z.ZodString;
|
|
325
|
+
label: z.ZodOptional<z.ZodString>;
|
|
326
|
+
}, "strip", z.ZodTypeAny, {
|
|
327
|
+
type: "highlight";
|
|
328
|
+
selector: string;
|
|
329
|
+
label?: string | undefined;
|
|
330
|
+
}, {
|
|
331
|
+
type: "highlight";
|
|
332
|
+
selector: string;
|
|
333
|
+
label?: string | undefined;
|
|
334
|
+
}>, z.ZodObject<{
|
|
335
|
+
type: z.ZodLiteral<"clear_highlight">;
|
|
336
|
+
}, "strip", z.ZodTypeAny, {
|
|
337
|
+
type: "clear_highlight";
|
|
338
|
+
}, {
|
|
339
|
+
type: "clear_highlight";
|
|
340
|
+
}>, z.ZodObject<{
|
|
341
|
+
type: z.ZodLiteral<"set_intent">;
|
|
342
|
+
text: z.ZodString;
|
|
343
|
+
}, "strip", z.ZodTypeAny, {
|
|
344
|
+
type: "set_intent";
|
|
345
|
+
text: string;
|
|
346
|
+
}, {
|
|
347
|
+
type: "set_intent";
|
|
348
|
+
text: string;
|
|
349
|
+
}>, z.ZodObject<{
|
|
350
|
+
type: z.ZodLiteral<"request_user_input">;
|
|
351
|
+
prompt: z.ZodString;
|
|
352
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
353
|
+
scope: z.ZodDefault<z.ZodEnum<["field", "page"]>>;
|
|
354
|
+
readBack: z.ZodDefault<z.ZodBoolean>;
|
|
355
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
356
|
+
}, "strip", z.ZodTypeAny, {
|
|
357
|
+
type: "request_user_input";
|
|
358
|
+
timeoutMs: number;
|
|
359
|
+
prompt: string;
|
|
360
|
+
scope: "field" | "page";
|
|
361
|
+
readBack: boolean;
|
|
362
|
+
selector?: string | undefined;
|
|
363
|
+
}, {
|
|
364
|
+
type: "request_user_input";
|
|
365
|
+
prompt: string;
|
|
366
|
+
selector?: string | undefined;
|
|
367
|
+
timeoutMs?: number | undefined;
|
|
368
|
+
scope?: "field" | "page" | undefined;
|
|
369
|
+
readBack?: boolean | undefined;
|
|
214
370
|
}>]>;
|
|
215
371
|
export type Action = z.infer<typeof ActionSchema>;
|
|
216
372
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-schema.d.ts","sourceRoot":"","sources":["../../src/mcp/action-schema.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qEAAqE;AACrE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;EAK5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,0DA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;;;;;;;;;;;;;;;;;;;;;IAgBvB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAyC3D"}
|
|
@@ -53,6 +53,49 @@ export const WaitForActionSchema = z.object({
|
|
|
53
53
|
selector: z.string().optional(),
|
|
54
54
|
timeoutMs: z.number().int().min(0).default(5000),
|
|
55
55
|
});
|
|
56
|
+
/** Press Enter on the active element or a specific selector (focus → keydown/keypress/keyup). */
|
|
57
|
+
export const EnterActionSchema = z.object({
|
|
58
|
+
type: z.literal('enter'),
|
|
59
|
+
selector: z.string().optional(),
|
|
60
|
+
});
|
|
61
|
+
/** Double-click a target element. */
|
|
62
|
+
export const DblClickActionSchema = z.object({
|
|
63
|
+
type: z.literal('dblclick'),
|
|
64
|
+
selector: z.string().min(1),
|
|
65
|
+
nth: z.number().int().min(0).optional(),
|
|
66
|
+
});
|
|
67
|
+
/** Agent-set banner string (Part 2). Rides execute_action rails; no DOM target. */
|
|
68
|
+
export const SetIntentActionSchema = z.object({
|
|
69
|
+
type: z.literal('set_intent'),
|
|
70
|
+
text: z.string().max(80),
|
|
71
|
+
});
|
|
72
|
+
/** Draw a non-destructive highlight overlay on a target, with an optional label. */
|
|
73
|
+
export const HighlightActionSchema = z.object({
|
|
74
|
+
type: z.literal('highlight'),
|
|
75
|
+
selector: z.string().min(1),
|
|
76
|
+
label: z.string().max(120).optional(),
|
|
77
|
+
});
|
|
78
|
+
/** Remove the active highlight overlay — no DOM target. */
|
|
79
|
+
export const ClearHighlightActionSchema = z.object({
|
|
80
|
+
type: z.literal('clear_highlight'),
|
|
81
|
+
});
|
|
82
|
+
/** Plan B — input handoff. Rides the execute_action rails (wire tool='execute_action'). */
|
|
83
|
+
export const RequestUserInputActionSchema = z.object({
|
|
84
|
+
type: z.literal('request_user_input'),
|
|
85
|
+
prompt: z.string().max(280),
|
|
86
|
+
selector: z.string().optional(),
|
|
87
|
+
scope: z.enum(['field', 'page']).default('field'),
|
|
88
|
+
readBack: z.boolean().default(false),
|
|
89
|
+
// This ceiling (10 min) is DOUBLE the bridge's DEFAULT_BRIDGE_TIMEOUT_MS
|
|
90
|
+
// (5 min, host-bridge.ts). server.ts's dispatchActTool now threads
|
|
91
|
+
// timeoutMs = handoffTimeout + 30000 into bridge.request, so the bridge waits
|
|
92
|
+
// with margin above the handoff timer instead of cutting the request off at
|
|
93
|
+
// its 5-min default. The SW controller's timer (clamped to
|
|
94
|
+
// MAX_HANDOFF_TIMEOUT_MS = 240000, action-handler.ts) fires FIRST, so a slow
|
|
95
|
+
// human yields a structured { resumed:false, reason:'timeout' } rather than a
|
|
96
|
+
// transport error.
|
|
97
|
+
timeoutMs: z.number().int().min(0).max(600000).default(120000),
|
|
98
|
+
});
|
|
56
99
|
/** The full Action discriminated union (P2 PRD §E.4). */
|
|
57
100
|
export const ActionSchema = z.discriminatedUnion('type', [
|
|
58
101
|
ClickActionSchema,
|
|
@@ -64,6 +107,12 @@ export const ActionSchema = z.discriminatedUnion('type', [
|
|
|
64
107
|
ScrollActionSchema,
|
|
65
108
|
ScreenshotActionSchema,
|
|
66
109
|
WaitForActionSchema,
|
|
110
|
+
EnterActionSchema,
|
|
111
|
+
DblClickActionSchema,
|
|
112
|
+
HighlightActionSchema,
|
|
113
|
+
ClearHighlightActionSchema,
|
|
114
|
+
SetIntentActionSchema,
|
|
115
|
+
RequestUserInputActionSchema,
|
|
67
116
|
]);
|
|
68
117
|
/**
|
|
69
118
|
* Mask the action's sensitive fields for audit-log persistence. `type`
|
|
@@ -90,6 +139,26 @@ export function redactActionForAudit(action) {
|
|
|
90
139
|
return action;
|
|
91
140
|
}
|
|
92
141
|
}
|
|
142
|
+
case 'request_user_input':
|
|
143
|
+
// Record what the AI asked: prompt + selector + scope. `scope` is non-
|
|
144
|
+
// secret and audit-relevant — it distinguishes a page-scope FULL takeover
|
|
145
|
+
// (broader surface) from a field/free-text card in the trail. NEVER the
|
|
146
|
+
// returned value — it lives in the result `details`, which the audit writer
|
|
147
|
+
// never receives (audit.ts buildAuditEntry takes only the action).
|
|
148
|
+
//
|
|
149
|
+
// This intentionally returns a PARTIAL object (drops readBack/timeoutMs),
|
|
150
|
+
// which is why the `as Action` cast is needed — the result is audit-only
|
|
151
|
+
// (consumed solely by buildAuditEntry -> JSON.stringify) and is NOT a
|
|
152
|
+
// dispatchable Action. Do not feed it back into the dispatcher.
|
|
153
|
+
return {
|
|
154
|
+
type: 'request_user_input',
|
|
155
|
+
prompt: action.prompt,
|
|
156
|
+
selector: action.selector,
|
|
157
|
+
scope: action.scope,
|
|
158
|
+
};
|
|
159
|
+
case 'set_intent':
|
|
160
|
+
// AI-authored status string (not secret); clipped defensively (schema also caps 80).
|
|
161
|
+
return { type: 'set_intent', text: action.text.slice(0, 80) };
|
|
93
162
|
default:
|
|
94
163
|
return action;
|
|
95
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-schema.js","sourceRoot":"","sources":["../../src/mcp/action-schema.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,gFAAgF;AAChF,+EAA+E;AAC/E,SAAS;AACT,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,6BAA6B;AAC7B,EAAE;AACF,2CAA2C;AAC3C,4EAA4E;AAC5E,6EAA6E;AAC7E,yBAAyB;AAEzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qEAAqE;AACrE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,C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
@@ -17,13 +17,23 @@ export declare function rrwebEventsDir(): string;
|
|
|
17
17
|
* Resolve a `sessions.events_blob_path` value to an absolute path. The column
|
|
18
18
|
* stores a path relative to {@link rrwebEventsDir}; an absolute value (older
|
|
19
19
|
* rows / tests) is honored as-is.
|
|
20
|
+
*
|
|
21
|
+
* Pre-alpha.10 rows store the path as `rrweb-events/<sessionId>` (a duplicated
|
|
22
|
+
* prefix relative to {@link peekHomeDir} instead of {@link rrwebEventsDir}).
|
|
23
|
+
* Strip that one specific leading segment so the legacy and current layouts
|
|
24
|
+
* resolve to the same on-disk directory.
|
|
20
25
|
*/
|
|
21
26
|
export declare function resolveBlobPath(blobPath: string, baseDir?: string): string;
|
|
22
27
|
/**
|
|
23
28
|
* Read + gunzip + JSON-parse a session's event blob into the rrweb event array.
|
|
24
29
|
* Returns an empty array when the session has no blob path recorded or the
|
|
25
|
-
* blob file is missing (e.g. an active session before its first flush, or
|
|
26
|
-
* blob pruned by retention) — callers degrade to "no events" rather than throw.
|
|
30
|
+
* blob file/dir is missing (e.g. an active session before its first flush, or
|
|
31
|
+
* a blob pruned by retention) — callers degrade to "no events" rather than throw.
|
|
32
|
+
*
|
|
33
|
+
* The native host writes one gzipped chunk per `session.append` batch at
|
|
34
|
+
* `<events-dir>/<sessionId>/<seq>.json.gz`, and stores `<events-dir>/<sessionId>`
|
|
35
|
+
* (a directory) in `sessions.events_blob_path`. Older rows / tests may instead
|
|
36
|
+
* point at a single `.gz` file — both layouts are honored here.
|
|
27
37
|
*
|
|
28
38
|
* @param blobPath the `sessions.events_blob_path` value (relative or absolute)
|
|
29
39
|
* @param baseDir override the ~/.peek/rrweb-events base (tests)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-blobs.d.ts","sourceRoot":"","sources":["../../src/mcp/event-blobs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGtE;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED,uEAAuE;AACvE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED
|
|
1
|
+
{"version":3,"file":"event-blobs.d.ts","sourceRoot":"","sources":["../../src/mcp/event-blobs.ts"],"names":[],"mappings":"AAUA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGtE;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED,uEAAuE;AACvE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAAyB,GAAG,MAAM,CAO5F;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,OAAO,GAAE,MAAyB,GACjC,aAAa,EAAE,CAajB"}
|