@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.
- package/NOTICE +10 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +7 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrate.d.ts +37 -0
- package/dist/db/migrate.d.ts.map +1 -0
- package/dist/db/migrate.js +86 -0
- package/dist/db/migrate.js.map +1 -0
- package/dist/db/migrations/0001_initial.sql +102 -0
- package/dist/db/migrations/0002_network_bodies.sql +15 -0
- package/dist/db/open.d.ts +57 -0
- package/dist/db/open.d.ts.map +1 -0
- package/dist/db/open.js +74 -0
- package/dist/db/open.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/action-schema.d.ts +223 -0
- package/dist/mcp/action-schema.d.ts.map +1 -0
- package/dist/mcp/action-schema.js +97 -0
- package/dist/mcp/action-schema.js.map +1 -0
- package/dist/mcp/event-blobs.d.ts +32 -0
- package/dist/mcp/event-blobs.d.ts.map +1 -0
- package/dist/mcp/event-blobs.js +65 -0
- package/dist/mcp/event-blobs.js.map +1 -0
- package/dist/mcp/event-walker.d.ts +86 -0
- package/dist/mcp/event-walker.d.ts.map +1 -0
- package/dist/mcp/event-walker.js +398 -0
- package/dist/mcp/event-walker.js.map +1 -0
- package/dist/mcp/host-bridge.d.ts +80 -0
- package/dist/mcp/host-bridge.d.ts.map +1 -0
- package/dist/mcp/host-bridge.js +88 -0
- package/dist/mcp/host-bridge.js.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +32 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/playwright-repro.d.ts +19 -0
- package/dist/mcp/playwright-repro.d.ts.map +1 -0
- package/dist/mcp/playwright-repro.js +78 -0
- package/dist/mcp/playwright-repro.js.map +1 -0
- package/dist/mcp/queries.d.ts +73 -0
- package/dist/mcp/queries.d.ts.map +1 -0
- package/dist/mcp/queries.js +139 -0
- package/dist/mcp/queries.js.map +1 -0
- package/dist/mcp/roots.d.ts +50 -0
- package/dist/mcp/roots.d.ts.map +1 -0
- package/dist/mcp/roots.js +97 -0
- package/dist/mcp/roots.js.map +1 -0
- package/dist/mcp/rrweb-types.d.ts +3 -0
- package/dist/mcp/rrweb-types.d.ts.map +1 -0
- package/dist/mcp/rrweb-types.js +7 -0
- package/dist/mcp/rrweb-types.js.map +1 -0
- package/dist/mcp/selector.d.ts +54 -0
- package/dist/mcp/selector.d.ts.map +1 -0
- package/dist/mcp/selector.js +209 -0
- package/dist/mcp/selector.js.map +1 -0
- package/dist/mcp/server.d.ts +49 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +469 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/summary.d.ts +26 -0
- package/dist/mcp/summary.d.ts.map +1 -0
- package/dist/mcp/summary.js +74 -0
- package/dist/mcp/summary.js.map +1 -0
- package/dist/native-host/action-protocol.d.ts +49 -0
- package/dist/native-host/action-protocol.d.ts.map +1 -0
- package/dist/native-host/action-protocol.js +36 -0
- package/dist/native-host/action-protocol.js.map +1 -0
- package/dist/native-host/audit.d.ts +69 -0
- package/dist/native-host/audit.d.ts.map +1 -0
- package/dist/native-host/audit.js +85 -0
- package/dist/native-host/audit.js.map +1 -0
- package/dist/native-host/config.d.ts +18 -0
- package/dist/native-host/config.d.ts.map +1 -0
- package/dist/native-host/config.js +56 -0
- package/dist/native-host/config.js.map +1 -0
- package/dist/native-host/extension-ids.json +6 -0
- package/dist/native-host/host.d.ts +30 -0
- package/dist/native-host/host.d.ts.map +1 -0
- package/dist/native-host/host.js +96 -0
- package/dist/native-host/host.js.map +1 -0
- package/dist/native-host/index.d.ts +4 -0
- package/dist/native-host/index.d.ts.map +1 -0
- package/dist/native-host/index.js +8 -0
- package/dist/native-host/index.js.map +1 -0
- package/dist/native-host/ingest.d.ts +83 -0
- package/dist/native-host/ingest.d.ts.map +1 -0
- package/dist/native-host/ingest.js +283 -0
- package/dist/native-host/ingest.js.map +1 -0
- package/dist/native-host/installer.d.ts +64 -0
- package/dist/native-host/installer.d.ts.map +1 -0
- package/dist/native-host/installer.js +110 -0
- package/dist/native-host/installer.js.map +1 -0
- package/dist/native-host/manifest.d.ts +64 -0
- package/dist/native-host/manifest.d.ts.map +1 -0
- package/dist/native-host/manifest.js +117 -0
- package/dist/native-host/manifest.js.map +1 -0
- package/dist/native-host/policy.d.ts +60 -0
- package/dist/native-host/policy.d.ts.map +1 -0
- package/dist/native-host/policy.js +116 -0
- package/dist/native-host/policy.js.map +1 -0
- package/dist/native-host/request-registry.d.ts +55 -0
- package/dist/native-host/request-registry.d.ts.map +1 -0
- package/dist/native-host/request-registry.js +111 -0
- package/dist/native-host/request-registry.js.map +1 -0
- package/dist/native-host/transport.d.ts +54 -0
- package/dist/native-host/transport.d.ts.map +1 -0
- package/dist/native-host/transport.js +113 -0
- package/dist/native-host/transport.js.map +1 -0
- package/dist/postinstall.d.ts +3 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +72 -0
- package/dist/postinstall.js.map +1 -0
- package/package.json +59 -0
- package/src/db/migrations/0001_initial.sql +102 -0
- package/src/db/migrations/0002_network_bodies.sql +15 -0
- package/src/native-host/extension-ids.json +6 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Click on a selector. Optionally pick nth match + which button. */
|
|
3
|
+
export declare const ClickActionSchema: z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"click">;
|
|
5
|
+
selector: z.ZodString;
|
|
6
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
button: z.ZodDefault<z.ZodEnum<["left", "middle", "right"]>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
type: "click";
|
|
10
|
+
selector: string;
|
|
11
|
+
button: "left" | "middle" | "right";
|
|
12
|
+
nth?: number | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
type: "click";
|
|
15
|
+
selector: string;
|
|
16
|
+
nth?: number | undefined;
|
|
17
|
+
button?: "left" | "middle" | "right" | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export type ClickAction = z.infer<typeof ClickActionSchema>;
|
|
20
|
+
/** Type into an input. `delay` is per-character in ms. */
|
|
21
|
+
export declare const TypeActionSchema: z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"type">;
|
|
23
|
+
selector: z.ZodString;
|
|
24
|
+
text: z.ZodString;
|
|
25
|
+
delay: z.ZodDefault<z.ZodNumber>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
type: "type";
|
|
28
|
+
selector: string;
|
|
29
|
+
text: string;
|
|
30
|
+
delay: number;
|
|
31
|
+
}, {
|
|
32
|
+
type: "type";
|
|
33
|
+
selector: string;
|
|
34
|
+
text: string;
|
|
35
|
+
delay?: number | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export type TypeAction = z.infer<typeof TypeActionSchema>;
|
|
38
|
+
/** Top-frame navigation to a URL. */
|
|
39
|
+
export declare const NavigateActionSchema: z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<"navigate">;
|
|
41
|
+
url: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
type: "navigate";
|
|
44
|
+
url: string;
|
|
45
|
+
}, {
|
|
46
|
+
type: "navigate";
|
|
47
|
+
url: string;
|
|
48
|
+
}>;
|
|
49
|
+
export type NavigateAction = z.infer<typeof NavigateActionSchema>;
|
|
50
|
+
/** History.back / forward / location.reload — no DOM target. */
|
|
51
|
+
export declare const BackActionSchema: z.ZodObject<{
|
|
52
|
+
type: z.ZodLiteral<"back">;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
type: "back";
|
|
55
|
+
}, {
|
|
56
|
+
type: "back";
|
|
57
|
+
}>;
|
|
58
|
+
export type BackAction = z.infer<typeof BackActionSchema>;
|
|
59
|
+
export declare const ForwardActionSchema: z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"forward">;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
type: "forward";
|
|
63
|
+
}, {
|
|
64
|
+
type: "forward";
|
|
65
|
+
}>;
|
|
66
|
+
export type ForwardAction = z.infer<typeof ForwardActionSchema>;
|
|
67
|
+
export declare const ReloadActionSchema: z.ZodObject<{
|
|
68
|
+
type: z.ZodLiteral<"reload">;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
type: "reload";
|
|
71
|
+
}, {
|
|
72
|
+
type: "reload";
|
|
73
|
+
}>;
|
|
74
|
+
export type ReloadAction = z.infer<typeof ReloadActionSchema>;
|
|
75
|
+
/** Scroll: either to absolute (x,y) or scrollIntoView on the selected element. */
|
|
76
|
+
export declare const ScrollActionSchema: z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<"scroll">;
|
|
78
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
79
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
type: "scroll";
|
|
83
|
+
selector?: string | undefined;
|
|
84
|
+
x?: number | undefined;
|
|
85
|
+
y?: number | undefined;
|
|
86
|
+
}, {
|
|
87
|
+
type: "scroll";
|
|
88
|
+
selector?: string | undefined;
|
|
89
|
+
x?: number | undefined;
|
|
90
|
+
y?: number | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
export type ScrollAction = z.infer<typeof ScrollActionSchema>;
|
|
93
|
+
/** chrome.tabs.captureVisibleTab — non-mutating, but still a Level-3+ tool. */
|
|
94
|
+
export declare const ScreenshotActionSchema: z.ZodObject<{
|
|
95
|
+
type: z.ZodLiteral<"screenshot">;
|
|
96
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
type: "screenshot";
|
|
99
|
+
selector?: string | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
type: "screenshot";
|
|
102
|
+
selector?: string | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
export type ScreenshotAction = z.infer<typeof ScreenshotActionSchema>;
|
|
105
|
+
/** Wait for a selector to appear or timeoutMs to elapse, whichever first. */
|
|
106
|
+
export declare const WaitForActionSchema: z.ZodObject<{
|
|
107
|
+
type: z.ZodLiteral<"waitFor">;
|
|
108
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
109
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
type: "waitFor";
|
|
112
|
+
timeoutMs: number;
|
|
113
|
+
selector?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
type: "waitFor";
|
|
116
|
+
selector?: string | undefined;
|
|
117
|
+
timeoutMs?: number | undefined;
|
|
118
|
+
}>;
|
|
119
|
+
export type WaitForAction = z.infer<typeof WaitForActionSchema>;
|
|
120
|
+
/** The full Action discriminated union (P2 PRD §E.4). */
|
|
121
|
+
export declare const ActionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
122
|
+
type: z.ZodLiteral<"click">;
|
|
123
|
+
selector: z.ZodString;
|
|
124
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
125
|
+
button: z.ZodDefault<z.ZodEnum<["left", "middle", "right"]>>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
type: "click";
|
|
128
|
+
selector: string;
|
|
129
|
+
button: "left" | "middle" | "right";
|
|
130
|
+
nth?: number | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
type: "click";
|
|
133
|
+
selector: string;
|
|
134
|
+
nth?: number | undefined;
|
|
135
|
+
button?: "left" | "middle" | "right" | undefined;
|
|
136
|
+
}>, z.ZodObject<{
|
|
137
|
+
type: z.ZodLiteral<"type">;
|
|
138
|
+
selector: z.ZodString;
|
|
139
|
+
text: z.ZodString;
|
|
140
|
+
delay: z.ZodDefault<z.ZodNumber>;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
type: "type";
|
|
143
|
+
selector: string;
|
|
144
|
+
text: string;
|
|
145
|
+
delay: number;
|
|
146
|
+
}, {
|
|
147
|
+
type: "type";
|
|
148
|
+
selector: string;
|
|
149
|
+
text: string;
|
|
150
|
+
delay?: number | undefined;
|
|
151
|
+
}>, z.ZodObject<{
|
|
152
|
+
type: z.ZodLiteral<"navigate">;
|
|
153
|
+
url: z.ZodString;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
type: "navigate";
|
|
156
|
+
url: string;
|
|
157
|
+
}, {
|
|
158
|
+
type: "navigate";
|
|
159
|
+
url: string;
|
|
160
|
+
}>, z.ZodObject<{
|
|
161
|
+
type: z.ZodLiteral<"back">;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
type: "back";
|
|
164
|
+
}, {
|
|
165
|
+
type: "back";
|
|
166
|
+
}>, z.ZodObject<{
|
|
167
|
+
type: z.ZodLiteral<"forward">;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
type: "forward";
|
|
170
|
+
}, {
|
|
171
|
+
type: "forward";
|
|
172
|
+
}>, z.ZodObject<{
|
|
173
|
+
type: z.ZodLiteral<"reload">;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
type: "reload";
|
|
176
|
+
}, {
|
|
177
|
+
type: "reload";
|
|
178
|
+
}>, z.ZodObject<{
|
|
179
|
+
type: z.ZodLiteral<"scroll">;
|
|
180
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
181
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
182
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
183
|
+
}, "strip", z.ZodTypeAny, {
|
|
184
|
+
type: "scroll";
|
|
185
|
+
selector?: string | undefined;
|
|
186
|
+
x?: number | undefined;
|
|
187
|
+
y?: number | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
type: "scroll";
|
|
190
|
+
selector?: string | undefined;
|
|
191
|
+
x?: number | undefined;
|
|
192
|
+
y?: number | undefined;
|
|
193
|
+
}>, z.ZodObject<{
|
|
194
|
+
type: z.ZodLiteral<"screenshot">;
|
|
195
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
196
|
+
}, "strip", z.ZodTypeAny, {
|
|
197
|
+
type: "screenshot";
|
|
198
|
+
selector?: string | undefined;
|
|
199
|
+
}, {
|
|
200
|
+
type: "screenshot";
|
|
201
|
+
selector?: string | undefined;
|
|
202
|
+
}>, z.ZodObject<{
|
|
203
|
+
type: z.ZodLiteral<"waitFor">;
|
|
204
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
205
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
206
|
+
}, "strip", z.ZodTypeAny, {
|
|
207
|
+
type: "waitFor";
|
|
208
|
+
timeoutMs: number;
|
|
209
|
+
selector?: string | undefined;
|
|
210
|
+
}, {
|
|
211
|
+
type: "waitFor";
|
|
212
|
+
selector?: string | undefined;
|
|
213
|
+
timeoutMs?: number | undefined;
|
|
214
|
+
}>]>;
|
|
215
|
+
export type Action = z.infer<typeof ActionSchema>;
|
|
216
|
+
/**
|
|
217
|
+
* Mask the action's sensitive fields for audit-log persistence. `type`
|
|
218
|
+
* `text` (TypeAction) and `url` query strings can carry passwords / tokens.
|
|
219
|
+
* We don't have access to the masking primitives via z's own pipeline, so
|
|
220
|
+
* this is a small explicit helper. Lossy by design.
|
|
221
|
+
*/
|
|
222
|
+
export declare function redactActionForAudit(action: Action): Action;
|
|
223
|
+
//# sourceMappingURL=action-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-schema.d.ts","sour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C,CAAC;AAEtE,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAI9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,yDAAyD;AACzD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUvB,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,CAqB3D"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Action zod schemas (P2 PRD §E.4) used by the two Level-3+ MCP write tools
|
|
2
|
+
// (Task 3.24): `execute_action` validates `Action`, and `request_authorization`
|
|
3
|
+
// accepts the same shape so the side panel banner can describe what it's about
|
|
4
|
+
// to do.
|
|
5
|
+
//
|
|
6
|
+
// Discriminated union on `type` — the SDK auto-converts zod to JSON Schema for
|
|
7
|
+
// MCP tool listings, and clients send back a tagged object the host routes to
|
|
8
|
+
// the MAIN-world dispatcher.
|
|
9
|
+
//
|
|
10
|
+
// Keep this in sync with the dispatcher in
|
|
11
|
+
// `packages/peek-extension/src/permissions/dispatcher.ts`. New `type`s land
|
|
12
|
+
// here first (the source of truth for tool inputSchema), then the dispatcher
|
|
13
|
+
// grows a matching case.
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
/** Click on a selector. Optionally pick nth match + which button. */
|
|
16
|
+
export const ClickActionSchema = z.object({
|
|
17
|
+
type: z.literal('click'),
|
|
18
|
+
selector: z.string().min(1),
|
|
19
|
+
nth: z.number().int().min(0).optional(),
|
|
20
|
+
button: z.enum(['left', 'middle', 'right']).default('left'),
|
|
21
|
+
});
|
|
22
|
+
/** Type into an input. `delay` is per-character in ms. */
|
|
23
|
+
export const TypeActionSchema = z.object({
|
|
24
|
+
type: z.literal('type'),
|
|
25
|
+
selector: z.string().min(1),
|
|
26
|
+
text: z.string(),
|
|
27
|
+
delay: z.number().int().min(0).default(40),
|
|
28
|
+
});
|
|
29
|
+
/** Top-frame navigation to a URL. */
|
|
30
|
+
export const NavigateActionSchema = z.object({
|
|
31
|
+
type: z.literal('navigate'),
|
|
32
|
+
url: z.string().url(),
|
|
33
|
+
});
|
|
34
|
+
/** History.back / forward / location.reload — no DOM target. */
|
|
35
|
+
export const BackActionSchema = z.object({ type: z.literal('back') });
|
|
36
|
+
export const ForwardActionSchema = z.object({ type: z.literal('forward') });
|
|
37
|
+
export const ReloadActionSchema = z.object({ type: z.literal('reload') });
|
|
38
|
+
/** Scroll: either to absolute (x,y) or scrollIntoView on the selected element. */
|
|
39
|
+
export const ScrollActionSchema = z.object({
|
|
40
|
+
type: z.literal('scroll'),
|
|
41
|
+
selector: z.string().optional(),
|
|
42
|
+
x: z.number().int().optional(),
|
|
43
|
+
y: z.number().int().optional(),
|
|
44
|
+
});
|
|
45
|
+
/** chrome.tabs.captureVisibleTab — non-mutating, but still a Level-3+ tool. */
|
|
46
|
+
export const ScreenshotActionSchema = z.object({
|
|
47
|
+
type: z.literal('screenshot'),
|
|
48
|
+
selector: z.string().optional(),
|
|
49
|
+
});
|
|
50
|
+
/** Wait for a selector to appear or timeoutMs to elapse, whichever first. */
|
|
51
|
+
export const WaitForActionSchema = z.object({
|
|
52
|
+
type: z.literal('waitFor'),
|
|
53
|
+
selector: z.string().optional(),
|
|
54
|
+
timeoutMs: z.number().int().min(0).default(5000),
|
|
55
|
+
});
|
|
56
|
+
/** The full Action discriminated union (P2 PRD §E.4). */
|
|
57
|
+
export const ActionSchema = z.discriminatedUnion('type', [
|
|
58
|
+
ClickActionSchema,
|
|
59
|
+
TypeActionSchema,
|
|
60
|
+
NavigateActionSchema,
|
|
61
|
+
BackActionSchema,
|
|
62
|
+
ForwardActionSchema,
|
|
63
|
+
ReloadActionSchema,
|
|
64
|
+
ScrollActionSchema,
|
|
65
|
+
ScreenshotActionSchema,
|
|
66
|
+
WaitForActionSchema,
|
|
67
|
+
]);
|
|
68
|
+
/**
|
|
69
|
+
* Mask the action's sensitive fields for audit-log persistence. `type`
|
|
70
|
+
* `text` (TypeAction) and `url` query strings can carry passwords / tokens.
|
|
71
|
+
* We don't have access to the masking primitives via z's own pipeline, so
|
|
72
|
+
* this is a small explicit helper. Lossy by design.
|
|
73
|
+
*/
|
|
74
|
+
export function redactActionForAudit(action) {
|
|
75
|
+
switch (action.type) {
|
|
76
|
+
case 'type':
|
|
77
|
+
// Replace the typed text with a token marker so the audit log records
|
|
78
|
+
// that a TypeAction happened on selector X without preserving the value.
|
|
79
|
+
return { ...action, text: '<<REDACTED>>' };
|
|
80
|
+
case 'navigate': {
|
|
81
|
+
// Strip query-string values (params keep their names, see mask.ts).
|
|
82
|
+
try {
|
|
83
|
+
const u = new URL(action.url);
|
|
84
|
+
for (const key of [...u.searchParams.keys()]) {
|
|
85
|
+
u.searchParams.set(key, '<<REDACTED>>');
|
|
86
|
+
}
|
|
87
|
+
return { ...action, url: u.href };
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return action;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
default:
|
|
94
|
+
return action;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=action-schema.js.map
|
|
@@ -0,0 +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,C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AAC,MAAM,YAAY,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACvD,iBAAiB;IACjB,gBAAgB;IAChB,oBAAoB;IACpB,gBAAgB;IAChB,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,sBAAsB;IACtB,mBAAmB;CACpB,CAAC,CAAC;AAGH;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,MAAM;YACT,sEAAsE;YACtE,yEAAyE;YACzE,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;QAC7C,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,oEAAoE;YACpE,IAAI,CAAC;gBACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC9B,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;oBAC7C,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;gBAC1C,CAAC;gBACD,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type eventWithTime } from '@cubenest/rrweb-core';
|
|
2
|
+
/**
|
|
3
|
+
* A blob exists on disk but couldn't be decoded — a corrupt/truncated gzip
|
|
4
|
+
* frame or a payload that doesn't deserialize to an event array. Distinct from
|
|
5
|
+
* "no blob" (which is a normal empty result): a present-but-broken blob is a
|
|
6
|
+
* real, attributable failure the tool surfaces clearly rather than silently
|
|
7
|
+
* treating as zero events.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SessionEventsError extends Error {
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/** Absolute base directory for the gzipped per-session event blobs. */
|
|
15
|
+
export declare function rrwebEventsDir(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a `sessions.events_blob_path` value to an absolute path. The column
|
|
18
|
+
* stores a path relative to {@link rrwebEventsDir}; an absolute value (older
|
|
19
|
+
* rows / tests) is honored as-is.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveBlobPath(blobPath: string, baseDir?: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Read + gunzip + JSON-parse a session's event blob into the rrweb event array.
|
|
24
|
+
* 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 a
|
|
26
|
+
* blob pruned by retention) — callers degrade to "no events" rather than throw.
|
|
27
|
+
*
|
|
28
|
+
* @param blobPath the `sessions.events_blob_path` value (relative or absolute)
|
|
29
|
+
* @param baseDir override the ~/.peek/rrweb-events base (tests)
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadSessionEvents(blobPath: string | null | undefined, baseDir?: string): eventWithTime[];
|
|
32
|
+
//# sourceMappingURL=event-blobs.d.ts.map
|
|
@@ -0,0 +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;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAAyB,GAAG,MAAM,CAE5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,OAAO,GAAE,MAAyB,GACjC,aAAa,EAAE,CAoBjB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Locate + load + decompress a session's rrweb event blob (ADR-0007). The
|
|
2
|
+
// native host persists each session's captured `eventWithTime[]` gzipped under
|
|
3
|
+
// ~/.peek/rrweb-events/, referenced by `sessions.events_blob_path` (a path
|
|
4
|
+
// relative to that directory). The event-level MCP tools
|
|
5
|
+
// (get_user_action_before_error, get_dom_snapshot, query_dom_history,
|
|
6
|
+
// generate_playwright_repro) read the blob through here and walk the decoded
|
|
7
|
+
// stream — the console/network tools read the structured SQL tables directly.
|
|
8
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
9
|
+
import { isAbsolute, join } from 'node:path';
|
|
10
|
+
import { decompress } from '@cubenest/rrweb-core';
|
|
11
|
+
import { peekHomeDir } from '../db/open.js';
|
|
12
|
+
/**
|
|
13
|
+
* A blob exists on disk but couldn't be decoded — a corrupt/truncated gzip
|
|
14
|
+
* frame or a payload that doesn't deserialize to an event array. Distinct from
|
|
15
|
+
* "no blob" (which is a normal empty result): a present-but-broken blob is a
|
|
16
|
+
* real, attributable failure the tool surfaces clearly rather than silently
|
|
17
|
+
* treating as zero events.
|
|
18
|
+
*/
|
|
19
|
+
export class SessionEventsError extends Error {
|
|
20
|
+
constructor(message, options) {
|
|
21
|
+
super(message, options);
|
|
22
|
+
this.name = 'SessionEventsError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Absolute base directory for the gzipped per-session event blobs. */
|
|
26
|
+
export function rrwebEventsDir() {
|
|
27
|
+
return join(peekHomeDir(), 'rrweb-events');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a `sessions.events_blob_path` value to an absolute path. The column
|
|
31
|
+
* stores a path relative to {@link rrwebEventsDir}; an absolute value (older
|
|
32
|
+
* rows / tests) is honored as-is.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveBlobPath(blobPath, baseDir = rrwebEventsDir()) {
|
|
35
|
+
return isAbsolute(blobPath) ? blobPath : join(baseDir, blobPath);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read + gunzip + JSON-parse a session's event blob into the rrweb event array.
|
|
39
|
+
* Returns an empty array when the session has no blob path recorded or the
|
|
40
|
+
* blob file is missing (e.g. an active session before its first flush, or a
|
|
41
|
+
* blob pruned by retention) — callers degrade to "no events" rather than throw.
|
|
42
|
+
*
|
|
43
|
+
* @param blobPath the `sessions.events_blob_path` value (relative or absolute)
|
|
44
|
+
* @param baseDir override the ~/.peek/rrweb-events base (tests)
|
|
45
|
+
*/
|
|
46
|
+
export function loadSessionEvents(blobPath, baseDir = rrwebEventsDir()) {
|
|
47
|
+
if (blobPath === null || blobPath === undefined || blobPath.length === 0) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const abs = resolveBlobPath(blobPath, baseDir);
|
|
51
|
+
if (!existsSync(abs)) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const bytes = readFileSync(abs);
|
|
55
|
+
try {
|
|
56
|
+
// readFileSync returns a Node Buffer; decompress wants a Uint8Array view.
|
|
57
|
+
// decompress throws (fflate gzip error / non-array payload) on a corrupt or
|
|
58
|
+
// truncated blob — translate that into a clear, attributable error.
|
|
59
|
+
return decompress(new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength));
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
throw new SessionEventsError(`Failed to decode the event blob at '${blobPath}' (corrupt or truncated recording).`, { cause: err });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=event-blobs.js.map
|
|
@@ -0,0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,CAAC;IAC/C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC;QACH,0EAA0E;QAC1E,4EAA4E;QAC5E,oEAAoE;QACpE,OAAO,UAAU,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACtF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAC1B,uCAAuC,QAAQ,qCAAqC,EACpF,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type eventWithTime, type serializedNodeWithId } from './rrweb-types.js';
|
|
2
|
+
/** A single extracted user action with the data a repro / explanation needs. */
|
|
3
|
+
export interface UserAction {
|
|
4
|
+
/** 'click' | 'input' | 'navigate' | 'submit' (a click on a submit control). */
|
|
5
|
+
readonly type: 'click' | 'input' | 'navigate';
|
|
6
|
+
/** Epoch-millis of the action (the event's `timestamp`). */
|
|
7
|
+
readonly ts: number;
|
|
8
|
+
/** Derived CSS selector for the target node, when resolvable. */
|
|
9
|
+
readonly selector?: string;
|
|
10
|
+
/** For input actions: the (already-masked-by-capture) value typed. */
|
|
11
|
+
readonly value?: string;
|
|
12
|
+
/** For navigations: the destination URL (Meta event href). */
|
|
13
|
+
readonly url?: string;
|
|
14
|
+
/** A short human description, e.g. `click button.submit`. */
|
|
15
|
+
readonly summary: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Walk the stream and pull out user actions (clicks, input commits, page
|
|
19
|
+
* navigations) in chronological order. The selector for a click/input is
|
|
20
|
+
* derived from whichever FullSnapshot is in effect at that point (rebuilt as
|
|
21
|
+
* new FullSnapshots arrive), with added nodes folded into the index so
|
|
22
|
+
* interactions on dynamically-inserted elements still resolve.
|
|
23
|
+
*
|
|
24
|
+
* Mouse *moves*, scrolls, and non-Click interactions are intentionally dropped
|
|
25
|
+
* — they're noise for repro/explanation and blow the token budget.
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractUserActions(events: eventWithTime[]): UserAction[];
|
|
28
|
+
/** The user actions strictly before `errorTs`, most-recent-last, capped to `window`. */
|
|
29
|
+
export declare function userActionsBeforeError(events: eventWithTime[], errorTs: number, window?: number): UserAction[];
|
|
30
|
+
/**
|
|
31
|
+
* Reconstruct the DOM at timestamp `ts` and render it to an HTML-ish string.
|
|
32
|
+
*
|
|
33
|
+
* v1 scope (deliberately bounded — see the task's "don't rabbit-hole" note):
|
|
34
|
+
* start from the most recent FullSnapshot at or before `ts`, then replay
|
|
35
|
+
* IncrementalSnapshot **mutations** (node adds/removes, attribute changes, text
|
|
36
|
+
* changes) up to and including `ts`. We do NOT run rrweb's Replayer/jsdom; we
|
|
37
|
+
* mutate the serialized tree directly and serialize it back. This faithfully
|
|
38
|
+
* reflects structural/attribute/text state at T — which is what the read tools
|
|
39
|
+
* need — while skipping canvas/media/stylesheet replay (not needed for DOM
|
|
40
|
+
* inspection and out of budget). The offset from the base snapshot is reported
|
|
41
|
+
* so a caller knows how much was applied.
|
|
42
|
+
*
|
|
43
|
+
* Returns `undefined` if there is no FullSnapshot at or before `ts`.
|
|
44
|
+
*/
|
|
45
|
+
export interface DomSnapshot {
|
|
46
|
+
/** Epoch-millis of the FullSnapshot the reconstruction started from. */
|
|
47
|
+
readonly baseSnapshotTs: number;
|
|
48
|
+
/** Number of mutation events applied on top of the base snapshot. */
|
|
49
|
+
readonly mutationsApplied: number;
|
|
50
|
+
/** The serialized (and mutated) document/element subtree. */
|
|
51
|
+
readonly root: serializedNodeWithId;
|
|
52
|
+
/** The rendered HTML-ish string (optionally scoped to a selector subtree). */
|
|
53
|
+
readonly html: string;
|
|
54
|
+
}
|
|
55
|
+
export declare function reconstructDomAt(events: eventWithTime[], ts: number, selector?: string): DomSnapshot | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Render a serialized node tree to an HTML-ish string (lightweight, not
|
|
58
|
+
* spec-perfect). Stops descending past {@link MAX_DOM_DEPTH} — emitting a
|
|
59
|
+
* truncation marker instead of recursing — so an adversarial deeply-nested
|
|
60
|
+
* recording can't overflow the stack (this code ingests untrusted blobs).
|
|
61
|
+
*/
|
|
62
|
+
export declare function serializeNode(node: serializedNodeWithId, depth?: number): string;
|
|
63
|
+
/** A single change in a node's history (query_dom_history). */
|
|
64
|
+
export interface DomChange {
|
|
65
|
+
readonly ts: number;
|
|
66
|
+
readonly op: 'attribute' | 'text' | 'added' | 'removed';
|
|
67
|
+
/** For attribute changes: the attribute name. */
|
|
68
|
+
readonly attribute?: string;
|
|
69
|
+
/** The new value (attribute value / text content); null = removed. */
|
|
70
|
+
readonly value?: string | null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Timeline of attribute and/or text changes for the node a `selector` resolves
|
|
74
|
+
* to in the base FullSnapshot. `op` filters to one dimension; default returns
|
|
75
|
+
* both. Bounded by `limit` for the token budget.
|
|
76
|
+
*
|
|
77
|
+
* v1 resolves the selector against the base FullSnapshot's tree (the common
|
|
78
|
+
* case — querying a stable element). A selector that only matches a
|
|
79
|
+
* dynamically-added node is not resolved here; that's a documented v1 limit.
|
|
80
|
+
*/
|
|
81
|
+
export interface QueryDomHistoryOptions {
|
|
82
|
+
readonly op?: 'attributeChanges' | 'innerText';
|
|
83
|
+
readonly limit?: number;
|
|
84
|
+
}
|
|
85
|
+
export declare function queryDomHistory(events: eventWithTime[], selector: string, options?: QueryDomHistoryOptions): DomChange[];
|
|
86
|
+
//# sourceMappingURL=event-walker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-walker.d.ts","sourceRoot":"","sources":["../../src/mcp/event-walker.ts"],"names":[],"mappings":"AAoBA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