lensmcp 1.0.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/main.js CHANGED
@@ -12,7 +12,7 @@ function __decorate(decorators, target, key, desc) {
12
12
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13
13
  }
14
14
 
15
- // servers/lensai-mcp/dist/main.js
15
+ // servers/lensmcp-mcp/dist/main.js
16
16
  import "reflect-metadata";
17
17
  import { FrontMcp, FrontMcpInstance, LogLevel } from "@frontmcp/sdk";
18
18
 
@@ -15922,11 +15922,11 @@ var AgentSessionSchema = ResourceEnvelopeSchema.extend({
15922
15922
  });
15923
15923
 
15924
15924
  // libs/protocol-types/dist/lib/tokens.js
15925
- var SessionToken = /* @__PURE__ */ Symbol.for("@lensai/session/Session");
15926
- var EventBusToken = /* @__PURE__ */ Symbol.for("@lensai/core/EventBus");
15927
- var GraphStoreToken = /* @__PURE__ */ Symbol.for("@lensai/core/GraphStore");
15928
- var ResourceStoreToken = /* @__PURE__ */ Symbol.for("@lensai/core/ResourceStore");
15929
- var StorageToken = /* @__PURE__ */ Symbol.for("@lensai/storage/Storage");
15925
+ var SessionToken = /* @__PURE__ */ Symbol.for("@lensmcp/session/Session");
15926
+ var EventBusToken = /* @__PURE__ */ Symbol.for("@lensmcp/core/EventBus");
15927
+ var GraphStoreToken = /* @__PURE__ */ Symbol.for("@lensmcp/core/GraphStore");
15928
+ var ResourceStoreToken = /* @__PURE__ */ Symbol.for("@lensmcp/core/ResourceStore");
15929
+ var StorageToken = /* @__PURE__ */ Symbol.for("@lensmcp/storage/Storage");
15930
15930
 
15931
15931
  // libs/session/dist/lib/providers.js
15932
15932
  var activeSession;
@@ -15935,21 +15935,21 @@ function setActiveSession(session2) {
15935
15935
  }
15936
15936
  function requireSession() {
15937
15937
  if (!activeSession) {
15938
- throw new Error("No LensAI session is active. Did you call bootstrapLensai() before the FrontMCP container started?");
15938
+ throw new Error("No LensMCP session is active. Did you call bootstrapLensmcp() before the FrontMCP container started?");
15939
15939
  }
15940
15940
  return activeSession;
15941
15941
  }
15942
15942
  var SessionProvider = AsyncProvider({
15943
15943
  provide: SessionToken,
15944
- name: "LensaiSession",
15945
- description: "The active LensAI Session instance.",
15944
+ name: "LensmcpSession",
15945
+ description: "The active LensMCP Session instance.",
15946
15946
  scope: ProviderScope.GLOBAL,
15947
15947
  inject: () => [],
15948
15948
  useFactory: () => requireSession()
15949
15949
  });
