lensmcp 1.1.0 → 1.2.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/bundled/bridge.js +4122 -0
- package/lib/cli.d.ts.map +1 -1
- package/lib/cli.js +67 -0
- package/package.json +1 -1
package/lib/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/lib/cli.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,gEAAgE;IAChE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/lib/cli.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,gEAAgE;IAChE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AA0CD,wBAAsB,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAkChE"}
|
package/lib/cli.js
CHANGED
|
@@ -16,6 +16,13 @@ Commands:
|
|
|
16
16
|
Serve a live web view of the lens (flows, signals,
|
|
17
17
|
stories, status) on --port (default 4321). Reads the
|
|
18
18
|
same .lensmcp/events.jsonl your agent-dev producers write.
|
|
19
|
+
bridge [--cwd <dir>] [--host <h>] [--port <n>]
|
|
20
|
+
Run the standalone browser-event bridge for hosts with
|
|
21
|
+
no LensMCP build plugin (webpack, Next.js, no build).
|
|
22
|
+
Listens on ws://--host:--port (default 127.0.0.1:5747)
|
|
23
|
+
and forwards @lensmcp/client-runtime envelopes into the
|
|
24
|
+
same .lensmcp/events.jsonl the MCP server tails. Point
|
|
25
|
+
your app at it with: import '@lensmcp/client-runtime/auto'
|
|
19
26
|
install [--cwd <dir>] [--skip-format] [--register-host-config <mode>]
|
|
20
27
|
Install LensMCP into the host Nx workspace at --cwd
|
|
21
28
|
(current directory by default). Delegates to
|
|
@@ -51,6 +58,8 @@ export async function runCli(ctx) {
|
|
|
51
58
|
return runMcp(ctx, rest, out, err);
|
|
52
59
|
case 'dashboard':
|
|
53
60
|
return runDashboard(ctx, rest, out, err);
|
|
61
|
+
case 'bridge':
|
|
62
|
+
return runBridge(ctx, rest, out, err);
|
|
54
63
|
case 'install':
|
|
55
64
|
return runInstall(ctx, rest, out, err);
|
|
56
65
|
case 'doctor':
|
|
@@ -133,6 +142,43 @@ function runDashboard(ctx, args, out, err) {
|
|
|
133
142
|
});
|
|
134
143
|
return { exitCode: result.status ?? 1 };
|
|
135
144
|
}
|
|
145
|
+
function runBridge(ctx, args, out, err) {
|
|
146
|
+
const opts = parseFlags(args, { string: ['--cwd', '--host', '--port'] });
|
|
147
|
+
const cwd = resolve(stringFlag(opts.flags['--cwd']) ?? ctx.cwd);
|
|
148
|
+
const host = stringFlag(opts.flags['--host']) ?? ctx.env?.['LENSMCP_WS_HOST'] ?? process.env['LENSMCP_WS_HOST'];
|
|
149
|
+
const port = stringFlag(opts.flags['--port']) ?? ctx.env?.['LENSMCP_WS_PORT'] ?? process.env['LENSMCP_WS_PORT'];
|
|
150
|
+
const binPath = findBridgeBundle(cwd);
|
|
151
|
+
if (!binPath) {
|
|
152
|
+
err('Could not locate the lensmcp bridge bundle.\n' +
|
|
153
|
+
'Looked in (in order):\n' +
|
|
154
|
+
' • <cli-package>/bundled/bridge.js (published bin)\n' +
|
|
155
|
+
' • <workspace>/libs/bridge/dist/main.js (dev build)\n' +
|
|
156
|
+
'For dev: `yarn nx build @lensmcp/bridge`.');
|
|
157
|
+
return { exitCode: 1 };
|
|
158
|
+
}
|
|
159
|
+
ensureLensmcpDir(cwd);
|
|
160
|
+
// Forward browser envelopes into the same JSONL the MCP server ingests, so
|
|
161
|
+
// the bridge sidecar and `lensmcp mcp` rendezvous with zero extra config.
|
|
162
|
+
const eventFile = ctx.env?.['LENSMCP_EVENT_FILE'] ??
|
|
163
|
+
process.env['LENSMCP_EVENT_FILE'] ??
|
|
164
|
+
join(cwd, '.lensmcp', 'events.jsonl');
|
|
165
|
+
const childEnv = {
|
|
166
|
+
...process.env,
|
|
167
|
+
...(ctx.env ?? {}),
|
|
168
|
+
LENSMCP_EVENT_FILE: eventFile,
|
|
169
|
+
};
|
|
170
|
+
if (host)
|
|
171
|
+
childEnv['LENSMCP_WS_HOST'] = host;
|
|
172
|
+
if (port)
|
|
173
|
+
childEnv['LENSMCP_WS_PORT'] = port;
|
|
174
|
+
out(`lensmcp bridge → ws://${host ?? '127.0.0.1'}:${port ?? '5747'} (forwarding to ${eventFile})`);
|
|
175
|
+
const result = spawnSync(process.execPath, [binPath], {
|
|
176
|
+
cwd,
|
|
177
|
+
stdio: 'inherit',
|
|
178
|
+
env: childEnv,
|
|
179
|
+
});
|
|
180
|
+
return { exitCode: result.status ?? 1 };
|
|
181
|
+
}
|
|
136
182
|
function runInstall(ctx, args, out, err) {
|
|
137
183
|
const opts = parseFlags(args, {
|
|
138
184
|
string: ['--cwd', '--register-host-config'],
|
|
@@ -423,6 +469,27 @@ function findServerBundle(cwd, file) {
|
|
|
423
469
|
}
|
|
424
470
|
return undefined;
|
|
425
471
|
}
|
|
472
|
+
/** Resolve the standalone bridge runner: the published `bundled/bridge.js`
|
|
473
|
+
* first, then the workspace dev build (`libs/bridge/dist/main.js`, walking up). */
|
|
474
|
+
function findBridgeBundle(cwd) {
|
|
475
|
+
// 1. Bundled inside the published lensmcp (ship step).
|
|
476
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
477
|
+
const bundled = resolve(here, '..', '..', 'bundled', 'bridge.js');
|
|
478
|
+
if (existsSync(bundled))
|
|
479
|
+
return bundled;
|
|
480
|
+
// 2. Dev build in the workspace (walk up from cwd).
|
|
481
|
+
let dir = cwd;
|
|
482
|
+
for (let i = 0; i < 5; i++) {
|
|
483
|
+
const candidate = join(dir, 'libs', 'bridge', 'dist', 'main.js');
|
|
484
|
+
if (existsSync(candidate))
|
|
485
|
+
return candidate;
|
|
486
|
+
const parent = dirname(dir);
|
|
487
|
+
if (parent === dir)
|
|
488
|
+
break;
|
|
489
|
+
dir = parent;
|
|
490
|
+
}
|
|
491
|
+
return undefined;
|
|
492
|
+
}
|
|
426
493
|
function findNxBinary(cwd) {
|
|
427
494
|
let dir = cwd;
|
|
428
495
|
for (let i = 0; i < 5; i++) {
|