Skip to content

Add a command API for Phoenix (natural-language and AI-agent control) #942

Description

@rx18-eng

What this is about

Phoenix already has a rich programmatic API. EventDisplay exposes around 56 public methods (loadEvent, nextEvent / previousEvent, highlightObject(uuid), lookAtObject(uuid), getCollection / getCollections, zoomTo, animatePreset, the on / emit event bus, and more).

What it doesn't have is a single, described command surface that something outside Phoenix (a script, another application, or an AI agent) can inspect and say "these are the actions I can perform and how to call them."

This issue is about adding that command layer, then putting a natural-language interface on top of it so users can simply ask Phoenix to do things:

  • "show the two muons and rotate to the transverse view"
  • "hide the calorimeter"
  • "next event"
  • "filter tracks above 20 GeV"

instead of navigating the toolbar.

It is also a direct step toward #826 (making Phoenix easier to embed and integrate with other applications), in what I think is the most future-proof form.

Proposal

1. Command / action registry

Wrap the existing public API as named actions, each with a machine-readable description:

  • name
  • description
  • parameters
  • return value (where applicable)

This is the durable piece. Even without AI it immediately enables:

  • scripting
  • embedding
  • automation
  • testing

2. In-browser natural language control (zero install)

Run a small local model (WebLLM or Transformers.js on WebGPU) entirely in the browser.

The model simply maps natural language onto the existing command registry.

No server.
No API key.
Nothing leaves the browser.

Phoenix stays a static site that can run from GitHub Pages.

3. External agent bridge

Because the actions already exist in a structured schema, expose the same registry through the postMessage bridge discussed in #826.

That would allow external agents (ChatGPT, Claude, etc.) to inspect the available commands and drive a running Phoenix instance.

This is the part that makes Phoenix an event display AI agents can operate.

Why this fits Phoenix

Physics-safe

The AI never performs physics itself.

It only invokes deterministic Phoenix functions and reports reconstructed quantities already produced by the framework. It cannot invent detector data or "guess" physics.

Accessibility and teaching

Students who don't yet know the UI can simply ask for an action instead of hunting through menus.

This also improves accessibility for keyboard and screen-reader users.

Zero install

The in-browser model is lazy-loaded and fully client-side.

Users who never touch the feature pay no startup cost, and Phoenix remains deployable as static files.

Builds toward #826

The command registry is useful even without AI because it gives Phoenix a stable automation surface for embedding, scripting, and integration.

New capability

Current event displays (REve, iSpy, Firebird, HYPATIA, Belle II, etc.) are fundamentally click-driven.

A browser-based event display that can both understand natural-language commands and expose a structured action API for AI agents would be a genuinely new capability.

Rough plan

Phase 1: Command registry

  • Introduce a command/action registry wrapping the existing public API.
  • Add a command palette that executes registered commands.
  • No AI model.

This alone advances #826 and provides immediate value for scripting and embedding.

Phase 2: Natural-language layer

  • Add an optional in-browser model (WebLLM or Transformers.js).
  • Map free text onto the command registry.
  • Use constrained JSON/schema output so generated actions must match the registered command definitions.

Phase 3: External agent bridge

  • Expose the command registry over the existing postMessage bridge.
  • Allow external AI agents to inspect available actions and invoke them.

Why this is safe

  • No existing APIs need to change; the registry wraps the current public methods.
  • The AI layer only invokes existing deterministic commands.
  • Everything remains optional and lazy-loaded.
  • Phoenix continues to work completely offline and without any external service.

Out of scope

  • AI that classifies events or identifies particles.
  • Server-side inference.
  • External API dependencies.
  • Changes to the data model, loaders, or detector physics.

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions