@peekdev/mcp 0.1.0-alpha.1

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 (120) hide show
  1. package/NOTICE +10 -0
  2. package/dist/db/index.d.ts +3 -0
  3. package/dist/db/index.d.ts.map +1 -0
  4. package/dist/db/index.js +7 -0
  5. package/dist/db/index.js.map +1 -0
  6. package/dist/db/migrate.d.ts +37 -0
  7. package/dist/db/migrate.d.ts.map +1 -0
  8. package/dist/db/migrate.js +86 -0
  9. package/dist/db/migrate.js.map +1 -0
  10. package/dist/db/migrations/0001_initial.sql +102 -0
  11. package/dist/db/migrations/0002_network_bodies.sql +15 -0
  12. package/dist/db/open.d.ts +57 -0
  13. package/dist/db/open.d.ts.map +1 -0
  14. package/dist/db/open.js +74 -0
  15. package/dist/db/open.js.map +1 -0
  16. package/dist/index.d.ts +10 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +58 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/mcp/action-schema.d.ts +223 -0
  21. package/dist/mcp/action-schema.d.ts.map +1 -0
  22. package/dist/mcp/action-schema.js +97 -0
  23. package/dist/mcp/action-schema.js.map +1 -0
  24. package/dist/mcp/event-blobs.d.ts +32 -0
  25. package/dist/mcp/event-blobs.d.ts.map +1 -0
  26. package/dist/mcp/event-blobs.js +65 -0
  27. package/dist/mcp/event-blobs.js.map +1 -0
  28. package/dist/mcp/event-walker.d.ts +86 -0
  29. package/dist/mcp/event-walker.d.ts.map +1 -0
  30. package/dist/mcp/event-walker.js +398 -0
  31. package/dist/mcp/event-walker.js.map +1 -0
  32. package/dist/mcp/host-bridge.d.ts +80 -0
  33. package/dist/mcp/host-bridge.d.ts.map +1 -0
  34. package/dist/mcp/host-bridge.js +88 -0
  35. package/dist/mcp/host-bridge.js.map +1 -0
  36. package/dist/mcp/index.d.ts +8 -0
  37. package/dist/mcp/index.d.ts.map +1 -0
  38. package/dist/mcp/index.js +32 -0
  39. package/dist/mcp/index.js.map +1 -0
  40. package/dist/mcp/playwright-repro.d.ts +19 -0
  41. package/dist/mcp/playwright-repro.d.ts.map +1 -0
  42. package/dist/mcp/playwright-repro.js +78 -0
  43. package/dist/mcp/playwright-repro.js.map +1 -0
  44. package/dist/mcp/queries.d.ts +73 -0
  45. package/dist/mcp/queries.d.ts.map +1 -0
  46. package/dist/mcp/queries.js +139 -0
  47. package/dist/mcp/queries.js.map +1 -0
  48. package/dist/mcp/roots.d.ts +50 -0
  49. package/dist/mcp/roots.d.ts.map +1 -0
  50. package/dist/mcp/roots.js +97 -0
  51. package/dist/mcp/roots.js.map +1 -0
  52. package/dist/mcp/rrweb-types.d.ts +3 -0
  53. package/dist/mcp/rrweb-types.d.ts.map +1 -0
  54. package/dist/mcp/rrweb-types.js +7 -0
  55. package/dist/mcp/rrweb-types.js.map +1 -0
  56. package/dist/mcp/selector.d.ts +54 -0
  57. package/dist/mcp/selector.d.ts.map +1 -0
  58. package/dist/mcp/selector.js +209 -0
  59. package/dist/mcp/selector.js.map +1 -0
  60. package/dist/mcp/server.d.ts +49 -0
  61. package/dist/mcp/server.d.ts.map +1 -0
  62. package/dist/mcp/server.js +469 -0
  63. package/dist/mcp/server.js.map +1 -0
  64. package/dist/mcp/summary.d.ts +26 -0
  65. package/dist/mcp/summary.d.ts.map +1 -0
  66. package/dist/mcp/summary.js +74 -0
  67. package/dist/mcp/summary.js.map +1 -0
  68. package/dist/native-host/action-protocol.d.ts +49 -0
  69. package/dist/native-host/action-protocol.d.ts.map +1 -0
  70. package/dist/native-host/action-protocol.js +36 -0
  71. package/dist/native-host/action-protocol.js.map +1 -0
  72. package/dist/native-host/audit.d.ts +69 -0
  73. package/dist/native-host/audit.d.ts.map +1 -0
  74. package/dist/native-host/audit.js +85 -0
  75. package/dist/native-host/audit.js.map +1 -0
  76. package/dist/native-host/config.d.ts +18 -0
  77. package/dist/native-host/config.d.ts.map +1 -0
  78. package/dist/native-host/config.js +56 -0
  79. package/dist/native-host/config.js.map +1 -0
  80. package/dist/native-host/extension-ids.json +6 -0
  81. package/dist/native-host/host.d.ts +30 -0
  82. package/dist/native-host/host.d.ts.map +1 -0
  83. package/dist/native-host/host.js +96 -0
  84. package/dist/native-host/host.js.map +1 -0
  85. package/dist/native-host/index.d.ts +4 -0
  86. package/dist/native-host/index.d.ts.map +1 -0
  87. package/dist/native-host/index.js +8 -0
  88. package/dist/native-host/index.js.map +1 -0
  89. package/dist/native-host/ingest.d.ts +83 -0
  90. package/dist/native-host/ingest.d.ts.map +1 -0
  91. package/dist/native-host/ingest.js +283 -0
  92. package/dist/native-host/ingest.js.map +1 -0
  93. package/dist/native-host/installer.d.ts +64 -0
  94. package/dist/native-host/installer.d.ts.map +1 -0
  95. package/dist/native-host/installer.js +110 -0
  96. package/dist/native-host/installer.js.map +1 -0
  97. package/dist/native-host/manifest.d.ts +64 -0
  98. package/dist/native-host/manifest.d.ts.map +1 -0
  99. package/dist/native-host/manifest.js +117 -0
  100. package/dist/native-host/manifest.js.map +1 -0
  101. package/dist/native-host/policy.d.ts +60 -0
  102. package/dist/native-host/policy.d.ts.map +1 -0
  103. package/dist/native-host/policy.js +116 -0
  104. package/dist/native-host/policy.js.map +1 -0
  105. package/dist/native-host/request-registry.d.ts +55 -0
  106. package/dist/native-host/request-registry.d.ts.map +1 -0
  107. package/dist/native-host/request-registry.js +111 -0
  108. package/dist/native-host/request-registry.js.map +1 -0
  109. package/dist/native-host/transport.d.ts +54 -0
  110. package/dist/native-host/transport.d.ts.map +1 -0
  111. package/dist/native-host/transport.js +113 -0
  112. package/dist/native-host/transport.js.map +1 -0
  113. package/dist/postinstall.d.ts +3 -0
  114. package/dist/postinstall.d.ts.map +1 -0
  115. package/dist/postinstall.js +72 -0
  116. package/dist/postinstall.js.map +1 -0
  117. package/package.json +59 -0
  118. package/src/db/migrations/0001_initial.sql +102 -0
  119. package/src/db/migrations/0002_network_bodies.sql +15 -0
  120. package/src/native-host/extension-ids.json +6 -0
@@ -0,0 +1,209 @@
1
+ // Derive a human/agent-readable CSS selector for an rrweb node id from a
2
+ // serialized snapshot tree. rrweb records interactions by numeric node id; to
3
+ // turn "click on id 42" into something an agent (or a Playwright script) can
4
+ // use, we walk the serialized DOM the id refers to and synthesize a selector,
5
+ // preferring stable hooks (#id, [data-testid], unique tag.class) and falling
6
+ // back to an `nth-of-type` path.
7
+ //
8
+ // This operates purely on the serialized node tree (no live DOM), so it works
9
+ // in plain Node — the same constraint the rest of the event walker honors.
10
+ import { NodeType } from './rrweb-types.js';
11
+ /**
12
+ * Max DOM nesting depth the offline walkers descend before stopping. Real
13
+ * browser DOMs are nowhere near this deep; the bound exists because this code
14
+ * ingests UNTRUSTED recordings — a crafted ~10k-deep tree would otherwise blow
15
+ * the call stack. Shared so the index builders and the serializer agree.
16
+ */
17
+ export const MAX_DOM_DEPTH = 1000;
18
+ /**
19
+ * Build a {@link NodeIndex} from a FullSnapshot's root serialized node. Nodes
20
+ * deeper than {@link MAX_DOM_DEPTH} are skipped (not indexed) rather than
21
+ * overflowing the stack on an adversarial blob.
22
+ */
23
+ export function indexNodes(root) {
24
+ const index = new Map();
25
+ const walk = (node, parentId, depth) => {
26
+ index.set(node.id, { node, parentId });
27
+ if (depth >= MAX_DOM_DEPTH)
28
+ return;
29
+ for (const child of nodeChildren(node)) {
30
+ walk(child, node.id, depth + 1);
31
+ }
32
+ };
33
+ walk(root, null, 0);
34
+ return index;
35
+ }
36
+ /** The serialized child nodes of a node, or `[]` for leaf/text/comment nodes. */
37
+ export function nodeChildren(node) {
38
+ if (node.type === NodeType.Document || node.type === NodeType.Element) {
39
+ // documentNode + elementNode both carry `childNodes`.
40
+ return node.childNodes ?? [];
41
+ }
42
+ return [];
43
+ }
44
+ function tagName(node) {
45
+ if (node.type === NodeType.Element) {
46
+ return node.tagName.toLowerCase();
47
+ }
48
+ return undefined;
49
+ }
50
+ function attributes(node) {
51
+ if (node.type === NodeType.Element) {
52
+ return node.attributes ?? {};
53
+ }
54
+ return {};
55
+ }
56
+ /** A non-empty string attribute value, or undefined. */
57
+ function strAttr(attrs, key) {
58
+ const v = attrs[key];
59
+ return typeof v === 'string' && v.length > 0 ? v : undefined;
60
+ }
61
+ /** CSS-escape an id/class token (only the characters that actually break a selector). */
62
+ function cssEscape(token) {
63
+ // A conservative escape: backslash-escape characters that aren't valid in an
64
+ // unescaped CSS identifier. Good enough for selectors emitted into JSON / a
65
+ // Playwright string; not a full CSS.escape polyfill.
66
+ return token.replace(/[^a-zA-Z0-9_-]/g, (ch) => `\\${ch}`);
67
+ }
68
+ /**
69
+ * Derive the most stable selector for a single node, ignoring ancestors:
70
+ * 1. `#id` (when the id looks static, not an obvious nonce)
71
+ * 2. `[data-testid="…"]` (or data-test / data-cy — test hooks)
72
+ * 3. `tag[name="…"]` (form controls)
73
+ * 4. `tag.class.class` (first two classes)
74
+ * 5. `tag`
75
+ * Returns `undefined` for non-element nodes.
76
+ */
77
+ export function localSelector(node) {
78
+ const tag = tagName(node);
79
+ if (tag === undefined)
80
+ return undefined;
81
+ const attrs = attributes(node);
82
+ const id = strAttr(attrs, 'id');
83
+ if (id !== undefined && isStableToken(id)) {
84
+ return `#${cssEscape(id)}`;
85
+ }
86
+ for (const hook of ['data-testid', 'data-test', 'data-cy']) {
87
+ const v = strAttr(attrs, hook);
88
+ if (v !== undefined)
89
+ return `[${hook}="${cssAttrValue(v)}"]`;
90
+ }
91
+ const name = strAttr(attrs, 'name');
92
+ if (name !== undefined && (tag === 'input' || tag === 'select' || tag === 'textarea')) {
93
+ return `${tag}[name="${cssAttrValue(name)}"]`;
94
+ }
95
+ const className = strAttr(attrs, 'class');
96
+ if (className !== undefined) {
97
+ const classes = className
98
+ .trim()
99
+ .split(/\s+/)
100
+ .filter((c) => isStableToken(c))
101
+ .slice(0, 2)
102
+ .map((c) => `.${cssEscape(c)}`)
103
+ .join('');
104
+ if (classes.length > 0)
105
+ return `${tag}${classes}`;
106
+ }
107
+ return tag;
108
+ }
109
+ /** Escape a double-quoted CSS attribute value. */
110
+ function cssAttrValue(value) {
111
+ return value.replace(/["\\]/g, (ch) => `\\${ch}`);
112
+ }
113
+ /**
114
+ * Heuristic: does a token look like a stable hook rather than a generated
115
+ * nonce? Rejects hashed/utility tokens (long hex-ish runs, CSS-module suffixes
116
+ * like `Button_x8Hk2`, emotion `css-1q2w3e`). Keeps short, word-y identifiers.
117
+ */
118
+ export function isStableToken(token) {
119
+ if (token.length === 0 || token.length > 40)
120
+ return false;
121
+ // emotion / styled-components generated classes. Thresholds kept low so short
122
+ // generated suffixes (e.g. `css-abc`, `sc-aBcd`) are rejected too.
123
+ if (/^css-[a-z0-9]{3,}$/i.test(token))
124
+ return false;
125
+ if (/^sc-[a-zA-Z0-9]{4,}$/.test(token))
126
+ return false;
127
+ // CSS-modules `Name_hash` / `Name__hash` suffixes.
128
+ if (/_{1,2}[a-zA-Z0-9]{5,}$/.test(token))
129
+ return false;
130
+ // A long run that's mostly hex digits → likely a content hash.
131
+ if (token.length >= 8 && /^[a-f0-9-]+$/i.test(token) && /[0-9]/.test(token))
132
+ return false;
133
+ return true;
134
+ }
135
+ /**
136
+ * The index of `node` among its same-tag siblings (1-based, for
137
+ * `:nth-of-type`). Returns 1 when the parent is unknown or there are no
138
+ * siblings to disambiguate.
139
+ */
140
+ function nthOfType(index, id) {
141
+ const entry = index.get(id);
142
+ if (!entry || entry.parentId === null)
143
+ return 1;
144
+ const parent = index.get(entry.parentId);
145
+ if (!parent)
146
+ return 1;
147
+ const tag = tagName(entry.node);
148
+ if (tag === undefined)
149
+ return 1;
150
+ let n = 0;
151
+ for (const sibling of nodeChildren(parent.node)) {
152
+ if (tagName(sibling) === tag) {
153
+ n += 1;
154
+ if (sibling.id === id)
155
+ return n;
156
+ }
157
+ }
158
+ return Math.max(n, 1);
159
+ }
160
+ /**
161
+ * Derive a full selector path for `id` within `index`, climbing ancestors until
162
+ * an id/test-hook anchor is hit (or the document root). Joins with `>` to keep
163
+ * the path specific and short. Returns `undefined` if `id` is missing or not an
164
+ * element. The result is a best-effort selector for human/agent consumption and
165
+ * Playwright scripts — not guaranteed unique on a live page, but stable enough
166
+ * for the recorded snapshot.
167
+ */
168
+ export function selectorFor(index, id) {
169
+ const start = index.get(id);
170
+ if (!start || tagName(start.node) === undefined)
171
+ return undefined;
172
+ const segments = [];
173
+ let currentId = id;
174
+ let depth = 0;
175
+ while (currentId !== null && depth < 12) {
176
+ const entry = index.get(currentId);
177
+ if (!entry)
178
+ break;
179
+ const tag = tagName(entry.node);
180
+ if (tag === undefined)
181
+ break; // reached the document node
182
+ const local = localSelector(entry.node);
183
+ if (local === undefined)
184
+ break;
185
+ // `body`/`html` are unique document-structure anchors — including them adds
186
+ // no specificity and just lengthens the selector, so stop the climb there
187
+ // (the segment so far is rooted at body, which is what an agent wants).
188
+ if (tag === 'body' || tag === 'html')
189
+ break;
190
+ // An id or any attribute selector (#id, [data-testid], tag[name=…]) is
191
+ // specific enough to stop climbing — and specific enough that it needs no
192
+ // nth-of-type disambiguation.
193
+ const isAnchor = local.startsWith('#') || local.includes('[');
194
+ if (isAnchor) {
195
+ segments.unshift(local);
196
+ break;
197
+ }
198
+ // Disambiguate a bare/`.class` segment with nth-of-type when it has same-tag
199
+ // siblings.
200
+ const n = nthOfType(index, currentId);
201
+ segments.unshift(n > 1 ? `${local}:nth-of-type(${n})` : local);
202
+ currentId = entry.parentId;
203
+ depth += 1;
204
+ }
205
+ if (segments.length === 0)
206
+ return undefined;
207
+ return segments.join(' > ');
208
+ }
209
+ //# sourceMappingURL=selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.js","sourceRoot":"","sources":["../../src/mcp/selector.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,iCAAiC;AACjC,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAE3E,OAAO,EAAE,QAAQ,EAA6B,MAAM,kBAAkB,CAAC;AAevE;;;;;G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AAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAE/D,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC3B,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { type HostBridge } from './host-bridge.js';
3
+ import { type RootsScope } from './roots.js';
4
+ export declare const SERVER_NAME = "peek-mcp";
5
+ export declare const SERVER_INSTRUCTIONS: string;
6
+ export interface PeekMcpServer {
7
+ /** The wrapped SDK server (for `connect`). */
8
+ readonly server: McpServer;
9
+ /** Release the DB handle, if open. */
10
+ close(): void;
11
+ /** Resolve + cache the roots scope (called on `oninitialized`; exposed for tests). */
12
+ refreshRootsScope(timeoutMs?: number): Promise<RootsScope>;
13
+ /** The current roots scope (undefined until resolved). */
14
+ readonly rootsScope: RootsScope | undefined;
15
+ }
16
+ export interface CreatePeekMcpServerOptions {
17
+ /** Override the DB path (tests). Defaults to ~/.peek/sessions.db. */
18
+ readonly dbPath?: string;
19
+ /** Override the rrweb-events base dir (tests). */
20
+ readonly eventsDir?: string;
21
+ /** Roots-list timeout (tests); defaults to 1000ms. */
22
+ readonly rootsTimeoutMs?: number;
23
+ /**
24
+ * The host bridge for act-tool dispatch (Task 3.24). Defaults to a
25
+ * {@link MissingHostBridge} that returns a structured "bridge not wired"
26
+ * denied — so the MCP server constructs cleanly in a process that has no
27
+ * native-host IPC + every act-tool call still goes through the audit log.
28
+ * Tests inject a {@link RegistryBackedHostBridge}; the production IPC
29
+ * implementation is the 3d-4/3e integration layer.
30
+ */
31
+ readonly hostBridge?: HostBridge;
32
+ /**
33
+ * Override the audit-log path (tests). Defaults to ~/.peek/audit.log via
34
+ * the audit module. The MCP server (this process) writes the audit log
35
+ * directly — it's the trust surface, so the closest process to the AI
36
+ * client gets the write. The user-policy reader lives on the native-host
37
+ * side (where the SW round-trip happens).
38
+ */
39
+ readonly auditLogPath?: string;
40
+ }
41
+ /**
42
+ * Build the peek MCP server with all Level-1 read tools registered. Call
43
+ * `.server.connect(transport)` to start it. The DB is opened lazily on the
44
+ * first tool call (and reused), so construction never fails on a missing store.
45
+ */
46
+ export declare function createPeekMcpServer(options?: CreatePeekMcpServerOptions): PeekMcpServer;
47
+ /** The tool names this server registers, for smoke tests / docs. */
48
+ export declare const PEEK_MCP_TOOLS: readonly ["list_recent_sessions", "get_session_summary", "get_session_console_errors", "get_session_network_errors", "get_user_action_before_error", "generate_playwright_repro", "get_dom_snapshot", "query_dom_history", "request_authorization", "execute_action"];
49
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAapE,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,kBAAkB,CAAC;AAUtE,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,YAAY,CAAC;AAGhE,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,mBAAmB,QAUqB,CAAC;AAsBtD,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,sCAAsC;IACtC,KAAK,IAAI,IAAI,CAAC;IACd,sFAAsF;IACtF,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3D,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,0BAA0B;IACzC,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B,GAAG,aAAa,CAqd3F;AAED,oEAAoE;AACpE,eAAO,MAAM,cAAc,uQAajB,CAAC"}