mcp-accessibility-scanner 1.1.1 → 2.0.0
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/lib/browserContextFactory.js +212 -0
- package/lib/browserContextFactory.js.map +1 -0
- package/lib/browserServerBackend.js +78 -0
- package/lib/browserServerBackend.js.map +1 -0
- package/lib/config.js +247 -0
- package/lib/config.js.map +1 -0
- package/lib/context.js +227 -0
- package/lib/context.js.map +1 -0
- package/lib/extension/cdpRelay.js +359 -0
- package/lib/extension/cdpRelay.js.map +1 -0
- package/lib/extension/extensionContextFactory.js +57 -0
- package/lib/extension/extensionContextFactory.js.map +1 -0
- package/lib/extension/protocol.js +19 -0
- package/lib/extension/protocol.js.map +1 -0
- package/lib/index.js +41 -0
- package/lib/index.js.map +1 -0
- package/lib/mcp/http.js +136 -0
- package/lib/mcp/http.js.map +1 -0
- package/lib/mcp/inProcessTransport.js +73 -0
- package/lib/mcp/inProcessTransport.js.map +1 -0
- package/lib/mcp/manualPromise.js +112 -0
- package/lib/mcp/manualPromise.js.map +1 -0
- package/lib/mcp/mdb.js +199 -0
- package/lib/mcp/mdb.js.map +1 -0
- package/lib/mcp/proxyBackend.js +105 -0
- package/lib/mcp/proxyBackend.js.map +1 -0
- package/lib/mcp/server.js +124 -0
- package/lib/mcp/server.js.map +1 -0
- package/lib/mcp/tool.js +33 -0
- package/lib/mcp/tool.js.map +1 -0
- package/lib/program.js +127 -0
- package/lib/program.js.map +1 -0
- package/lib/response.js +166 -0
- package/lib/response.js.map +1 -0
- package/lib/sessionLog.js +122 -0
- package/lib/sessionLog.js.map +1 -0
- package/lib/tab.js +250 -0
- package/lib/tab.js.map +1 -0
- package/lib/tools/common.js +56 -0
- package/lib/tools/common.js.map +1 -0
- package/lib/tools/console.js +34 -0
- package/lib/tools/console.js.map +1 -0
- package/lib/tools/dialogs.js +48 -0
- package/lib/tools/dialogs.js.map +1 -0
- package/lib/tools/evaluate.js +54 -0
- package/lib/tools/evaluate.js.map +1 -0
- package/lib/tools/files.js +45 -0
- package/lib/tools/files.js.map +1 -0
- package/lib/tools/form.js +58 -0
- package/lib/tools/form.js.map +1 -0
- package/lib/tools/install.js +54 -0
- package/lib/tools/install.js.map +1 -0
- package/lib/tools/keyboard.js +79 -0
- package/lib/tools/keyboard.js.map +1 -0
- package/lib/tools/mouse.js +100 -0
- package/lib/tools/mouse.js.map +1 -0
- package/lib/tools/navigate.js +55 -0
- package/lib/tools/navigate.js.map +1 -0
- package/lib/tools/network.js +42 -0
- package/lib/tools/network.js.map +1 -0
- package/lib/tools/pdf.js +41 -0
- package/lib/tools/pdf.js.map +1 -0
- package/lib/tools/screenshot.js +80 -0
- package/lib/tools/screenshot.js.map +1 -0
- package/lib/tools/snapshot.js +194 -0
- package/lib/tools/snapshot.js.map +1 -0
- package/lib/tools/tabs.js +60 -0
- package/lib/tools/tabs.js.map +1 -0
- package/lib/tools/tool.js +34 -0
- package/lib/tools/tool.js.map +1 -0
- package/lib/tools/utils.js +75 -0
- package/lib/tools/utils.js.map +1 -0
- package/lib/tools/verify.js +138 -0
- package/lib/tools/verify.js.map +1 -0
- package/lib/tools/wait.js +56 -0
- package/lib/tools/wait.js.map +1 -0
- package/lib/tools.js +55 -0
- package/lib/tools.js.map +1 -0
- package/lib/utils/codegen.js +50 -0
- package/lib/utils/codegen.js.map +1 -0
- package/lib/utils/fileUtils.js +37 -0
- package/lib/utils/fileUtils.js.map +1 -0
- package/lib/utils/guid.js +23 -0
- package/lib/utils/guid.js.map +1 -0
- package/lib/utils/log.js +22 -0
- package/lib/utils/log.js.map +1 -0
- package/lib/utils/package.js +21 -0
- package/lib/utils/package.js.map +1 -0
- package/lib/vscode/host.js +129 -0
- package/lib/vscode/host.js.map +1 -0
- package/lib/vscode/main.js +63 -0
- package/lib/vscode/main.js.map +1 -0
- package/package.json +19 -19
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import debug from 'debug';
|
|
17
|
+
import * as playwright from 'playwright';
|
|
18
|
+
import { startHttpServer } from '../mcp/http.js';
|
|
19
|
+
import { CDPRelayServer } from './cdpRelay.js';
|
|
20
|
+
const debugLogger = debug('pw:mcp:relay');
|
|
21
|
+
export class ExtensionContextFactory {
|
|
22
|
+
_browserChannel;
|
|
23
|
+
_userDataDir;
|
|
24
|
+
_executablePath;
|
|
25
|
+
constructor(browserChannel, userDataDir, executablePath) {
|
|
26
|
+
this._browserChannel = browserChannel;
|
|
27
|
+
this._userDataDir = userDataDir;
|
|
28
|
+
this._executablePath = executablePath;
|
|
29
|
+
}
|
|
30
|
+
async createContext(clientInfo, abortSignal, toolName) {
|
|
31
|
+
const browser = await this._obtainBrowser(clientInfo, abortSignal, toolName);
|
|
32
|
+
return {
|
|
33
|
+
browserContext: browser.contexts()[0],
|
|
34
|
+
close: async () => {
|
|
35
|
+
debugLogger('close() called for browser context');
|
|
36
|
+
await browser.close();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async _obtainBrowser(clientInfo, abortSignal, toolName) {
|
|
41
|
+
const relay = await this._startRelay(abortSignal);
|
|
42
|
+
await relay.ensureExtensionConnectionForMCPContext(clientInfo, abortSignal, toolName);
|
|
43
|
+
return await playwright.chromium.connectOverCDP(relay.cdpEndpoint());
|
|
44
|
+
}
|
|
45
|
+
async _startRelay(abortSignal) {
|
|
46
|
+
const httpServer = await startHttpServer({});
|
|
47
|
+
if (abortSignal.aborted) {
|
|
48
|
+
httpServer.close();
|
|
49
|
+
throw new Error(abortSignal.reason);
|
|
50
|
+
}
|
|
51
|
+
const cdpRelayServer = new CDPRelayServer(httpServer, this._browserChannel, this._userDataDir, this._executablePath);
|
|
52
|
+
abortSignal.addEventListener('abort', () => cdpRelayServer.stop());
|
|
53
|
+
debugLogger(`CDP relay server started, extension endpoint: ${cdpRelayServer.extensionEndpoint()}.`);
|
|
54
|
+
return cdpRelayServer;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=extensionContextFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensionContextFactory.js","sourceRoot":"","sources":["../../src/extension/extensionContextFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;AAE1C,MAAM,OAAO,uBAAuB;IAC1B,eAAe,CAAS;IACxB,YAAY,CAAU;IACtB,eAAe,CAAU;IAEjC,YAAY,cAAsB,EAAE,WAA+B,EAAE,cAAkC;QACrG,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAsB,EAAE,WAAwB,EAAE,QAA4B;QAChG,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,WAA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) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
// Whenever the commands/events change, the version must be updated. The latest
|
|
17
|
+
// extension version should be compatible with the old MCP clients.
|
|
18
|
+
export const VERSION = 1;
|
|
19
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/extension/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,+EAA+E;AAC/E,mEAAmE;AACnE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { BrowserServerBackend } from './browserServerBackend.js';
|
|
17
|
+
import { resolveConfig } from './config.js';
|
|
18
|
+
import { contextFactory } from './browserContextFactory.js';
|
|
19
|
+
import * as mcpServer from './mcp/server.js';
|
|
20
|
+
import { packageJSON } from './utils/package.js';
|
|
21
|
+
export async function createConnection(userConfig = {}, contextGetter) {
|
|
22
|
+
const config = await resolveConfig(userConfig);
|
|
23
|
+
const factory = contextGetter ? new SimpleBrowserContextFactory(contextGetter) : contextFactory(config);
|
|
24
|
+
return mcpServer.createServer('Playwright', packageJSON.version, new BrowserServerBackend(config, factory), false);
|
|
25
|
+
}
|
|
26
|
+
class SimpleBrowserContextFactory {
|
|
27
|
+
name = 'custom';
|
|
28
|
+
description = 'Connect to a browser using a custom context getter';
|
|
29
|
+
_contextGetter;
|
|
30
|
+
constructor(contextGetter) {
|
|
31
|
+
this._contextGetter = contextGetter;
|
|
32
|
+
}
|
|
33
|
+
async createContext() {
|
|
34
|
+
const browserContext = await this._contextGetter();
|
|
35
|
+
return {
|
|
36
|
+
browserContext,
|
|
37
|
+
close: () => browserContext.close()
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOjD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,aAAqB,EAAE,EAAE,aAA6C;IAC3G,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,2BAA2B,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACxG,OAAO,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;AACrH,CAAC;AAED,MAAM,2BAA2B;IAC/B,IAAI,GAAG,QAAQ,CAAC;IAChB,WAAW,GAAG,oDAAoD,CAAC;IAElD,cAAc,CAAgC;IAE/D,YAAY,aAA4C;QACtD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QACnD,OAAO;YACL,cAAc;YACd,KAAK,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE;SACpC,CAAC;IACJ,CAAC;CACF"}
|
package/lib/mcp/http.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import assert from 'assert';
|
|
17
|
+
import http from 'http';
|
|
18
|
+
import crypto from 'crypto';
|
|
19
|
+
import debug from 'debug';
|
|
20
|
+
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
|
21
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
22
|
+
import * as mcpServer from './server.js';
|
|
23
|
+
const testDebug = debug('pw:mcp:test');
|
|
24
|
+
export async function startHttpServer(config, abortSignal) {
|
|
25
|
+
const { host, port } = config;
|
|
26
|
+
const httpServer = http.createServer();
|
|
27
|
+
decorateServer(httpServer);
|
|
28
|
+
await new Promise((resolve, reject) => {
|
|
29
|
+
httpServer.on('error', reject);
|
|
30
|
+
abortSignal?.addEventListener('abort', () => {
|
|
31
|
+
httpServer.close();
|
|
32
|
+
reject(new Error('Aborted'));
|
|
33
|
+
});
|
|
34
|
+
httpServer.listen(port, host, () => {
|
|
35
|
+
resolve();
|
|
36
|
+
httpServer.removeListener('error', reject);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return httpServer;
|
|
40
|
+
}
|
|
41
|
+
export function httpAddressToString(address) {
|
|
42
|
+
assert(address, 'Could not bind server socket');
|
|
43
|
+
if (typeof address === 'string')
|
|
44
|
+
return address;
|
|
45
|
+
const resolvedPort = address.port;
|
|
46
|
+
let resolvedHost = address.family === 'IPv4' ? address.address : `[${address.address}]`;
|
|
47
|
+
if (resolvedHost === '0.0.0.0' || resolvedHost === '[::]')
|
|
48
|
+
resolvedHost = 'localhost';
|
|
49
|
+
return `http://${resolvedHost}:${resolvedPort}`;
|
|
50
|
+
}
|
|
51
|
+
export async function installHttpTransport(httpServer, serverBackendFactory) {
|
|
52
|
+
const sseSessions = new Map();
|
|
53
|
+
const streamableSessions = new Map();
|
|
54
|
+
httpServer.on('request', async (req, res) => {
|
|
55
|
+
const url = new URL(`http://localhost${req.url}`);
|
|
56
|
+
if (url.pathname.startsWith('/sse'))
|
|
57
|
+
await handleSSE(serverBackendFactory, req, res, url, sseSessions);
|
|
58
|
+
else
|
|
59
|
+
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function handleSSE(serverBackendFactory, req, res, url, sessions) {
|
|
63
|
+
if (req.method === 'POST') {
|
|
64
|
+
const sessionId = url.searchParams.get('sessionId');
|
|
65
|
+
if (!sessionId) {
|
|
66
|
+
res.statusCode = 400;
|
|
67
|
+
return res.end('Missing sessionId');
|
|
68
|
+
}
|
|
69
|
+
const transport = sessions.get(sessionId);
|
|
70
|
+
if (!transport) {
|
|
71
|
+
res.statusCode = 404;
|
|
72
|
+
return res.end('Session not found');
|
|
73
|
+
}
|
|
74
|
+
return await transport.handlePostMessage(req, res);
|
|
75
|
+
}
|
|
76
|
+
else if (req.method === 'GET') {
|
|
77
|
+
const transport = new SSEServerTransport('/sse', res);
|
|
78
|
+
sessions.set(transport.sessionId, transport);
|
|
79
|
+
testDebug(`create SSE session: ${transport.sessionId}`);
|
|
80
|
+
await mcpServer.connect(serverBackendFactory, transport, false);
|
|
81
|
+
res.on('close', () => {
|
|
82
|
+
testDebug(`delete SSE session: ${transport.sessionId}`);
|
|
83
|
+
sessions.delete(transport.sessionId);
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
res.statusCode = 405;
|
|
88
|
+
res.end('Method not allowed');
|
|
89
|
+
}
|
|
90
|
+
async function handleStreamable(serverBackendFactory, req, res, sessions) {
|
|
91
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
92
|
+
if (sessionId) {
|
|
93
|
+
const transport = sessions.get(sessionId);
|
|
94
|
+
if (!transport) {
|
|
95
|
+
res.statusCode = 404;
|
|
96
|
+
res.end('Session not found');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
return await transport.handleRequest(req, res);
|
|
100
|
+
}
|
|
101
|
+
if (req.method === 'POST') {
|
|
102
|
+
const transport = new StreamableHTTPServerTransport({
|
|
103
|
+
sessionIdGenerator: () => crypto.randomUUID(),
|
|
104
|
+
onsessioninitialized: async (sessionId) => {
|
|
105
|
+
testDebug(`create http session: ${transport.sessionId}`);
|
|
106
|
+
await mcpServer.connect(serverBackendFactory, transport, true);
|
|
107
|
+
sessions.set(sessionId, transport);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
transport.onclose = () => {
|
|
111
|
+
if (!transport.sessionId)
|
|
112
|
+
return;
|
|
113
|
+
sessions.delete(transport.sessionId);
|
|
114
|
+
testDebug(`delete http session: ${transport.sessionId}`);
|
|
115
|
+
};
|
|
116
|
+
await transport.handleRequest(req, res);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
res.statusCode = 400;
|
|
120
|
+
res.end('Invalid request');
|
|
121
|
+
}
|
|
122
|
+
function decorateServer(server) {
|
|
123
|
+
const sockets = new Set();
|
|
124
|
+
server.on('connection', socket => {
|
|
125
|
+
sockets.add(socket);
|
|
126
|
+
socket.once('close', () => sockets.delete(socket));
|
|
127
|
+
});
|
|
128
|
+
const close = server.close;
|
|
129
|
+
server.close = (callback) => {
|
|
130
|
+
for (const socket of sockets)
|
|
131
|
+
socket.destroy();
|
|
132
|
+
sockets.clear();
|
|
133
|
+
return close.call(server, callback);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/mcp/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC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CAAC,MAAM,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,MAAM,CAAC,KAAK,GAAG,CAAC,QAAgC,EAAE,EAAE;QAClD,KAAK,MAAM,MAAM,IAAI,OAAO;YAC1B,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export class InProcessTransport {
|
|
17
|
+
_server;
|
|
18
|
+
_serverTransport;
|
|
19
|
+
_connected = false;
|
|
20
|
+
constructor(server) {
|
|
21
|
+
this._server = server;
|
|
22
|
+
this._serverTransport = new InProcessServerTransport(this);
|
|
23
|
+
}
|
|
24
|
+
async start() {
|
|
25
|
+
if (this._connected)
|
|
26
|
+
throw new Error('InprocessTransport already started!');
|
|
27
|
+
await this._server.connect(this._serverTransport);
|
|
28
|
+
this._connected = true;
|
|
29
|
+
}
|
|
30
|
+
async send(message, options) {
|
|
31
|
+
if (!this._connected)
|
|
32
|
+
throw new Error('Transport not connected');
|
|
33
|
+
this._serverTransport._receiveFromClient(message);
|
|
34
|
+
}
|
|
35
|
+
async close() {
|
|
36
|
+
if (this._connected) {
|
|
37
|
+
this._connected = false;
|
|
38
|
+
this.onclose?.();
|
|
39
|
+
this._serverTransport.onclose?.();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
onclose;
|
|
43
|
+
onerror;
|
|
44
|
+
onmessage;
|
|
45
|
+
sessionId;
|
|
46
|
+
setProtocolVersion;
|
|
47
|
+
_receiveFromServer(message, extra) {
|
|
48
|
+
this.onmessage?.(message, extra);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class InProcessServerTransport {
|
|
52
|
+
_clientTransport;
|
|
53
|
+
constructor(clientTransport) {
|
|
54
|
+
this._clientTransport = clientTransport;
|
|
55
|
+
}
|
|
56
|
+
async start() {
|
|
57
|
+
}
|
|
58
|
+
async send(message, options) {
|
|
59
|
+
this._clientTransport._receiveFromServer(message);
|
|
60
|
+
}
|
|
61
|
+
async close() {
|
|
62
|
+
this.onclose?.();
|
|
63
|
+
}
|
|
64
|
+
onclose;
|
|
65
|
+
onerror;
|
|
66
|
+
onmessage;
|
|
67
|
+
sessionId;
|
|
68
|
+
setProtocolVersion;
|
|
69
|
+
_receiveFromClient(message) {
|
|
70
|
+
this.onmessage?.(message);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=inProcessTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inProcessTransport.js","sourceRoot":"","sources":["../../src/mcp/inProcessTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,MAAM,OAAO,kBAAkB;IACrB,OAAO,CAAS;IAChB,gBAAgB,CAA2B;IAC3C,UAAU,GAAY,KAAK,CAAC;IAEpC,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,IAAI,wBAAw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AK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;IACnB,CAAC;IAED,OAAO,CAA4B;IACnC,OAAO,CAAwC;IAC/C,SAAS,CAA6E;IACtF,SAAS,CAAsB;IAC/B,kBAAkB,CAA2C;IAC7D,kBAAkB,CAAC,OAAuB;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export class ManualPromise extends Promise {
|
|
17
|
+
_resolve;
|
|
18
|
+
_reject;
|
|
19
|
+
_isDone;
|
|
20
|
+
constructor() {
|
|
21
|
+
let resolve;
|
|
22
|
+
let reject;
|
|
23
|
+
super((f, r) => {
|
|
24
|
+
resolve = f;
|
|
25
|
+
reject = r;
|
|
26
|
+
});
|
|
27
|
+
this._isDone = false;
|
|
28
|
+
this._resolve = resolve;
|
|
29
|
+
this._reject = reject;
|
|
30
|
+
}
|
|
31
|
+
isDone() {
|
|
32
|
+
return this._isDone;
|
|
33
|
+
}
|
|
34
|
+
resolve(t) {
|
|
35
|
+
this._isDone = true;
|
|
36
|
+
this._resolve(t);
|
|
37
|
+
}
|
|
38
|
+
reject(e) {
|
|
39
|
+
this._isDone = true;
|
|
40
|
+
this._reject(e);
|
|
41
|
+
}
|
|
42
|
+
static get [Symbol.species]() {
|
|
43
|
+
return Promise;
|
|
44
|
+
}
|
|
45
|
+
get [Symbol.toStringTag]() {
|
|
46
|
+
return 'ManualPromise';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class LongStandingScope {
|
|
50
|
+
_terminateError;
|
|
51
|
+
_closeError;
|
|
52
|
+
_terminatePromises = new Map();
|
|
53
|
+
_isClosed = false;
|
|
54
|
+
reject(error) {
|
|
55
|
+
this._isClosed = true;
|
|
56
|
+
this._terminateError = error;
|
|
57
|
+
for (const p of this._terminatePromises.keys())
|
|
58
|
+
p.resolve(error);
|
|
59
|
+
}
|
|
60
|
+
close(error) {
|
|
61
|
+
this._isClosed = true;
|
|
62
|
+
this._closeError = error;
|
|
63
|
+
for (const [p, frames] of this._terminatePromises)
|
|
64
|
+
p.resolve(cloneError(error, frames));
|
|
65
|
+
}
|
|
66
|
+
isClosed() {
|
|
67
|
+
return this._isClosed;
|
|
68
|
+
}
|
|
69
|
+
static async raceMultiple(scopes, promise) {
|
|
70
|
+
return Promise.race(scopes.map(s => s.race(promise)));
|
|
71
|
+
}
|
|
72
|
+
async race(promise) {
|
|
73
|
+
return this._race(Array.isArray(promise) ? promise : [promise], false);
|
|
74
|
+
}
|
|
75
|
+
async safeRace(promise, defaultValue) {
|
|
76
|
+
return this._race([promise], true, defaultValue);
|
|
77
|
+
}
|
|
78
|
+
async _race(promises, safe, defaultValue) {
|
|
79
|
+
const terminatePromise = new ManualPromise();
|
|
80
|
+
const frames = captureRawStack();
|
|
81
|
+
if (this._terminateError)
|
|
82
|
+
terminatePromise.resolve(this._terminateError);
|
|
83
|
+
if (this._closeError)
|
|
84
|
+
terminatePromise.resolve(cloneError(this._closeError, frames));
|
|
85
|
+
this._terminatePromises.set(terminatePromise, frames);
|
|
86
|
+
try {
|
|
87
|
+
return await Promise.race([
|
|
88
|
+
terminatePromise.then(e => safe ? defaultValue : Promise.reject(e)),
|
|
89
|
+
...promises
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
this._terminatePromises.delete(terminatePromise);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function cloneError(error, frames) {
|
|
98
|
+
const clone = new Error();
|
|
99
|
+
clone.name = error.name;
|
|
100
|
+
clone.message = error.message;
|
|
101
|
+
clone.stack = [error.name + ':' + error.message, ...frames].join('\n');
|
|
102
|
+
return clone;
|
|
103
|
+
}
|
|
104
|
+
function captureRawStack() {
|
|
105
|
+
const stackTraceLimit = Error.stackTraceLimit;
|
|
106
|
+
Error.stackTraceLimit = 50;
|
|
107
|
+
const error = new Error();
|
|
108
|
+
const stack = error.stack || '';
|
|
109
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
110
|
+
return stack.split('\n');
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=manualPromise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manualPromise.js","sourceRoot":"","sources":["../../src/mcp/manualPromise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,OAAO,aAAwB,SAAQ,OAAU;IAC7C,QAAQ,CAAkB;IAC1B,OAAO,CAAsB;IAC7B,OAAO,CAAU;IAEzB;QACE,IAAI,OAAuB,CAAC;QAC5B,IAAI,MAA0B,CAAC;QAC/B,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACb,OAAO,GAAG,CAAC,CAAC;YACZ,MAAM,GAAG,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,OAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,MAAO,CAAC;IACzB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,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