@ericmhalvorsen/aperture 0.2.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/README.md +148 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +64 -0
- package/dist/client/handlers.d.ts +2 -0
- package/dist/client/handlers.js +171 -0
- package/dist/client/patches.d.ts +18 -0
- package/dist/client/patches.js +56 -0
- package/dist/client/storage.d.ts +5 -0
- package/dist/client/storage.js +31 -0
- package/dist/client/ui.d.ts +26 -0
- package/dist/client/ui.js +600 -0
- package/dist/client.d.ts +60 -0
- package/dist/client.js +435 -0
- package/dist/frameworks/next.d.ts +3 -0
- package/dist/frameworks/next.js +12 -0
- package/dist/frameworks/shared.d.ts +1 -0
- package/dist/frameworks/shared.js +61 -0
- package/dist/frameworks/vite.d.ts +10 -0
- package/dist/frameworks/vite.js +22 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/mcp-server.d.ts +39 -0
- package/dist/mcp-server.js +237 -0
- package/dist/react.d.ts +8 -0
- package/dist/react.js +20 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +2 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.js +315 -0
- package/dist/tools.d.ts +165 -0
- package/dist/tools.js +161 -0
- package/dist/transports.d.ts +29 -0
- package/dist/transports.js +86 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.js +1 -0
- package/dist-browser/client.js +457 -0
- package/package.json +123 -0
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export declare const BROWSER_TOOLS: {
|
|
2
|
+
readonly browser_dom_query: {
|
|
3
|
+
readonly description: "Query the DOM using a CSS selector. Returns matched elements with their tag, text content, attributes, and visibility. Always prefer targeted selectors (e.g. '#app h1', '.nav-links a') over broad ones like 'body' or 'html'.";
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly selector: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "CSS selector (e.g., '#app h1', '.error')";
|
|
10
|
+
};
|
|
11
|
+
readonly includeHtml: {
|
|
12
|
+
readonly type: "boolean";
|
|
13
|
+
readonly default: false;
|
|
14
|
+
readonly description: "Include outer HTML for each matched element";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
readonly required: readonly ["selector"];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly browser_network_requests: {
|
|
21
|
+
readonly description: "Return recent network requests (fetch/XHR) captured by the bridge. Returns an array of request objects with method, URL, status, and timing. Only captures fetch() calls — XHR is not intercepted.";
|
|
22
|
+
readonly inputSchema: {
|
|
23
|
+
readonly type: "object";
|
|
24
|
+
readonly properties: {
|
|
25
|
+
readonly limit: {
|
|
26
|
+
readonly type: "integer";
|
|
27
|
+
readonly default: 20;
|
|
28
|
+
readonly description: "Max number of requests to return";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly browser_page_info: {
|
|
34
|
+
readonly description: "Get the current state of the page: URL, title, viewport dimensions, scroll position, user agent, and recent console logs. Use this to orient yourself before querying specific elements.";
|
|
35
|
+
readonly inputSchema: {
|
|
36
|
+
readonly type: "object";
|
|
37
|
+
readonly properties: {
|
|
38
|
+
readonly logLimit: {
|
|
39
|
+
readonly type: "integer";
|
|
40
|
+
readonly default: 20;
|
|
41
|
+
readonly description: "Max number of console log entries to include";
|
|
42
|
+
};
|
|
43
|
+
readonly logLevel: {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
readonly enum: readonly ["all", "log", "warn", "error", "info"];
|
|
46
|
+
readonly default: "all";
|
|
47
|
+
readonly description: "Filter console logs by level";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
readonly browser_storage_get: {
|
|
53
|
+
readonly description: "Read values from browser storage. Use type='localStorage' to read localStorage entries (by exact key, prefix, or all). Use type='cookie' to read document cookies (by exact name or all).";
|
|
54
|
+
readonly inputSchema: {
|
|
55
|
+
readonly type: "object";
|
|
56
|
+
readonly properties: {
|
|
57
|
+
readonly type: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly enum: readonly ["localStorage", "cookie"];
|
|
60
|
+
readonly description: "Storage type to read from";
|
|
61
|
+
};
|
|
62
|
+
readonly key: {
|
|
63
|
+
readonly type: "string";
|
|
64
|
+
readonly description: "Exact key to read from localStorage (localStorage only)";
|
|
65
|
+
};
|
|
66
|
+
readonly prefix: {
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
readonly description: "Key prefix to match in localStorage — returns all keys starting with this string (localStorage only)";
|
|
69
|
+
};
|
|
70
|
+
readonly name: {
|
|
71
|
+
readonly type: "string";
|
|
72
|
+
readonly description: "Exact cookie name to retrieve (cookie only). If omitted, returns all cookies.";
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
readonly required: readonly ["type"];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly browser_screenshot: {
|
|
79
|
+
readonly description: "Capture a screenshot of the current viewport as base64 PNG. NOTE: If the user has not yet granted screenshot access for this browser session, an approval modal will appear in the page. Ask the user to click 'Allow' in the dialog before proceeding.";
|
|
80
|
+
readonly inputSchema: {
|
|
81
|
+
readonly type: "object";
|
|
82
|
+
readonly properties: {
|
|
83
|
+
readonly selector: {
|
|
84
|
+
readonly type: "string";
|
|
85
|
+
readonly description: "Optional: screenshot a specific element instead of full viewport";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly browser_evaluate: {
|
|
91
|
+
readonly description: "Evaluate JavaScript in the page context and return the result as a string. Objects are JSON-serialized. NOTE: This requires explicit user approval. If not yet approved, a dialog will appear in the page — ask the user to click 'Allow' before proceeding.";
|
|
92
|
+
readonly inputSchema: {
|
|
93
|
+
readonly type: "object";
|
|
94
|
+
readonly properties: {
|
|
95
|
+
readonly expression: {
|
|
96
|
+
readonly type: "string";
|
|
97
|
+
readonly description: "JavaScript expression to evaluate";
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
readonly required: readonly ["expression"];
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
readonly browser_click: {
|
|
104
|
+
readonly description: "Click an element on the page using a CSS selector. Dispatches the full pointer/mouse event sequence (pointerdown, mousedown, pointerup, mouseup, click) for maximum compatibility with frameworks. Returns success or an error if the element is not found.";
|
|
105
|
+
readonly inputSchema: {
|
|
106
|
+
readonly type: "object";
|
|
107
|
+
readonly properties: {
|
|
108
|
+
readonly selector: {
|
|
109
|
+
readonly type: "string";
|
|
110
|
+
readonly description: "CSS selector of the element to click";
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
readonly required: readonly ["selector"];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
readonly browser_type: {
|
|
117
|
+
readonly description: "Type text into an input, textarea, or contenteditable element. Uses native value setters to trigger framework change handlers. Dispatches 'input' and 'change' events after setting the value.";
|
|
118
|
+
readonly inputSchema: {
|
|
119
|
+
readonly type: "object";
|
|
120
|
+
readonly properties: {
|
|
121
|
+
readonly selector: {
|
|
122
|
+
readonly type: "string";
|
|
123
|
+
readonly description: "CSS selector of the input element";
|
|
124
|
+
};
|
|
125
|
+
readonly text: {
|
|
126
|
+
readonly type: "string";
|
|
127
|
+
readonly description: "Text to type";
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
readonly required: readonly ["selector", "text"];
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
readonly browser_scroll: {
|
|
134
|
+
readonly description: "Scroll the page or a specific element to a position, or scroll an element into view. Without coordinates, scrolls to the specified x/y offset. With scrollIntoView=true, smoothly scrolls the element into the viewport center.";
|
|
135
|
+
readonly inputSchema: {
|
|
136
|
+
readonly type: "object";
|
|
137
|
+
readonly properties: {
|
|
138
|
+
readonly selector: {
|
|
139
|
+
readonly type: "string";
|
|
140
|
+
readonly description: "Optional CSS selector of the element to scroll. If omitted, scrolls the window.";
|
|
141
|
+
};
|
|
142
|
+
readonly x: {
|
|
143
|
+
readonly type: "integer";
|
|
144
|
+
readonly description: "Horizontal scroll position in pixels";
|
|
145
|
+
};
|
|
146
|
+
readonly y: {
|
|
147
|
+
readonly type: "integer";
|
|
148
|
+
readonly description: "Vertical scroll position in pixels";
|
|
149
|
+
};
|
|
150
|
+
readonly scrollIntoView: {
|
|
151
|
+
readonly type: "boolean";
|
|
152
|
+
readonly description: "If true, scrolls the target element into view (requires selector).";
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
readonly browser_list_sessions: {
|
|
158
|
+
readonly description: "List all connected browser sessions with metadata (URL, title, approval status). Use this to choose which session to interact with when multiple tabs are connected.";
|
|
159
|
+
readonly inputSchema: {
|
|
160
|
+
readonly type: "object";
|
|
161
|
+
readonly properties: {};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export type BrowserToolName = keyof typeof BROWSER_TOOLS;
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
export const BROWSER_TOOLS = {
|
|
2
|
+
browser_dom_query: {
|
|
3
|
+
description: "Query the DOM using a CSS selector. Returns matched elements with their tag, text content, attributes, and visibility. Always prefer targeted selectors (e.g. '#app h1', '.nav-links a') over broad ones like 'body' or 'html'.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
selector: {
|
|
8
|
+
type: "string",
|
|
9
|
+
description: "CSS selector (e.g., '#app h1', '.error')",
|
|
10
|
+
},
|
|
11
|
+
includeHtml: {
|
|
12
|
+
type: "boolean",
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Include outer HTML for each matched element",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ["selector"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
browser_network_requests: {
|
|
21
|
+
description: "Return recent network requests (fetch/XHR) captured by the bridge. Returns an array of request objects with method, URL, status, and timing. Only captures fetch() calls — XHR is not intercepted.",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
limit: {
|
|
26
|
+
type: "integer",
|
|
27
|
+
default: 20,
|
|
28
|
+
description: "Max number of requests to return",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
browser_page_info: {
|
|
34
|
+
description: "Get the current state of the page: URL, title, viewport dimensions, scroll position, user agent, and recent console logs. Use this to orient yourself before querying specific elements.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
logLimit: {
|
|
39
|
+
type: "integer",
|
|
40
|
+
default: 20,
|
|
41
|
+
description: "Max number of console log entries to include",
|
|
42
|
+
},
|
|
43
|
+
logLevel: {
|
|
44
|
+
type: "string",
|
|
45
|
+
enum: ["all", "log", "warn", "error", "info"],
|
|
46
|
+
default: "all",
|
|
47
|
+
description: "Filter console logs by level",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
browser_storage_get: {
|
|
53
|
+
description: "Read values from browser storage. Use type='localStorage' to read localStorage entries (by exact key, prefix, or all). Use type='cookie' to read document cookies (by exact name or all).",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
type: {
|
|
58
|
+
type: "string",
|
|
59
|
+
enum: ["localStorage", "cookie"],
|
|
60
|
+
description: "Storage type to read from",
|
|
61
|
+
},
|
|
62
|
+
key: {
|
|
63
|
+
type: "string",
|
|
64
|
+
description: "Exact key to read from localStorage (localStorage only)",
|
|
65
|
+
},
|
|
66
|
+
prefix: {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Key prefix to match in localStorage — returns all keys starting with this string (localStorage only)",
|
|
69
|
+
},
|
|
70
|
+
name: {
|
|
71
|
+
type: "string",
|
|
72
|
+
description: "Exact cookie name to retrieve (cookie only). If omitted, returns all cookies.",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
required: ["type"],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
browser_screenshot: {
|
|
79
|
+
description: "Capture a screenshot of the current viewport as base64 PNG. NOTE: If the user has not yet granted screenshot access for this browser session, an approval modal will appear in the page. Ask the user to click 'Allow' in the dialog before proceeding.",
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: "object",
|
|
82
|
+
properties: {
|
|
83
|
+
selector: {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "Optional: screenshot a specific element instead of full viewport",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
browser_evaluate: {
|
|
91
|
+
description: "Evaluate JavaScript in the page context and return the result as a string. Objects are JSON-serialized. NOTE: This requires explicit user approval. If not yet approved, a dialog will appear in the page — ask the user to click 'Allow' before proceeding.",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {
|
|
95
|
+
expression: {
|
|
96
|
+
type: "string",
|
|
97
|
+
description: "JavaScript expression to evaluate",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ["expression"],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
browser_click: {
|
|
104
|
+
description: "Click an element on the page using a CSS selector. Dispatches the full pointer/mouse event sequence (pointerdown, mousedown, pointerup, mouseup, click) for maximum compatibility with frameworks. Returns success or an error if the element is not found.",
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
selector: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "CSS selector of the element to click",
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
required: ["selector"],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
browser_type: {
|
|
117
|
+
description: "Type text into an input, textarea, or contenteditable element. Uses native value setters to trigger framework change handlers. Dispatches 'input' and 'change' events after setting the value.",
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
properties: {
|
|
121
|
+
selector: {
|
|
122
|
+
type: "string",
|
|
123
|
+
description: "CSS selector of the input element",
|
|
124
|
+
},
|
|
125
|
+
text: { type: "string", description: "Text to type" },
|
|
126
|
+
},
|
|
127
|
+
required: ["selector", "text"],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
browser_scroll: {
|
|
131
|
+
description: "Scroll the page or a specific element to a position, or scroll an element into view. Without coordinates, scrolls to the specified x/y offset. With scrollIntoView=true, smoothly scrolls the element into the viewport center.",
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: "object",
|
|
134
|
+
properties: {
|
|
135
|
+
selector: {
|
|
136
|
+
type: "string",
|
|
137
|
+
description: "Optional CSS selector of the element to scroll. If omitted, scrolls the window.",
|
|
138
|
+
},
|
|
139
|
+
x: {
|
|
140
|
+
type: "integer",
|
|
141
|
+
description: "Horizontal scroll position in pixels",
|
|
142
|
+
},
|
|
143
|
+
y: {
|
|
144
|
+
type: "integer",
|
|
145
|
+
description: "Vertical scroll position in pixels",
|
|
146
|
+
},
|
|
147
|
+
scrollIntoView: {
|
|
148
|
+
type: "boolean",
|
|
149
|
+
description: "If true, scrolls the target element into view (requires selector).",
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
browser_list_sessions: {
|
|
155
|
+
description: "List all connected browser sessions with metadata (URL, title, approval status). Use this to choose which session to interact with when multiple tabs are connected.",
|
|
156
|
+
inputSchema: {
|
|
157
|
+
type: "object",
|
|
158
|
+
properties: {},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
|
+
import type { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { WebSocket } from "ws";
|
|
5
|
+
export declare class WebSocketTransport implements Transport {
|
|
6
|
+
private ws;
|
|
7
|
+
onclose?: () => void;
|
|
8
|
+
onerror?: (error: Error) => void;
|
|
9
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
10
|
+
sessionId: string;
|
|
11
|
+
constructor(ws: WebSocket);
|
|
12
|
+
start(): Promise<void>;
|
|
13
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare class SseTransport implements Transport {
|
|
17
|
+
private res;
|
|
18
|
+
onclose?: () => void;
|
|
19
|
+
onerror?: (error: Error) => void;
|
|
20
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
constructor(res: ServerResponse);
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
receiveMessage(message: JSONRPCMessage): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function parseJsonRpcBody(req: IncomingMessage): Promise<JSONRPCMessage>;
|
|
29
|
+
export declare function writeParseError(res: ServerResponse): void;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { WebSocket } from "ws";
|
|
2
|
+
export class WebSocketTransport {
|
|
3
|
+
ws;
|
|
4
|
+
onclose;
|
|
5
|
+
onerror;
|
|
6
|
+
onmessage;
|
|
7
|
+
sessionId;
|
|
8
|
+
constructor(ws) {
|
|
9
|
+
this.ws = ws;
|
|
10
|
+
this.sessionId = crypto.randomUUID();
|
|
11
|
+
ws.on("message", (raw) => {
|
|
12
|
+
try {
|
|
13
|
+
const msg = JSON.parse(raw.toString());
|
|
14
|
+
this.onmessage?.(msg);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
this.onerror?.(err instanceof Error ? err : new Error(String(err)));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
ws.on("close", () => {
|
|
21
|
+
this.onclose?.();
|
|
22
|
+
});
|
|
23
|
+
ws.on("error", (err) => {
|
|
24
|
+
this.onerror?.(err);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async start() { }
|
|
28
|
+
async send(message) {
|
|
29
|
+
if (this.ws.readyState === WebSocket.OPEN) {
|
|
30
|
+
this.ws.send(JSON.stringify(message));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async close() {
|
|
34
|
+
this.ws.close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class SseTransport {
|
|
38
|
+
res;
|
|
39
|
+
onclose;
|
|
40
|
+
onerror;
|
|
41
|
+
onmessage;
|
|
42
|
+
sessionId;
|
|
43
|
+
constructor(res) {
|
|
44
|
+
this.res = res;
|
|
45
|
+
this.sessionId = crypto.randomUUID();
|
|
46
|
+
res.on("close", () => {
|
|
47
|
+
this.onclose?.();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async start() { }
|
|
51
|
+
async send(message) {
|
|
52
|
+
const data = JSON.stringify(message);
|
|
53
|
+
this.res.write(`event: message\ndata: ${data}\n\n`);
|
|
54
|
+
}
|
|
55
|
+
async close() {
|
|
56
|
+
this.res.end();
|
|
57
|
+
}
|
|
58
|
+
receiveMessage(message) {
|
|
59
|
+
this.onmessage?.(message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export async function parseJsonRpcBody(req) {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
let body = "";
|
|
65
|
+
req.on("data", (chunk) => {
|
|
66
|
+
body += chunk;
|
|
67
|
+
});
|
|
68
|
+
req.on("end", () => {
|
|
69
|
+
try {
|
|
70
|
+
resolve(JSON.parse(body));
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
reject(err);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
req.on("error", (err) => reject(err));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export function writeParseError(res) {
|
|
80
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
81
|
+
res.end(JSON.stringify({
|
|
82
|
+
jsonrpc: "2.0",
|
|
83
|
+
id: null,
|
|
84
|
+
error: { code: -32700, message: "Parse error" },
|
|
85
|
+
}));
|
|
86
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface ToolMetadata {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: object;
|
|
5
|
+
}
|
|
6
|
+
interface WSRegisterMessage {
|
|
7
|
+
type: "register";
|
|
8
|
+
url: string;
|
|
9
|
+
title: string;
|
|
10
|
+
customTools?: ToolMetadata[];
|
|
11
|
+
}
|
|
12
|
+
interface WSRegisteredMessage {
|
|
13
|
+
type: "registered";
|
|
14
|
+
sessionId: string;
|
|
15
|
+
}
|
|
16
|
+
interface WSAgentConnectedMessage {
|
|
17
|
+
type: "agent_connected";
|
|
18
|
+
}
|
|
19
|
+
interface WSApprovalMessage {
|
|
20
|
+
type: "approval";
|
|
21
|
+
approved: boolean;
|
|
22
|
+
capabilities?: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface WSToolCallMessage {
|
|
25
|
+
type: "tool_call";
|
|
26
|
+
requestId: string;
|
|
27
|
+
tool: string;
|
|
28
|
+
args: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
interface WSFocusMessage {
|
|
31
|
+
type: "focus";
|
|
32
|
+
focused: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface WSResultMessage {
|
|
35
|
+
type: "result";
|
|
36
|
+
requestId: string;
|
|
37
|
+
result: unknown;
|
|
38
|
+
}
|
|
39
|
+
export type ClientToServerMessage = WSRegisterMessage | WSApprovalMessage | WSFocusMessage | WSResultMessage;
|
|
40
|
+
export type ServerToClientMessage = WSRegisteredMessage | WSAgentConnectedMessage | WSToolCallMessage;
|
|
41
|
+
export interface BrowserSession {
|
|
42
|
+
ws: import("ws").WebSocket;
|
|
43
|
+
url: string;
|
|
44
|
+
title: string;
|
|
45
|
+
approved: boolean;
|
|
46
|
+
lastActiveAt: number;
|
|
47
|
+
capabilities: Set<string>;
|
|
48
|
+
customTools?: ToolMetadata[];
|
|
49
|
+
}
|
|
50
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|