@opentabs-dev/mcp-server 0.0.26 → 0.0.28
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/dist/adapter-files.js +4 -4
- package/dist/adapter-files.js.map +1 -1
- package/dist/browser-tools/extension-get-logs.d.ts +2 -2
- package/dist/browser-tools/get-console-logs.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -7
- package/dist/config.js.map +1 -1
- package/dist/dev-mode.d.ts.map +1 -1
- package/dist/dev-mode.js +2 -1
- package/dist/dev-mode.js.map +1 -1
- package/dist/extension-handlers.d.ts +1 -1
- package/dist/extension-handlers.d.ts.map +1 -1
- package/dist/extension-handlers.js +2 -2
- package/dist/extension-handlers.js.map +1 -1
- package/dist/extension-install.d.ts.map +1 -1
- package/dist/extension-install.js +5 -6
- package/dist/extension-install.js.map +1 -1
- package/dist/extension-protocol.js +1 -1
- package/dist/extension-protocol.js.map +1 -1
- package/dist/file-watcher.d.ts +2 -2
- package/dist/file-watcher.d.ts.map +1 -1
- package/dist/file-watcher.js +6 -6
- package/dist/file-watcher.js.map +1 -1
- package/dist/http-routes.d.ts +6 -6
- package/dist/http-routes.d.ts.map +1 -1
- package/dist/http-routes.js +10 -10
- package/dist/http-routes.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -21
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +16 -13
- package/dist/loader.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +3 -2
- package/dist/logger.js.map +1 -1
- package/dist/plugin-management.d.ts +4 -5
- package/dist/plugin-management.d.ts.map +1 -1
- package/dist/plugin-management.js +35 -81
- package/dist/plugin-management.js.map +1 -1
- package/dist/reload.d.ts.map +1 -1
- package/dist/reload.js +7 -4
- package/dist/reload.js.map +1 -1
- package/dist/resolver.d.ts +3 -4
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +33 -30
- package/dist/resolver.js.map +1 -1
- package/dist/sdk-version.d.ts.map +1 -1
- package/dist/sdk-version.js +2 -1
- package/dist/sdk-version.js.map +1 -1
- package/dist/server-node.d.ts +45 -0
- package/dist/server-node.d.ts.map +1 -0
- package/dist/server-node.js +234 -0
- package/dist/server-node.js.map +1 -0
- package/dist/skip-confirmation.d.ts.map +1 -1
- package/dist/skip-confirmation.js +2 -1
- package/dist/skip-confirmation.js.map +1 -1
- package/dist/skip-npm-discovery.d.ts.map +1 -1
- package/dist/skip-npm-discovery.js +2 -1
- package/dist/skip-npm-discovery.js.map +1 -1
- package/dist/version-check.d.ts +8 -7
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +20 -33
- package/dist/version-check.js.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +2 -1
- package/dist/version.js.map +1 -1
- package/package.json +5 -3
package/dist/resolver.js
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* path resolution from plugin loading so each phase can be tested independently.
|
|
7
7
|
*
|
|
8
8
|
* Also provides global npm plugin auto-discovery: scans global node_modules
|
|
9
|
-
* directories
|
|
10
|
-
* naming convention.
|
|
9
|
+
* directories for packages matching the opentabs-plugin-* naming convention.
|
|
11
10
|
*/
|
|
12
11
|
import { log } from './logger.js';
|
|
13
|
-
import { ok, err, PLUGIN_PREFIX, platformExec, toErrorMessage } from '@opentabs-dev/shared';
|
|
12
|
+
import { ok, err, getEnv, isBun, PLUGIN_PREFIX, platformExec, readJsonFile, spawnProcessSync, toErrorMessage, } from '@opentabs-dev/shared';
|
|
14
13
|
import { readdir, realpath, stat } from 'node:fs/promises';
|
|
14
|
+
import { createRequire } from 'node:module';
|
|
15
15
|
import { homedir, tmpdir } from 'node:os';
|
|
16
16
|
import { dirname, join, resolve, sep } from 'node:path';
|
|
17
17
|
/**
|
|
@@ -72,14 +72,15 @@ const resolveLocalPath = (specifier, configDir) => {
|
|
|
72
72
|
}
|
|
73
73
|
return resolve(configDir, specifier);
|
|
74
74
|
};
|
|
75
|
+
const require = createRequire(import.meta.url);
|
|
75
76
|
/**
|
|
76
77
|
* Resolve an npm package specifier to the directory containing its package.json.
|
|
77
|
-
* Uses
|
|
78
|
-
* the containing directory.
|
|
78
|
+
* Uses require.resolve to locate the package's package.json, then returns
|
|
79
|
+
* the containing directory. Works in both Node.js and Bun.
|
|
79
80
|
*/
|
|
80
81
|
const resolveNpmPackage = (specifier) => {
|
|
81
82
|
try {
|
|
82
|
-
const resolved =
|
|
83
|
+
const resolved = require.resolve(`${specifier}/package.json`, { paths: [process.cwd()] });
|
|
83
84
|
return ok(dirname(resolved));
|
|
84
85
|
}
|
|
85
86
|
catch {
|
|
@@ -96,7 +97,7 @@ const resolveNpmPackage = (specifier) => {
|
|
|
96
97
|
* For local paths, resolves relative to configDir and validates the path is
|
|
97
98
|
* under an allowed root directory (homedir or tmpdir).
|
|
98
99
|
*
|
|
99
|
-
* For npm packages, uses
|
|
100
|
+
* For npm packages, uses require.resolve to locate the package directory.
|
|
100
101
|
*
|
|
101
102
|
* Returns the directory path containing the plugin's package.json.
|
|
102
103
|
*/
|
|
@@ -120,17 +121,17 @@ const resolvePluginPath = async (specifier, configDir) => {
|
|
|
120
121
|
}
|
|
121
122
|
return resolveNpmPackage(specifier);
|
|
122
123
|
};
|
|
123
|
-
/** globalThis key for persisting cached global paths across
|
|
124
|
+
/** globalThis key for persisting cached global paths across process lifetime */
|
|
124
125
|
const GLOBAL_PATHS_KEY = '__opentabs_global_paths__';
|
|
125
|
-
/** Access the cached global paths from globalThis so the value
|
|
126
|
+
/** Access the cached global paths from globalThis so the value persists across process lifetime */
|
|
126
127
|
const getCachedGlobalPaths = () => globalThis[GLOBAL_PATHS_KEY] ?? null;
|
|
127
128
|
const setCachedGlobalPaths = (paths) => {
|
|
128
129
|
globalThis[GLOBAL_PATHS_KEY] = paths;
|
|
129
130
|
};
|
|
130
131
|
/**
|
|
131
|
-
* Get global node_modules directories from
|
|
132
|
+
* Get global node_modules directories from npm (and bun when running under Bun).
|
|
132
133
|
* Results are cached on globalThis so the shell commands run at most once
|
|
133
|
-
* per process lifetime
|
|
134
|
+
* per process lifetime.
|
|
134
135
|
*/
|
|
135
136
|
const getGlobalNodeModulesPaths = () => {
|
|
136
137
|
const cached = getCachedGlobalPaths();
|
|
@@ -139,9 +140,9 @@ const getGlobalNodeModulesPaths = () => {
|
|
|
139
140
|
const paths = [];
|
|
140
141
|
// npm global node_modules
|
|
141
142
|
try {
|
|
142
|
-
const result =
|
|
143
|
+
const result = spawnProcessSync(platformExec('npm'), ['root', '-g']);
|
|
143
144
|
if (result.exitCode === 0) {
|
|
144
|
-
const npmPath = result.stdout.
|
|
145
|
+
const npmPath = result.stdout.trim();
|
|
145
146
|
if (npmPath.length > 0)
|
|
146
147
|
paths.push(npmPath);
|
|
147
148
|
}
|
|
@@ -149,21 +150,23 @@ const getGlobalNodeModulesPaths = () => {
|
|
|
149
150
|
catch (e) {
|
|
150
151
|
log.debug(`npm root -g failed: ${toErrorMessage(e)}`);
|
|
151
152
|
}
|
|
152
|
-
// bun global node_modules (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
paths.
|
|
153
|
+
// bun global node_modules (only when running under Bun — normal Node.js users
|
|
154
|
+
// install plugins via npm, so bun's global directory is irrelevant)
|
|
155
|
+
if (isBun) {
|
|
156
|
+
try {
|
|
157
|
+
const result = spawnProcessSync(platformExec('bun'), ['pm', '-g', 'bin']);
|
|
158
|
+
if (result.exitCode === 0) {
|
|
159
|
+
const bunBinPath = result.stdout.trim();
|
|
160
|
+
if (bunBinPath.length > 0) {
|
|
161
|
+
const bunNodeModules = join(dirname(bunBinPath), 'node_modules');
|
|
162
|
+
if (!paths.includes(bunNodeModules))
|
|
163
|
+
paths.push(bunNodeModules);
|
|
164
|
+
}
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
catch (e) {
|
|
168
|
+
log.debug(`bun pm -g bin failed: ${toErrorMessage(e)}`);
|
|
169
|
+
}
|
|
167
170
|
}
|
|
168
171
|
setCachedGlobalPaths(paths);
|
|
169
172
|
return paths;
|
|
@@ -174,7 +177,7 @@ const getGlobalNodeModulesPaths = () => {
|
|
|
174
177
|
*/
|
|
175
178
|
const hasOpentabsField = async (dir) => {
|
|
176
179
|
try {
|
|
177
|
-
const raw = (await
|
|
180
|
+
const raw = (await readJsonFile(join(dir, 'package.json')));
|
|
178
181
|
return typeof raw.opentabs === 'object' && raw.opentabs !== null && !Array.isArray(raw.opentabs);
|
|
179
182
|
}
|
|
180
183
|
catch (e) {
|
|
@@ -236,7 +239,7 @@ const scanGlobalDir = async (globalDir) => {
|
|
|
236
239
|
/**
|
|
237
240
|
* Discover globally installed npm plugin packages.
|
|
238
241
|
*
|
|
239
|
-
* Scans global node_modules directories (
|
|
242
|
+
* Scans global node_modules directories (npm, and bun when available) for packages
|
|
240
243
|
* matching the opentabs-plugin-* naming convention. Each match is validated
|
|
241
244
|
* by checking for a package.json with an `opentabs` field.
|
|
242
245
|
*
|
|
@@ -244,7 +247,7 @@ const scanGlobalDir = async (globalDir) => {
|
|
|
244
247
|
* plus any non-fatal errors encountered during scanning.
|
|
245
248
|
*/
|
|
246
249
|
const discoverGlobalNpmPlugins = async () => {
|
|
247
|
-
if (
|
|
250
|
+
if (getEnv('OPENTABS_SKIP_NPM_DISCOVERY') === '1') {
|
|
248
251
|
log.info('Skipping npm auto-discovery (OPENTABS_SKIP_NPM_DISCOVERY=1)');
|
|
249
252
|
return { dirs: [], errors: [] };
|
|
250
253
|
}
|
|
@@ -261,7 +264,7 @@ const discoverGlobalNpmPlugins = async () => {
|
|
|
261
264
|
try {
|
|
262
265
|
const dirs = await scanGlobalDir(globalDir);
|
|
263
266
|
for (const dir of dirs) {
|
|
264
|
-
// Deduplicate across
|
|
267
|
+
// Deduplicate across global paths (same package may appear in multiple locations)
|
|
265
268
|
if (!seen.has(dir)) {
|
|
266
269
|
seen.add(dir);
|
|
267
270
|
allDirs.push(dir);
|
package/dist/resolver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,EAAE,EACF,GAAG,EACH,MAAM,EACN,KAAK,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGxD;;;;GAIG;AACH,MAAM,eAAe,GAAG,GAAa,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAE9D;;;GAGG;AACH,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAmB,EAAE;IAC3D,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,KAAK,EAAE,YAAoB,EAAoB,EA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"sdk-version.d.ts","sourceRoot":"","sources":["../src/sdk-version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,QAAA,IAAI,UAAU,QAAU,CAAC;AAYzB,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/sdk-version.js
CHANGED
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
* SDK compatibility: a plugin's sdkVersion (from its tools.json) must have a
|
|
7
7
|
* major.minor <= the server's SDK major.minor.
|
|
8
8
|
*/
|
|
9
|
+
import { readJsonFile } from '@opentabs-dev/shared';
|
|
9
10
|
import { join, dirname } from 'node:path';
|
|
10
11
|
import { fileURLToPath } from 'node:url';
|
|
11
12
|
let sdkVersion = '0.0.0';
|
|
12
13
|
try {
|
|
13
14
|
const sdkPkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'plugin-sdk', 'package.json');
|
|
14
|
-
const pkgJson = await
|
|
15
|
+
const pkgJson = await readJsonFile(sdkPkgPath);
|
|
15
16
|
if (pkgJson !== null && typeof pkgJson === 'object' && 'version' in pkgJson && typeof pkgJson.version === 'string') {
|
|
16
17
|
sdkVersion = pkgJson.version;
|
|
17
18
|
}
|
package/dist/sdk-version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-version.js","sourceRoot":"","sources":["../src/sdk-version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,IAAI,UAAU,GAAG,OAAO,CAAC;AAEzB,IAAI,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IAC3G,MAAM,OAAO,GAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"sdk-version.js","sourceRoot":"","sources":["../src/sdk-version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,IAAI,UAAU,GAAG,OAAO,CAAC;AAEzB,IAAI,CAAC;IACH,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IAC3G,MAAM,OAAO,GAAY,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;IACxD,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,SAAS,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACnH,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAC/B,CAAC;AACH,CAAC;AAAC,MAAM,CAAC;IACP,uEAAuE;AACzE,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js HTTP + WebSocket server adapter.
|
|
3
|
+
*
|
|
4
|
+
* Provides the same interface as the Bun.serve() delegate shell but uses
|
|
5
|
+
* node:http and the ws package. Converts between Node.js IncomingMessage /
|
|
6
|
+
* ServerResponse and the Web Standard Request / Response objects that the
|
|
7
|
+
* route handlers expect.
|
|
8
|
+
*
|
|
9
|
+
* Node.js 20+ has global Request / Response via undici, so no polyfills needed.
|
|
10
|
+
*/
|
|
11
|
+
import type { ServerAdapter } from './http-routes.js';
|
|
12
|
+
import type { WsHandle } from '@opentabs-dev/shared';
|
|
13
|
+
/** Configuration mirroring the subset of Bun.serve() options used by index.ts */
|
|
14
|
+
interface NodeServerOptions {
|
|
15
|
+
hostname: string;
|
|
16
|
+
port: number;
|
|
17
|
+
fetch: (req: Request, server: ServerAdapter) => Promise<Response | undefined>;
|
|
18
|
+
websocket: {
|
|
19
|
+
open: (ws: WsHandle) => void;
|
|
20
|
+
message: (ws: WsHandle, message: string | ArrayBuffer | Uint8Array) => void;
|
|
21
|
+
close: (ws: WsHandle) => void;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Return type matching the subset of Bun.serve() return used by index.ts */
|
|
25
|
+
interface NodeServer {
|
|
26
|
+
port: number;
|
|
27
|
+
stop: () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a Node.js HTTP + WebSocket server that presents the ServerAdapter
|
|
31
|
+
* interface to the MCP server route handlers.
|
|
32
|
+
*
|
|
33
|
+
* The tricky part is WebSocket upgrades. Bun.serve() handles upgrades inline
|
|
34
|
+
* in the fetch handler — `server.upgrade(req)` completes the handshake and
|
|
35
|
+
* returns a boolean. Node.js + ws handle upgrades via the 'upgrade' event on
|
|
36
|
+
* the HTTP server, which is separate from normal request handling.
|
|
37
|
+
*
|
|
38
|
+
* Strategy: The 'upgrade' event constructs a Web Request, calls the fetch
|
|
39
|
+
* handler (which calls `adapter.upgrade()`), and if upgrade was requested,
|
|
40
|
+
* completes it via `wss.handleUpgrade()`.
|
|
41
|
+
*/
|
|
42
|
+
declare const createNodeServer: (options: NodeServerOptions) => Promise<NodeServer>;
|
|
43
|
+
export type { NodeServer, NodeServerOptions };
|
|
44
|
+
export { createNodeServer };
|
|
45
|
+
//# sourceMappingURL=server-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-node.d.ts","sourceRoot":"","sources":["../src/server-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMrD,iFAAiF;AACjF,UAAU,iBAAiB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;IAC9E,SAAS,EAAE;QACT,IAAI,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;QAC7B,OAAO,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,KAAK,IAAI,CAAC;QAC5E,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;KAC/B,CAAC;CACH;AAED,6EAA6E;AAC7E,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB;AAgLD;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,gBAAgB,GAAI,SAAS,iBAAiB,KAAG,OAAO,CAAC,UAAU,CA4ErE,CAAC;AAEL,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js HTTP + WebSocket server adapter.
|
|
3
|
+
*
|
|
4
|
+
* Provides the same interface as the Bun.serve() delegate shell but uses
|
|
5
|
+
* node:http and the ws package. Converts between Node.js IncomingMessage /
|
|
6
|
+
* ServerResponse and the Web Standard Request / Response objects that the
|
|
7
|
+
* route handlers expect.
|
|
8
|
+
*
|
|
9
|
+
* Node.js 20+ has global Request / Response via undici, so no polyfills needed.
|
|
10
|
+
*/
|
|
11
|
+
import { log } from './logger.js';
|
|
12
|
+
import { WebSocketServer } from 'ws';
|
|
13
|
+
import { createServer } from 'node:http';
|
|
14
|
+
import { Readable } from 'node:stream';
|
|
15
|
+
/** Send a Web Response through a Node.js ServerResponse */
|
|
16
|
+
const sendResponse = (webResponse, res) => {
|
|
17
|
+
res.writeHead(webResponse.status, Object.fromEntries(webResponse.headers));
|
|
18
|
+
const body = webResponse.body;
|
|
19
|
+
if (!body) {
|
|
20
|
+
res.end();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Handle ReadableStream (web streams) by piping to the Node.js response.
|
|
24
|
+
// SSE responses from MCP Streamable HTTP transport use ReadableStream —
|
|
25
|
+
// piping preserves the streaming behavior.
|
|
26
|
+
const nodeStream = Readable.fromWeb(body);
|
|
27
|
+
nodeStream.pipe(res);
|
|
28
|
+
res.on('close', () => nodeStream.destroy());
|
|
29
|
+
};
|
|
30
|
+
/** Wrap a ws WebSocket to match the WsHandle interface used by handlers */
|
|
31
|
+
const wrapWs = (ws) => ({
|
|
32
|
+
send: (data) => ws.send(data),
|
|
33
|
+
close: (code, reason) => ws.close(code, reason),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Convert a Node.js IncomingMessage to a Web Standard Request.
|
|
37
|
+
*/
|
|
38
|
+
const toWebRequest = (req, body) => {
|
|
39
|
+
const host = req.headers.host ?? 'localhost';
|
|
40
|
+
const url = `http://${host}${req.url ?? '/'}`;
|
|
41
|
+
const headers = new Headers();
|
|
42
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
43
|
+
if (value === undefined)
|
|
44
|
+
continue;
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
for (const v of value)
|
|
47
|
+
headers.append(key, v);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
headers.set(key, value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const method = req.method ?? 'GET';
|
|
54
|
+
const hasBody = method !== 'GET' && method !== 'HEAD';
|
|
55
|
+
const init = {
|
|
56
|
+
method,
|
|
57
|
+
headers,
|
|
58
|
+
body: hasBody && body ? new Uint8Array(body) : undefined,
|
|
59
|
+
};
|
|
60
|
+
// Node.js 20+ requires duplex: 'half' for requests with a body.
|
|
61
|
+
// This property is not in bun-types' RequestInit, but this file only
|
|
62
|
+
// runs under Node.js.
|
|
63
|
+
if (hasBody) {
|
|
64
|
+
init['duplex'] = 'half';
|
|
65
|
+
}
|
|
66
|
+
return new Request(url, init);
|
|
67
|
+
};
|
|
68
|
+
/** Collect the full request body from an IncomingMessage */
|
|
69
|
+
const collectBody = (req) => new Promise((resolve, reject) => {
|
|
70
|
+
const chunks = [];
|
|
71
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
72
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
73
|
+
req.on('error', reject);
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Handle an HTTP request by converting it to a Web Request, running the
|
|
77
|
+
* fetch handler, and sending the Web Response back through the Node.js response.
|
|
78
|
+
*/
|
|
79
|
+
const handleHttpRequest = (options, adapter, req, res) => {
|
|
80
|
+
const run = async () => {
|
|
81
|
+
try {
|
|
82
|
+
const body = req.method !== 'GET' && req.method !== 'HEAD' ? await collectBody(req) : null;
|
|
83
|
+
const webReq = toWebRequest(req, body);
|
|
84
|
+
const webRes = await options.fetch(webReq, adapter);
|
|
85
|
+
if (webRes) {
|
|
86
|
+
sendResponse(webRes, res);
|
|
87
|
+
}
|
|
88
|
+
else if (!res.headersSent) {
|
|
89
|
+
res.writeHead(204);
|
|
90
|
+
res.end();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
log.error('Unhandled error in HTTP handler:', err);
|
|
95
|
+
if (!res.headersSent) {
|
|
96
|
+
res.writeHead(500);
|
|
97
|
+
res.end('Internal Server Error');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
void run();
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Handle a WebSocket upgrade by running the fetch handler (which calls
|
|
105
|
+
* adapter.upgrade()), then completing the upgrade via the ws library.
|
|
106
|
+
*/
|
|
107
|
+
const handleWsUpgradeEvent = (options, adapter, wss, getUpgradeContext, setUpgradeContext, setPendingHeaders, req, socket, head) => {
|
|
108
|
+
const run = async () => {
|
|
109
|
+
try {
|
|
110
|
+
setUpgradeContext({ requested: false });
|
|
111
|
+
const webReq = toWebRequest(req, null);
|
|
112
|
+
await options.fetch(webReq, adapter);
|
|
113
|
+
const ctx = getUpgradeContext();
|
|
114
|
+
setUpgradeContext(null);
|
|
115
|
+
if (!ctx?.requested) {
|
|
116
|
+
socket.destroy();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Stash custom headers (e.g., sec-websocket-protocol) so the 'headers'
|
|
120
|
+
// event listener on the WebSocketServer can inject them into the 101 response.
|
|
121
|
+
if (ctx.headers) {
|
|
122
|
+
const h = new Headers(ctx.headers);
|
|
123
|
+
const headerMap = {};
|
|
124
|
+
for (const [key, value] of h) {
|
|
125
|
+
headerMap[key] = value;
|
|
126
|
+
}
|
|
127
|
+
setPendingHeaders(headerMap);
|
|
128
|
+
}
|
|
129
|
+
wss.handleUpgrade(req, socket, head, ws => {
|
|
130
|
+
const handle = wrapWs(ws);
|
|
131
|
+
ws.on('message', (data, isBinary) => {
|
|
132
|
+
if (isBinary) {
|
|
133
|
+
if (Buffer.isBuffer(data)) {
|
|
134
|
+
options.websocket.message(handle, new Uint8Array(data));
|
|
135
|
+
}
|
|
136
|
+
else if (data instanceof ArrayBuffer) {
|
|
137
|
+
options.websocket.message(handle, data);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (Buffer.isBuffer(data)) {
|
|
141
|
+
options.websocket.message(handle, data.toString('utf-8'));
|
|
142
|
+
}
|
|
143
|
+
else if (Array.isArray(data)) {
|
|
144
|
+
options.websocket.message(handle, Buffer.concat(data).toString('utf-8'));
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
options.websocket.message(handle, new TextDecoder().decode(data));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
ws.on('close', () => options.websocket.close(handle));
|
|
151
|
+
options.websocket.open(handle);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
log.error('Unhandled error in WebSocket upgrade handler:', err);
|
|
156
|
+
setUpgradeContext(null);
|
|
157
|
+
socket.destroy();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
void run();
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Create a Node.js HTTP + WebSocket server that presents the ServerAdapter
|
|
164
|
+
* interface to the MCP server route handlers.
|
|
165
|
+
*
|
|
166
|
+
* The tricky part is WebSocket upgrades. Bun.serve() handles upgrades inline
|
|
167
|
+
* in the fetch handler — `server.upgrade(req)` completes the handshake and
|
|
168
|
+
* returns a boolean. Node.js + ws handle upgrades via the 'upgrade' event on
|
|
169
|
+
* the HTTP server, which is separate from normal request handling.
|
|
170
|
+
*
|
|
171
|
+
* Strategy: The 'upgrade' event constructs a Web Request, calls the fetch
|
|
172
|
+
* handler (which calls `adapter.upgrade()`), and if upgrade was requested,
|
|
173
|
+
* completes it via `wss.handleUpgrade()`.
|
|
174
|
+
*/
|
|
175
|
+
const createNodeServer = (options) => new Promise((resolveServer, rejectServer) => {
|
|
176
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
177
|
+
// The ws library emits 'headers' with the raw header lines just before
|
|
178
|
+
// sending the 101 response. We use this to inject custom headers
|
|
179
|
+
// (e.g., Sec-WebSocket-Protocol) from the route handler's upgrade call.
|
|
180
|
+
let pendingUpgradeHeaders = {};
|
|
181
|
+
wss.on('headers', (headers) => {
|
|
182
|
+
for (const [key, value] of Object.entries(pendingUpgradeHeaders)) {
|
|
183
|
+
headers.push(`${key}: ${value}`);
|
|
184
|
+
}
|
|
185
|
+
pendingUpgradeHeaders = {};
|
|
186
|
+
});
|
|
187
|
+
/**
|
|
188
|
+
* Mutable ref set during upgrade event processing. The adapter.upgrade()
|
|
189
|
+
* method reads/writes this to communicate upgrade intent back to the
|
|
190
|
+
* 'upgrade' event handler.
|
|
191
|
+
*/
|
|
192
|
+
let upgradeContext = null;
|
|
193
|
+
const adapter = {
|
|
194
|
+
upgrade: (_req, opts) => {
|
|
195
|
+
if (upgradeContext) {
|
|
196
|
+
upgradeContext.requested = true;
|
|
197
|
+
upgradeContext.headers = opts.headers;
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
},
|
|
202
|
+
timeout: () => {
|
|
203
|
+
// Node.js http server uses socket-level timeouts. The default is
|
|
204
|
+
// sufficient — long-running MCP responses keep the socket open as
|
|
205
|
+
// long as data is being written.
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
const httpServer = createServer((req, res) => {
|
|
209
|
+
handleHttpRequest(options, adapter, req, res);
|
|
210
|
+
});
|
|
211
|
+
httpServer.on('upgrade', (req, socket, head) => {
|
|
212
|
+
handleWsUpgradeEvent(options, adapter, wss, () => upgradeContext, ctx => {
|
|
213
|
+
upgradeContext = ctx;
|
|
214
|
+
}, headers => {
|
|
215
|
+
pendingUpgradeHeaders = headers;
|
|
216
|
+
}, req, socket, head);
|
|
217
|
+
});
|
|
218
|
+
httpServer.on('error', (err) => {
|
|
219
|
+
rejectServer(err);
|
|
220
|
+
});
|
|
221
|
+
httpServer.listen(options.port, options.hostname, () => {
|
|
222
|
+
const addr = httpServer.address();
|
|
223
|
+
const actualPort = typeof addr === 'object' && addr !== null ? addr.port : options.port;
|
|
224
|
+
resolveServer({
|
|
225
|
+
port: actualPort,
|
|
226
|
+
stop: () => {
|
|
227
|
+
wss.close();
|
|
228
|
+
httpServer.close();
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
export { createNodeServer };
|
|
234
|
+
//# sourceMappingURL=server-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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AAG,CAAC,KAAK,EAAE,CAAC;gBACZ,UAAU,CAAC,KAAK,EAAE,CAAC;YACrB,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAGL,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-confirmation.d.ts","sourceRoot":"","sources":["../src/skip-confirmation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"skip-confirmation.d.ts","sourceRoot":"","sources":["../src/skip-confirmation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,QAAO,OAA8B,CAAC"}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* The config.json `skipConfirmation` field is checked separately at reload
|
|
11
11
|
* time and combined with this flag in state.skipConfirmation.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
import { getArgv, getEnv } from '@opentabs-dev/shared';
|
|
14
|
+
const cliSkipConfirmation = getArgv().includes('--dangerously-skip-confirmation') || getEnv('OPENTABS_SKIP_CONFIRMATION') === '1';
|
|
14
15
|
/** Whether the CLI flag or env var requests confirmation bypass */
|
|
15
16
|
export const isCliSkipConfirmation = () => cliSkipConfirmation;
|
|
16
17
|
//# sourceMappingURL=skip-confirmation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-confirmation.js","sourceRoot":"","sources":["../src/skip-confirmation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,mBAAmB,GACvB,
|
|
1
|
+
{"version":3,"file":"skip-confirmation.js","sourceRoot":"","sources":["../src/skip-confirmation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,mBAAmB,GACvB,OAAO,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC,IAAI,MAAM,CAAC,4BAA4B,CAAC,KAAK,GAAG,CAAC;AAExG,mEAAmE;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAY,EAAE,CAAC,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-npm-discovery.d.ts","sourceRoot":"","sources":["../src/skip-npm-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"skip-npm-discovery.d.ts","sourceRoot":"","sources":["../src/skip-npm-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,eAAO,MAAM,kBAAkB,QAAO,OAA2B,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* This is used by E2E tests to prevent globally-installed npm plugins
|
|
9
9
|
* on the developer's machine from polluting test isolation.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
import { getEnv } from '@opentabs-dev/shared';
|
|
12
|
+
const skipNpmDiscovery = getEnv('OPENTABS_SKIP_NPM_DISCOVERY') === '1';
|
|
12
13
|
export const isSkipNpmDiscovery = () => skipNpmDiscovery;
|
|
13
14
|
//# sourceMappingURL=skip-npm-discovery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip-npm-discovery.js","sourceRoot":"","sources":["../src/skip-npm-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"skip-npm-discovery.js","sourceRoot":"","sources":["../src/skip-npm-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,gBAAgB,GAAG,MAAM,CAAC,6BAA6B,CAAC,KAAK,GAAG,CAAC;AAEvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAY,EAAE,CAAC,gBAAgB,CAAC"}
|
package/dist/version-check.d.ts
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { ServerState } from './state.js';
|
|
9
9
|
/**
|
|
10
|
-
* Query the
|
|
11
|
-
*
|
|
10
|
+
* Query the latest published version of a package via `npm view`.
|
|
11
|
+
* Delegates auth to npm itself, which reads ~/.npmrc for tokens —
|
|
12
|
+
* this handles private/scoped packages without manual token management.
|
|
12
13
|
*
|
|
13
14
|
* @param packageName - npm package name (e.g., 'opentabs-plugin-slack' or '@scope/opentabs-plugin-foo')
|
|
14
|
-
* @returns The latest version string
|
|
15
|
+
* @returns The latest version string, or null on failure
|
|
15
16
|
*/
|
|
16
|
-
export declare const fetchLatestVersion: (packageName: string) =>
|
|
17
|
+
export declare const fetchLatestVersion: (packageName: string) => string | null;
|
|
17
18
|
/**
|
|
18
19
|
* Compare two semver version strings (major.minor.patch only).
|
|
19
20
|
* Strips prerelease suffixes (e.g., "1.0.0-beta.1" → [1, 0, 0]) and leading 'v'
|
|
@@ -26,10 +27,10 @@ export declare const fetchLatestVersion: (packageName: string) => Promise<string
|
|
|
26
27
|
export declare const isNewer: (current: string, latest: string) => boolean;
|
|
27
28
|
/**
|
|
28
29
|
* Check all npm-installed plugins for newer versions on the registry.
|
|
29
|
-
* Runs
|
|
30
|
-
* results in `state.outdatedPlugins`. Skips local plugins
|
|
30
|
+
* Runs `npm view` for each plugin sequentially, logs outdated entries,
|
|
31
|
+
* and stores results in `state.outdatedPlugins`. Skips local plugins.
|
|
31
32
|
*
|
|
32
33
|
* @param state - Server state containing the plugin registry and outdatedPlugins target
|
|
33
34
|
*/
|
|
34
|
-
export declare const checkForUpdates: (state: ServerState) =>
|
|
35
|
+
export declare const checkForUpdates: (state: ServerState) => void;
|
|
35
36
|
//# sourceMappingURL=version-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-check.d.ts","sourceRoot":"","sources":["../src/version-check.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"version-check.d.ts","sourceRoot":"","sources":["../src/version-check.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AAK9D;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,aAAa,MAAM,KAAG,MAAM,GAAG,IAajE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,OAqBzD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,WAAW,KAAG,IAwDpD,CAAC"}
|