feat: Geutebruck GeViScope/GeViSoft Action Mapping System - MVP
This MVP release provides a complete full-stack solution for managing action mappings in Geutebruck's GeViScope and GeViSoft video surveillance systems. ## Features ### Flutter Web Application (Port 8081) - Modern, responsive UI for managing action mappings - Action picker dialog with full parameter configuration - Support for both GSC (GeViScope) and G-Core server actions - Consistent UI for input and output actions with edit/delete capabilities - Real-time action mapping creation, editing, and deletion - Server categorization (GSC: prefix for GeViScope, G-Core: prefix for G-Core servers) ### FastAPI REST Backend (Port 8000) - RESTful API for action mapping CRUD operations - Action template service with comprehensive action catalog (247 actions) - Server management (G-Core and GeViScope servers) - Configuration tree reading and writing - JWT authentication with role-based access control - PostgreSQL database integration ### C# SDK Bridge (gRPC, Port 50051) - Native integration with GeViSoft SDK (GeViProcAPINET_4_0.dll) - Action mapping creation with correct binary format - Support for GSC and G-Core action types - Proper Camera parameter inclusion in action strings (fixes CrossSwitch bug) - Action ID lookup table with server-specific action IDs - Configuration reading/writing via SetupClient ## Bug Fixes - **CrossSwitch Bug**: GSC and G-Core actions now correctly display camera/PTZ head parameters in GeViSet - Action strings now include Camera parameter: `@ PanLeft (Comment: "", Camera: 101028)` - Proper filter flags and VideoInput=0 for action mappings - Correct action ID assignment (4198 for GSC, 9294 for G-Core PanLeft) ## Technical Stack - **Frontend**: Flutter Web, Dart, Dio HTTP client - **Backend**: Python FastAPI, PostgreSQL, Redis - **SDK Bridge**: C# .NET 8.0, gRPC, GeViSoft SDK - **Authentication**: JWT tokens - **Configuration**: GeViSoft .set files (binary format) ## Credentials - GeViSoft/GeViScope: username=sysadmin, password=masterkey - Default admin: username=admin, password=admin123 ## Deployment All services run on localhost: - Flutter Web: http://localhost:8081 - FastAPI: http://localhost:8000 - SDK Bridge gRPC: localhost:50051 - GeViServer: localhost (default port) Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
81
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/bundle.js
generated
vendored
Normal file
81
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/bundle.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var bundle_exports = {};
|
||||
__export(bundle_exports, {
|
||||
CallToolRequestSchema: () => CallToolRequestSchema,
|
||||
Client: () => Client,
|
||||
ListRootsRequestSchema: () => ListRootsRequestSchema,
|
||||
ListToolsRequestSchema: () => ListToolsRequestSchema,
|
||||
PingRequestSchema: () => PingRequestSchema,
|
||||
ProgressNotificationSchema: () => ProgressNotificationSchema,
|
||||
SSEClientTransport: () => SSEClientTransport,
|
||||
SSEServerTransport: () => SSEServerTransport,
|
||||
Server: () => Server,
|
||||
StdioClientTransport: () => StdioClientTransport,
|
||||
StdioServerTransport: () => StdioServerTransport,
|
||||
StreamableHTTPClientTransport: () => StreamableHTTPClientTransport,
|
||||
StreamableHTTPServerTransport: () => StreamableHTTPServerTransport,
|
||||
z: () => z,
|
||||
zodToJsonSchema: () => zodToJsonSchema
|
||||
});
|
||||
module.exports = __toCommonJS(bundle_exports);
|
||||
var bundle = __toESM(require("../../mcpBundleImpl"));
|
||||
const zodToJsonSchema = bundle.zodToJsonSchema;
|
||||
const Client = bundle.Client;
|
||||
const Server = bundle.Server;
|
||||
const SSEClientTransport = bundle.SSEClientTransport;
|
||||
const SSEServerTransport = bundle.SSEServerTransport;
|
||||
const StdioClientTransport = bundle.StdioClientTransport;
|
||||
const StdioServerTransport = bundle.StdioServerTransport;
|
||||
const StreamableHTTPServerTransport = bundle.StreamableHTTPServerTransport;
|
||||
const StreamableHTTPClientTransport = bundle.StreamableHTTPClientTransport;
|
||||
const CallToolRequestSchema = bundle.CallToolRequestSchema;
|
||||
const ListRootsRequestSchema = bundle.ListRootsRequestSchema;
|
||||
const ProgressNotificationSchema = bundle.ProgressNotificationSchema;
|
||||
const ListToolsRequestSchema = bundle.ListToolsRequestSchema;
|
||||
const PingRequestSchema = bundle.PingRequestSchema;
|
||||
const z = bundle.z;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
CallToolRequestSchema,
|
||||
Client,
|
||||
ListRootsRequestSchema,
|
||||
ListToolsRequestSchema,
|
||||
PingRequestSchema,
|
||||
ProgressNotificationSchema,
|
||||
SSEClientTransport,
|
||||
SSEServerTransport,
|
||||
Server,
|
||||
StdioClientTransport,
|
||||
StdioServerTransport,
|
||||
StreamableHTTPClientTransport,
|
||||
StreamableHTTPServerTransport,
|
||||
z,
|
||||
zodToJsonSchema
|
||||
});
|
||||
30
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/exports.js
generated
vendored
Normal file
30
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/exports.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var exports_exports = {};
|
||||
module.exports = __toCommonJS(exports_exports);
|
||||
__reExport(exports_exports, require("./inProcessTransport"), module.exports);
|
||||
__reExport(exports_exports, require("./proxyBackend"), module.exports);
|
||||
__reExport(exports_exports, require("./server"), module.exports);
|
||||
__reExport(exports_exports, require("./tool"), module.exports);
|
||||
__reExport(exports_exports, require("./http"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("./inProcessTransport"),
|
||||
...require("./proxyBackend"),
|
||||
...require("./server"),
|
||||
...require("./tool"),
|
||||
...require("./http")
|
||||
});
|
||||
187
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/http.js
generated
vendored
Normal file
187
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/http.js
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var http_exports = {};
|
||||
__export(http_exports, {
|
||||
httpAddressToString: () => httpAddressToString,
|
||||
installHttpTransport: () => installHttpTransport,
|
||||
startHttpServer: () => startHttpServer
|
||||
});
|
||||
module.exports = __toCommonJS(http_exports);
|
||||
var import_assert = __toESM(require("assert"));
|
||||
var import_http = __toESM(require("http"));
|
||||
var import_crypto = __toESM(require("crypto"));
|
||||
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
||||
var mcpBundle = __toESM(require("./bundle"));
|
||||
var mcpServer = __toESM(require("./server"));
|
||||
const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
|
||||
async function startHttpServer(config, abortSignal) {
|
||||
const { host, port } = config;
|
||||
const httpServer = import_http.default.createServer();
|
||||
decorateServer(httpServer);
|
||||
await new Promise((resolve, reject) => {
|
||||
httpServer.on("error", reject);
|
||||
abortSignal?.addEventListener("abort", () => {
|
||||
httpServer.close();
|
||||
reject(new Error("Aborted"));
|
||||
});
|
||||
httpServer.listen(port, host, () => {
|
||||
resolve();
|
||||
httpServer.removeListener("error", reject);
|
||||
});
|
||||
});
|
||||
return httpServer;
|
||||
}
|
||||
function httpAddressToString(address) {
|
||||
(0, import_assert.default)(address, "Could not bind server socket");
|
||||
if (typeof address === "string")
|
||||
return address;
|
||||
const resolvedPort = address.port;
|
||||
let resolvedHost = address.family === "IPv4" ? address.address : `[${address.address}]`;
|
||||
if (resolvedHost === "0.0.0.0" || resolvedHost === "[::]")
|
||||
resolvedHost = "localhost";
|
||||
return `http://${resolvedHost}:${resolvedPort}`;
|
||||
}
|
||||
async function installHttpTransport(httpServer, serverBackendFactory, unguessableUrl, allowedHosts) {
|
||||
const url = httpAddressToString(httpServer.address());
|
||||
const host = new URL(url).host;
|
||||
allowedHosts = (allowedHosts || [host]).map((h) => h.toLowerCase());
|
||||
const allowAnyHost = allowedHosts.includes("*");
|
||||
const pathPrefix = unguessableUrl ? `/${import_crypto.default.randomUUID()}` : "";
|
||||
const sseSessions = /* @__PURE__ */ new Map();
|
||||
const streamableSessions = /* @__PURE__ */ new Map();
|
||||
httpServer.on("request", async (req, res) => {
|
||||
if (!allowAnyHost) {
|
||||
const host2 = req.headers.host?.toLowerCase();
|
||||
if (!host2) {
|
||||
res.statusCode = 400;
|
||||
return res.end("Missing host");
|
||||
}
|
||||
if (!allowedHosts.includes(host2)) {
|
||||
res.statusCode = 403;
|
||||
return res.end("Access is only allowed at " + allowedHosts.join(", "));
|
||||
}
|
||||
}
|
||||
if (!req.url?.startsWith(pathPrefix)) {
|
||||
res.statusCode = 404;
|
||||
return res.end("Not found");
|
||||
}
|
||||
const path = req.url?.slice(pathPrefix.length);
|
||||
const url2 = new URL(`http://localhost${path}`);
|
||||
if (url2.pathname === "/killkillkill" && req.method === "GET") {
|
||||
res.statusCode = 200;
|
||||
res.end("Killing process");
|
||||
process.emit("SIGINT");
|
||||
return;
|
||||
}
|
||||
if (url2.pathname.startsWith("/sse"))
|
||||
await handleSSE(serverBackendFactory, req, res, url2, sseSessions);
|
||||
else
|
||||
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
|
||||
});
|
||||
return `${url}${pathPrefix}`;
|
||||
}
|
||||
async function handleSSE(serverBackendFactory, req, res, url, sessions) {
|
||||
if (req.method === "POST") {
|
||||
const sessionId = url.searchParams.get("sessionId");
|
||||
if (!sessionId) {
|
||||
res.statusCode = 400;
|
||||
return res.end("Missing sessionId");
|
||||
}
|
||||
const transport = sessions.get(sessionId);
|
||||
if (!transport) {
|
||||
res.statusCode = 404;
|
||||
return res.end("Session not found");
|
||||
}
|
||||
return await transport.handlePostMessage(req, res);
|
||||
} else if (req.method === "GET") {
|
||||
const transport = new mcpBundle.SSEServerTransport("/sse", res);
|
||||
sessions.set(transport.sessionId, transport);
|
||||
testDebug(`create SSE session: ${transport.sessionId}`);
|
||||
await mcpServer.connect(serverBackendFactory, transport, false);
|
||||
res.on("close", () => {
|
||||
testDebug(`delete SSE session: ${transport.sessionId}`);
|
||||
sessions.delete(transport.sessionId);
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.statusCode = 405;
|
||||
res.end("Method not allowed");
|
||||
}
|
||||
async function handleStreamable(serverBackendFactory, req, res, sessions) {
|
||||
const sessionId = req.headers["mcp-session-id"];
|
||||
if (sessionId) {
|
||||
const transport = sessions.get(sessionId);
|
||||
if (!transport) {
|
||||
res.statusCode = 404;
|
||||
res.end("Session not found");
|
||||
return;
|
||||
}
|
||||
return await transport.handleRequest(req, res);
|
||||
}
|
||||
if (req.method === "POST") {
|
||||
const transport = new mcpBundle.StreamableHTTPServerTransport({
|
||||
sessionIdGenerator: () => import_crypto.default.randomUUID(),
|
||||
onsessioninitialized: async (sessionId2) => {
|
||||
testDebug(`create http session: ${transport.sessionId}`);
|
||||
await mcpServer.connect(serverBackendFactory, transport, true);
|
||||
sessions.set(sessionId2, transport);
|
||||
}
|
||||
});
|
||||
transport.onclose = () => {
|
||||
if (!transport.sessionId)
|
||||
return;
|
||||
sessions.delete(transport.sessionId);
|
||||
testDebug(`delete http session: ${transport.sessionId}`);
|
||||
};
|
||||
await transport.handleRequest(req, res);
|
||||
return;
|
||||
}
|
||||
res.statusCode = 400;
|
||||
res.end("Invalid request");
|
||||
}
|
||||
function decorateServer(server) {
|
||||
const sockets = /* @__PURE__ */ new Set();
|
||||
server.on("connection", (socket) => {
|
||||
sockets.add(socket);
|
||||
socket.once("close", () => sockets.delete(socket));
|
||||
});
|
||||
const close = server.close;
|
||||
server.close = (callback) => {
|
||||
for (const socket of sockets)
|
||||
socket.destroy();
|
||||
sockets.clear();
|
||||
return close.call(server, callback);
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
httpAddressToString,
|
||||
installHttpTransport,
|
||||
startHttpServer
|
||||
});
|
||||
71
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/inProcessTransport.js
generated
vendored
Normal file
71
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/inProcessTransport.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var inProcessTransport_exports = {};
|
||||
__export(inProcessTransport_exports, {
|
||||
InProcessTransport: () => InProcessTransport
|
||||
});
|
||||
module.exports = __toCommonJS(inProcessTransport_exports);
|
||||
class InProcessTransport {
|
||||
constructor(server) {
|
||||
this._connected = false;
|
||||
this._server = server;
|
||||
this._serverTransport = new InProcessServerTransport(this);
|
||||
}
|
||||
async start() {
|
||||
if (this._connected)
|
||||
throw new Error("InprocessTransport already started!");
|
||||
await this._server.connect(this._serverTransport);
|
||||
this._connected = true;
|
||||
}
|
||||
async send(message, options) {
|
||||
if (!this._connected)
|
||||
throw new Error("Transport not connected");
|
||||
this._serverTransport._receiveFromClient(message);
|
||||
}
|
||||
async close() {
|
||||
if (this._connected) {
|
||||
this._connected = false;
|
||||
this.onclose?.();
|
||||
this._serverTransport.onclose?.();
|
||||
}
|
||||
}
|
||||
_receiveFromServer(message, extra) {
|
||||
this.onmessage?.(message, extra);
|
||||
}
|
||||
}
|
||||
class InProcessServerTransport {
|
||||
constructor(clientTransport) {
|
||||
this._clientTransport = clientTransport;
|
||||
}
|
||||
async start() {
|
||||
}
|
||||
async send(message, options) {
|
||||
this._clientTransport._receiveFromServer(message);
|
||||
}
|
||||
async close() {
|
||||
this.onclose?.();
|
||||
}
|
||||
_receiveFromClient(message) {
|
||||
this.onmessage?.(message);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
InProcessTransport
|
||||
});
|
||||
128
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/proxyBackend.js
generated
vendored
Normal file
128
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/proxyBackend.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var proxyBackend_exports = {};
|
||||
__export(proxyBackend_exports, {
|
||||
ProxyBackend: () => ProxyBackend
|
||||
});
|
||||
module.exports = __toCommonJS(proxyBackend_exports);
|
||||
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
||||
var mcpBundle = __toESM(require("./bundle"));
|
||||
const errorsDebug = (0, import_utilsBundle.debug)("pw:mcp:errors");
|
||||
const { z, zodToJsonSchema } = mcpBundle;
|
||||
class ProxyBackend {
|
||||
constructor(mcpProviders) {
|
||||
this._mcpProviders = mcpProviders;
|
||||
this._contextSwitchTool = this._defineContextSwitchTool();
|
||||
}
|
||||
async initialize(clientInfo) {
|
||||
this._clientInfo = clientInfo;
|
||||
}
|
||||
async listTools() {
|
||||
const currentClient = await this._ensureCurrentClient();
|
||||
const response = await currentClient.listTools();
|
||||
if (this._mcpProviders.length === 1)
|
||||
return response.tools;
|
||||
return [
|
||||
...response.tools,
|
||||
this._contextSwitchTool
|
||||
];
|
||||
}
|
||||
async callTool(name, args) {
|
||||
if (name === this._contextSwitchTool.name)
|
||||
return this._callContextSwitchTool(args);
|
||||
const currentClient = await this._ensureCurrentClient();
|
||||
return await currentClient.callTool({
|
||||
name,
|
||||
arguments: args
|
||||
});
|
||||
}
|
||||
serverClosed() {
|
||||
void this._currentClient?.close().catch(errorsDebug);
|
||||
}
|
||||
async _callContextSwitchTool(params) {
|
||||
try {
|
||||
const factory = this._mcpProviders.find((factory2) => factory2.name === params.name);
|
||||
if (!factory)
|
||||
throw new Error("Unknown connection method: " + params.name);
|
||||
await this._setCurrentClient(factory);
|
||||
return {
|
||||
content: [{ type: "text", text: "### Result\nSuccessfully changed connection method.\n" }]
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
content: [{ type: "text", text: `### Result
|
||||
Error: ${error}
|
||||
` }],
|
||||
isError: true
|
||||
};
|
||||
}
|
||||
}
|
||||
_defineContextSwitchTool() {
|
||||
return {
|
||||
name: "browser_connect",
|
||||
description: [
|
||||
"Connect to a browser using one of the available methods:",
|
||||
...this._mcpProviders.map((factory) => `- "${factory.name}": ${factory.description}`)
|
||||
].join("\n"),
|
||||
inputSchema: zodToJsonSchema(z.object({
|
||||
name: z.enum(this._mcpProviders.map((factory) => factory.name)).default(this._mcpProviders[0].name).describe("The method to use to connect to the browser")
|
||||
}), { strictUnions: true }),
|
||||
annotations: {
|
||||
title: "Connect to a browser context",
|
||||
readOnlyHint: true,
|
||||
openWorldHint: false
|
||||
}
|
||||
};
|
||||
}
|
||||
async _ensureCurrentClient() {
|
||||
if (this._currentClient)
|
||||
return this._currentClient;
|
||||
return await this._setCurrentClient(this._mcpProviders[0]);
|
||||
}
|
||||
async _setCurrentClient(factory) {
|
||||
await this._currentClient?.close();
|
||||
this._currentClient = void 0;
|
||||
const client = new mcpBundle.Client({ name: "Playwright MCP Proxy", version: "0.0.0" });
|
||||
client.registerCapabilities({
|
||||
roots: {
|
||||
listRoots: true
|
||||
}
|
||||
});
|
||||
client.setRequestHandler(mcpBundle.ListRootsRequestSchema, () => ({ roots: this._clientInfo?.roots || [] }));
|
||||
client.setRequestHandler(mcpBundle.PingRequestSchema, () => ({}));
|
||||
const transport = await factory.connect();
|
||||
await client.connect(transport);
|
||||
this._currentClient = client;
|
||||
return client;
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
ProxyBackend
|
||||
});
|
||||
198
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/server.js
generated
vendored
Normal file
198
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/server.js
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var server_exports = {};
|
||||
__export(server_exports, {
|
||||
connect: () => connect,
|
||||
createServer: () => createServer,
|
||||
firstRootPath: () => firstRootPath,
|
||||
start: () => start,
|
||||
wrapInProcess: () => wrapInProcess
|
||||
});
|
||||
module.exports = __toCommonJS(server_exports);
|
||||
var import_url = require("url");
|
||||
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
||||
var mcpBundle = __toESM(require("./bundle"));
|
||||
var import_http = require("./http");
|
||||
var import_inProcessTransport = require("./inProcessTransport");
|
||||
const serverDebug = (0, import_utilsBundle.debug)("pw:mcp:server");
|
||||
const serverDebugResponse = (0, import_utilsBundle.debug)("pw:mcp:server:response");
|
||||
async function connect(factory, transport, runHeartbeat) {
|
||||
const server = createServer(factory.name, factory.version, factory.create(), runHeartbeat);
|
||||
await server.connect(transport);
|
||||
}
|
||||
async function wrapInProcess(backend) {
|
||||
const server = createServer("Internal", "0.0.0", backend, false);
|
||||
return new import_inProcessTransport.InProcessTransport(server);
|
||||
}
|
||||
function createServer(name, version, backend, runHeartbeat) {
|
||||
const server = new mcpBundle.Server({ name, version }, {
|
||||
capabilities: {
|
||||
tools: {}
|
||||
}
|
||||
});
|
||||
server.setRequestHandler(mcpBundle.ListToolsRequestSchema, async () => {
|
||||
serverDebug("listTools");
|
||||
const tools = await backend.listTools();
|
||||
return { tools };
|
||||
});
|
||||
let initializePromise;
|
||||
server.setRequestHandler(mcpBundle.CallToolRequestSchema, async (request, extra) => {
|
||||
serverDebug("callTool", request);
|
||||
const progressToken = request.params._meta?.progressToken;
|
||||
let progressCounter = 0;
|
||||
const progress = progressToken ? (params) => {
|
||||
extra.sendNotification({
|
||||
method: "notifications/progress",
|
||||
params: {
|
||||
progressToken,
|
||||
progress: params.progress ?? ++progressCounter,
|
||||
total: params.total,
|
||||
message: params.message
|
||||
}
|
||||
}).catch(serverDebug);
|
||||
} : () => {
|
||||
};
|
||||
try {
|
||||
if (!initializePromise)
|
||||
initializePromise = initializeServer(server, backend, runHeartbeat);
|
||||
await initializePromise;
|
||||
const toolResult = await backend.callTool(request.params.name, request.params.arguments || {}, progress);
|
||||
const mergedResult = mergeTextParts(toolResult);
|
||||
serverDebugResponse("callResult", mergedResult);
|
||||
return mergedResult;
|
||||
} catch (error) {
|
||||
return {
|
||||
content: [{ type: "text", text: "### Result\n" + String(error) }],
|
||||
isError: true
|
||||
};
|
||||
}
|
||||
});
|
||||
addServerListener(server, "close", () => backend.serverClosed?.(server));
|
||||
return server;
|
||||
}
|
||||
const initializeServer = async (server, backend, runHeartbeat) => {
|
||||
const capabilities = server.getClientCapabilities();
|
||||
let clientRoots = [];
|
||||
if (capabilities?.roots) {
|
||||
const { roots } = await server.listRoots().catch((e) => {
|
||||
serverDebug(e);
|
||||
return { roots: [] };
|
||||
});
|
||||
clientRoots = roots;
|
||||
}
|
||||
const clientInfo = {
|
||||
name: server.getClientVersion()?.name ?? "unknown",
|
||||
version: server.getClientVersion()?.version ?? "unknown",
|
||||
roots: clientRoots,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
await backend.initialize?.(clientInfo);
|
||||
if (runHeartbeat)
|
||||
startHeartbeat(server);
|
||||
};
|
||||
const startHeartbeat = (server) => {
|
||||
const beat = () => {
|
||||
Promise.race([
|
||||
server.ping(),
|
||||
new Promise((_, reject) => setTimeout(() => reject(new Error("ping timeout")), 5e3))
|
||||
]).then(() => {
|
||||
setTimeout(beat, 3e3);
|
||||
}).catch(() => {
|
||||
void server.close();
|
||||
});
|
||||
};
|
||||
beat();
|
||||
};
|
||||
function addServerListener(server, event, listener) {
|
||||
const oldListener = server[`on${event}`];
|
||||
server[`on${event}`] = () => {
|
||||
oldListener?.();
|
||||
listener();
|
||||
};
|
||||
}
|
||||
async function start(serverBackendFactory, options) {
|
||||
if (options.port === void 0) {
|
||||
await connect(serverBackendFactory, new mcpBundle.StdioServerTransport(), false);
|
||||
return;
|
||||
}
|
||||
const httpServer = await (0, import_http.startHttpServer)(options);
|
||||
const url = await (0, import_http.installHttpTransport)(httpServer, serverBackendFactory, false, options.allowedHosts);
|
||||
const mcpConfig = { mcpServers: {} };
|
||||
mcpConfig.mcpServers[serverBackendFactory.nameInConfig] = {
|
||||
url: `${url}/mcp`
|
||||
};
|
||||
const message = [
|
||||
`Listening on ${url}`,
|
||||
"Put this in your client config:",
|
||||
JSON.stringify(mcpConfig, void 0, 2),
|
||||
"For legacy SSE transport support, you can use the /sse endpoint instead."
|
||||
].join("\n");
|
||||
console.error(message);
|
||||
}
|
||||
function firstRootPath(clientInfo) {
|
||||
if (clientInfo.roots.length === 0)
|
||||
return void 0;
|
||||
const firstRootUri = clientInfo.roots[0]?.uri;
|
||||
const url = firstRootUri ? new URL(firstRootUri) : void 0;
|
||||
try {
|
||||
return url ? (0, import_url.fileURLToPath)(url) : void 0;
|
||||
} catch (error) {
|
||||
serverDebug(error);
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
function mergeTextParts(result) {
|
||||
const content = [];
|
||||
const testParts = [];
|
||||
for (const part of result.content) {
|
||||
if (part.type === "text") {
|
||||
testParts.push(part.text);
|
||||
continue;
|
||||
}
|
||||
if (testParts.length > 0) {
|
||||
content.push({ type: "text", text: testParts.join("\n") });
|
||||
testParts.length = 0;
|
||||
}
|
||||
content.push(part);
|
||||
}
|
||||
if (testParts.length > 0)
|
||||
content.push({ type: "text", text: testParts.join("\n") });
|
||||
return {
|
||||
...result,
|
||||
content
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
connect,
|
||||
createServer,
|
||||
firstRootPath,
|
||||
start,
|
||||
wrapInProcess
|
||||
});
|
||||
47
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/tool.js
generated
vendored
Normal file
47
.playwright-mcp/node_modules/playwright/lib/mcp/sdk/tool.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var tool_exports = {};
|
||||
__export(tool_exports, {
|
||||
defineToolSchema: () => defineToolSchema,
|
||||
toMcpTool: () => toMcpTool
|
||||
});
|
||||
module.exports = __toCommonJS(tool_exports);
|
||||
var import_bundle = require("../sdk/bundle");
|
||||
function toMcpTool(tool) {
|
||||
const readOnly = tool.type === "readOnly" || tool.type === "assertion";
|
||||
return {
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
inputSchema: (0, import_bundle.zodToJsonSchema)(tool.inputSchema, { strictUnions: true }),
|
||||
annotations: {
|
||||
title: tool.title,
|
||||
readOnlyHint: readOnly,
|
||||
destructiveHint: !readOnly,
|
||||
openWorldHint: true
|
||||
}
|
||||
};
|
||||
}
|
||||
function defineToolSchema(tool) {
|
||||
return tool;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
defineToolSchema,
|
||||
toMcpTool
|
||||
});
|
||||
Reference in New Issue
Block a user