currentAgentVisuals
Returns the cursor controls of the most recently started createWebAgents (so of WebAgentsProvider), or null.
Returns the cursor controls (setSpotlight, setYieldToUser) of the most recently started createWebAgents, so of <WebAgentsProvider>, that has a cursor, or null. For UI that sits beside the provider without a handle on it: the devtools’ Settings switches find the cursor this way, which is why @webmcp-agents/devtools needs nothing from @webmcp-agents/react.
Import
import { currentAgentVisuals } from "@webmcp-agents/core";
Example
A spotlight switch of your own, wired to whatever cursor the page has started.
import { currentAgentVisuals } from "@webmcp-agents/core";
// A spotlight switch of your own, beside a provider you have no handle
// on: it drives that provider's cursor, or is disabled without one.
const toggle = document.querySelector<HTMLInputElement>("#spotlight");
if (toggle) {
toggle.disabled = !currentAgentVisuals();
toggle.addEventListener("change", () => {
currentAgentVisuals()?.setSpotlight(toggle.checked);
});
}
Options
None: currentAgentVisuals() takes no arguments.
Returns
Pick<AgentVisuals, "setSpotlight" | "setYieldToUser"> | null: the same object as that instance’s agents.visuals. null when nothing is started, or every started instance has visuals: false.
Notes
- Read it when you need it, not at import time: an instance counts from
start()todestroy(). A React component reads it in an effect: the provider’s layout effect has started it by then. - With several started instances, the latest started wins; one with
visuals: falseis skipped. - A change made while the cursor is not installed yet (the polyfill still loading) becomes the cursor’s starting option.
- On the server it returns
null: nothing starts there.
See also
createWebAgents, whosevisualsthis returnsinstallWebAgentsDevtools, whosevisualsdefaults to itinstallAgentVisuals, the cursor and its options