◐ Shell
clean mode source ↗

refactor(core): update signalGraphTool to accept an Injector by csmick · Pull Request #69366 · angular/angular

Bug: x-mcp-type tells Chrome DevTools for Agents to pass an element in. The agent itself doesn't actually see DOM elements, just some uid identifiers which refer to them. You can see this with the take_snapshot tool I think which shows DOM elements and a mapping of uid values.

x-mcp-type allows the agent to provide that uid when invoking its tool and then the Puppeteer layer converts that to the actual DOM element reference before invoking our JavaScript. The agent doesn't know what an Injector is and cannot provide that value.

So I don't think we can change this in the tool definition, but we can potentially make it parameterized so we break the link on getInjector. Maybe something like:

export function createSignalGraphTool(getInjector: (el: HTMLElement) => Injector): ... {
  return {
    name: 'angular:get_signal_graph',
    description: '...',
    execute: async ({target}: {target: HTMLElement}) => {
      const injector = getInjector(target); // Use from closure
      // ...
    },
  };
}

Then Angular's entry point can link this into discovery utils while Wiz can link in its own mapping.

Alternatively, we could break this dependency entirely and call globalThis.ng.getInjector, trusting that this will be set up with the right implementation, but that feels trickier to test and less reliable overall, so I probably would avoid that unless we didn't see a better option.