15950
15950
  var EventBusProvider = AsyncProvider({
15951
15951
  provide: EventBusToken,
15952
- name: "LensaiEventBus",
15952
+ name: "LensmcpEventBus",
15953
15953
  description: "The session's normalised event bus.",
15954
15954
  scope: ProviderScope.GLOBAL,
15955
15955
  inject: () => [],
@@ -15957,7 +15957,7 @@ var EventBusProvider = AsyncProvider({
15957
15957
  });
15958
15958
  var GraphStoreProvider = AsyncProvider({
15959
15959
  provide: GraphStoreToken,
15960
- name: "LensaiGraphStore",
15960
+ name: "LensmcpGraphStore",
15961
15961
  description: "The typed multi-axis trace graph.",
15962
15962
  scope: ProviderScope.GLOBAL,
15963
15963
  inject: () => [],
@@ -15965,7 +15965,7 @@ var GraphStoreProvider = AsyncProvider({
15965
15965
  });
15966
15966
  var ResourceStoreProvider = AsyncProvider({
15967
15967
  provide: ResourceStoreToken,
15968
- name: "LensaiResourceStore",
15968
+ name: "LensmcpResourceStore",
15969
15969
  description: "Registry of agent-readable MCP resources.",
15970
15970
  scope: ProviderScope.GLOBAL,
15971
15971
  inject: () => [],
@@ -15973,13 +15973,13 @@ var ResourceStoreProvider = AsyncProvider({
15973
15973
  });
15974
15974
  var StorageProvider = AsyncProvider({
15975
15975
  provide: StorageToken,
15976
- name: "LensaiStorage",
15976
+ name: "LensmcpStorage",
15977
15977
  description: "Hot-tier storage backend (in-memory ring buffer by default).",
15978
15978
  scope: ProviderScope.GLOBAL,
15979
15979
  inject: () => [],
15980
15980
  useFactory: () => requireSession().storage
15981
15981
  });
15982
- var lensaiProviderArray = [
15982
+ var lensmcpProviderArray = [
15983
15983
  SessionProvider,
15984
15984
  EventBusProvider,
15985
15985
  GraphStoreProvider,
@@ -15988,11 +15988,11 @@ var lensaiProviderArray = [
15988
15988
  ];
15989
15989
 
15990
15990
  // libs/session/dist/lib/bootstrap.js
15991
- function bootstrapLensai(opts = {}) {
15991
+ function bootstrapLensmcp(opts = {}) {
15992
15992
  const session2 = new Session(opts);
15993
15993
  session2.start();
15994
15994
  setActiveSession(session2);
15995
- return { session: session2, providers: lensaiProviderArray };
15995
+ return { session: session2, providers: lensmcpProviderArray };
15996
15996
  }
15997
15997
 
15998
15998
  // libs/session/dist/lib/collectors/tsc-collector.js
@@ -16060,9 +16060,9 @@ function createUdsServer(opts) {
16060
16060
 
16061
16061
  // libs/session/dist/lib/ingest.js
16062
16062
  function startEventIngest(opts) {
16063
- const eventFile = opts.eventFile ?? process.env["LENSAI_EVENT_FILE"];
16064
- const socketPath = opts.socketPath ?? process.env["LENSAI_IPC_SOCKET"];
16065
- const udsPath = opts.udsPath ?? process.env["LENSAI_UDS"];
16063
+ const eventFile = opts.eventFile ?? process.env["LENSMCP_EVENT_FILE"];
16064
+ const socketPath = opts.socketPath ?? process.env["LENSMCP_IPC_SOCKET"];
16065
+ const udsPath = opts.udsPath ?? process.env["LENSMCP_UDS"];
16066
16066
  const onError = opts.onError ?? (() => void 0);
16067
16067
  let published = 0;
16068
16068
  const publish = (line) => {
@@ -16094,7 +16094,7 @@ function startEventIngest(opts) {
16094
16094
  let position = 0;
16095
16095
  let carry = "";
16096
16096
  let skipPartialFirstLine = false;
16097
- const replayBytes = opts.replayBytes ?? Number(process.env["LENSAI_REPLAY_BYTES"] ?? 4 * 1024 * 1024);
16097
+ const replayBytes = opts.replayBytes ?? Number(process.env["LENSMCP_REPLAY_BYTES"] ?? 4 * 1024 * 1024);
16098
16098
  if (existsSync2(eventFile)) {
16099
16099
  try {
16100
16100
  const size = statSync(eventFile).size;
@@ -16228,7 +16228,7 @@ function loadWorkspaceThresholds(cwd = process.cwd()) {
16228
16228
  return resolveThresholds();
16229
16229
  try {
16230
16230
  const nx = JSON.parse(readFileSync(nxPath, "utf8"));
16231
- return resolveThresholds(nx.lensai?.thresholds);
16231
+ return resolveThresholds(nx.lensmcp?.thresholds);
16232
16232
  } catch {
16233
16233
  return resolveThresholds();
16234
16234
  }
@@ -17970,7 +17970,7 @@ VisualRulesResource = __decorate([
17970
17970
  name: "visual-rules",
17971
17971
  uri: "visual://rules",
17972
17972
  mimeType: "application/json",
17973
- description: "All registered visual rules (builtins + lensai.rules.json + visual.register_rule)."
17973
+ description: "All registered visual rules (builtins + lensmcp.rules.json + visual.register_rule)."
17974
17974
  })
17975
17975
  ], VisualRulesResource);
17976
17976
  var rules_resource_default = VisualRulesResource;
@@ -17988,7 +17988,7 @@ VisualTokensResource = __decorate([
17988
17988
  name: "visual-tokens",
17989
17989
  uri: "visual://tokens",
17990
17990
  mimeType: "application/json",
17991
- description: "Resolved design tokens from lensai.tokens.json."
17991
+ description: "Resolved design tokens from lensmcp.tokens.json."
17992
17992
  })
17993
17993
  ], VisualTokensResource);
17994
17994
  var tokens_resource_default = VisualTokensResource;
@@ -18356,7 +18356,7 @@ ReactPagesCurrentResource = __decorate([
18356
18356
  name: "react-pages-current",
18357
18357
  uri: "react://pages/current",
18358
18358
  mimeType: "application/json",
18359
- description: "The most recently active React page (from <LensaiRoot>)."
18359
+ description: "The most recently active React page (from <LensmcpRoot>)."
18360
18360
  })
18361
18361
  ], ReactPagesCurrentResource);
18362
18362
  var pages_current_resource_default = ReactPagesCurrentResource;
@@ -18789,7 +18789,7 @@ ValtioStoresResource = __decorate([
18789
18789
  name: "valtio-stores",
18790
18790
  uri: "valtio://stores",
18791
18791
  mimeType: "application/json",
18792
- description: "Registered Valtio stores (created via lensai-wrapped proxy())."
18792
+ description: "Registered Valtio stores (created via lensmcp-wrapped proxy())."
18793
18793
  })
18794
18794
  ], ValtioStoresResource);
18795
18795
  var stores_resource_default = ValtioStoresResource;
@@ -19684,9 +19684,9 @@ function toOwnerView(o) {
19684
19684
  };
19685
19685
  }
19686
19686
 
19687
- // servers/lensai-mcp/dist/bootstrap.js
19687
+ // servers/lensmcp-mcp/dist/bootstrap.js
19688
19688
  function createLensSession() {
19689
- const { session: session2, providers: providers2 } = bootstrapLensai();
19689
+ const { session: session2, providers: providers2 } = bootstrapLensmcp();
19690
19690
  const thresholds = loadWorkspaceThresholds();
19691
19691
  installBuildReducer({ bus: session2.bus, resources: session2.resources });
19692
19692
  installLintReducer({ bus: session2.bus, resources: session2.resources });
@@ -19750,10 +19750,10 @@ function createLensSession() {
19750
19750
  });
19751
19751
  const ingest = startEventIngest({
19752
19752
  bus: session2.bus,
19753
- onError: (err) => console.error("[lensai] ingest error:", err)
19753
+ onError: (err) => console.error("[lensmcp] ingest error:", err)
19754
19754
  });
19755
19755
  if (ingest.mode !== "none") {
19756
- console.error(`[lensai] event ingest active (mode=${ingest.mode})`);
19756
+ console.error(`[lensmcp] event ingest active (mode=${ingest.mode})`);
19757
19757
  }
19758
19758
  session2.onShutdown({ name: "event-ingest", stop: () => ingest.stop() });
19759
19759
  return { session: session2, providers: providers2, ingest };
@@ -19764,7 +19764,7 @@ import { App as App17 } from "@frontmcp/sdk";
19764
19764
 
19765
19765
  // apps/meta/dist/tools/session.tool.js
19766
19766
  import { Tool as Tool22, ToolContext as ToolContext22 } from "@frontmcp/sdk";
19767
- var LensaiSessionTool = class LensaiSessionTool2 extends ToolContext22 {
19767
+ var LensmcpSessionTool = class LensmcpSessionTool2 extends ToolContext22 {
19768
19768
  async execute() {
19769
19769
  const session2 = this.get(SessionToken);
19770
19770
  const resources = this.get(ResourceStoreToken);
@@ -19774,7 +19774,7 @@ var LensaiSessionTool = class LensaiSessionTool2 extends ToolContext22 {
19774
19774
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
19775
19775
  sessionId: session2.id,
19776
19776
  supportedResources: resources.list(),
19777
- supportedTools: ["lensai.session", "observe.current_status"],
19777
+ supportedTools: ["lensmcp.session", "observe.current_status"],
19778
19778
  supportedJobs: [],
19779
19779
  supportedChannels: [],
19780
19780
  subscribedByDefault: ["agent://current-status"],
@@ -19784,29 +19784,29 @@ var LensaiSessionTool = class LensaiSessionTool2 extends ToolContext22 {
19784
19784
  node: process.version
19785
19785
  },
19786
19786
  project: {
19787
- name: "lensai"
19787
+ name: "lensmcp"
19788
19788
  }
19789
19789
  };
19790
19790
  }
19791
19791
  };
19792
- LensaiSessionTool = __decorate([
19792
+ LensmcpSessionTool = __decorate([
19793
19793
  Tool22({
19794
- name: "lensai.session",
19795
- description: "Returns the LensAI session bootstrap response (schema version, supported resources/tools, transport info, host info).",
19794
+ name: "lensmcp.session",
19795
+ description: "Returns the LensMCP session bootstrap response (schema version, supported resources/tools, transport info, host info).",
19796
19796
  inputSchema: {}
19797
19797
  })
19798
- ], LensaiSessionTool);
19799
- var session_tool_default = LensaiSessionTool;
19798
+ ], LensmcpSessionTool);
19799
+ var session_tool_default = LensmcpSessionTool;
19800
19800
 
19801
19801
  // apps/meta/dist/skills/lens.skill.js
19802
19802
  import { Skill } from "@frontmcp/sdk";
19803
- var UsingLensaiSkill = class UsingLensaiSkill2 {
19803
+ var UsingLensmcpSkill = class UsingLensmcpSkill2 {
19804
19804
  };
19805
- UsingLensaiSkill = __decorate([
19805
+ UsingLensmcpSkill = __decorate([
19806
19806
  Skill({
19807
- name: "using-lensai",
19808
- description: "Drive the LensAI lens to observe a running Vite+React+NestJS app: the install\u2192agent-dev\u2192read loop, which resource/tool answers which question, and how to trace a user action across the stack.",
19809
- tags: ["lensai", "observability", "debugging", "how-to"],
19807
+ name: "using-lensmcp",
19808
+ description: "Drive the LensMCP lens to observe a running Vite+React+NestJS app: the install\u2192agent-dev\u2192read loop, which resource/tool answers which question, and how to trace a user action across the stack.",
19809
+ tags: ["lensmcp", "observability", "debugging", "how-to"],
19810
19810
  priority: 100,
19811
19811
  toolValidation: "ignore",
19812
19812
  tools: [
@@ -19826,9 +19826,9 @@ UsingLensaiSkill = __decorate([
19826
19826
  expectedOutcome: "Call graph.explain_rerender for the component, then graph.trace_from_origin from the click flow."
19827
19827
  }
19828
19828
  ],
19829
- instructions: `# Using LensAI
19829
+ instructions: `# Using LensMCP
19830
19830
 
19831
- LensAI is an MCP server that gives you **deterministic observability into a
19831
+ LensMCP is an MCP server that gives you **deterministic observability into a
19832
19832
  running Vite + React + NestJS app**. Reach for it after you change code, to
19833
19833
  see what the running app actually did \u2014 not to read source. It is **zero
19834
19834
  config**: no app-code edits are required; the lens is wired in at the build
@@ -19836,21 +19836,21 @@ and bootstrap layer.
19836
19836
 
19837
19837
  ## The loop
19838
19838
 
19839
- 1. **Install once** (per workspace): \`npx -y lensai install\` \u2014 registers
19839
+ 1. **Install once** (per workspace): \`npx -y lensmcp install\` \u2014 registers
19840
19840
  the plugin + this MCP server in the workspace .mcp.json. Then
19841
- \`nx g @lensai/nx-plugin:setup-vite <web>\` and \`:setup-nest <api>\` wire each
19842
- project (rewrites main.ts \u2192 createLensaiNestApp; adds the Vite plugin).
19841
+ \`nx g @lensmcp/nx-plugin:setup-vite <web>\` and \`:setup-nest <api>\` wire each
19842
+ project (rewrites main.ts \u2192 createLensmcpNestApp; adds the Vite plugin).
19843
19843
  2. **Run** with capture: \`nx run <project>:agent-dev\` \u2014 starts the app and
19844
19844
  auto-captures backend spans, React renders, Valtio state, browser console/
19845
19845
  network, and (when a dev URL is set) real Chrome DOM/visual snapshots.
19846
19846
  3. **Read** the resources / call the tools below to answer your question.
19847
- 4. **If resources look empty**, run \`npx lensai doctor --json\` first \u2014 it
19847
+ 4. **If resources look empty**, run \`npx lensmcp doctor --json\` first \u2014 it
19848
19848
  reports Node, plugin registration, .mcp.json, per-project wiring, and
19849
19849
  agent-dev targets, each with a fix hint.
19850
19850
 
19851
19851
  Resources are **live snapshots** of the running app; re-read them after you
19852
19852
  act. Thresholds (when a signal fires) are tunable in
19853
- \`nx.json#lensai.thresholds\` (dbInLoop, nPlusOne, renderStorm, slowRouteMs,
19853
+ \`nx.json#lensmcp.thresholds\` (dbInLoop, nPlusOne, renderStorm, slowRouteMs,
19854
19854
  slowRenderMs).
19855
19855
 
19856
19856
  ## Decision map \u2014 question \u2192 where to look
@@ -19891,7 +19891,7 @@ slowRenderMs).
19891
19891
  ## Trace a user action across the whole stack
19892
19892
 
19893
19893
  A user interaction (onClick/onSubmit/onChange) is auto-wrapped so it starts a
19894
- **flow**: the browser stamps \`x-lensai-flow-id\` on outgoing fetches, and the
19894
+ **flow**: the browser stamps \`x-lensmcp-flow-id\` on outgoing fetches, and the
19895
19895
  backend stamps the same flowId on its spans. So you can ask "what did this
19896
19896
  click cause?":
19897
19897
 
@@ -19912,18 +19912,18 @@ click cause?":
19912
19912
  - \`events://recent\` is the raw firehose \u2014 use it only when a specific
19913
19913
  resource doesn't exist for what you need.`
19914
19914
  })
19915
- ], UsingLensaiSkill);
19915
+ ], UsingLensmcpSkill);
19916
19916
 
19917
19917
  // apps/meta/dist/meta.app.js
19918
19918
  var MetaApp = class MetaApp2 {
19919
19919
  };
19920
19920
  MetaApp = __decorate([
19921
19921
  App17({
19922
- id: "lensai",
19923
- name: "LensAI Meta",
19924
- description: 'Session, health, and config tools, plus the "how to use LensAI" skill.',
19922
+ id: "lensmcp",
19923
+ name: "LensMCP Meta",
19924
+ description: 'Session, health, and config tools, plus the "how to use LensMCP" skill.',
19925
19925
  tools: [session_tool_default],
19926
- skills: [UsingLensaiSkill]
19926
+ skills: [UsingLensmcpSkill]
19927
19927
  })
19928
19928
  ], MetaApp);
19929
19929
 
@@ -19989,8 +19989,8 @@ import { Job, JobContext, z as z23 } from "@frontmcp/sdk";
19989
19989
  var VerifyFixJob = class VerifyFixJob2 extends JobContext {
19990
19990
  async execute(input) {
19991
19991
  const startedAt = Date.now();
19992
- const projectName = input.project ?? process.env["LENSAI_VERIFY_PROJECT"] ?? "example-web";
19993
- const cwd = resolve(input.cwd ?? process.env["LENSAI_WORKSPACE_ROOT"] ?? process.cwd());
19992
+ const projectName = input.project ?? process.env["LENSMCP_VERIFY_PROJECT"] ?? "example-web";
19993
+ const cwd = resolve(input.cwd ?? process.env["LENSMCP_WORKSPACE_ROOT"] ?? process.cwd());
19994
19994
  const workspaceRoot = findNxWorkspaceRoot(cwd);
19995
19995
  if (!workspaceRoot) {
19996
19996
  this.log(`No nx.json found above ${cwd}`);
@@ -20050,7 +20050,7 @@ var VerifyFixJob = class VerifyFixJob2 extends JobContext {
20050
20050
  reportPath: null
20051
20051
  };
20052
20052
  }
20053
- const reportPath = join2(workspaceRoot, ".lensai", "verifications", "latest.json");
20053
+ const reportPath = join2(workspaceRoot, ".lensmcp", "verifications", "latest.json");
20054
20054
  let onDisk;
20055
20055
  if (existsSync4(reportPath)) {
20056
20056
  try {
@@ -20074,8 +20074,8 @@ VerifyFixJob = __decorate([
20074
20074
  name: "observe.verify_fix",
20075
20075
  description: "Run the deterministic verification loop (typecheck \u2192 lint \u2192 build) for a host project. Returns a per-stage report; suggested next read on failure is the relevant *://errors resource.",
20076
20076
  inputSchema: {
20077
- project: z23.string().describe('Nx project name in the host workspace to verify. Defaults to LENSAI_VERIFY_PROJECT or "example-web".').optional(),
20078
- cwd: z23.string().describe("Override the host workspace root. Defaults to LENSAI_WORKSPACE_ROOT or process.cwd().").optional(),
20077
+ project: z23.string().describe('Nx project name in the host workspace to verify. Defaults to LENSMCP_VERIFY_PROJECT or "example-web".').optional(),
20078
+ cwd: z23.string().describe("Override the host workspace root. Defaults to LENSMCP_WORKSPACE_ROOT or process.cwd().").optional(),
20079
20079
  timeoutMs: z23.number().int().positive().default(5 * 6e4).describe("How long to wait for the verify pipeline before declaring it stuck.")
20080
20080
  },
20081
20081
  outputSchema: {
@@ -20232,9 +20232,9 @@ RenderApp = __decorate([
20232
20232
  })
20233
20233
  ], RenderApp);
20234
20234
 
20235
- // servers/lensai-mcp/dist/main.js
20235
+ // servers/lensmcp-mcp/dist/main.js
20236
20236
  var { session, providers } = createLensSession();
20237
- var transport = process.env["LENSAI_TRANSPORT"] ?? "stdio";
20237
+ var transport = process.env["LENSMCP_TRANSPORT"] ?? "stdio";
20238
20238
  var apps = [
20239
20239
  MetaApp,
20240
20240
  AgentApp,
@@ -20258,28 +20258,28 @@ var apps = [
20258
20258
  MemoryApp
20259
20259
  ];
20260
20260
  var serverConfig = {
20261
- info: { name: "LensAI MCP", version: "1.0.0" },
20261
+ info: { name: "LensMCP MCP", version: "1.0.0" },
20262
20262
  apps,
20263
20263
  providers: [...providers]
20264
20264
  };
20265
- var LensaiMcpServer = class LensaiMcpServer2 {
20265
+ var LensmcpMcpServer = class LensmcpMcpServer2 {
20266
20266
  };
20267
- LensaiMcpServer = __decorate([
20267
+ LensmcpMcpServer = __decorate([
20268
20268
  FrontMcp({ ...serverConfig, serve: false })
20269
- ], LensaiMcpServer);
20270
- var main_default = LensaiMcpServer;
20269
+ ], LensmcpMcpServer);
20270
+ var main_default = LensmcpMcpServer;
20271
20271
  if (transport === "stdio") {
20272
20272
  FrontMcpInstance.runStdio({
20273
20273
  ...serverConfig,
20274
20274
  logging: { level: LogLevel.Warn }
20275
20275
  }).catch((err) => {
20276
- process.stderr.write(`[lensai] runStdio failed: ${err instanceof Error ? err.stack ?? err.message : String(err)}
20276
+ process.stderr.write(`[lensmcp] runStdio failed: ${err instanceof Error ? err.stack ?? err.message : String(err)}
20277
20277
  `);
20278
20278
  process.exit(1);
20279
20279
  });
20280
20280
  } else {
20281
- const entryPath = process.env["LENSAI_HTTP_PATH"] ?? "/mcp";
20282
- const http = transport === "socket" ? { socketPath: process.env["LENSAI_SOCKET_PATH"] ?? "/tmp/lensai-mcp.sock", entryPath } : { port: Number(process.env["LENSAI_PORT"] ?? 3e3), entryPath };
20281
+ const entryPath = process.env["LENSMCP_HTTP_PATH"] ?? "/mcp";
20282
+ const http = transport === "socket" ? { socketPath: process.env["LENSMCP_SOCKET_PATH"] ?? "/tmp/lensmcp-mcp.sock", entryPath } : { port: Number(process.env["LENSMCP_PORT"] ?? 3e3), entryPath };
20283
20283
  void FrontMcpInstance.bootstrap({
20284
20284
  ...serverConfig,
20285
20285
  logging: { level: LogLevel.Info },
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;AAmCD,wBAAsB,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAgChE"}
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++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lensmcp",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",