@zibby/mcp-browser 0.1.0 → 0.1.6

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.
@@ -1,197 +0,0 @@
1
- "use strict";
2
- const __create = Object.create;
3
- const __defProp = Object.defineProperty;
4
- const __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- const __getOwnPropNames = Object.getOwnPropertyNames;
6
- const __getProtoOf = Object.getPrototypeOf;
7
- const __hasOwnProp = Object.prototype.hasOwnProperty;
8
- const __export = (target, all) => {
9
- for (const name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- const __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (const key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- const __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- const __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- const snapshot_exports = {};
30
- __export(snapshot_exports, {
31
- default: () => snapshot_default,
32
- elementSchema: () => elementSchema
33
- });
34
- module.exports = __toCommonJS(snapshot_exports);
35
- const import_bundle = require("../../sdk/bundle");
36
- const import_tool = require("./tool");
37
- const javascript = __toESM(require("../codegen"));
38
- const snapshot = (0, import_tool.defineTool)({
39
- capability: "core",
40
- schema: {
41
- name: "browser_snapshot",
42
- title: "Page snapshot",
43
- description: "Capture accessibility snapshot of the current page, this is better than screenshot",
44
- inputSchema: import_bundle.z.object({}),
45
- type: "readOnly"
46
- },
47
- handle: async (context, params, response) => {
48
- await context.ensureTab();
49
- response.setIncludeSnapshot("full");
50
- // ZIBBY: Record snapshot event
51
- if (typeof global.__zibbyRecordEvent === 'function') {
52
- global.__zibbyRecordEvent('snapshot', {});
53
- }
54
- }
55
- });
56
- const elementSchema = import_bundle.z.object({
57
- element: import_bundle.z.string().describe("Human-readable element description used to obtain permission to interact with the element"),
58
- ref: import_bundle.z.string().describe("Exact target element reference from the page snapshot")
59
- });
60
- const clickSchema = elementSchema.extend({
61
- doubleClick: import_bundle.z.boolean().optional().describe("Whether to perform a double click instead of a single click"),
62
- button: import_bundle.z.enum(["left", "right", "middle"]).optional().describe("Button to click, defaults to left"),
63
- modifiers: import_bundle.z.array(import_bundle.z.enum(["Alt", "Control", "ControlOrMeta", "Meta", "Shift"])).optional().describe("Modifier keys to press")
64
- });
65
- const click = (0, import_tool.defineTabTool)({
66
- capability: "core",
67
- schema: {
68
- name: "browser_click",
69
- title: "Click",
70
- description: "Perform click on a web page",
71
- inputSchema: clickSchema,
72
- type: "input"
73
- },
74
- handle: async (tab, params, response) => {
75
- response.setIncludeSnapshot();
76
- const { locator, resolved, stableId } = await tab.refLocator(params);
77
- const options = {
78
- button: params.button,
79
- modifiers: params.modifiers
80
- };
81
- const formatted = javascript.formatObject(options, " ", "oneline");
82
- const optionsAttr = formatted !== "{}" ? formatted : "";
83
- if (params.doubleClick)
84
- response.addCode(`await page.${resolved}.dblclick(${optionsAttr});`);
85
- else
86
- response.addCode(`await page.${resolved}.click(${optionsAttr});`);
87
- await tab.waitForCompletion(async () => {
88
- if (params.doubleClick)
89
- await locator.dblclick(options);
90
- else
91
- await locator.click(options);
92
- });
93
- // ZIBBY: Record event with stable ID
94
- if (typeof global.__zibbyRecordEvent === 'function') {
95
- global.__zibbyRecordEvent('click', { element: params.element, ref: params.ref, stableId });
96
- }
97
- }
98
- });
99
- const drag = (0, import_tool.defineTabTool)({
100
- capability: "core",
101
- schema: {
102
- name: "browser_drag",
103
- title: "Drag mouse",
104
- description: "Perform drag and drop between two elements",
105
- inputSchema: import_bundle.z.object({
106
- startElement: import_bundle.z.string().describe("Human-readable source element description used to obtain the permission to interact with the element"),
107
- startRef: import_bundle.z.string().describe("Exact source element reference from the page snapshot"),
108
- endElement: import_bundle.z.string().describe("Human-readable target element description used to obtain the permission to interact with the element"),
109
- endRef: import_bundle.z.string().describe("Exact target element reference from the page snapshot")
110
- }),
111
- type: "input"
112
- },
113
- handle: async (tab, params, response) => {
114
- response.setIncludeSnapshot();
115
- const [start, end] = await tab.refLocators([
116
- { ref: params.startRef, element: params.startElement },
117
- { ref: params.endRef, element: params.endElement }
118
- ]);
119
- await tab.waitForCompletion(async () => {
120
- await start.locator.dragTo(end.locator);
121
- });
122
- response.addCode(`await page.${start.resolved}.dragTo(page.${end.resolved});`);
123
- }
124
- });
125
- const hover = (0, import_tool.defineTabTool)({
126
- capability: "core",
127
- schema: {
128
- name: "browser_hover",
129
- title: "Hover mouse",
130
- description: "Hover over element on page",
131
- inputSchema: elementSchema,
132
- type: "input"
133
- },
134
- handle: async (tab, params, response) => {
135
- response.setIncludeSnapshot();
136
- const { locator, resolved, stableId } = await tab.refLocator(params);
137
- response.addCode(`await page.${resolved}.hover();`);
138
- await tab.waitForCompletion(async () => {
139
- await locator.hover();
140
- });
141
- // ZIBBY: Record event with stable ID
142
- if (typeof global.__zibbyRecordEvent === 'function') {
143
- global.__zibbyRecordEvent('hover', { element: params.element, ref: params.ref, stableId });
144
- }
145
- }
146
- });
147
- const selectOptionSchema = elementSchema.extend({
148
- values: import_bundle.z.array(import_bundle.z.string()).describe("Array of values to select in the dropdown. This can be a single value or multiple values.")
149
- });
150
- const selectOption = (0, import_tool.defineTabTool)({
151
- capability: "core",
152
- schema: {
153
- name: "browser_select_option",
154
- title: "Select option",
155
- description: "Select an option in a dropdown",
156
- inputSchema: selectOptionSchema,
157
- type: "input"
158
- },
159
- handle: async (tab, params, response) => {
160
- response.setIncludeSnapshot();
161
- const { locator, resolved, stableId } = await tab.refLocator(params);
162
- response.addCode(`await page.${resolved}.selectOption(${javascript.formatObject(params.values)});`);
163
- await tab.waitForCompletion(async () => {
164
- await locator.selectOption(params.values);
165
- });
166
- // ZIBBY: Record event with stable ID
167
- if (typeof global.__zibbyRecordEvent === 'function') {
168
- global.__zibbyRecordEvent('select', { element: params.element, ref: params.ref, values: params.values, stableId });
169
- }
170
- }
171
- });
172
- const pickLocator = (0, import_tool.defineTabTool)({
173
- capability: "testing",
174
- schema: {
175
- name: "browser_generate_locator",
176
- title: "Create locator for element",
177
- description: "Generate locator for the given element to use in tests",
178
- inputSchema: elementSchema,
179
- type: "readOnly"
180
- },
181
- handle: async (tab, params, response) => {
182
- const { resolved } = await tab.refLocator(params);
183
- response.addResult(resolved);
184
- }
185
- });
186
- var snapshot_default = [
187
- snapshot,
188
- click,
189
- drag,
190
- hover,
191
- selectOption,
192
- pickLocator
193
- ];
194
- // Annotate the CommonJS export names for ESM import in node:
195
- 0 && (module.exports = {
196
- elementSchema
197
- });
package/lib/sdk/bundle.js DELETED
@@ -1,84 +0,0 @@
1
- "use strict";
2
- const __create = Object.create;
3
- const __defProp = Object.defineProperty;
4
- const __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- const __getOwnPropNames = Object.getOwnPropertyNames;
6
- const __getProtoOf = Object.getPrototypeOf;
7
- const __hasOwnProp = Object.prototype.hasOwnProperty;
8
- const __export = (target, all) => {
9
- for (const name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- const __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (const key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- const __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- const __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- const bundle_exports = {};
30
- __export(bundle_exports, {
31
- CallToolRequestSchema: () => CallToolRequestSchema,
32
- Client: () => Client,
33
- ListRootsRequestSchema: () => ListRootsRequestSchema,
34
- ListToolsRequestSchema: () => ListToolsRequestSchema,
35
- PingRequestSchema: () => PingRequestSchema,
36
- ProgressNotificationSchema: () => ProgressNotificationSchema,
37
- SSEClientTransport: () => SSEClientTransport,
38
- SSEServerTransport: () => SSEServerTransport,
39
- Server: () => Server,
40
- StdioClientTransport: () => StdioClientTransport,
41
- StdioServerTransport: () => StdioServerTransport,
42
- StreamableHTTPClientTransport: () => StreamableHTTPClientTransport,
43
- StreamableHTTPServerTransport: () => StreamableHTTPServerTransport,
44
- z: () => z,
45
- zodToJsonSchema: () => zodToJsonSchema
46
- });
47
- module.exports = __toCommonJS(bundle_exports);
48
- // ZIBBY: Use require.resolve workaround for unexported internal file
49
- const playwrightPath = require.resolve('playwright');
50
- const bundlePath = require('path').join(require('path').dirname(playwrightPath), 'lib', 'mcpBundleImpl');
51
- const bundle = __toESM(require(bundlePath));
52
- const zodToJsonSchema = bundle.zodToJsonSchema;
53
- const Client = bundle.Client;
54
- const Server = bundle.Server;
55
- const SSEClientTransport = bundle.SSEClientTransport;
56
- const SSEServerTransport = bundle.SSEServerTransport;
57
- const StdioClientTransport = bundle.StdioClientTransport;
58
- const StdioServerTransport = bundle.StdioServerTransport;
59
- const StreamableHTTPServerTransport = bundle.StreamableHTTPServerTransport;
60
- const StreamableHTTPClientTransport = bundle.StreamableHTTPClientTransport;
61
- const CallToolRequestSchema = bundle.CallToolRequestSchema;
62
- const ListRootsRequestSchema = bundle.ListRootsRequestSchema;
63
- const ProgressNotificationSchema = bundle.ProgressNotificationSchema;
64
- const ListToolsRequestSchema = bundle.ListToolsRequestSchema;
65
- const PingRequestSchema = bundle.PingRequestSchema;
66
- const z = bundle.z;
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- CallToolRequestSchema,
70
- Client,
71
- ListRootsRequestSchema,
72
- ListToolsRequestSchema,
73
- PingRequestSchema,
74
- ProgressNotificationSchema,
75
- SSEClientTransport,
76
- SSEServerTransport,
77
- Server,
78
- StdioClientTransport,
79
- StdioServerTransport,
80
- StreamableHTTPClientTransport,
81
- StreamableHTTPServerTransport,
82
- z,
83
- zodToJsonSchema
84
- });