Skip to content

Inspector CLI#18229

Merged
sebavan merged 47 commits intoBabylonJS:masterfrom
ryantrem:inspector-v2/cli
Apr 8, 2026
Merged

Inspector CLI#18229
sebavan merged 47 commits intoBabylonJS:masterfrom
ryantrem:inspector-v2/cli

Conversation

@ryantrem
Copy link
Copy Markdown
Member

@ryantrem ryantrem commented Apr 2, 2026

This change introduces the Inspector CLI. High level, the CLI includes a long lived node process for the "bridge", a short lived node process for the CLI (which communicates with the bridge), and a new StartInspectable API that runs in the browser/app side and connects to the bridge. StartInspectable uses parts of the Inspector framework, like the ServiceContainer for modularity/extensibility. Services can introduce additional commands, which are dynamically fetched from the CLI. The "inspectable" ServiceContainer is longer lived than the one in Inspector, and the one in Inspector is aware of the "inspectable" one, which means Inspector can launch the "inspectable" if needed, can expose bridge connection status, and even contribute more CLI commands.

  • Add the ability for ServiceContainer to have a "parent" ServiceContainer (longer lived).
  • Add StartInspectable that sets up a ServiceContainerwith a set of services that are browser independent and provide a set of CLI commands (query scene entities, query entity details, take a screenshot, get stats, get shader code, etc.).
  • ShowInspector now calls StartInspectable, which is ref counted so if it has already been called, it just returns the existing instance. The inspectable ServiceContainer is used as a "parent" container for the Inspector ServiceContainer.
  • There is a new Inspector service that monitors the CLI "bridge" connection status and shows an icon in the bottom right toolbar, plus shows connect/disconnect toasts.
  • Added a CLI and CLI bridge (using WebSockets). There are a few fixed commands, like --help and --sessions, but everything else is dynamic and the commands are determined by the browser/app side.
  • Updated Inspector readme.md files to call out the CLI (largely for AI agent discoverability).
  • Updated the core readme.md (@babylonjs/core + babylonjs umd) with a tiny note about the Inspector (another breadcrumb for AI agents).
  • Updated the @babylonjs/inspector to fully bundle the CLI and the bridge, including all the node WebSocket code. This way it is very easy to run the CLI without having any external dependencies.
  • Marked new Inspectable related APIs as @experimental for now.

When developing the Inspector CLI, you can run npm run babylon-inspector -- --help (or other commands) from the packages/dev/inspector-v2 directory.
If you've built the full monorepo, you can also run npx babylon-inspector --help (or other commands) from anywhere, which will pick up the final built CLI from the public package. This is the same way someone consuming the @babylonjs/inspector package would run the CLI.

There is still an open question about whether we should have an Inspector MCP instead of or in addition to the CLI itself (most of the code would still stay the same though). Need to follow up with @RaananW on this.

After this PR, I will also explore more the idea of calling StartInspectable by default in Sandbox and Playground, and also the idea of exposing additional tool specific CLI commands, like getting/setting Playground code for example. We need some more discussion around this to see how it relates to other tool MCP efforts, so this will be a possible future change.

image
[04/02 11:12:27] /Users/ryantremblay/Repos/Babylon.js/packages/dev/inspector-v2> npm run babylon-inspector -- --session 2 --command get-count-stats

> @dev/inspector@1.0.0 babylon-inspector
> node --no-warnings dist/cli/cli.js --bridge-script dist/cli/bridge.js --session 2 --command get-count-stats

{
  "totalMeshes": 13,
  "activeMeshes": 13,
  "activeIndices": 1631379,
  "activeFaces": 543793,
  "activeBones": 6,
  "activeParticles": 30,
  "drawCalls": 2212014,
  "totalLights": 2,
  "totalVertices": 274644,
  "totalMaterials": 10,
  "totalTextures": 20
}

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18229/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18229/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18229/merge/?snapshot=refs/pull/18229/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18229/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18229/merge/?snapshot=refs/pull/18229/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18229/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 2, 2026

Copy link
Copy Markdown
Member

@sebavan sebavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a tiny question but LGTM. Is the plan to provide a skill though another package or should it be available there ?

Comment thread packages/public/umd/babylonjs/readme.md
Comment thread packages/public/@babylonjs/core/readme.md
@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/18229/merge/

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18229/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/18229/merge/?snapshot=refs/pull/18229/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 8, 2026

@sebavan sebavan merged commit 8622f35 into BabylonJS:master Apr 8, 2026
24 checks passed
SergioRZMasson added a commit to SergioRZMasson/Babylon.js that referenced this pull request Apr 28, 2026
The original squash branch carried 6 files for an older Inspector v2 CLI
WIP that was independently superseded in master by PRs BabylonJS#18229, BabylonJS#18271,
BabylonJS#18332, and BabylonJS#18337. Master never had these files; their import-path fixes
in d204462 only existed to keep them building and were unrelated to
the KHR_interactivity work.

Removed:
- packages/dev/inspector-v2/src/cli/protocol.ts
- packages/dev/inspector-v2/src/services/cli/cliConnectionStatus.ts
- packages/dev/inspector-v2/src/services/cli/inspectableBridgeService.ts
- packages/dev/inspector-v2/src/services/cli/inspectableCommandRegistry.ts
- packages/dev/inspector-v2/test/unit/modularity/serviceContainer.test.ts
- packages/dev/inspector-v2/test/unit/services/inspectableBridgeService.test.ts

These files have no consumers in master code (the live
cliConnectionStatusService.tsx imports from
shared-ui-components/modularTool/services/cli/bridgeConnectionStatus
instead).

Also fixes a strict-mode TS error in babylonScenePathToObjectConverter
(narrowing IBabylonSceneObjectModelTree to a Record<string, ...> needs a
double cast through unknown).

Overview.glb regression: still 168 passing / 17 failing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants