mastra-ai/mastra · error · Error
Keyboard event injection not supported by this provider
Error message
Keyboard event injection not supported by this provider
What it means
injectKeyboardEvent is a base-class stub that providers override when they support text/key event injection (e.g. CDP Input.dispatchKeyEvent). The default implementation always throws for providers without keyboard input support.
Source
Thrown at packages/core/src/browser/browser.ts:1512
// Event Injection (optional - for Studio live view)
// ---------------------------------------------------------------------------
/**
* Inject a mouse event. Override in subclass if supported.
* @param event - Mouse event parameters
* @param threadId - Optional thread ID for thread-isolated sessions
*/
async injectMouseEvent(_event: MouseEventParams, _threadId?: string): Promise<void> {
throw new Error('Mouse event injection not supported by this provider');
}
/**
* Inject a keyboard event. Override in subclass if supported.
* @param event - Keyboard event parameters
* @param threadId - Optional thread ID for thread-isolated sessions
*/
async injectKeyboardEvent(_event: KeyboardEventParams, _threadId?: string): Promise<void> {
throw new Error('Keyboard event injection not supported by this provider');
}
// ---------------------------------------------------------------------------
// Abstract Methods (providers must implement)
// ---------------------------------------------------------------------------
/**
* Get the active page for a thread.
* Used by screencast reconnection to emit the current URL.
*
* @param threadId - Optional thread ID (uses current thread if not provided)
* @returns The active Playwright Page, or null if not available
*/
protected abstract getActivePage(threadId?: string): Promise<{ url(): string } | null>;
/**
* Get the current browser state for a thread.
* Used to persist and restore browser state across sessions.View on GitHub (pinned to 75dd419e61)
Solutions
- Use a provider that implements injectKeyboardEvent.
- Check capability before calling and fall back to higher-level typing APIs.
- Implement the override in a custom provider subclass.
- Inject input directly on the page/session object the provider exposes.
Example fix
// before
await browser.injectKeyboardEvent({ type: 'keyDown', key: 'Enter' });
// after
await page.keyboard.press('Enter'); // via provider-exposed page handle Defensive patterns
Strategy: validation
Validate before calling
if (browser.injectKeyboardEvent === MastraBrowser.prototype.injectKeyboardEvent) {
throw new Error(`Provider ${browser.provider} cannot inject keyboard events`);
} Type guard
function supportsKeyboardInput(b: object): boolean {
return b.injectKeyboardEvent !== MastraBrowser.prototype.injectKeyboardEvent;
} Try / catch
try {
await browser.injectKeyboardEvent(ev, threadId);
} catch (err) {
if (err instanceof Error && err.message.includes('Keyboard event injection not supported')) {
await page.keyboard.type(ev.key); // fallback via page handle
} else throw err;
} Prevention
- Feature-detect input injection before enabling form-filling flows.
- Bundle mouse/keyboard capability checks together since they usually co-vary.
- Prefer providers that expose a page/session handle as a fallback path.
- Add capability assertions to integration tests.
When it happens
Trigger: Calling browser.injectKeyboardEvent(event, threadId?) on a provider that has not overridden the method.
Common situations: Typing into forms during agent automation against a provider lacking input injection; shared tooling that sends both mouse and keyboard events but runs on a launch-only provider.
Related errors
- Mouse event injection not supported by this provider
- Sandbox provider "${config.sandbox.provider}" does not suppo
- ${this.provider} does not support connecting to external CDP
- Screencast not supported by this provider
- No CDP session available
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/1576aadf2832c922.
Report an issue: GitHub.