Back to Eliza

Capacitor Plugins

packages/docs/apps/mobile/capacitor-plugins.md

2.0.121.5 KB
Original Source

The Eliza mobile app ships custom Capacitor plugins plus core @capacitor/* plugins. Each custom plugin is an independent package under packages/native/plugins/<name>/ and must be compiled before the web app can bundle it (bun run plugin:build from packages/app). Platform availability differs by package: some plugins ship Swift and Kotlin implementations, some are iOS-only or Android-only, and some are web or TypeScript facades used by the app shell.

Most plugins follow the same structure: a TypeScript interface describing the web-facing API, a web implementation used in browser environments, and native implementations for iOS (Swift) or Android (Kotlin) when the platform allows the feature. Platform-specific gaps are intentional for phone, SMS, contacts, Wi-Fi, system settings, Apple Calendar, and iOS Screen Time surfaces.

Plugin Bridge

The bridge is the single entry point for all plugin access. It initializes at app startup, probes each plugin for availability, and exposes the results at window.Eliza.plugins and window.Eliza.pluginCapabilities.

Use waitForBridge() before accessing any plugin, then check isFeatureAvailable() for platform-specific features before calling them:

typescript
import { waitForBridge, isFeatureAvailable } from "./bridge/plugin-bridge";

await waitForBridge();

if (isFeatureAvailable("gateway")) {
  await window.Eliza.plugins.gateway.startDiscovery();
}

Capability map — keys accepted by isFeatureAvailable():

KeyPlugin
gateway@elizaos/capacitor-gateway
voiceWake@elizaos/capacitor-swabble
talkMode@elizaos/capacitor-talkmode
camera@elizaos/capacitor-camera
location@elizaos/capacitor-location
screenCapture@elizaos/capacitor-screencapture
canvas@elizaos/capacitor-canvas
desktop@elizaos/capacitor-desktop

@elizaos/capacitor-gateway

WebSocket RPC connection to a Eliza gateway with mDNS/Bonjour discovery of local gateways on the same network. Handles token or password authentication, automatic reconnection, and session continuity via session keys.

Methods

MethodParametersReturnsDescription
startDiscoveryPromise<void>Begin mDNS scanning for gateways on the local network
stopDiscoveryPromise<void>Stop mDNS scanning
getDiscoveredGatewaysPromise<Gateway[]>Return the current list of discovered gateways
connecturl: string, token?: string, password?: string, clientName?: string, sessionKey?: string, role?: string, scopes?: string[]Promise<void>Open a WebSocket RPC connection to the given gateway URL
disconnectPromise<void>Close the active connection
isConnectedPromise<{ connected: boolean }>Return the current connection status
sendmethod: string, params?: Record<string, unknown>Promise<unknown>Send an RPC message over the active connection
getConnectionInfoPromise<ConnectionInfo>Return metadata for the current connection (URL, role, scopes, session key)

Events

EventPayloadDescription
gatewayEvent{ type: string, data: unknown }Arbitrary RPC event pushed from the gateway
stateChange{ state: "connecting" | "connected" | "disconnected" | "reconnecting" }Connection state transitions
error{ message: string, code?: string }Connection or protocol error
discovery{ action: "found" | "lost" | "updated", gateway: Gateway }A gateway was discovered, lost, or its metadata changed

@elizaos/capacitor-swabble

Continuous background wake-word detection. Uses the native Speech framework on iOS, SpeechRecognizer on Android, or Whisper.cpp on desktop. Falls back to the Web Speech API in browser environments.

Methods

MethodParametersReturnsDescription
startconfig: { triggers: string[], locale?: string, sampleRate?: number, modelSize?: string }Promise<void>Start listening for wake words
stopPromise<void>Stop listening
isListeningPromise<{ listening: boolean }>Return whether the detector is currently active
getConfigPromise<SwabbleConfig>Return the active configuration
updateConfigconfig: Partial<SwabbleConfig>Promise<void>Update configuration without stopping the detector
checkPermissionsPromise<PermissionStatus>Check microphone and speech recognition permissions
requestPermissionsPromise<PermissionStatus>Request required permissions from the user
getAudioDevicesPromise<AudioDevice[]>List available audio input devices
setAudioDevicedeviceId: stringPromise<void>Set the active audio input device

Events

EventPayloadDescription
wakeWord{ trigger: string, confidence: number }A wake word from the triggers list was detected
transcript{ text: string, isFinal: boolean }Interim or final speech transcription following a wake word
stateChange{ state: "idle" | "listening" | "processing" | "error" }Detector state transitions
audioLevel{ level: number }Real-time microphone amplitude (0–1) for UI indicators
error{ message: string, code?: string }Detection or permission error

@elizaos/capacitor-talkmode

Full speech pipeline integrating STT, chat relay to the agent, and TTS output. STT uses native recognition or Whisper; TTS uses ElevenLabs streaming or native speech synthesis. The pipeline is stateful — only one phase is active at a time.

Methods

MethodParametersReturnsDescription
startconfig?: TalkModeConfigPromise<void>Activate the talk mode pipeline
stopPromise<void>Deactivate and release audio resources
isEnabledPromise<{ enabled: boolean }>Return whether talk mode is currently active
getStatePromise<{ state: "idle" | "listening" | "processing" | "speaking" | "error" }>Return the current pipeline state
updateConfigconfig: Partial<TalkModeConfig>Promise<void>Update pipeline settings at runtime
speaktext: string, directive?: string, useSystemTts?: booleanPromise<void>Speak text directly, bypassing STT/chat phases
stopSpeakingPromise<void>Interrupt current TTS playback
isSpeakingPromise<{ speaking: boolean }>Return whether TTS is currently active
checkPermissionsPromise<PermissionStatus>Check microphone permissions
requestPermissionsPromise<PermissionStatus>Request microphone permissions

Events

EventPayloadDescription
stateChange{ state: "idle" | "listening" | "processing" | "speaking" | "error" }Pipeline state transitions
transcript{ text: string, isFinal: boolean }STT output (interim and final)
speaking{ text: string }TTS has begun speaking this text
speakComplete{ text: string }TTS finished speaking
error{ message: string, code?: string, phase?: string }Error in any pipeline phase

@elizaos/capacitor-camera

Camera enumeration, live preview rendering into an HTML element, photo capture, video recording, and manual controls. On web, falls back to getUserMedia.

Methods

MethodParametersReturnsDescription
getDevicesPromise<CameraDevice[]>List all available camera devices
startPreviewelement: HTMLElement, deviceId?: string, direction?: "front" | "back", resolution?: string, frameRate?: number, mirror?: booleanPromise<void>Begin a live camera preview rendered into the given element
stopPreviewPromise<void>Stop the live preview
switchCameraPromise<void>Toggle between front and back cameras
capturePhotoquality?: number, format?: "jpeg" | "png" | "webp", width?: number, height?: numberPromise<{ dataUrl: string }>Capture a still photo from the active preview
startRecordingquality?: string, maxDuration?: number, audio?: boolean, bitrate?: numberPromise<void>Begin video recording
stopRecordingPromise<{ uri: string }>Stop recording and return the file URI
getRecordingStatePromise<{ state: string, duration: number }>Return current recording state and elapsed duration
getSettingsPromise<CameraSettings>Return current camera settings
setSettingssettings: Partial<CameraSettings>Promise<void>Update camera settings
setZoomfactor: numberPromise<void>Set the zoom level (1.0 = no zoom)
setFocusPointx: number, y: numberPromise<void>Set manual focus point (normalized 0–1 coordinates)
setExposurePointx: number, y: numberPromise<void>Set manual exposure point (normalized 0–1 coordinates)
checkPermissionsPromise<PermissionStatus>Check camera and microphone permissions
requestPermissionsPromise<PermissionStatus>Request camera and microphone permissions

Events

EventPayloadDescription
frame{ timestamp: number }Fired for each rendered preview frame
error{ message: string, code?: string }Camera or recording error
recordingState{ state: string, duration: number }Recording state change

@elizaos/capacitor-location

GPS and network-based geolocation with configurable accuracy, position watching, and background location support on iOS and Android.

Methods

MethodParametersReturnsDescription
getCurrentPositionaccuracy?: "high" | "balanced" | "low", maxAge?: number, timeout?: numberPromise<Position>Fetch the current device position
watchPositionminDistance?: number, minInterval?: numberPromise<{ watchId: string }>Begin continuous position updates
clearWatchwatchId: stringPromise<void>Stop a position watch
checkPermissionsPromise<PermissionStatus>Check location permissions
requestPermissionsPromise<PermissionStatus>Request location permissions

Events

EventPayloadDescription
locationChange{ position: Position }A new position is available from an active watch
error{ code: "PERMISSION_DENIED" | "POSITION_UNAVAILABLE" | "TIMEOUT", message: string }Position acquisition failed

@elizaos/capacitor-screencapture

Screenshots and screen recording with pause/resume support. On web, falls back to getDisplayMedia for screen recording.

Methods

MethodParametersReturnsDescription
isSupportedPromise<{ supported: boolean }>Check whether screen capture is available on the current platform
captureScreenshotformat?: "png" | "jpeg" | "webp", quality?: number, scale?: numberPromise<{ dataUrl: string }>Capture a still screenshot
startRecordingquality?: string, maxDuration?: number, fps?: number, captureAudio?: booleanPromise<void>Begin screen recording
stopRecordingPromise<{ uri: string }>Stop recording and return the file URI
pauseRecordingPromise<void>Pause an active recording
resumeRecordingPromise<void>Resume a paused recording
getRecordingStatePromise<{ state: string, duration: number }>Return recording state and elapsed duration
checkPermissionsPromise<PermissionStatus>Check screen capture permissions
requestPermissionsPromise<PermissionStatus>Request screen capture permissions

Events

EventPayloadDescription
recordingState{ state: string, duration: number }Recording state change (started, paused, stopped)
error{ message: string, code?: string }Capture or recording error

@elizaos/capacitor-canvas

Drawing primitives, layer management, embedded web view control, JavaScript evaluation, A2UI directive injection, and eliza:// deep link interception. The canvas layer renders natively on iOS and Android and sits above the Capacitor web view.

Drawing Methods

MethodParametersDescription
createid: string, config?: CanvasConfigCreate a new canvas surface
destroyid: stringDestroy a canvas surface and release resources
attachid: string, element: HTMLElementAttach a canvas to a DOM element
detachid: stringDetach a canvas from its DOM element
resizeid: string, width: number, height: numberResize the canvas surface
clearid: stringClear all content from the canvas
drawRectid: string, x: number, y: number, width: number, height: number, style?: DrawStyleDraw a rectangle
drawEllipseid: string, cx: number, cy: number, rx: number, ry: number, style?: DrawStyleDraw an ellipse
drawLineid: string, x1: number, y1: number, x2: number, y2: number, style?: DrawStyleDraw a line segment
drawPathid: string, path: PathCommand[], style?: DrawStyleDraw an arbitrary path
drawTextid: string, text: string, x: number, y: number, style?: TextStyleDraw text
drawImageid: string, src: string, x: number, y: number, width?: number, height?: numberDraw an image from a URI or data URL
drawBatchid: string, commands: DrawCommand[]Execute multiple draw commands in a single call
getPixelDataid: string, x: number, y: number, width: number, height: numberReturn raw pixel data for a region
toImageid: string, format?: string, quality?: numberExport the canvas as a data URL
setTransformid: string, matrix: number[]Apply a transformation matrix
resetTransformid: stringReset to the identity transform

Layer Methods

MethodParametersDescription
createLayercanvasId: string, layerId: string, config?: LayerConfigAdd a new layer to a canvas
updateLayercanvasId: string, layerId: string, config: Partial<LayerConfig>Update layer properties (opacity, visibility, order)
deleteLayercanvasId: string, layerId: stringRemove a layer
getLayerscanvasId: stringReturn all layers for a canvas

Web View Methods

MethodParametersDescription
navigatecanvasId: string, url: stringNavigate the embedded web view to a URL
evalcanvasId: string, script: stringEvaluate JavaScript in the embedded web view
snapshotcanvasId: stringCapture a screenshot of the embedded web view
a2uiPushcanvasId: string, directive: objectInject an A2UI directive into the web view
a2uiResetcanvasId: stringReset the A2UI state in the web view

Events

EventPayloadDescription
touch{ canvasId: string, x: number, y: number, type: string }Touch or pointer event on the canvas
render{ canvasId: string, timestamp: number }Canvas render frame tick
webViewReady{ canvasId: string }Embedded web view has finished loading
navigationError{ canvasId: string, url: string, error: string }Web view navigation failed
deepLink{ canvasId: string, url: string }A eliza:// deep link was intercepted in the web view
a2uiAction{ canvasId: string, action: string, payload: unknown }An A2UI action was triggered from within the web view

@elizaos/capacitor-agent

Agent lifecycle management. Communicates with the Eliza agent process via IPC on Electrobun and via HTTP on iOS, Android, and web.

Methods

MethodParametersReturnsDescription
startPromise<void>Start the agent process
stopPromise<void>Stop the agent process
getStatusPromise<{ state: AgentState }>Return the current agent state
chattext: stringPromise<void>Send a text message to the running agent

Agent States

StateDescription
not_startedAgent has never been started in this session
startingAgent process is initializing
runningAgent is active and accepting messages
stoppedAgent was stopped cleanly
errorAgent encountered a fatal error

@elizaos/capacitor-desktop

Electrobun-only plugin for desktop integration. All methods are no-ops on iOS and Android. Check isFeatureAvailable("desktop") before calling any method.

Tray Methods

MethodParametersDescription
createTrayconfig: TrayConfigCreate the system tray icon
updateTrayconfig: Partial<TrayConfig>Update the tray icon or tooltip
destroyTrayRemove the system tray icon
setTrayMenuitems: MenuItem[]Set the tray context menu items

Global Shortcut Methods

MethodParametersDescription
registerShortcutaccelerator: string, id: stringRegister a global keyboard shortcut
unregisterShortcutaccelerator: stringUnregister a specific shortcut
unregisterAllShortcutsUnregister all shortcuts registered by this app
isShortcutRegisteredaccelerator: stringCheck whether a shortcut is currently registered

Auto Launch Methods

MethodParametersDescription
setAutoLaunchenabled: booleanEnable or disable launch at login
getAutoLaunchStatusReturn whether auto launch is currently enabled

Window Methods

MethodParametersDescription
minimizeMinimize the window
maximizeMaximize the window
unmaximizeRestore the window from maximized state
isMaximizedCheck whether the window is maximized
hideHide the window
showShow the window
focusBring the window to focus
closeClose the window
setFullscreenfullscreen: booleanEnter or exit fullscreen mode
isFullscreenCheck whether the window is fullscreen
getBoundsReturn { x, y, width, height } for the window
setBoundsbounds: Partial<Rectangle>Set the window position and/or size
setOpacityopacity: numberSet window opacity (0–1)
getOpacityReturn the current window opacity
setAlwaysOnTopflag: booleanPin or unpin the window above others
isAlwaysOnTopCheck whether always-on-top is active
centerMove the window to the center of the screen
setTitletitle: stringSet the window title bar text

Notification Methods

MethodParametersDescription
showNotificationconfig: NotificationConfigShow a system notification
closeNotificationid: stringDismiss a specific notification

Power Methods

MethodParametersDescription
getPowerStateReturn battery level, charging state, and power source

App Methods

MethodParametersDescription
quitQuit the Electrobun application
relaunchRelaunch the Electrobun application
getVersionReturn the application version string
isPackagedReturn whether the app is running from a packaged build
getPathname: stringReturn an Electrobun app path (e.g., userData, logs)

Clipboard Methods

MethodParametersDescription
writeToClipboardtext: stringWrite text to the system clipboard
readFromClipboardRead text from the system clipboard
clearClipboardClear the system clipboard

Shell Methods

MethodParametersDescription
openExternalurl: stringOpen a URL in the default browser
showItemInFolderpath: stringReveal a file in Finder/Explorer
beepPlay the system alert sound

@capacitor/haptics

Standard Capacitor haptics plugin. Provides impact, notification, and selection feedback patterns on iOS and Android. No-op on web and desktop.

typescript
import { Haptics, ImpactStyle, NotificationType } from "@capacitor/haptics";

await Haptics.impact({ style: ImpactStyle.Medium });
await Haptics.notification({ type: NotificationType.Success });
await Haptics.selectionStart();
await Haptics.selectionChanged();
await Haptics.selectionEnd();

  • Mobile App — platform configuration, build targets, and project structure
  • Build Guide — how to compile plugins and produce signed iOS/Android builds
  • Native Modules — equivalent capability system for the Electrobun desktop app