@ateam-ai-mobile/plugin-runtime 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-PKDQLNBL.mjs +2873 -0
- package/dist/chunk-PKDQLNBL.mjs.map +1 -0
- package/dist/index.d.mts +1759 -8
- package/dist/index.d.ts +1759 -8
- package/dist/index.js +2467 -1321
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +335 -2139
- package/dist/index.mjs.map +1 -1
- package/dist/loader-5LUVXUY2.mjs +9 -0
- package/dist/loader-5LUVXUY2.mjs.map +1 -0
- package/package.json +2 -2
- package/src/bundles/bundleManager.ts +368 -27
- package/src/bundles/integrity.ts +29 -0
- package/src/bundles/storage.ts +40 -0
- package/src/deviceStateHost.ts +197 -0
- package/src/hooks/usePlugin.ts +1 -1
- package/src/host.ts +80 -8
- package/src/index.ts +90 -1
- package/src/pluginRuntime.ts +97 -0
- package/src/sdk/CameraPreview.tsx +94 -0
- package/src/sdk/device-state.ts +1225 -0
- package/src/sdk/index.ts +35 -3
- package/src/sdk/registration.ts +39 -0
- package/src/sdk/types.ts +345 -8
- package/src/sdk/voice.ts +148 -0
- package/src/tools/loader.ts +167 -0
- package/src/tools/platformTools.ts +41 -0
- package/src/tools/registry.ts +183 -0
- package/src/tools/serverCalls.ts +78 -0
- package/src/tools/sessionSync.ts +107 -0
- package/src/voiceHost.ts +126 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/plugins.ts","../src/bundles/bundleManager.ts","../src/sdk/index.ts","../src/sdk/registration.ts","../src/sdk/voice.ts","../src/sdk/primitives.ts","../src/sdk/components.ts","../src/host.ts","../src/sdk/CameraPreview.tsx","../src/sdk/usePluginTheme.ts","../src/sdk/useApi.ts","../src/surfaces/SurfaceDrawer.tsx","../src/surfaces/AdaOrb.tsx","../src/surfaces/SurfaceCard.tsx","../src/surfaces/SurfaceFullscreen.tsx","../src/registry/store.ts","../src/registry/SurfaceDispatcher.tsx","../src/utils/sha256.ts","../src/bundles/integrity.ts","../src/bundles/storage.ts","../src/bridge/native.ts","../src/deviceStateHost.ts","../src/tools/registry.ts","../src/tools/loader.ts"],"sourcesContent":["import { apiFetch } from '@ateam-ai-mobile/core';\nimport { getCoreApiUrl } from '@ateam-ai-mobile/core';\n\n/**\n * Summary returned by cp.listContextPlugins — no `render` field.\n * Used for the plugin grid (name, icon, description).\n */\nexport interface PluginSurfaceMeta {\n type: 'drawer' | 'card' | 'fullscreen' | 'header' | 'ambient' | 'nudge';\n visibility?: 'always' | 'user' | 'engine';\n trigger?: { from?: string; gesture?: string };\n icon?: string;\n title?: string;\n subtitle?: string;\n privacy?: boolean;\n prompt?: string;\n}\n\nexport interface PluginSummary {\n id: string;\n name: string;\n version: string;\n description?: string;\n _source?: string; // \"mcp\" for connector plugins\n _connectorId?: string;\n /** Declarative surface placement — added by the surface-SDK migration */\n surface?: PluginSurfaceMeta;\n}\n\n/**\n * Native capability flags (declared in manifest).\n */\nexport interface NativeCapabilities {\n camera?: boolean;\n location?: boolean;\n biometrics?: boolean;\n offline?: boolean;\n backgroundTasks?: boolean;\n fileSystem?: boolean;\n notifications?: boolean;\n bluetooth?: boolean;\n haptics?: boolean;\n}\n\n/**\n * Lifecycle hooks for service/hybrid plugins.\n */\nexport interface PluginHooks {\n onAppStart?: boolean;\n onPushReceived?: boolean;\n onConnectivity?: boolean;\n onForeground?: boolean;\n onBackground?: boolean;\n}\n\n/**\n * Render mode — polymorphic.\n * - 'iframe': existing WebView (backward compat)\n * - 'react-native': native RN component only\n * - 'adaptive': both web and native, host picks best\n */\nexport type PluginRenderMode =\n | { mode: 'iframe'; iframeUrl: string; bundleUrl?: string; bundleHash?: string; external?: boolean }\n | { mode: 'react-native'; component: string; bundleUrl?: string; bundleHash?: string; bundleId?: string }\n | {\n mode: 'adaptive';\n iframe: { iframeUrl: string; external?: boolean };\n reactNative: { component: string; bundleUrl?: string; bundleHash?: string; bundleId?: string };\n };\n\n/**\n * Full manifest returned by cp.getContextPlugin.\n * Extended to support native mobile plugins alongside existing web plugins.\n */\nexport interface PluginManifest extends PluginSummary {\n type?: 'ui' | 'service' | 'hybrid';\n render: PluginRenderMode;\n native?: NativeCapabilities;\n hooks?: PluginHooks;\n channels?: string[] | {\n events: string[];\n actions: string[];\n };\n capabilities?: Record<string, unknown>;\n _mcpEndpoint?: string;\n}\n\n/**\n * Determine if a manifest supports native rendering.\n */\nexport function supportsNative(manifest: PluginManifest): boolean {\n const mode = manifest.render?.mode;\n return mode === 'react-native' || mode === 'adaptive';\n}\n\n/**\n * Get the native component ID from a manifest (if it has native support).\n */\nexport function getNativeComponentId(manifest: PluginManifest): string | null {\n if (manifest.render?.mode === 'react-native') return manifest.render.component;\n if (manifest.render?.mode === 'adaptive') return manifest.render.reactNative?.component;\n return null;\n}\n\n/**\n * Get the native bundle URL from a manifest (if it has native support).\n */\nexport function getNativeBundleUrl(manifest: PluginManifest): string | null {\n // Check direct bundleUrl on manifest or within render structure\n const direct = (manifest as any).bundleUrl;\n if (direct) return direct;\n\n const render = manifest.render;\n if (render.mode === 'react-native') return render.bundleUrl || null;\n if (render.mode === 'adaptive') return render.reactNative?.bundleUrl || null;\n\n return null;\n}\n\n/**\n * Get the SHA-256 integrity hash for a native bundle, if the server provided one.\n * Used post-download to verify the bundle bytes weren't tampered in transit\n * — a MITM-replaced bundle gets `eval`'d as RN code with full capability access.\n */\nexport function getNativeBundleHash(manifest: PluginManifest): string | null {\n const direct = (manifest as any).bundleHash;\n if (direct) return direct;\n const render = manifest.render;\n if (render.mode === 'react-native') return (render as any).bundleHash || null;\n if (render.mode === 'adaptive') return render.reactNative?.bundleHash || null;\n return null;\n}\n\n/**\n * Check if a manifest can be rendered as a WebView (iframe or adaptive with iframe).\n */\nexport function supportsWebView(manifest: PluginManifest): boolean {\n return manifest.render?.mode === 'iframe' || manifest.render?.mode === 'adaptive';\n}\n\n/**\n * List all available UI plugins via MCP JSON-RPC.\n * Returns summary data only (no render field).\n * Protocol: cp.listContextPlugins → core plugins + MCP connector plugins.\n */\nexport async function listPlugins(): Promise<PluginSummary[]> {\n const res = await apiFetch<{\n result: {\n content: Array<{ type: string; text: string }>;\n structuredContent?: { plugins?: PluginSummary[] };\n };\n }>('/mcp', {\n method: 'POST',\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: Date.now(),\n method: 'tools/call',\n params: {\n name: 'cp.listContextPlugins',\n arguments: {},\n },\n }),\n });\n\n // Accept multiple response formats (matches web mcpClient.js fallback chain)\n const structured = res.result?.structuredContent?.plugins;\n if (structured) return structured;\n\n const text = res.result?.content?.[0]?.text;\n if (!text) return [];\n try {\n const parsed = JSON.parse(text);\n return parsed.plugins || parsed || [];\n } catch {\n return [];\n }\n}\n\n/**\n * Get a specific plugin's FULL manifest (with render.iframeUrl).\n * Protocol: cp.getContextPlugin({ id }) → resolves iframeUrl for core/MCP/external.\n *\n * IMPORTANT: The backend parameter is `id`, not `pluginId`.\n */\nexport async function getPlugin(pluginId: string): Promise<PluginManifest | null> {\n const res = await apiFetch<{\n result: {\n content: Array<{ type: string; text: string }>;\n structuredContent?: PluginManifest;\n };\n }>('/mcp', {\n method: 'POST',\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: Date.now(),\n method: 'tools/call',\n params: {\n name: 'cp.getContextPlugin',\n arguments: { id: pluginId }, // Backend expects { id }, NOT { pluginId }\n },\n }),\n });\n\n // Accept structured or text response\n if (res.result?.structuredContent) return res.result.structuredContent;\n\n const text = res.result?.content?.[0]?.text;\n if (!text) return null;\n try {\n const parsed = JSON.parse(text);\n // Backend may return error object\n if (parsed.error) {\n console.warn('[getPlugin] Backend error:', parsed.error);\n return null;\n }\n return parsed;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve plugin iframe URL to a full URL for WebView.\n * Matches the web frontend's PluginHost.jsx logic:\n * - External (absolute http): append ?tenant=\n * - MCP plugin (/mcp-ui/...): inject tenant into path → /mcp-ui/{tenant}/{connectorId}/...\n * - Core plugin (/assets/...): prepend getCoreApiUrl()\n */\nexport function resolvePluginUrl(manifest: PluginManifest, tenant?: string): string {\n // Extract iframeUrl from different render modes.\n // Adaptive manifests in the wild use a flat shape — `render.iframeUrl` —\n // not the nested `render.iframe.iframeUrl` from the type. Accept both.\n const render = manifest.render as any;\n let url: string | undefined;\n if (render?.mode === 'iframe') {\n url = render.iframeUrl;\n } else if (render?.mode === 'adaptive') {\n url = render.iframeUrl || render.iframe?.iframeUrl;\n }\n // react-native only → no URL\n if (!url) return '';\n\n // Already absolute URL (external plugins like Voice)\n if (url.startsWith('http')) {\n const sep = url.includes('?') ? '&' : '?';\n return tenant ? `${url}${sep}tenant=${encodeURIComponent(tenant)}` : url;\n }\n\n // MCP plugin — inject tenant into path: /mcp-ui/{connectorId}/... → /mcp-ui/{tenant}/{connectorId}/...\n if (tenant && url.startsWith('/mcp-ui/')) {\n const tenantUrl = url.replace('/mcp-ui/', `/mcp-ui/${encodeURIComponent(tenant)}/`);\n return `${getCoreApiUrl()}${tenantUrl}`;\n }\n\n // Core plugin — prepend core API base\n return `${getCoreApiUrl()}${url}`;\n}\n","/**\n * Global Plugin Bundle Manager — singleton.\n *\n * ONE download per bundleUrl (deduplicates multi-plugin bundles); all plugin\n * renderer instances share the same loaded modules. Persistence goes through\n * the BundleStorage adapter (in-memory by default; @ateam-ai-mobile/expo provides disk).\n *\n * Usage:\n * const component = await bundleManager.load(pluginId, bundleUrl, version, hash);\n * // component = { id, type, Component, ... } (RegisteredUIPlugin)\n */\nimport React from 'react';\nimport {\n useState, useEffect, useCallback, useMemo, useRef,\n useContext, useReducer, useLayoutEffect, useImperativeHandle, useDebugValue,\n} from 'react';\nimport * as ReactNative from 'react-native';\nimport { apiFetchRaw, getTenant } from '@ateam-ai-mobile/core';\nimport * as PluginSDKModule from '../sdk';\nimport SurfaceDrawer from '../surfaces/SurfaceDrawer';\nimport SurfaceCard from '../surfaces/SurfaceCard';\nimport SurfaceFullscreen from '../surfaces/SurfaceFullscreen';\nimport { useSurfaceStore } from '../registry/store';\nimport SurfaceDispatcher from '../registry/SurfaceDispatcher';\nimport { resolveBundleModule } from '../host';\nimport { sha256Hex } from '../utils/sha256';\nimport { assertBundleIntegrity } from './integrity';\nimport { getBundleStorage, type BundleCacheEntry } from './storage';\nimport { registerDeviceTools, unregisterDeviceTools, listDeviceTools } from '../tools/registry';\nimport type { RegisteredUIPlugin } from '../sdk/types';\n\n// ── Require shim ─────────────────────────────────────────────\n// Bundles are built with external: ['react', 'react-native', '@adas/plugin-sdk']\n// so they emit require() calls that this shim resolves at runtime. Anything\n// beyond the built-ins (react-native-webview, expo-linking, …) must be\n// registered by the host via registerBundleModules() — the host is the one\n// that actually has those modules installed.\n\nconst ReactShim: any = {\n __esModule: true,\n default: React,\n ...React,\n // Explicitly include hooks (React 19 may not have them as own enumerable props)\n useState, useEffect, useCallback, useMemo, useRef, useContext,\n useReducer, useLayoutEffect, useImperativeHandle, useDebugValue,\n createElement: React.createElement,\n Fragment: React.Fragment,\n Component: React.Component,\n PureComponent: React.PureComponent,\n createContext: React.createContext,\n forwardRef: React.forwardRef,\n memo: React.memo,\n Children: React.Children,\n cloneElement: React.cloneElement,\n isValidElement: React.isValidElement,\n createRef: React.createRef,\n lazy: React.lazy,\n Suspense: React.Suspense,\n};\n\n// Freeze PluginSDK shim to prevent bundle monkey-patching of register().\n// Surface containers + registry ride along — the reference app's original\n// shim exposed the FULL plugin-sdk index, and bundles built against it may\n// import SurfaceDrawer/useSurfaceStore/etc. from '@adas/plugin-sdk'.\nconst PluginSDKShim = Object.freeze({\n ...PluginSDKModule,\n SurfaceDrawer,\n SurfaceCard,\n SurfaceFullscreen,\n useSurfaceStore,\n SurfaceDispatcher,\n PluginSDK: Object.freeze({\n ...PluginSDKModule.PluginSDK,\n register: PluginSDKModule.PluginSDK.register,\n }),\n register: PluginSDKModule.register,\n});\n\nconst requireShim = (name: string) => {\n if (name === 'react') return ReactShim;\n if (name === 'react-native') return ReactNative;\n if (name === '@adas/plugin-sdk') return PluginSDKShim;\n const hostModule = resolveBundleModule(name);\n if (hostModule !== undefined) return hostModule;\n console.warn(`[BundleManager] Unknown module: ${name} — register it via registerBundleModules()`);\n return {};\n};\n\n// ── Cache constants ──────────────────────────────────────────\n\nconst CACHE_TTL = 7 * 24 * 60 * 60 * 1000; // 7 days\n\n// ── BundleManager singleton ──────────────────────────────────\n\n/** Where the bytes currently running came from. */\nexport type LoadedBundleSource = 'download' | 'disk-cache' | 'memory';\n\n/**\n * Provenance of one loaded bundle — what is RUNNING, not what was requested.\n *\n * `hash` is the sha256 of the evaluated bytes. `expected` is the hash the\n * server's manifest advertised for that url. Equal means the phone is running\n * the build the server currently describes; different means it is not, and the\n * pair says so without needing a rebuild, a reinstall or a guess.\n */\nexport interface LoadedBundleInfo {\n bundleUrl: string;\n version: string;\n /** sha256 (hex, lowercase) of the bytes that were evaluated. */\n hash: string | null;\n /** sha256 the server advertised for this url at load time, if any. */\n expected: string | null;\n source: LoadedBundleSource;\n tenant: string | null;\n loadedAt: number;\n}\n\nclass BundleManager {\n /** In-memory module cache: bundleUrl → evaluated module.exports. Holds ONE\n * tenant's modules at a time — the tenant boundary is `cacheTenant` /\n * `requireTenant()`, NOT the key. */\n private modules = new Map<string, any>();\n /** What is actually RUNNING, keyed by bundleUrl (for the current tenant). See\n * getLoadedBundles(). */\n private provenance = new Map<string, LoadedBundleInfo>();\n\n /** In-flight download deduplication: bundleUrl → Promise */\n private inflight = new Map<string, Promise<any>>();\n\n /**\n * The tenant the in-memory caches (modules / provenance / inflight) currently\n * belong to. This is the tenant BOUNDARY for evaluated code.\n *\n * A bundleUrl resolves PER-TENANT on the server — one url, different bytes for\n * different tenants — so a memory hit keyed on url alone would hand tenant B\n * the module tenant A already evaluated and ran. PR #9 scoped the DISK cache\n * (per-tenant index + hash gate); the in-memory map was left url-keyed. This\n * closes that: the caches only ever hold ONE tenant's modules, and a switch\n * drops them before anything is served.\n */\n private cacheTenant: string | null = null;\n\n /**\n * pluginIds this manager registered device tools for. A tenant switch drops\n * the in-memory modules AND unregisters these, so the incoming tenant's bundle\n * re-registers into a clean registry instead of being refused as a duplicate\n * of the previous tenant's tools.\n */\n private registeredToolPluginIds = new Set<string>();\n\n /**\n * Enforce the in-memory tenant boundary. Call at the top of every public load\n * path, BEFORE any cache read.\n *\n * FAIL CLOSED: without a tenant identity we cannot prove a cached module is\n * this session's, so we drop everything and refuse rather than risk serving\n * one tenant's evaluated code to another. On a tenant change we drop the\n * previous tenant's modules (and their tool registrations) before proceeding.\n */\n /**\n * Monotonic load generation. Bumped on every in-memory wipe (a tenant change,\n * fail-closed, or clearAll). A load captures it at ENTRY; a completion whose\n * generation no longer matches is stale and is discarded before it can commit.\n * This closes the async race the sequential guard cannot: tenant A's in-flight\n * loadModule can resolve AFTER a switch to B — clearing `inflight` does not\n * cancel that Promise — and would otherwise write A's module / provenance /\n * device tools into the singleton now marked cacheTenant=B.\n */\n private epoch = 0;\n\n private requireTenant(): string {\n const tenant = getTenant();\n if (!tenant) {\n this.dropInMemory();\n this.cacheTenant = null;\n throw new Error(\n '[BundleManager] refusing to load a tenant-scoped bundle without a tenant identity (fail closed)',\n );\n }\n if (tenant !== this.cacheTenant) {\n // First load, or a tenant switch: the caches hold the previous tenant's\n // evaluated modules — none of it may cross the boundary.\n this.dropInMemory();\n this.cacheTenant = tenant;\n }\n return tenant;\n }\n\n /** Drop every in-memory cache and unregister the device tools this manager\n * registered — used on a tenant change and by clearAll(). */\n private dropInMemory(): void {\n for (const pluginId of this.registeredToolPluginIds) {\n try { unregisterDeviceTools(pluginId); } catch { /* ignore */ }\n }\n this.registeredToolPluginIds.clear();\n this.modules.clear();\n this.provenance.clear();\n this.inflight.clear();\n // Bump the generation: any load that started before this wipe is now stale\n // and must not commit its results (see epoch / stale check in loadModule).\n this.epoch++;\n }\n\n /** True once the boundary has moved since a load captured `epoch` — i.e. a\n * tenant switch (or wipe) happened while this load was in flight. Its results\n * belong to a tenant that is no longer current and must be discarded. */\n private isStale(epoch: number, tenant: string): boolean {\n return this.epoch !== epoch || getTenant() !== tenant;\n }\n\n /** Flip an existing provenance record to source:'memory' — a later serve of an\n * already-evaluated bundle came from the in-memory cache, not a fresh\n * download/disk read. No-op if nothing was recorded yet. */\n private markMemoryHit(bundleUrl: string): void {\n const prev = this.provenance.get(bundleUrl);\n if (prev && prev.source !== 'memory') {\n this.provenance.set(bundleUrl, { ...prev, source: 'memory' });\n }\n }\n\n // ── Public API ──────────────────────────────────────────────\n\n /**\n * Load a plugin component. Returns the RegisteredUIPlugin object.\n * Handles: in-memory cache → disk cache → download → evaluate → extract.\n *\n * `expectedHash` (SHA-256 hex from cp.getContextPlugin manifest) MUST be\n * provided for any bundle the user has not previously verified — without\n * it, a tampered bundle is `eval`'d as JS with full RN runtime + every\n * native capability the manifest declares.\n */\n async load(\n pluginId: string,\n bundleUrl: string,\n version: string,\n expectedHash?: string,\n ): Promise<RegisteredUIPlugin> {\n // Tenant boundary FIRST — fail closed without a tenant, drop the previous\n // tenant's modules on a switch, and CAPTURE the tenant + generation at entry\n // so a switch during the async load is caught before any result is used.\n const tenant = this.requireTenant();\n const epoch = this.epoch;\n\n // 1. In-memory cache — instant\n const cached = this.getComponentFromMemory(pluginId, bundleUrl);\n if (cached) {\n // Record the reuse. load() returns HERE, before loadModule, so without\n // this the provenance would freeze on the first download/disk source and\n // getLoadedBundles() would never report a memory serve. (loadModule's\n // own memory branch covers the loadTools path, which has no early return.)\n this.markMemoryHit(bundleUrl);\n return cached;\n }\n\n // 2. Deduplicate in-flight downloads for same bundleUrl\n let modulePromise = this.inflight.get(bundleUrl);\n if (!modulePromise) {\n const promise = this.loadModule(bundleUrl, version, expectedHash, tenant, epoch);\n modulePromise = promise;\n this.inflight.set(bundleUrl, promise);\n // Swallow rejection on the cleanup chain — the original `await` below\n // still surfaces the error to the caller. Delete ONLY our own entry: a\n // tenant switch clears `inflight` and the incoming tenant installs a NEW\n // promise for the same url, so an unconditional delete here would evict\n // B's live entry when stale A finally settles — breaking dedup and letting\n // a duplicate B load start.\n promise.catch(() => {}).finally(() => {\n if (this.inflight.get(bundleUrl) === promise) this.inflight.delete(bundleUrl);\n });\n }\n\n await modulePromise;\n\n // The switch could have landed while we awaited. Even if another tenant has\n // since populated modules[bundleUrl], this load must not return that code.\n if (this.isStale(epoch, tenant)) {\n throw new Error('[BundleManager] tenant changed while loading — discarding (fail closed)');\n }\n\n // 3. Extract component for this specific pluginId\n const component = this.getComponentFromMemory(pluginId, bundleUrl);\n if (!component) {\n throw new Error(\n `Bundle loaded from ${bundleUrl} but no component found for \"${pluginId}\". ` +\n `Available exports: ${this.describeModule(this.modules.get(bundleUrl))}`\n );\n }\n\n return component;\n }\n\n /**\n * Load a bundle for its `tools/` section only — no UI required.\n *\n * Same download, same integrity check, same evaluation as `load()`; the only\n * difference is that a bundle exporting tools and no `Component` is a success\n * here rather than \"no component found\". Returns the tool names registered.\n */\n async loadTools(\n pluginId: string,\n bundleUrl: string,\n version: string,\n expectedHash?: string,\n ): Promise<string[]> {\n // Tenant boundary FIRST — same fail-closed / drop-on-switch as load(), and\n // capture the tenant + generation for the stale check after the async load.\n const tenant = this.requireTenant();\n const epoch = this.epoch;\n let modulePromise = this.inflight.get(bundleUrl);\n if (!modulePromise) {\n const promise = this.loadModule(bundleUrl, version, expectedHash, tenant, epoch);\n modulePromise = promise;\n this.inflight.set(bundleUrl, promise);\n // Delete ONLY our own entry — see load() for why an unconditional delete\n // lets stale A evict B's live inflight promise across a tenant switch.\n promise.catch(() => {}).finally(() => {\n if (this.inflight.get(bundleUrl) === promise) this.inflight.delete(bundleUrl);\n });\n }\n await modulePromise;\n\n if (this.isStale(epoch, tenant)) {\n throw new Error('[BundleManager] tenant changed while loading tools — discarding (fail closed)');\n }\n\n const names = listDeviceTools()\n .filter(t => t.pluginId === pluginId)\n .map(t => t.name);\n\n if (names.length === 0) {\n console.warn(\n `[BundleManager] ${pluginId}: bundle loaded from ${bundleUrl} but registered no tools. ` +\n `Available exports: ${this.describeModule(this.modules.get(bundleUrl))}`,\n );\n }\n return names;\n }\n\n /**\n * Prewarm: load every plugin bundle in the background after app boot, so a\n * later open is instant (in-memory hit) instead of round-tripping the\n * network. Errors are swallowed per-plugin — one bad bundle shouldn't\n * block others. Concurrency capped at 3.\n */\n async prewarmAll(items: Array<{\n pluginId: string;\n bundleUrl: string;\n version: string;\n bundleHash?: string;\n }>): Promise<void> {\n const queue = [...items];\n const concurrency = Math.min(3, queue.length);\n const start = Date.now();\n let okCount = 0;\n let failCount = 0;\n\n const worker = async () => {\n while (queue.length > 0) {\n const it = queue.shift();\n if (!it) return;\n try {\n await this.load(it.pluginId, it.bundleUrl, it.version, it.bundleHash);\n okCount++;\n } catch (err) {\n failCount++;\n // Silent — preload is best-effort. Log for diagnostics only.\n console.log(`[prewarm] ${it.pluginId}: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n };\n\n await Promise.all(Array.from({ length: concurrency }, worker));\n console.log(`[prewarm] ${okCount} loaded, ${failCount} failed in ${Date.now() - start}ms`);\n }\n\n /**\n * Clear all caches (in-memory + storage).\n */\n async clearAll(): Promise<void> {\n // Full reset — in-memory modules + provenance + inflight + the device tools\n // this manager registered, then the tenant marker and the disk storage.\n this.dropInMemory();\n this.cacheTenant = null;\n try {\n await getBundleStorage().clearAll();\n } catch (err) {\n console.warn('[BundleManager] clearAll error:', err);\n }\n }\n\n /**\n * Clear cache for a specific plugin/bundle.\n */\n async clearPlugin(pluginId: string): Promise<void> {\n const storage = getBundleStorage();\n const index = await storage.loadIndex();\n const entry = index[pluginId];\n if (entry) {\n this.modules.delete(entry.bundleUrl);\n delete index[pluginId];\n await storage.saveIndex(index);\n try {\n await storage.deleteBundle(entry.localPath);\n } catch { /* ignore */ }\n }\n }\n\n /**\n * What every loaded bundle IS, right now: the sha256 of the bytes running,\n * the hash the server advertised, and where they came from.\n *\n * Deliberately not filtered or prettified — this is the raw answer to \"did my\n * redeploy reach the phone?\", and it is comparable directly against the\n * manifest `bundleHash` and the server's X-Bundle-SHA256 header.\n */\n getLoadedBundles(): LoadedBundleInfo[] {\n return [...this.provenance.values()];\n }\n\n // ── Private: module loading pipeline ────────────────────────\n\n private async loadModule(\n bundleUrl: string,\n version: string,\n expectedHash: string | undefined,\n // The tenant + generation captured at the caller's ENTRY. Every step that\n // commits into the singleton (disk write, evaluate, module/provenance set,\n // tool registration) is gated on these still being current — a switch to\n // another tenant during the download must NOT let this load's results land.\n expectedTenant: string,\n expectedEpoch: number,\n ): Promise<void> {\n // The boundary may already have moved before we even start (a switch landed\n // between requireTenant() and here). Fail closed rather than proceed.\n if (this.isStale(expectedEpoch, expectedTenant)) {\n throw new Error('[BundleManager] tenant changed before load started — discarding (fail closed)');\n }\n // Already in memory? Then the running bytes are whatever this session\n // already evaluated — record the reuse so provenance never goes silent.\n if (this.modules.has(bundleUrl)) {\n const prev = this.provenance.get(bundleUrl);\n if (prev) this.provenance.set(bundleUrl, { ...prev, source: 'memory', expected: expectedHash?.toLowerCase() ?? prev.expected });\n return;\n }\n\n const storage = getBundleStorage();\n const index = await storage.loadIndex();\n const expectedLc = expectedHash ? expectedHash.toLowerCase() : null;\n\n // Check disk cache. A cache hit is only valid when the cached SHA-256\n // matches the manifest hash exactly — never trust a cached bundle\n // without proof. The file is read via entry.localPath (the content-addressed\n // path recorded at write time), never reconstructed from url+version, so a\n // hit follows the index straight to the right bytes.\n let content: string | null = null;\n // The SHA-256 that gate-kept THIS content (the manifest hash for a cache hit,\n // the freshly-verified download hash otherwise) — re-checked inline at the\n // eval so a tampered cache file cannot run (see evaluate()).\n let verifiedHash: string | null = null;\n let servedFrom: LoadedBundleSource = 'download';\n for (const entry of Object.values(index)) {\n if (entry.bundleUrl === bundleUrl && entry.version === version) {\n const age = Date.now() - entry.timestamp;\n const hashOk = expectedLc && entry.bundleHash && entry.bundleHash.toLowerCase() === expectedLc;\n if (age < CACHE_TTL && hashOk) {\n content = await storage.readBundle(entry.localPath);\n if (content) { verifiedHash = entry.bundleHash!.toLowerCase(); servedFrom = 'disk-cache'; break; }\n }\n }\n }\n\n // Download if not cached\n if (!content) {\n const downloaded = await this.download(bundleUrl, expectedLc);\n content = downloaded.content;\n verifiedHash = downloaded.sha256.toLowerCase();\n // The download is the long await where a tenant switch is most likely to\n // land. If it did, discard NOW — before we stamp a disk-cache entry with\n // the (now wrong) current tenant.\n if (this.isStale(expectedEpoch, expectedTenant)) {\n throw new Error('[BundleManager] tenant changed during download — discarding (fail closed)');\n }\n // Save with verified hash. CONTENT-ADDRESS the file by its own sha256, NOT\n // by url+version: a bundleUrl+version pair is identical across tenants but\n // resolves to DIFFERENT bytes per tenant, so a url+version filename is\n // SHARED between them. A stale tenant-A writeBundle that completes after a\n // switch to B would then clobber B's cached file bytes at that shared path.\n // Keying the file by verifiedHash gives A's bytes and B's bytes distinct\n // paths that can never collide (identical bytes dedup to one file, which is\n // correct). The index entry below — keyed by url, stamped with the captured\n // tenant + hash + this localPath — is unchanged and stays authoritative.\n try {\n const localPath = await storage.writeBundle(`${verifiedHash}.js`, content);\n // The index entry is the AUTHORITATIVE disk-cache commit: loadFromDiskCache\n // reads the index (a loose file with no entry is never selected), and it\n // trusts the entry's `tenant` stamp as the authorization boundary while\n // passing the entry's OWN hash (an integrity check that cannot fail). So:\n // (a) stamp ownership from the CAPTURED tenant, never live getTenant() —\n // writeBundle awaited, and a switch here would otherwise label A's\n // bytes as B, which the recovery path would later re-run under B;\n // (b) do not publish the entry at all if the tenant/generation moved\n // while we awaited — fail closed, leaving only an orphan file.\n if (!this.isStale(expectedEpoch, expectedTenant)) {\n index[bundleUrl] = {\n localPath,\n version,\n timestamp: Date.now(),\n bundleUrl,\n bundleHash: downloaded.sha256,\n tenant: expectedTenant,\n } satisfies BundleCacheEntry;\n await storage.saveIndex(index);\n }\n } catch (err) {\n console.warn('[BundleManager] Cache write error:', err);\n }\n }\n\n // FINAL boundary check before anything commits into the singleton. This is\n // the one that also covers the disk-cache-hit path (which never entered the\n // download branch above). Everything after this line — evaluate, module set,\n // provenance set, tool registration — writes tenant-scoped state; if the\n // tenant moved while we awaited, none of it may land (fail closed).\n if (this.isStale(expectedEpoch, expectedTenant)) {\n throw new Error('[BundleManager] tenant changed while loading — discarding stale bundle before eval (fail closed)');\n }\n\n // Evaluate — the eval re-hashes `content` against verifiedHash first.\n const mod = this.evaluate(content, bundleUrl, verifiedHash);\n this.modules.set(bundleUrl, mod);\n\n // Record WHAT IS RUNNING. Until this existed, nothing on the device or the\n // server could answer \"which build is the phone actually executing?\" — so a\n // redeploy that failed to arrive was indistinguishable from one that did,\n // and the only diagnosis available was to reinstall and guess.\n // `expected` is the server's advertised manifest hash: when it differs from\n // `hash`, the phone is running something the server did not just describe.\n this.provenance.set(bundleUrl, {\n bundleUrl,\n version,\n hash: verifiedHash,\n expected: expectedLc,\n source: servedFrom,\n // The captured owner — same rule as the disk stamp. The final stale check\n // above guarantees getTenant() === expectedTenant here, but binding it to\n // the captured value keeps the ownership record impossible to mislabel.\n tenant: expectedTenant,\n loadedAt: Date.now(),\n });\n console.log(\n `[BundleManager] RUNNING ${bundleUrl} v${version} sha=${(verifiedHash || 'none').slice(0, 12)} ` +\n `(${servedFrom}${expectedLc && verifiedHash && expectedLc !== verifiedHash ? `, EXPECTED ${expectedLc.slice(0, 12)} — STALE` : ''})`,\n );\n\n // Tools register at LOAD, not at mount — that is what makes a tool callable\n // with nothing of the plugin on screen.\n this.registerToolsFromModule(mod, bundleUrl);\n }\n\n /**\n * Pick up every `tools` section in an evaluated bundle and put it in the\n * device tool registry. Runs for UI, hybrid and tools-only bundles alike: a\n * plugin that ships both gets its tools registered without its UI mounting.\n */\n private registerToolsFromModule(mod: any, bundleUrl: string): void {\n if (!mod) return;\n\n for (const key of Object.keys(mod)) {\n const val = mod[key];\n if (!val || typeof val !== 'object' || !Array.isArray(val.tools) || val.tools.length === 0) {\n continue;\n }\n const pluginId = typeof val.id === 'string' ? val.id : `${bundleUrl}#${key}`;\n try {\n registerDeviceTools(pluginId, val.tools, val.capabilities, val.stateDomains);\n // Remember it so a tenant switch (or clearAll) can unregister the OLD\n // tenant's tools before the incoming tenant re-registers.\n this.registeredToolPluginIds.add(pluginId);\n } catch (err) {\n console.warn(\n `[BundleManager] tool registration failed for ${pluginId}:`,\n err instanceof Error ? err.message : String(err),\n );\n }\n }\n }\n\n /**\n * Download + integrity-verify a bundle. Refuses to return when:\n * - manifest hash and computed hash disagree\n * - server's `X-Bundle-SHA256` disagrees with manifest hash\n * - no expected hash AND no server hash header (cannot prove the bundle\n * wasn't tampered with — fail closed rather than trust the wire).\n */\n private async download(bundleUrl: string, expectedHash: string | null): Promise<{ content: string; sha256: string }> {\n const cacheBust = `${bundleUrl}${bundleUrl.includes('?') ? '&' : '?'}t=${Date.now()}`;\n const response = await apiFetchRaw(cacheBust);\n if (!response.ok) {\n const body = await response.text().catch(() => '');\n throw new Error(`Download failed: ${response.status} ${response.statusText} — ${body.substring(0, 200)}`);\n }\n\n const content = await response.text();\n if (content.length < 50 || content.trimStart().startsWith('<!')) {\n throw new Error('Bundle content is empty or HTML — server may have returned an error page');\n }\n\n const headerHash = (response.headers.get('x-bundle-sha256') || '').toLowerCase();\n const computed = sha256Hex(content);\n\n if (expectedHash) {\n if (computed !== expectedHash) {\n throw new Error(\n `Bundle integrity FAIL: expected sha256=${expectedHash.slice(0, 12)}... got ${computed.slice(0, 12)}.... Refusing to evaluate.`\n );\n }\n if (headerHash && headerHash !== expectedHash) {\n throw new Error(\n `Bundle hash mismatch: manifest=${expectedHash.slice(0, 12)}... server=${headerHash.slice(0, 12)}.... Refusing to evaluate.`\n );\n }\n } else if (headerHash) {\n if (computed !== headerHash) {\n throw new Error(\n `Bundle body sha256 (${computed.slice(0, 12)}...) does not match server's X-Bundle-SHA256 (${headerHash.slice(0, 12)}...).`\n );\n }\n console.warn(`[BundleManager] No manifest bundleHash — verified via X-Bundle-SHA256 header only`);\n } else {\n throw new Error(\n `No bundleHash in manifest and no X-Bundle-SHA256 header from server. Refusing to evaluate untrusted bundle.`\n );\n }\n\n return { content, sha256: computed };\n }\n\n private evaluate(content: string, bundleUrl: string, verifiedHash: string | null): any {\n // R8 SECURITY GATE — mandatory, fail-closed integrity INLINE at the eval, on\n // the exact bytes about to run. The download path verifies too, but a disk-\n // cache hit reads a file whose STORED metadata hash matched; it never re-hashes\n // the actual bytes, so a tampered cache file would execute. Re-hashing here\n // refuses a missing or mismatched hash whatever path produced `content`.\n //\n // NOTE — this is integrity, NOT a sandbox. `new Function` shares this JS\n // realm; a bundle that passes the hash still runs with full in-app authority\n // (its only capability gating is the plugin manifest via gatePluginNative).\n // The hash proves the bytes are the ones the trusted manifest names; it does\n // not isolate them. Publisher SIGNATURE is deliberately NOT required — the\n // manifest hash already comes from an authenticated Core call\n // (docs/decisions/REMOTE_BUNDLE_INTEGRITY.md).\n assertBundleIntegrity(content, verifiedHash, bundleUrl);\n\n // Strip __toESM wrapping — our shim already provides correct ESM objects.\n // esbuild's __toESM + isNodeMode=1 double-wraps and breaks React 19 hooks.\n let cleaned = content.replace(\n /__toESM\\(require\\((\"[^\"]+\")\\)(?:,\\s*\\d+)?\\)/g,\n 'require($1)',\n );\n\n // Strip __toCommonJS wrapper — it creates a getter-based Proxy that\n // collapses all named exports to the same object in Hermes/JSC.\n cleaned = cleaned.replace(\n /module\\.exports\\s*=\\s*__toCommonJS\\((\\w+)\\)/g,\n 'module.exports = $1',\n );\n\n const mod: { exports: any } = { exports: {} };\n try {\n const factory = new Function(\n 'module', 'exports', 'require', '__filename', '__dirname',\n cleaned,\n );\n factory(mod, mod.exports, requireShim, bundleUrl, 'adas-plugin-bundles');\n } catch (err) {\n throw new Error(`Bundle evaluation failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n\n // Materialize getter-based exports into plain values.\n // esbuild's __export uses Object.defineProperty getters which can\n // misbehave in Hermes/JSC — force-resolve them now.\n const raw = mod.exports;\n const materialized: Record<string, any> = {};\n for (const key of Object.getOwnPropertyNames(raw)) {\n try {\n materialized[key] = raw[key];\n } catch { /* skip broken getters */ }\n }\n return materialized;\n }\n\n // ── Private: component extraction ───────────────────────────\n\n /**\n * Find a plugin component in a loaded module.\n * Handles: default export, direct key match, multi-plugin .id match.\n */\n private getComponentFromMemory(pluginId: string, bundleUrl: string): RegisteredUIPlugin | null {\n const mod = this.modules.get(bundleUrl);\n if (!mod) return null;\n\n const shortName = pluginId.includes(':') ? pluginId.split(':').pop()! : pluginId;\n\n // 1. Direct key match (full pluginId as key)\n if (mod[pluginId] && typeof mod[pluginId].Component === 'function') {\n return mod[pluginId] as RegisteredUIPlugin;\n }\n\n // 2. PascalCase match from shortName (most reliable for combined bundles)\n // e.g., \"memories-panel\" → \"MemoriesPanel\"\n const pascal = shortName.replace(/(^|-)([a-z])/g, (_: string, __: string, c: string) => c.toUpperCase());\n if (mod[pascal] && typeof mod[pascal] === 'object' && typeof mod[pascal].Component === 'function') {\n return mod[pascal] as RegisteredUIPlugin;\n }\n\n // 3. Default export (single-plugin bundles)\n if (mod.default && typeof mod.default === 'object' && typeof mod.default.Component === 'function') {\n return mod.default as RegisteredUIPlugin;\n }\n\n // 4. Match by .id field (last resort — can be unreliable in combined bundles)\n for (const key of Object.keys(mod)) {\n const val = mod[key];\n if (\n val &&\n typeof val === 'object' &&\n val.id === shortName &&\n typeof val.Component === 'function'\n ) {\n return val as RegisteredUIPlugin;\n }\n }\n\n return null;\n }\n\n private describeModule(mod: any): string {\n if (!mod) return '(empty)';\n return Object.keys(mod)\n .map(k => {\n const v = mod[k];\n if (v && typeof v === 'object' && v.id) return `${k}(id=\"${v.id}\")`;\n return k;\n })\n .join(', ');\n }\n}\n\n/** Singleton — shared across all plugin renderers */\nexport const bundleManager = new BundleManager();\n","/**\n * @adas/plugin-sdk namespace — everything a PLUGIN author imports.\n * Remote bundles resolve `require('@adas/plugin-sdk')` to exactly this\n * module via the bundle manager's require shim.\n */\n\n// Registration API\nexport { register, registerService, registerTools } from './registration';\nimport { register, registerService, registerTools } from './registration';\nexport const PluginSDK = { register, registerService, registerTools } as const;\n\n// Types\nexport type {\n PluginBridge,\n PluginNative,\n PluginContext,\n PluginProps,\n ThemeTokens,\n HapticsAPI,\n CameraAPI,\n LocationAPI,\n StorageAPI,\n NotificationsAPI,\n ConnectivityAPI,\n FileSystemAPI,\n CookiesAPI,\n WebViewCookie,\n SharingAPI,\n ScannerAPI,\n NfcAPI,\n BluetoothAPI,\n BluetoothDevice,\n VisionAPI,\n VisionText,\n VisionLabel,\n VisionObject,\n VisionFrameQuality,\n BiometricsAPI,\n BiometricsAPIv2,\n NativeCapabilities,\n PluginHooks,\n PluginManifest,\n RenderMode,\n RegisteredPlugin,\n RegisteredUIPlugin,\n RegisteredServicePlugin,\n RegisteredToolsPlugin,\n DeviceToolContext,\n DeviceToolDefinition,\n DeviceToolFn,\n} from './types';\n\n// Voice — the live conversational SESSION surface (props.voice).\nexport type {\n VoiceAPI,\n VoiceState,\n VoiceSnapshot,\n VoiceTranscriptEntry,\n VoiceStartOptions,\n VoiceEvent,\n VoiceSubscription,\n VoiceCaller,\n VoiceSessionProvider,\n} from './voice';\n// The privileged platform caller (a value) — the host injects the owner-aware\n// provider and its own surfaces call it as this caller. See VoiceSessionProvider.\nexport { PLATFORM_VOICE_CALLER } from './voice';\n\n// RN primitives (plugins import from the SDK, not from react-native)\nexport {\n View,\n Text,\n ScrollView,\n FlatList,\n SectionList,\n Pressable,\n TouchableOpacity,\n TextInput,\n Image,\n ActivityIndicator,\n Modal,\n Switch,\n StyleSheet,\n Animated,\n Platform,\n RefreshControl,\n} from './primitives';\n\n// Pre-built components\nexport {\n Card,\n Badge,\n TabBar,\n ListItem,\n SearchBar,\n EmptyState,\n ErrorState,\n LoadingState,\n ActionButton,\n} from './components';\n\n// Theme + API hooks\n// Showing the camera is a COMPONENT, not a native module handed to bundles —\n// one door, one lock. See CameraPreview.tsx for why.\nexport { CameraPreview } from './CameraPreview';\nexport type { CameraPreviewProps } from './CameraPreview';\nexport { usePluginTheme, setPluginThemeColors } from './usePluginTheme';\nexport { useApi } from './useApi';\n","/**\n * Plugin registration API.\n * Solution developers use these to register their plugins.\n */\nimport type {\n DeviceToolDefinition,\n NativeCapabilities,\n PluginHooks,\n PluginProps,\n RegisteredUIPlugin,\n RegisteredServicePlugin,\n RegisteredToolsPlugin,\n} from './types';\nimport type { DeviceBridgeDomain } from './device-state';\n\n/**\n * Register a UI or hybrid plugin (has a visual component).\n *\n * `tools` is optional: a plugin may ship UI and local tools together. Tools are\n * picked up when the bundle loads, independently of whether the UI is mounted.\n */\nexport function register(\n id: string,\n config: {\n type?: 'ui' | 'hybrid';\n capabilities?: NativeCapabilities;\n /** L3 DeviceState domains this plugin's UI reads via props.deviceState (e.g.\n * ['spatial','visual']). Carried through so a HOST-registered plugin (no\n * server manifest) can declare its domains — resolvePluginRuntimeProps reads\n * this as the trusted source when there is no manifest. Dropping it here left\n * every registered UI plugin with no L3, silently. Mirrors registerTools. */\n stateDomains?: DeviceBridgeDomain[];\n Component: React.FC<PluginProps>;\n tools?: DeviceToolDefinition[];\n },\n): RegisteredUIPlugin {\n return {\n id,\n type: config.type || 'ui',\n capabilities: config.capabilities,\n stateDomains: config.stateDomains,\n Component: config.Component,\n tools: config.tools,\n };\n}\n\n/**\n * Register a tools-only plugin — a `tools/` section with no UI at all.\n *\n * Nothing here mounts. The tools become callable as soon as the bundle is\n * evaluated, and stay callable with nothing of the plugin on screen.\n */\nexport function registerTools(\n id: string,\n config: {\n capabilities?: NativeCapabilities;\n /** L3 DeviceState domains the tools may read via ctx.deviceState (e.g. ['visual']). */\n stateDomains?: DeviceBridgeDomain[];\n tools: DeviceToolDefinition[];\n },\n): RegisteredToolsPlugin {\n return {\n id,\n type: 'tools',\n capabilities: config.capabilities,\n stateDomains: config.stateDomains,\n tools: config.tools,\n };\n}\n\n/**\n * Register a headless service plugin (no UI).\n */\nexport function registerService(\n id: string,\n config: {\n capabilities?: NativeCapabilities;\n hooks?: PluginHooks;\n onStart: (props: Omit<PluginProps, 'theme'>) => Promise<void> | void;\n onStop?: () => Promise<void> | void;\n },\n): RegisteredServicePlugin {\n return {\n id,\n type: 'service',\n capabilities: config.capabilities,\n hooks: config.hooks,\n onStart: config.onStart,\n onStop: config.onStop,\n };\n}\n","/**\n * props.voice — the live conversational SESSION a plugin may drive.\n *\n * Voice is a SESSION, not a device sensor. `props.device.*` is mechanical verbs\n * that throw; `props.deviceState.*` is eight semantic domains describing the\n * device. A Realtime conversation is neither — it is a long-lived loop with its\n * own state (connecting/connected), its own transcript, and two ways to take a\n * turn (the user speaks, or the agent speaks first). So it gets its own gated\n * surface, mirroring the deviceState GRAMMAR (start / stop / getSnapshot /\n * subscribe) because a reasoning loop reads it the same way — state with\n * freshness, not bare values.\n *\n * TRUST BOUNDARY. This type is the WHOLE surface. There is deliberately NO way\n * from here to inject fake user speech, read raw audio, reach the WebView, or\n * hide the mic-active indicator — those are new doors, and the reason\n * `CameraPreview` is a component rather than a module is that we keep closing\n * doors of that shape. `prompt()` is an AGENT turn, not a forged user turn.\n *\n * See docs/handoff/SPEC_voice_session_without_the_voice_screen_2026-09-12.md.\n */\n\n/** The session lifecycle — identical vocabulary to the built-in `CallState`. */\nexport type VoiceState = 'idle' | 'connecting' | 'connected' | 'error';\n\n/** One line of the conversation. `tool` entries are device/skill tool activity. */\nexport interface VoiceTranscriptEntry {\n role: 'user' | 'ai' | 'tool';\n text: string;\n ts: number;\n}\n\n/** A point-in-time read of the session — what a reasoning loop polls. */\nexport interface VoiceSnapshot {\n state: VoiceState;\n sessionId: string | null;\n muted: boolean;\n /** The agent is currently producing audio. */\n speaking: boolean;\n /** The user is currently being heard (partial user transcript in flight). */\n listening: boolean;\n /** The user is currently speaking, per the session's own VAD (authoritative,\n * distinct from `listening` which tracks a partial transcript). */\n userSpeaking: boolean;\n /**\n * Epoch ms of the last moment the user STOPPED speaking, or `null` if they\n * have not spoken yet this session. `null` is deliberate and load-bearing: a\n * silence timer must arm on the first real `speaking:false`, never at session\n * start — \"not speaking\" and \"has never spoken\" are different, and arming on\n * the wrong one fires before anyone has said anything.\n */\n lastUserSpeechEndedAt: number | null;\n /** The last error, if `state === 'error'`; also carries a refusal reason when\n * this surface was handed to a plugin that did not declare `voice`. */\n lastError: string | null;\n}\n\nexport interface VoiceStartOptions {\n /** Hand the mic to a specific skill on connect (voice /session → takeMic),\n * exactly as `sys.focusUiPlugin(\"platform:voice\", { skillSlug })` does. */\n skillSlug?: string;\n}\n\n/**\n * What changed. Coarse on purpose: `state` covers connect/mute/session/partials,\n * `transcript` fires when a finalized line was appended. A subscriber re-reads\n * `getSnapshot()` / `transcript()` — the event is a nudge, not a payload, so the\n * surface never has to keep two shapes of the same fact in sync.\n */\nexport type VoiceEvent = { type: 'state' } | { type: 'transcript' };\n\nexport interface VoiceSubscription {\n unsubscribe(): void;\n}\n\n/**\n * WHO is asking. The one physical session has an OWNER; access is scoped to it.\n *\n * A plugin's caller is its `pluginId` (a string), stamped by gateVoice so the\n * plugin never supplies its own identity. The PLATFORM caller — the built-in\n * voice screen, the user's own surface — is a Symbol, deliberately: a Symbol can\n * never equal any pluginId string, so a plugin cannot forge platform access by\n * naming itself `platform:voice`.\n */\nexport type VoiceCaller = string | symbol;\n\n/** The privileged caller — the platform's own surfaces (the built-in sheet, the\n * mic indicator, the session host). Sees and controls any live session, because\n * it is the USER's direct surface onto their own conversation. Unforgeable. */\nexport const PLATFORM_VOICE_CALLER: unique symbol = Symbol('adas.voice.platform');\n\n/**\n * The OWNER-AWARE session the HOST implements and hands to setVoiceProvider.\n *\n * This is NOT what a plugin receives — a plugin gets a `VoiceAPI` facade\n * (gateVoice) that stamps its `pluginId` as the caller on every call, so the\n * provider can enforce that a plugin only ever reads, controls, or attaches to a\n * session IT owns. One physical session, isolated per authorized identity.\n */\nexport interface VoiceSessionProvider {\n start(opts: VoiceStartOptions | undefined, caller: VoiceCaller): Promise<VoiceSnapshot>;\n stop(caller: VoiceCaller): void;\n setMuted(muted: boolean, caller: VoiceCaller): void;\n prompt(input: string, caller: VoiceCaller): void;\n observe(text: string, caller: VoiceCaller): void;\n getSnapshot(caller: VoiceCaller): VoiceSnapshot;\n subscribe(cb: (event: VoiceEvent) => void, caller: VoiceCaller): VoiceSubscription;\n transcript(caller: VoiceCaller): VoiceTranscriptEntry[];\n}\n\n/**\n * The gated surface a plugin receives as `props.voice`. Present on EVERY plugin;\n * a plugin that did not declare `capabilities: { voice: true }` gets a version\n * whose reads say so and whose actions throw — never a silent no-op, never a\n * fake `idle` (see gateVoice in voiceHost.ts).\n */\nexport interface VoiceAPI {\n /** Open the live loop. Resolves once connected (or rejects on connect error).\n * If a session is ALREADY live, ATTACHES to it and resolves immediately —\n * never a second Realtime loop (one phone, one mic, one bill). */\n start(opts?: VoiceStartOptions): Promise<VoiceSnapshot>;\n /** End the live loop. Safe to call when idle. */\n stop(): void;\n /** Mute/unmute the microphone. The session stays live; the mic indicator\n * reflects it. */\n setMuted(muted: boolean): void;\n /**\n * Make the agent take a turn WITHOUT the user speaking — the guide speaking\n * first. `input` is the instruction for that turn. This is an agent-initiated\n * turn into the SAME session, NOT fabricated user speech: one session, two\n * trigger sources. Throws if the session is not connected.\n */\n prompt(input: string): void;\n /**\n * Stream a silent OBSERVATION into the session — tell the model something\n * without asking it to speak (a `system` conversation item). Cheap and\n * high-frequency (safe once or twice a second): this is the channel for what\n * the camera sees while the user walks. The model answers with the\n * observations in hand the next time it takes a turn (user VAD, or prompt()) —\n * an observation never triggers a turn by itself. Throws if not connected.\n */\n observe(text: string): void;\n /** Point-in-time session state. */\n getSnapshot(): VoiceSnapshot;\n /** Subscribe to state + transcript changes. Returns an unsubscribe handle. */\n subscribe(cb: (event: VoiceEvent) => void): VoiceSubscription;\n /** The conversation so far. */\n transcript(): VoiceTranscriptEntry[];\n}\n","/**\n * Re-exported React Native primitives.\n * Plugins import these from '@adas/plugin-sdk' — never from 'react-native' directly.\n */\nexport {\n View,\n Text,\n ScrollView,\n FlatList,\n SectionList,\n Pressable,\n TouchableOpacity,\n TextInput,\n Image,\n ActivityIndicator,\n Modal,\n Switch,\n StyleSheet,\n Animated,\n Platform,\n RefreshControl,\n} from 'react-native';\n","/**\n * Pre-built UI components for native plugins.\n * These provide consistent styling using ThemeTokens.\n */\nimport React from 'react';\nimport {\n View,\n Text,\n Pressable,\n TextInput,\n ActivityIndicator,\n StyleSheet,\n} from 'react-native';\nimport type { ThemeTokens } from './types';\n\n// ── Card ────────────────────────────────────────────────────\n\ninterface CardProps {\n theme: ThemeTokens;\n children: React.ReactNode;\n style?: any;\n onPress?: () => void;\n}\n\nexport function Card({ theme, children, style, onPress }: CardProps) {\n const cardStyle = [\n styles.card,\n {\n backgroundColor: theme.colors.surface,\n borderColor: theme.colors.border,\n },\n style,\n ];\n\n if (onPress) {\n return React.createElement(Pressable, { style: cardStyle, onPress }, children);\n }\n return React.createElement(View, { style: cardStyle }, children);\n}\n\n// ── Badge ───────────────────────────────────────────────────\n\ninterface BadgeProps {\n theme: ThemeTokens;\n label: string;\n color?: 'accent' | 'success' | 'warning' | 'error' | 'purple';\n style?: any;\n}\n\nconst BADGE_COLORS = {\n accent: { bg: 'accentSoft', text: 'accent' },\n success: { bg: 'successSoft', text: 'success' },\n warning: { bg: 'warningSoft', text: 'warning' },\n error: { bg: 'errorSoft', text: 'error' },\n purple: { bg: 'purpleSoft', text: 'purple' },\n} as const;\n\nexport function Badge({ theme, label, color = 'accent', style }: BadgeProps) {\n const mapping = BADGE_COLORS[color];\n return React.createElement(\n View,\n {\n style: [\n styles.badge,\n {\n backgroundColor: theme.colors[mapping.bg],\n borderRadius: theme.borderRadius.sm,\n },\n style,\n ],\n },\n React.createElement(Text, {\n style: [styles.badgeText, { color: theme.colors[mapping.text] }],\n }, label),\n );\n}\n\n// ── TabBar ──────────────────────────────────────────────────\n\ninterface TabBarProps {\n theme: ThemeTokens;\n tabs: string[];\n activeTab: string;\n onTabChange: (tab: string) => void;\n style?: any;\n}\n\nexport function TabBar({ theme, tabs, activeTab, onTabChange, style }: TabBarProps) {\n return React.createElement(\n View,\n {\n style: [\n styles.tabBar,\n { borderBottomColor: theme.colors.border },\n style,\n ],\n },\n tabs.map((tab) =>\n React.createElement(\n Pressable,\n {\n key: tab,\n style: [\n styles.tab,\n {\n borderBottomColor: tab === activeTab ? theme.colors.accent : 'transparent',\n },\n ],\n onPress: () => onTabChange(tab),\n },\n React.createElement(Text, {\n style: {\n color: tab === activeTab ? theme.colors.accent : theme.colors.textSecondary,\n fontSize: theme.fontSize.sm,\n fontWeight: tab === activeTab ? '600' : '400',\n },\n }, tab),\n ),\n ),\n );\n}\n\n// ── ListItem ────────────────────────────────────────────────\n\ninterface ListItemProps {\n theme: ThemeTokens;\n title: string;\n subtitle?: string;\n right?: React.ReactNode;\n onPress?: () => void;\n style?: any;\n}\n\nexport function ListItem({ theme, title, subtitle, right, onPress, style }: ListItemProps) {\n const content = [\n React.createElement(\n View,\n { key: 'content', style: styles.listItemContent },\n React.createElement(Text, {\n style: { color: theme.colors.text, fontSize: theme.fontSize.md },\n numberOfLines: 1,\n }, title),\n subtitle\n ? React.createElement(Text, {\n style: { color: theme.colors.textSecondary, fontSize: theme.fontSize.xs, marginTop: 2 },\n numberOfLines: 1,\n }, subtitle)\n : null,\n ),\n right ? React.createElement(View, { key: 'right' }, right) : null,\n ];\n\n if (onPress) {\n return React.createElement(\n Pressable,\n { style: [styles.listItem, { borderBottomColor: theme.colors.border }, style], onPress },\n ...content,\n );\n }\n return React.createElement(\n View,\n { style: [styles.listItem, { borderBottomColor: theme.colors.border }, style] },\n ...content,\n );\n}\n\n// ── SearchBar ───────────────────────────────────────────────\n\ninterface SearchBarProps {\n theme: ThemeTokens;\n value: string;\n onChangeText: (text: string) => void;\n placeholder?: string;\n style?: any;\n}\n\nexport function SearchBar({ theme, value, onChangeText, placeholder = 'Search...', style }: SearchBarProps) {\n return React.createElement(TextInput, {\n style: [\n styles.searchBar,\n {\n backgroundColor: theme.colors.input,\n color: theme.colors.text,\n borderColor: theme.colors.border,\n borderRadius: theme.borderRadius.sm,\n fontSize: theme.fontSize.sm,\n },\n style,\n ],\n value,\n onChangeText,\n placeholder,\n placeholderTextColor: theme.colors.textMuted,\n autoCapitalize: 'none',\n autoCorrect: false,\n });\n}\n\n// ── EmptyState ──────────────────────────────────────────────\n\ninterface EmptyStateProps {\n theme: ThemeTokens;\n title: string;\n subtitle?: string;\n style?: any;\n}\n\nexport function EmptyState({ theme, title, subtitle, style }: EmptyStateProps) {\n return React.createElement(\n View,\n { style: [styles.emptyState, style] },\n React.createElement(Text, {\n style: { color: theme.colors.textSecondary, fontSize: theme.fontSize.md, textAlign: 'center' },\n }, title),\n subtitle\n ? React.createElement(Text, {\n style: { color: theme.colors.textMuted, fontSize: theme.fontSize.sm, textAlign: 'center', marginTop: 4 },\n }, subtitle)\n : null,\n );\n}\n\n// ── ErrorState ──────────────────────────────────────────────\n\ninterface ErrorStateProps {\n theme: ThemeTokens;\n message: string;\n onRetry?: () => void;\n style?: any;\n}\n\nexport function ErrorState({ theme, message, onRetry, style }: ErrorStateProps) {\n return React.createElement(\n View,\n { style: [styles.emptyState, style] },\n React.createElement(Text, {\n style: { color: theme.colors.error, fontSize: theme.fontSize.md, textAlign: 'center' },\n }, message),\n onRetry\n ? React.createElement(\n Pressable,\n {\n style: [styles.retryButton, { backgroundColor: theme.colors.accentSoft, borderRadius: theme.borderRadius.sm }],\n onPress: onRetry,\n },\n React.createElement(Text, {\n style: { color: theme.colors.accent, fontSize: theme.fontSize.sm, fontWeight: '600' },\n }, 'Retry'),\n )\n : null,\n );\n}\n\n// ── LoadingState ────────────────────────────────────────────\n\ninterface LoadingStateProps {\n theme: ThemeTokens;\n message?: string;\n style?: any;\n}\n\nexport function LoadingState({ theme, message = 'Loading...', style }: LoadingStateProps) {\n return React.createElement(\n View,\n { style: [styles.emptyState, style] },\n React.createElement(ActivityIndicator, { size: 'small', color: theme.colors.accent }),\n React.createElement(Text, {\n style: { color: theme.colors.textSecondary, fontSize: theme.fontSize.sm, marginTop: 8 },\n }, message),\n );\n}\n\n// ── ActionButton (FAB) ──────────────────────────────────────\n\ninterface ActionButtonProps {\n theme: ThemeTokens;\n label?: string;\n icon?: React.ReactNode;\n onPress: () => void;\n style?: any;\n}\n\nexport function ActionButton({ theme, label, icon, onPress, style }: ActionButtonProps) {\n return React.createElement(\n Pressable,\n {\n style: [\n styles.fab,\n { backgroundColor: theme.colors.accent, borderRadius: theme.borderRadius.full },\n style,\n ],\n onPress,\n },\n icon || React.createElement(Text, { style: styles.fabText }, label || '+'),\n );\n}\n\n// ── Styles ──────────────────────────────────────────────────\n\nconst styles = StyleSheet.create({\n card: {\n padding: 12,\n borderRadius: 12,\n borderWidth: 1,\n marginBottom: 8,\n },\n badge: {\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n badgeText: {\n fontSize: 11,\n fontWeight: '600',\n },\n tabBar: {\n flexDirection: 'row',\n borderBottomWidth: 1,\n },\n tab: {\n flex: 1,\n padding: 12,\n alignItems: 'center',\n borderBottomWidth: 2,\n },\n listItem: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 12,\n paddingHorizontal: 16,\n borderBottomWidth: StyleSheet.hairlineWidth,\n },\n listItemContent: {\n flex: 1,\n },\n searchBar: {\n height: 40,\n paddingHorizontal: 12,\n borderWidth: 1,\n },\n emptyState: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n padding: 32,\n },\n retryButton: {\n marginTop: 12,\n paddingHorizontal: 16,\n paddingVertical: 8,\n },\n fab: {\n position: 'absolute',\n bottom: 24,\n right: 24,\n width: 56,\n height: 56,\n justifyContent: 'center',\n alignItems: 'center',\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 2 },\n shadowOpacity: 0.25,\n shadowRadius: 4,\n elevation: 5,\n },\n fabText: {\n color: '#fff',\n fontSize: 24,\n fontWeight: '600',\n },\n});\n","/**\n * Host integration points — the DI seams that keep this package free of\n * Expo imports. The host app (or @ateam-ai-mobile/expo) plugs in concrete providers\n * once at startup; everything here has a safe no-op/in-memory default so\n * a bare host works with zero configuration.\n */\n\nimport type { HapticsAPI, NativeCapabilities, PluginNative } from './sdk/types';\nimport type { RegisteredPlugin } from './sdk/types';\n\n// ── Haptics ────────────────────────────────────────────────────────────────\n\nlet _haptics: HapticsAPI | null = null;\n\n/** Register a haptics implementation (e.g. expo-haptics via @ateam-ai-mobile/expo). */\nexport function setHapticsProvider(haptics: HapticsAPI | null): void {\n _haptics = haptics;\n}\n\n/** No-op safe accessor — surfaces call this for tap feedback. */\nexport function getHaptics(): HapticsAPI | null {\n return _haptics;\n}\n\n// ── PluginNative (device capabilities handed to plugins) ──────────────────\n// The full implementation lives in the HOST (it owns the native modules —\n// e.g. ateam-mobile's device-bridge). Without a provider, plugins get\n// clearly-erroring stubs instead of crashes.\n\nfunction unavailable(api: string): any {\n return new Proxy({}, {\n get: (_t, method) => () =>\n Promise.reject(new Error(`[adas] native.${api}.${String(method)} unavailable — host did not call setPluginNativeProvider()`)),\n });\n}\n\nconst noopNative: PluginNative = {\n camera: unavailable('camera'),\n location: unavailable('location'),\n storage: unavailable('storage'),\n biometrics: unavailable('biometrics'),\n biometricsV2: unavailable('biometricsV2'),\n notifications: unavailable('notifications'),\n haptics: { impact: () => {}, notification: () => {}, selection: () => {}, error: () => {} },\n connectivity: { isOnline: () => true, onChange: () => () => {} },\n fileSystem: unavailable('fileSystem'),\n cookies: unavailable('cookies'),\n sharing: unavailable('sharing'),\n scanner: unavailable('scanner'),\n nfc: unavailable('nfc'),\n bluetooth: unavailable('bluetooth'),\n vision: unavailable('vision'),\n};\n\nlet _pluginNative: PluginNative = noopNative;\n\n/** Install the device-capabilities implementation plugins receive as\n * `props.device` (the L1 native modules keep the `native` name; the plugin-\n * facing prop is `device`). The host owns the native modules. */\nexport function setPluginNativeProvider(native: PluginNative): void {\n _pluginNative = native;\n}\n\nexport function getPluginNative(): PluginNative {\n return _pluginNative;\n}\n\n/** Blocked-capability proxy: any call warns and is ignored (no throw) —\n * matches the reference app's behaviour for undeclared capabilities. */\nfunction blocked(api: string, reason?: string): any {\n return new Proxy({}, {\n get: (_t, method) => {\n if (typeof method !== 'string') return undefined;\n return () => {\n console.warn(`[adas] native.${api}.${method} blocked — ${reason ?? `capability '${api}' not declared in the plugin manifest`}`);\n };\n },\n });\n}\n\n/**\n * Gate a PluginNative by the capabilities a plugin's manifest declares.\n * Undeclared capabilities become warn-and-ignore proxies, so a plugin can\n * only touch device APIs it asked for (per-plugin security model, preserved\n * from the reference app). Connectivity is always allowed.\n *\n * Flag mapping mirrors the manifest contract: `storage` is gated by\n * `offline` (offline data ⇒ local storage).\n */\nexport function gatePluginNative(\n native: PluginNative,\n declared?: NativeCapabilities,\n pluginId?: string,\n): PluginNative {\n const caps = declared || {};\n // Per-plugin filesystem + storage isolation, FAIL CLOSED. A declared plugin\n // gets a sandbox/namespace scoped to its OWN id (plugin-files/<pluginId>/,\n // @plugin:<id>: KV, plugin-storage-<id>.db) via the provider's\n // fileSystemFor/storageFor. There is deliberately NO shared fallback: if the\n // id is missing or the provider can't scope, the plugin is BLOCKED, not handed\n // a bucket some other plugin also holds. A silent shared fallback is exactly\n // the P1 that reopened when the UI renderer omitted the id — the isolation must\n // fail closed, never degrade to \"shared\" without anyone noticing.\n const scopedFileSystem =\n native.fileSystemFor && pluginId ? native.fileSystemFor(pluginId) : null;\n const scopedStorage =\n native.storageFor && pluginId ? native.storageFor(pluginId) : null;\n const gated = {\n camera: caps.camera ? native.camera : blocked('camera'),\n location: caps.location ? native.location : blocked('location'),\n storage: caps.offline\n ? (scopedStorage ?? blocked('storage', \"no trusted pluginId to scope storage — refusing shared access (fail closed)\"))\n : blocked('storage'),\n biometrics: caps.biometrics ? native.biometrics : blocked('biometrics'),\n biometricsV2: caps.biometricsV2 ? native.biometricsV2 : blocked('biometricsV2'),\n notifications: caps.notifications ? native.notifications : blocked('notifications'),\n haptics: caps.haptics ? native.haptics : blocked('haptics'),\n connectivity: native.connectivity,\n fileSystem: caps.fileSystem\n ? (scopedFileSystem ?? blocked('fileSystem', \"no trusted pluginId to scope the filesystem — refusing shared access (fail closed)\"))\n : blocked('fileSystem'),\n cookies: caps.cookies ? native.cookies : blocked('cookies'),\n sharing: caps.sharing ? native.sharing : blocked('sharing'),\n scanner: caps.scanner ? native.scanner : blocked('scanner'),\n nfc: caps.nfc ? native.nfc : blocked('nfc'),\n // Gated like the rest even though nothing implements it yet. An undeclared\n // plugin gets the usual blocked proxy; a DECLARED one reaches an API whose\n // every method refuses by name. Both are better than the `undefined` this\n // used to be, which crashed with \"cannot read properties of undefined\".\n bluetooth: caps.bluetooth ? native.bluetooth : blocked('bluetooth'),\n vision: caps.vision ? native.vision : blocked('vision'),\n // What this plugin DECLARED, carried on the object it already receives.\n //\n // It is how a COMPONENT can be capability-gated: <CameraPreview> is handed\n // `native` and reads this, so showing the camera obeys the same flag as\n // calling it. Without this the preview would be a second door to the camera\n // with only one lock. Non-enumerable so it cannot be mistaken for an API.\n } as any;\n\n Object.defineProperty(gated, '__declaredCapabilities', {\n value: Object.freeze({ ...caps }),\n enumerable: false,\n writable: false,\n });\n return gated;\n}\n\n// ── Camera preview (the plugin-facing way to SHOW the camera) ─────────────\n//\n// A plugin composes <CameraPreview native={native} /> from the SDK; the HOST\n// supplies what actually renders, because only the host has the native module.\n//\n// This exists so we do NOT register raw `expo-camera` for bundles. That would\n// be a third door to the device with no capability gate and no honest failure\n// mode — a plugin could mount a camera without declaring it. Here the pixels\n// stay on the host's side: a plugin can SHOW the camera and still cannot touch\n// a frame.\n\n/** Props the host's preview implementation receives. */\nexport interface CameraPreviewImplProps {\n facing?: 'front' | 'back';\n style?: any;\n renderUnavailable?: (reason: string) => any;\n}\n\nlet _cameraPreview: ((props: CameraPreviewImplProps) => any) | null = null;\n\n/** Install the host's camera preview (e.g. an expo-camera CameraView). */\nexport function setCameraPreviewProvider(\n Component: ((props: CameraPreviewImplProps) => any) | null,\n): void {\n _cameraPreview = Component;\n}\n\n/** Null when the host installed none — the SDK then renders a stated reason,\n * never a black rectangle that looks like a dark room. */\nexport function getCameraPreviewProvider(): ((props: CameraPreviewImplProps) => any) | null {\n return _cameraPreview;\n}\n\n// ── Native (host-bundled) plugin registry ─────────────────────────────────\n// Plugins compiled into the host binary (dev plugins, first-party panels).\n// usePlugin checks this registry before hitting the remote bundle pipeline.\n// Values may be lazy loaders so heavy plugins don't cost app-start time.\n\ntype PluginResolver = RegisteredPlugin | (() => Promise<RegisteredPlugin | null>);\n\nconst _nativeRegistry = new Map<string, PluginResolver>();\n\nexport function registerNativePlugin(id: string, plugin: PluginResolver): void {\n _nativeRegistry.set(id, plugin);\n}\n\nexport function unregisterNativePlugin(id: string): void {\n _nativeRegistry.delete(id);\n}\n\nexport const nativePluginRegistry = {\n has(id: string): boolean {\n return _nativeRegistry.has(id);\n },\n async get(id: string): Promise<RegisteredPlugin | null> {\n const entry = _nativeRegistry.get(id);\n if (!entry) return null;\n if (typeof entry === 'function') {\n try {\n return await entry();\n } catch (err) {\n console.warn(`[adas-plugins] lazy native plugin '${id}' failed to load:`, err);\n return null;\n }\n }\n return entry;\n },\n};\n\n// ── Extra bundle modules ───────────────────────────────────────────────────\n// Remote bundles are built with externals resolved by the require shim in\n// bundleManager. react / react-native / @adas/plugin-sdk are always provided;\n// anything else (react-native-webview, expo-linking, …) must be registered\n// by the host, which actually has those modules installed.\n\nconst _bundleModules = new Map<string, any>();\n\nexport function registerBundleModules(modules: Record<string, any>): void {\n for (const [name, mod] of Object.entries(modules)) {\n _bundleModules.set(name, mod);\n }\n}\n\nexport function resolveBundleModule(name: string): any | undefined {\n return _bundleModules.get(name);\n}\n","/**\n * CameraPreview — the plugin-facing way to SHOW the user what the camera sees.\n *\n * WHY THIS EXISTS RATHER THAN HANDING PLUGINS `expo-camera`.\n *\n * The design has exactly two doors to the device: `props.native.*` (mechanical\n * verbs, capability-gated, throws) and `props.deviceState.*` (semantic state,\n * gated, says unknown). Registering a raw native module for bundles would open\n * a THIRD door with no grammar, no gate and no honest failure mode — a plugin\n * could mount a camera without declaring it, and nothing in the manifest would\n * say so. That is the shape of hole this platform keeps closing, not opening.\n *\n * So the preview is a COMPONENT the plugin composes, and the pixels stay on the\n * host's side of the boundary. A plugin can show the camera; it still cannot\n * touch a frame. Reading frames remains `deviceState.visual` (semantic, with\n * freshness) and analysing them remains `native.vision` (which takes an id and\n * resolves it inside the trusted layer).\n *\n * IT IS GATED BY THE SAME FLAG AS `native.camera`. One door, one lock: a plugin\n * that has not declared `capabilities: { camera: true }` gets a refusal panel\n * saying exactly that, not a black rectangle it might mistake for a dark room.\n *\n * IT NEVER RENDERS NOTHING. Every failure — capability not declared, host has\n * not installed a provider, OS permission refused — draws a panel stating which\n * one. A preview that silently renders empty is indistinguishable from a camera\n * pointed at a wall, and a guide built on it would describe a scene nobody saw.\n */\nimport React from 'react';\nimport { View, Text } from './primitives';\nimport type { PluginNative } from './types';\nimport { getCameraPreviewProvider } from '../host';\n\nexport interface CameraPreviewProps {\n /**\n * The plugin's own `props.native`. REQUIRED, and it is the gate: the runtime\n * stamps the declared capabilities onto this object, so passing it is how the\n * component knows whether this plugin may show a camera at all.\n */\n native: PluginNative;\n facing?: 'front' | 'back';\n style?: any;\n /** Rendered instead of the built-in panel when the preview is unavailable. */\n renderUnavailable?: (reason: string) => React.ReactElement | null;\n}\n\n/** Declared capabilities, stamped onto the gated object by gatePluginNative. */\nfunction declaredCapabilities(native: any): Record<string, boolean> | null {\n return (native && native.__declaredCapabilities) || null;\n}\n\nexport function CameraPreview({ native, facing = 'back', style, renderUnavailable }: CameraPreviewProps) {\n const caps = declaredCapabilities(native);\n\n // The gate. Deliberately checked BEFORE asking the host for a provider, so a\n // plugin cannot learn whether a camera exists without declaring that it wants\n // one — an undeclared plugin gets the same answer on every device.\n if (caps && !caps.camera) {\n return unavailable(\n \"this plugin did not declare `capabilities: { camera: true }`, so it may not show the camera\",\n renderUnavailable,\n style,\n );\n }\n\n const Provider = getCameraPreviewProvider();\n if (!Provider) {\n // The host has not installed a preview implementation. Say so rather than\n // rendering black: \"no provider\" and \"a dark room\" must never look alike.\n return unavailable(\n 'this app does not provide a camera preview (the host has not called setCameraPreviewProvider)',\n renderUnavailable,\n style,\n );\n }\n\n return <Provider facing={facing} style={style} renderUnavailable={renderUnavailable} />;\n}\n\nfunction unavailable(\n reason: string,\n render: CameraPreviewProps['renderUnavailable'],\n style: any,\n): React.ReactElement | null {\n if (render) return render(reason);\n return (\n <View style={[{ flex: 1, backgroundColor: '#000', alignItems: 'center', justifyContent: 'center', padding: 20 }, style]}>\n <Text style={{ color: '#39FF66', fontSize: 12, textAlign: 'center' }}>\n {`NO CAMERA PREVIEW\\n${reason}`}\n </Text>\n </View>\n );\n}\n\nexport default CameraPreview;\n","/**\n * Theme delivered to plugins via `usePluginTheme()`.\n *\n * Theming flows from the HOST — plugin-side fallback hex values are a no-op\n * by design. The default is the Ada warm-paper palette (matching the\n * reference app); hosts with their own brand call `setPluginThemeColors()`\n * once at startup to override.\n */\nimport { useMemo, useSyncExternalStore } from 'react';\nimport { useColorScheme } from 'react-native';\nimport { ada, spacing, fontSize, borderRadius } from '@ateam-ai-mobile/core';\nimport type { ThemeTokens } from './types';\n\ntype ThemeColors = ThemeTokens['colors'];\n\n// Ada palette mapped onto the plugin theme contract — mirrors the reference\n// app's useTheme.ts. Everything renders against warm paper; dark mode is on\n// the roadmap.\nconst adaColors: ThemeColors = {\n bg: ada.paper,\n surface: ada.paperSoft,\n surfaceAlt: ada.paperDeep,\n input: ada.paper,\n border: ada.border,\n text: ada.ink,\n textSecondary: ada.inkSoft,\n textMuted: ada.inkMuted,\n accent: ada.orange,\n accentSoft: ada.orangeSoft,\n success: '#5A8A5C',\n successSoft: 'rgba(90,138,92,0.14)',\n warning: '#D49A4E',\n warningSoft: 'rgba(212,154,78,0.16)',\n error: '#C15545',\n errorSoft: 'rgba(193,85,69,0.14)',\n purple: ada.orangeDeep,\n purpleSoft: ada.orangeSoft,\n};\n\nlet _colors: ThemeColors = adaColors;\n// null = host hasn't pinned it → track the device color scheme live\n// (parity with the reference app, whose isDark followed useColorScheme()).\nlet _isDark: boolean | null = null;\nconst _subscribers = new Set<() => void>();\n\n/** Override the plugin theme (host brand). Call once at startup — mounted\n * plugins re-render with the new tokens. */\nexport function setPluginThemeColors(colors: Partial<ThemeColors>, opts?: { isDark?: boolean }): void {\n _colors = { ...adaColors, ...colors };\n if (opts?.isDark !== undefined) _isDark = opts.isDark;\n _subscribers.forEach(fn => fn());\n}\n\nfunction subscribe(fn: () => void): () => void {\n _subscribers.add(fn);\n return () => { _subscribers.delete(fn); };\n}\n\nexport function usePluginTheme(): ThemeTokens {\n const colors = useSyncExternalStore(subscribe, () => _colors);\n const hostIsDark = useSyncExternalStore(subscribe, () => _isDark);\n const scheme = useColorScheme();\n const isDark = hostIsDark ?? scheme === 'dark';\n\n // Memoize so plugins don't re-render on every host render.\n return useMemo(() => ({\n colors,\n spacing: {\n xs: spacing.xs,\n sm: spacing.sm,\n md: spacing.md,\n lg: spacing.lg,\n xl: spacing.xl,\n xxl: spacing.xxl,\n },\n fontSize: {\n xs: fontSize.xs,\n sm: fontSize.sm,\n md: fontSize.md,\n lg: fontSize.lg,\n xl: fontSize.xl,\n },\n borderRadius: {\n sm: borderRadius.sm,\n md: borderRadius.md,\n lg: borderRadius.lg,\n full: borderRadius.full,\n },\n isDark,\n }), [colors, isDark]);\n}\n","/**\n * Simple plugin API — call any connector tool.\n *\n * Supports THREE usage patterns:\n *\n * // Pattern 1: Direct function call\n * const api = useApi(bridge);\n * const tasks = await api('task-board-mcp', 'tasks.list', {});\n *\n * // Pattern 2: .call(connector, tool, args) — connector first\n * const api = useApi(bridge);\n * const tasks = await api.call('memory-mcp', 'rules.list', {});\n *\n * // Pattern 3: .call(tool, args, connector) — connector last (rn-src plugins use this!)\n * const api = useApi(bridge);\n * const tasks = await api.call('memory.list', { type: 'rule' }, 'memory-mcp');\n *\n * All three work. The .call method auto-detects argument order.\n */\nimport { useMemo } from 'react';\nimport type { PluginBridge } from './types';\n\ninterface PluginApi {\n (connectorId: string, tool: string, args?: Record<string, any>): Promise<any>;\n call(connectorOrTool: string, toolOrArgs?: string | Record<string, any>, argsOrConnector?: Record<string, any> | string): Promise<any>;\n}\n\n/**\n * Create a simple API function to call connector tools.\n */\nexport function useApi(bridge: PluginBridge): PluginApi {\n return useMemo(() => {\n // Core implementation: (connectorId, tool, args) => Promise\n const apiFn = async (connectorId: string, tool: string, args: Record<string, any> = {}): Promise<any> => {\n if (!bridge) {\n throw new Error('useApi: bridge is required. Pass it from plugin props.');\n }\n return bridge.mcpCall(tool, args, connectorId);\n };\n\n // Add .call method that supports ALL THREE patterns:\n // api.call(connector, tool, args) — 2nd arg is string → connector first\n // api.call(tool, args, connector) — 3rd arg is string → connector last (rn-src pattern)\n // api.call(tool, args) — 2 args only → use bridge default connector\n const callMethod = async (\n first: string,\n second?: string | Record<string, any>,\n third?: Record<string, any> | string,\n ): Promise<any> => {\n if (!bridge) {\n throw new Error('useApi: bridge is required. Pass it from plugin props.');\n }\n\n if (typeof second === 'string') {\n // api.call(connector, tool, args) — 2nd arg is tool name string\n return bridge.mcpCall(second, (third as Record<string, any>) || {}, first);\n }\n\n if (typeof third === 'string') {\n // api.call(tool, args, connector) — 3rd arg is connector ID string\n return bridge.mcpCall(first, (second as Record<string, any>) || {}, third);\n }\n\n // api.call(tool, args) — no connector, use bridge default\n return bridge.mcpCall(first, (second as Record<string, any>) || {});\n };\n\n // Override .call on the function to be our custom method\n // (shadows Function.prototype.call intentionally)\n Object.defineProperty(apiFn, 'call', {\n value: callMethod,\n writable: false,\n configurable: false,\n });\n\n return apiFn as PluginApi;\n }, [bridge]);\n}\n","/**\n * SurfaceDrawer — generic bottom-sheet container for plugins.\n *\n * Plugins render their content; SurfaceDrawer provides the Ada chrome:\n * drag handle, header (orb + title + subtitle + optional privacy pill),\n * close button, motion, backdrop dismiss.\n *\n * Usage:\n * <SurfaceDrawer\n * visible={open}\n * onClose={() => setOpen(false)}\n * title=\"What I remember about you\"\n * subtitle=\"Only you can see this\"\n * privacy\n * >\n * <MyPluginContent />\n * </SurfaceDrawer>\n */\nimport { useEffect, useRef, type ReactNode } from 'react';\nimport {\n View,\n Text,\n Pressable,\n StyleSheet,\n Animated,\n Dimensions,\n Platform,\n} from 'react-native';\nimport Svg, { Path } from 'react-native-svg';\nimport { ada } from '@ateam-ai-mobile/core';\nimport AdaOrb from './AdaOrb';\n\nconst SCREEN_H = Dimensions.get('window').height;\nconst fontFam = Platform.OS === 'ios' ? 'SF Pro Rounded' : undefined;\n\nexport interface SurfaceDrawerProps {\n visible: boolean;\n onClose: () => void;\n title: string;\n subtitle?: string;\n /** Show the lock + \"Only you can see this\" privacy pill under the title */\n privacy?: boolean;\n /** Show the small Ada orb in the header (default: true) */\n showOrb?: boolean;\n /** Sheet height ratio of screen (default: 0.85) */\n heightRatio?: number;\n children: ReactNode;\n}\n\nexport default function SurfaceDrawer({\n visible,\n onClose,\n title,\n subtitle,\n privacy,\n showOrb = true,\n heightRatio = 0.85,\n children,\n}: SurfaceDrawerProps) {\n const sheetH = Math.round(SCREEN_H * heightRatio);\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const slideAnim = useRef(new Animated.Value(sheetH)).current;\n\n useEffect(() => {\n if (visible) {\n Animated.parallel([\n Animated.timing(fadeAnim, { toValue: 1, duration: 220, useNativeDriver: true }),\n Animated.spring(slideAnim, { toValue: 0, useNativeDriver: true, tension: 80, friction: 12 }),\n ]).start();\n } else {\n fadeAnim.setValue(0);\n slideAnim.setValue(sheetH);\n }\n }, [visible]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const close = () => {\n Animated.parallel([\n Animated.timing(fadeAnim, { toValue: 0, duration: 160, useNativeDriver: true }),\n Animated.timing(slideAnim, { toValue: sheetH, duration: 200, useNativeDriver: true }),\n ]).start(() => onClose());\n };\n\n if (!visible) return null;\n\n return (\n <Animated.View style={[styles.overlay, { opacity: fadeAnim }]} pointerEvents=\"auto\">\n <Pressable style={StyleSheet.absoluteFill} onPress={close} />\n <Animated.View\n style={[\n styles.sheet,\n { height: sheetH, transform: [{ translateY: slideAnim }] },\n ]}\n >\n {/* Drag handle */}\n <View style={styles.handle} />\n\n {/* Header */}\n <View style={styles.header}>\n {showOrb ? (\n <View style={styles.headerOrb}>\n <AdaOrb size={36} state=\"idle\" />\n </View>\n ) : null}\n <View style={{ flex: 1 }}>\n <Text style={styles.title}>{title}</Text>\n {subtitle ? <Text style={styles.subtitle}>{subtitle}</Text> : null}\n {privacy ? (\n <View style={styles.privacyPill}>\n <Svg width={11} height={11} viewBox=\"0 0 24 24\" fill=\"none\" stroke={ada.inkSoft} strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <Path d=\"M19 11H5a2 2 0 00-2 2v7a2 2 0 002 2h14a2 2 0 002-2v-7a2 2 0 00-2-2z\" />\n <Path d=\"M7 11V7a5 5 0 0110 0v4\" />\n </Svg>\n <Text style={styles.privacyText}>Only you can see this</Text>\n </View>\n ) : null}\n </View>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Close\"\n style={styles.closeBtn}\n onPress={close}\n hitSlop={12}\n >\n <Svg width={18} height={18} viewBox=\"0 0 24 24\" fill=\"none\" stroke={ada.inkSoft} strokeWidth={2.2} strokeLinecap=\"round\">\n <Path d=\"M18 6L6 18M6 6l12 12\" />\n </Svg>\n </Pressable>\n </View>\n\n {/* Body — caller renders content */}\n <View style={styles.body}>{children}</View>\n </Animated.View>\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n overlay: {\n position: 'absolute',\n top: 0, left: 0, right: 0, bottom: 0,\n backgroundColor: 'rgba(26, 20, 16, 0.35)',\n justifyContent: 'flex-end',\n zIndex: 999,\n elevation: 999,\n },\n sheet: {\n backgroundColor: ada.paper,\n borderTopLeftRadius: 28,\n borderTopRightRadius: 28,\n overflow: 'hidden',\n },\n handle: {\n width: 40,\n height: 4,\n borderRadius: 2,\n backgroundColor: ada.inkMuted,\n opacity: 0.3,\n alignSelf: 'center',\n marginTop: 10,\n marginBottom: 6,\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 22,\n paddingVertical: 16,\n gap: 12,\n borderBottomWidth: 1,\n borderBottomColor: ada.border,\n },\n headerOrb: {\n width: 36,\n height: 36,\n alignItems: 'center',\n justifyContent: 'center',\n },\n title: {\n fontSize: 17,\n fontWeight: '600',\n color: ada.ink,\n letterSpacing: -0.2,\n fontFamily: fontFam,\n },\n subtitle: {\n fontSize: 13,\n fontWeight: '400',\n color: ada.inkSoft,\n marginTop: 2,\n letterSpacing: -0.1,\n fontFamily: fontFam,\n },\n privacyPill: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n marginTop: 4,\n },\n privacyText: {\n fontSize: 11,\n fontWeight: '500',\n color: ada.inkSoft,\n letterSpacing: 0.2,\n fontFamily: fontFam,\n },\n closeBtn: {\n width: 32,\n height: 32,\n borderRadius: 16,\n backgroundColor: ada.paperSoft,\n justifyContent: 'center',\n alignItems: 'center',\n },\n body: {\n flex: 1,\n },\n});\n","import { useEffect } from 'react';\nimport { View, StyleSheet } from 'react-native';\nimport Animated, {\n useSharedValue,\n useAnimatedProps,\n withRepeat,\n withTiming,\n withSequence,\n withDelay,\n Easing,\n cancelAnimation,\n} from 'react-native-reanimated';\nimport Svg, { Circle, Defs, RadialGradient, Stop, Text as SvgText } from 'react-native-svg';\n\nconst AnimatedCircle = Animated.createAnimatedComponent(Circle);\n\nexport type AdaOrbState = 'idle' | 'listening' | 'thinking' | 'speaking';\n\ninterface AdaOrbProps {\n size?: number;\n state?: AdaOrbState;\n /** Show the \"iA\" wordmark inside the orb. Suppressed below 60px because\n * glyphs become unreadable at avatar/chevron sizes — render as a plain\n * orb there. Default true. */\n inscription?: boolean;\n}\n\nexport default function AdaOrb({ size = 120, state = 'idle', inscription = true }: AdaOrbProps) {\n const showInscription = inscription && size >= 60;\n const center = size / 2;\n const coreR = size * 0.32;\n const innerHaloR = size * 0.42;\n const outerHaloR = size * 0.5;\n\n // Base breath layers\n const coreScale = useSharedValue(1);\n const innerScale = useSharedValue(1);\n const outerScale = useSharedValue(1);\n const outerOpacity = useSharedValue(0.55);\n\n // Listening: continuous ripple cycle (one shared value, phase-shifted reads)\n const rippleCycle = useSharedValue(0);\n\n // Thinking: 3 orbiting sparks at different speeds + directions\n const orbit1 = useSharedValue(0); // fast inner\n const orbit2 = useSharedValue(0); // medium mid\n const orbit3 = useSharedValue(0); // slow outer (counter)\n\n // Speaking: secondary fast double-beat overlay\n const beat = useSharedValue(1);\n\n useEffect(() => {\n cancelAnimation(coreScale);\n cancelAnimation(innerScale);\n cancelAnimation(outerScale);\n cancelAnimation(outerOpacity);\n cancelAnimation(rippleCycle);\n cancelAnimation(orbit1);\n cancelAnimation(orbit2);\n cancelAnimation(orbit3);\n cancelAnimation(beat);\n\n // Reset state-specific drivers\n rippleCycle.value = 0;\n orbit1.value = 0;\n orbit2.value = 0;\n orbit3.value = 0;\n beat.value = 1;\n\n let breathMs = 3600;\n let breathAmount = 0.025;\n\n if (state === 'listening') {\n breathMs = 2000;\n breathAmount = 0.05;\n // Continuous ripple loop — one cycle = one ripple lifetime\n rippleCycle.value = withRepeat(\n withTiming(1, { duration: 2000, easing: Easing.out(Easing.quad) }),\n -1,\n false,\n );\n } else if (state === 'thinking') {\n breathMs = 2400;\n breathAmount = 0.04;\n // Three sparks orbiting at different speeds + directions — feels like processing\n orbit1.value = withRepeat(\n withTiming(1, { duration: 1100, easing: Easing.linear }),\n -1,\n false,\n );\n orbit2.value = withRepeat(\n withTiming(1, { duration: 1900, easing: Easing.linear }),\n -1,\n false,\n );\n orbit3.value = withRepeat(\n withTiming(-1, { duration: 2700, easing: Easing.linear }),\n -1,\n false,\n );\n } else if (state === 'speaking') {\n breathMs = 700;\n breathAmount = 0.13;\n // Double-beat overlay — quick punch + secondary kick\n beat.value = withRepeat(\n withSequence(\n withTiming(1.08, { duration: 90, easing: Easing.out(Easing.quad) }),\n withTiming(1.0, { duration: 130, easing: Easing.in(Easing.quad) }),\n withTiming(1.05, { duration: 80, easing: Easing.out(Easing.quad) }),\n withTiming(1.0, { duration: 200, easing: Easing.in(Easing.quad) }),\n withTiming(1.0, { duration: 280 }),\n ),\n -1,\n false,\n );\n }\n\n // Base breath — different easing per state\n const breathEasing =\n state === 'speaking' ? Easing.out(Easing.cubic) : Easing.inOut(Easing.sin);\n\n coreScale.value = withRepeat(\n withSequence(\n withTiming(1 + breathAmount, { duration: breathMs, easing: breathEasing }),\n withTiming(1, { duration: breathMs, easing: breathEasing }),\n ),\n -1,\n false,\n );\n innerScale.value = withRepeat(\n withSequence(\n withTiming(1 + breathAmount * 1.4, { duration: breathMs * 1.15, easing: breathEasing }),\n withTiming(1, { duration: breathMs * 1.15, easing: breathEasing }),\n ),\n -1,\n false,\n );\n outerScale.value = withRepeat(\n withSequence(\n withTiming(1 + breathAmount * 1.8, { duration: breathMs * 1.3, easing: breathEasing }),\n withTiming(1, { duration: breathMs * 1.3, easing: breathEasing }),\n ),\n -1,\n false,\n );\n outerOpacity.value = withRepeat(\n withSequence(\n withTiming(state === 'idle' ? 0.55 : 0.8, { duration: breathMs * 1.3, easing: breathEasing }),\n withTiming(0.35, { duration: breathMs * 1.3, easing: breathEasing }),\n ),\n -1,\n false,\n );\n }, [state]);\n\n // Animated props for base layers — multiplied by `beat` so speaking double-pulse stacks\n const coreProps = useAnimatedProps(() => ({\n r: coreR * coreScale.value * beat.value,\n }));\n const innerProps = useAnimatedProps(() => ({\n r: innerHaloR * innerScale.value * beat.value,\n }));\n const outerProps = useAnimatedProps(() => ({\n r: outerHaloR * outerScale.value,\n opacity: outerOpacity.value,\n }));\n\n // Listening ripples — three phase-shifted reads of rippleCycle\n const ripple1Props = useAnimatedProps(() => {\n const t = rippleCycle.value;\n return {\n r: outerHaloR * (1 + t * 0.55),\n opacity: state === 'listening' ? 0.55 * (1 - t) : 0,\n };\n });\n const ripple2Props = useAnimatedProps(() => {\n const t = (rippleCycle.value + 0.34) % 1;\n return {\n r: outerHaloR * (1 + t * 0.55),\n opacity: state === 'listening' ? 0.45 * (1 - t) : 0,\n };\n });\n const ripple3Props = useAnimatedProps(() => {\n const t = (rippleCycle.value + 0.67) % 1;\n return {\n r: outerHaloR * (1 + t * 0.55),\n opacity: state === 'listening' ? 0.35 * (1 - t) : 0,\n };\n });\n\n // Thinking sparks — three at different radii and angular velocities\n const spark1Props = useAnimatedProps(() => {\n const angle = orbit1.value * Math.PI * 2 - Math.PI / 2;\n const r = coreR * 0.55;\n return {\n cx: center + Math.cos(angle) * r,\n cy: center + Math.sin(angle) * r,\n opacity: state === 'thinking' ? 1 : 0,\n };\n });\n const spark2Props = useAnimatedProps(() => {\n const angle = orbit2.value * Math.PI * 2 + Math.PI * 0.6;\n const r = coreR * 0.85;\n return {\n cx: center + Math.cos(angle) * r,\n cy: center + Math.sin(angle) * r,\n opacity: state === 'thinking' ? 0.9 : 0,\n };\n });\n const spark3Props = useAnimatedProps(() => {\n const angle = orbit3.value * Math.PI * 2 + Math.PI * 1.3;\n const r = coreR * 1.05;\n return {\n cx: center + Math.cos(angle) * r,\n cy: center + Math.sin(angle) * r,\n opacity: state === 'thinking' ? 0.7 : 0,\n };\n });\n\n return (\n <View style={[styles.wrap, { width: size, height: size }]}>\n <Svg width={size} height={size}>\n <Defs>\n <RadialGradient id=\"adaCore\" cx=\"36%\" cy=\"30%\" r=\"70%\">\n <Stop offset=\"0%\" stopColor=\"#FFE0B0\" stopOpacity=\"1\" />\n <Stop offset=\"28%\" stopColor=\"#FFA85A\" stopOpacity=\"1\" />\n <Stop offset=\"65%\" stopColor=\"#FF7A28\" stopOpacity=\"1\" />\n <Stop offset=\"100%\" stopColor=\"#B8410A\" stopOpacity=\"1\" />\n </RadialGradient>\n <RadialGradient id=\"adaInner\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n <Stop offset=\"0%\" stopColor=\"#FF8A3C\" stopOpacity=\"0.55\" />\n <Stop offset=\"100%\" stopColor=\"#FF7028\" stopOpacity=\"0\" />\n </RadialGradient>\n <RadialGradient id=\"adaOuter\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n <Stop offset=\"0%\" stopColor=\"#FF7A28\" stopOpacity=\"0.4\" />\n <Stop offset=\"100%\" stopColor=\"#FF6018\" stopOpacity=\"0\" />\n </RadialGradient>\n <RadialGradient id=\"adaSpark\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n <Stop offset=\"0%\" stopColor=\"#FFFAEB\" stopOpacity=\"1\" />\n <Stop offset=\"60%\" stopColor=\"#FFD095\" stopOpacity=\"0.9\" />\n <Stop offset=\"100%\" stopColor=\"#FFA85A\" stopOpacity=\"0\" />\n </RadialGradient>\n </Defs>\n\n {/* Listening ripples — drawn behind orb body */}\n <AnimatedCircle\n cx={center}\n cy={center}\n stroke=\"#FF7A28\"\n strokeWidth={1.5}\n fill=\"none\"\n animatedProps={ripple1Props}\n />\n <AnimatedCircle\n cx={center}\n cy={center}\n stroke=\"#FF7A28\"\n strokeWidth={1.5}\n fill=\"none\"\n animatedProps={ripple2Props}\n />\n <AnimatedCircle\n cx={center}\n cy={center}\n stroke=\"#FF7A28\"\n strokeWidth={1.5}\n fill=\"none\"\n animatedProps={ripple3Props}\n />\n\n {/* Base orb body */}\n <AnimatedCircle cx={center} cy={center} fill=\"url(#adaOuter)\" animatedProps={outerProps} />\n <AnimatedCircle cx={center} cy={center} fill=\"url(#adaInner)\" animatedProps={innerProps} />\n <AnimatedCircle cx={center} cy={center} fill=\"url(#adaCore)\" animatedProps={coreProps} />\n\n {/* Thinking sparks — three orbiting particles drawn on top */}\n <AnimatedCircle\n r={Math.max(3, size * 0.05)}\n fill=\"url(#adaSpark)\"\n animatedProps={spark1Props}\n />\n <AnimatedCircle\n r={Math.max(2.5, size * 0.04)}\n fill=\"url(#adaSpark)\"\n animatedProps={spark2Props}\n />\n <AnimatedCircle\n r={Math.max(2, size * 0.032)}\n fill=\"url(#adaSpark)\"\n animatedProps={spark3Props}\n />\n\n {/* \"iA\" wordmark — matches the app icon. Suppressed at small sizes\n where the glyphs would be unreadable (see showInscription). */}\n {showInscription && (\n <SvgText\n x={center}\n y={center + size * 0.11}\n fontSize={size * 0.34}\n fontWeight=\"600\"\n fill=\"#FFF5E0\"\n textAnchor=\"middle\"\n letterSpacing={-size * 0.005}\n >\n iA\n </SvgText>\n )}\n </Svg>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","/**\n * SurfaceCard — a tappable tile shape for plugins that surface as cards\n * (empty-state suggestions, dashboards, daily-brief items).\n *\n * Plugins declare icon + title + subtitle + onPress; the host provides\n * the warm Ada chrome (paper-soft bg, soft border, arrow chevron, haptic).\n *\n * Optional `children` render below the title block for richer previews\n * (e.g. small ring widget, last-meal photo, current weather).\n *\n * Usage:\n * <SurfaceCard\n * icon=\"🥗\"\n * title=\"Today's plate\"\n * subtitle=\"2,100 kcal · 140g protein\"\n * onPress={() => sendPrompt('Tell me about my nutrition today')}\n * />\n */\nimport { type ReactNode } from 'react';\nimport {\n View,\n Text,\n Pressable,\n StyleSheet,\n Platform,\n} from 'react-native';\nimport { getHaptics } from '../host';\nimport { ada, borderRadius } from '@ateam-ai-mobile/core';\n\nconst fontFam = Platform.OS === 'ios' ? 'SF Pro Rounded' : undefined;\n\nexport interface SurfaceCardProps {\n /** Emoji or short string icon shown on the left */\n icon?: string;\n /** Card headline (e.g. \"Today's plate\") */\n title: string;\n /** Optional secondary line below title */\n subtitle?: string;\n /** Tap handler. Fires haptic before invoking. */\n onPress?: () => void;\n /** Long-press handler. Fires a heavier haptic. Used by user widgets for\n * the Delete / (later) Hide / Rename context menu. */\n onLongPress?: () => void;\n /** Whether to show the ›-style trailing arrow (default: true if onPress) */\n showArrow?: boolean;\n /** Optional preview content rendered below the title block */\n children?: ReactNode;\n}\n\nexport default function SurfaceCard({\n icon,\n title,\n subtitle,\n onPress,\n onLongPress,\n showArrow,\n children,\n}: SurfaceCardProps) {\n const arrow = showArrow ?? !!onPress;\n const handlePress = () => {\n if (!onPress) return;\n getHaptics()?.impact('light');\n onPress();\n };\n const handleLongPress = () => {\n if (!onLongPress) return;\n getHaptics()?.impact('medium');\n onLongPress();\n };\n\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={[icon, title, subtitle].filter(Boolean).join(', ')}\n accessibilityHint={onLongPress ? 'Long-press for more options' : undefined}\n style={styles.card}\n onPress={onPress ? handlePress : undefined}\n onLongPress={onLongPress ? handleLongPress : undefined}\n disabled={!onPress && !onLongPress}\n >\n <View style={styles.row}>\n {icon ? <Text style={styles.icon}>{icon}</Text> : null}\n <View style={{ flex: 1 }}>\n <Text style={styles.title}>{title}</Text>\n {subtitle ? <Text style={styles.subtitle}>{subtitle}</Text> : null}\n </View>\n {arrow ? <Text style={styles.arrow}>{'\\u2192'}</Text> : null}\n </View>\n {children ? <View style={styles.body}>{children}</View> : null}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n card: {\n backgroundColor: ada.paperSoft,\n borderWidth: 1,\n borderColor: ada.border,\n borderRadius: borderRadius.xl,\n paddingHorizontal: 16,\n paddingVertical: 14,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 14,\n },\n icon: {\n fontSize: 22,\n },\n title: {\n fontSize: 15,\n fontWeight: '600',\n color: ada.ink,\n letterSpacing: -0.2,\n fontFamily: fontFam,\n },\n subtitle: {\n fontSize: 13,\n fontWeight: '400',\n color: ada.inkMuted,\n marginTop: 2,\n letterSpacing: -0.1,\n fontFamily: fontFam,\n },\n arrow: {\n fontSize: 18,\n color: ada.inkMuted,\n fontWeight: '400',\n },\n body: {\n marginTop: 10,\n paddingTop: 10,\n borderTopWidth: 1,\n borderTopColor: ada.border,\n },\n});\n","/**\n * SurfaceFullscreen — edge-to-edge takeover container for plugins\n * (voice mode, focus modes, photo capture, etc.).\n *\n * Plugins render their content; SurfaceFullscreen provides:\n * - Paper background, fade-in motion\n * - Top status line (\"ada\" wordmark + status text)\n * - Optional hero element above body (e.g. AdaOrb)\n * - Bottom close button with label\n * - Spring entry on the hero (scale 0.6 → 1)\n *\n * Usage:\n * <SurfaceFullscreen\n * visible={open}\n * onClose={hangUp}\n * status=\"Ada is speaking\"\n * hero={<AdaOrb size={180} state=\"speaking\" />}\n * closeIcon=\"hangup\"\n * closeLabel=\"End\"\n * >\n * <Transcript ... />\n * </SurfaceFullscreen>\n */\nimport { useEffect, useRef, type ReactNode } from 'react';\nimport {\n View,\n Text,\n Pressable,\n StyleSheet,\n Animated,\n Platform,\n} from 'react-native';\nimport Svg, { Path } from 'react-native-svg';\nimport { ada } from '@ateam-ai-mobile/core';\n\nconst fontFam = Platform.OS === 'ios' ? 'SF Pro Rounded' : undefined;\n\nexport interface SurfaceFullscreenProps {\n visible: boolean;\n onClose: () => void;\n /** Status text shown under the wordmark */\n status?: string;\n /** Optional hero element above body (typically an AdaOrb) */\n hero?: ReactNode;\n /** Body content */\n children?: ReactNode;\n /** Whether to show the small \"ada\" wordmark (default: true) */\n showWordmark?: boolean;\n /** Built-in close icon flavor or a custom node. Default: 'x' */\n closeIcon?: 'x' | 'hangup' | ReactNode;\n /** Label under the close button (default: \"Close\") */\n closeLabel?: string;\n}\n\nexport default function SurfaceFullscreen({\n visible,\n onClose,\n status,\n hero,\n children,\n showWordmark = true,\n closeIcon = 'x',\n closeLabel = 'Close',\n}: SurfaceFullscreenProps) {\n const fadeAnim = useRef(new Animated.Value(0)).current;\n const heroScale = useRef(new Animated.Value(0.6)).current;\n\n useEffect(() => {\n if (visible) {\n Animated.parallel([\n Animated.timing(fadeAnim, { toValue: 1, duration: 280, useNativeDriver: true }),\n Animated.spring(heroScale, { toValue: 1, useNativeDriver: true, tension: 60, friction: 11 }),\n ]).start();\n } else {\n fadeAnim.setValue(0);\n heroScale.setValue(0.6);\n }\n }, [visible]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const close = () => {\n Animated.parallel([\n Animated.timing(fadeAnim, { toValue: 0, duration: 180, useNativeDriver: true }),\n Animated.timing(heroScale, { toValue: 0.6, duration: 180, useNativeDriver: true }),\n ]).start(() => onClose());\n };\n\n if (!visible) return null;\n\n const renderCloseIcon = () => {\n if (closeIcon === 'hangup') {\n return (\n <Svg width={22} height={22} viewBox=\"0 0 24 24\" fill={ada.paper}>\n <Path d=\"M3.68 16.07l3.92-3.11c.28-.23.68-.28 1.01-.14l2.77 1.15c.36.15.61.5.61.89v2.82c4.34-.76 7.93-4.35 8.69-8.69h-2.82c-.39 0-.74-.25-.89-.61L16.12 5.6c-.13-.33-.09-.73.14-1.01l3.11-3.92c.29-.37.81-.41 1.15-.08l3.24 3.24c.2.2.31.47.31.76C24 14.44 14.44 24 4.59 24c-.29 0-.56-.11-.76-.31L.59 20.45c-.33-.34-.29-.86.09-1.15z\" />\n </Svg>\n );\n }\n if (closeIcon === 'x') {\n return (\n <Svg width={20} height={20} viewBox=\"0 0 24 24\" fill=\"none\" stroke={ada.paper} strokeWidth={2.5} strokeLinecap=\"round\">\n <Path d=\"M18 6L6 18M6 6l12 12\" />\n </Svg>\n );\n }\n return closeIcon;\n };\n\n return (\n <Animated.View style={[styles.overlay, { opacity: fadeAnim }]} pointerEvents=\"auto\">\n {/* Top status */}\n <View style={styles.topBar}>\n {showWordmark ? <Text style={styles.wordmark}>ada</Text> : null}\n {status ? <Text style={styles.status}>{status}</Text> : null}\n </View>\n\n {/* Optional hero (e.g. AdaOrb) — springs in */}\n {hero ? (\n <View style={styles.heroWrap}>\n <Animated.View style={{ transform: [{ scale: heroScale }] }}>\n {hero}\n </Animated.View>\n </View>\n ) : null}\n\n {/* Body — caller content */}\n <View style={styles.body}>{children}</View>\n\n {/* Bottom close */}\n <View style={styles.bottomBar}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={closeLabel}\n style={styles.closeBtn}\n onPress={close}\n hitSlop={12}\n >\n {renderCloseIcon()}\n </Pressable>\n {closeLabel ? <Text style={styles.closeLabel}>{closeLabel}</Text> : null}\n </View>\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n overlay: {\n position: 'absolute',\n top: 0, left: 0, right: 0, bottom: 0,\n backgroundColor: ada.paper,\n zIndex: 1000,\n elevation: 1000,\n },\n topBar: {\n paddingTop: Platform.OS === 'ios' ? 64 : 36,\n paddingHorizontal: 24,\n alignItems: 'center',\n gap: 6,\n },\n wordmark: {\n fontSize: 14,\n fontFamily: fontFam,\n fontWeight: '500',\n color: ada.inkMuted,\n letterSpacing: 4,\n },\n status: {\n fontSize: 17,\n fontFamily: fontFam,\n fontWeight: '500',\n color: ada.ink,\n letterSpacing: -0.2,\n },\n heroWrap: {\n paddingTop: 24,\n paddingBottom: 12,\n alignItems: 'center',\n justifyContent: 'center',\n },\n body: {\n flex: 1,\n },\n bottomBar: {\n paddingBottom: Platform.OS === 'ios' ? 48 : 32,\n paddingTop: 12,\n alignItems: 'center',\n gap: 8,\n },\n closeBtn: {\n width: 64,\n height: 64,\n borderRadius: 32,\n backgroundColor: ada.ink,\n justifyContent: 'center',\n alignItems: 'center',\n shadowColor: ada.ink,\n shadowOffset: { width: 0, height: 8 },\n shadowOpacity: 0.18,\n shadowRadius: 14,\n elevation: 8,\n },\n closeLabel: {\n fontSize: 13,\n fontFamily: fontFam,\n fontWeight: '500',\n color: ada.inkMuted,\n letterSpacing: 0.3,\n },\n});\n","/**\n * Surface registry + active-state store.\n *\n * - `manifests`: map of registered surface plugins\n * - `activeDrawer` / `activeFullscreen`: which surface (if any) is currently mounted\n * (only one of each at a time)\n *\n * Plugins are registered by calling `register(...)` from bootstrap or by an\n * \"engine\" event. The dispatcher subscribes to active state and mounts.\n */\nimport { create } from 'zustand';\nimport type {\n SurfaceManifest,\n SurfaceType,\n SurfaceVisibility,\n SurfacePlacement,\n InlineSurfaceManifest,\n MountSurfaceManifest,\n} from './types';\n\ninterface SurfaceState {\n manifests: Record<string, SurfaceManifest>;\n activeDrawer: string | null;\n activeFullscreen: string | null;\n /** Props passed by the engine when summoning a surface via sys.focusUiPlugin.\n * Keyed by surface id; cleared on hide. Plugins read these on first mount. */\n activeProps: Record<string, any>;\n /** Increments on every `show()` call. Used as a React `key` so the Surface\n * Component remounts even if the same surface is shown again — guarantees\n * the plugin's data-fetching effects re-run, so the user always sees fresh\n * data when they open a drawer. */\n mountKey: number;\n\n register: (manifest: SurfaceManifest) => void;\n unregister: (id: string) => void;\n\n /** Open a surface in its declared container. Props (optional) are forwarded\n * to the mounted plugin on first render. */\n show: (id: string, props?: any) => void;\n /** Close the surface with the given id (or whatever is active for the matching type) */\n hide: (id?: string) => void;\n\n /** All registered manifests, optionally filtered.\n * `placement: 'unset'` selects only plugins WITHOUT a placement (default list). */\n list: (filter?: {\n type?: SurfaceType;\n visibility?: SurfaceVisibility[];\n placement?: SurfacePlacement | 'unset';\n }) => SurfaceManifest[];\n}\n\nexport const useSurfaceStore = create<SurfaceState>((set, get) => ({\n manifests: {},\n activeDrawer: null,\n activeFullscreen: null,\n activeProps: {},\n mountKey: 0,\n\n register: (manifest) =>\n set(s => ({ manifests: { ...s.manifests, [manifest.id]: manifest } })),\n\n unregister: (id) =>\n set(s => {\n const next = { ...s.manifests };\n delete next[id];\n const nextProps = { ...s.activeProps };\n delete nextProps[id];\n return { manifests: next, activeProps: nextProps };\n }),\n\n show: (id, props) => {\n const m = get().manifests[id];\n if (!m) {\n console.warn('[SurfaceStore] show: unknown surface id', id);\n return;\n }\n set(s => {\n const nextProps = props !== undefined\n ? { ...s.activeProps, [id]: props }\n : s.activeProps;\n // Bump mountKey on every show so the dispatcher remounts the Component,\n // forcing the plugin's data fetch to re-run with fresh results.\n const mountKey = s.mountKey + 1;\n if (m.type === 'drawer') return { activeDrawer: id, activeProps: nextProps, mountKey };\n if (m.type === 'fullscreen') return { activeFullscreen: id, activeProps: nextProps, mountKey };\n return { mountKey };\n });\n },\n\n hide: (id) => {\n const s = get();\n if (!id) {\n // Hide whichever is active and clear their props\n const cleanup = { ...s.activeProps };\n if (s.activeDrawer) delete cleanup[s.activeDrawer];\n if (s.activeFullscreen) delete cleanup[s.activeFullscreen];\n set({ activeDrawer: null, activeFullscreen: null, activeProps: cleanup });\n return;\n }\n const cleanup = { ...s.activeProps };\n delete cleanup[id];\n const patch: Partial<SurfaceState> = { activeProps: cleanup };\n if (s.activeDrawer === id) patch.activeDrawer = null;\n if (s.activeFullscreen === id) patch.activeFullscreen = null;\n set(patch);\n },\n\n list: (filter) => {\n const all = Object.values(get().manifests);\n return all.filter(m => {\n if (filter?.type && m.type !== filter.type) return false;\n if (filter?.visibility && !filter.visibility.includes(m.visibility)) return false;\n if (filter?.placement) {\n if (filter.placement === 'unset') {\n if (m.placement) return false;\n } else if (m.placement !== filter.placement) {\n return false;\n }\n }\n return true;\n });\n },\n}));\n\n// Convenience guards\nexport function isMountSurface(m: SurfaceManifest): m is MountSurfaceManifest {\n return m.type === 'drawer' || m.type === 'fullscreen';\n}\nexport function isInlineSurface(m: SurfaceManifest): m is InlineSurfaceManifest {\n return m.type === 'card' || m.type === 'header' || m.type === 'ambient' || m.type === 'nudge';\n}\n","/**\n * SurfaceDispatcher — mounted once at the app root.\n *\n * Watches the surface store and:\n * - Mounts the active drawer surface (max one at a time)\n * - Mounts the active fullscreen surface (max one at a time)\n *\n * The mounted Component receives `dismiss` to close itself; the dispatcher\n * clears active-state after dismiss.\n *\n * Inline surfaces (card / header / ambient / nudge) are NOT rendered by the\n * dispatcher — they're queried via `useSurfaceStore().list({ type: 'card' })`\n * and rendered inline by the host screen that owns that placement.\n */\nimport { useEffect } from 'react';\nimport { useSurfaceStore } from './store';\nimport { pluginCommandEmitter } from '@ateam-ai-mobile/core';\n\nexport default function SurfaceDispatcher() {\n const manifests = useSurfaceStore(s => s.manifests);\n const activeDrawer = useSurfaceStore(s => s.activeDrawer);\n const activeFullscreen = useSurfaceStore(s => s.activeFullscreen);\n const activeProps = useSurfaceStore(s => s.activeProps);\n const mountKey = useSurfaceStore(s => s.mountKey);\n const hide = useSurfaceStore(s => s.hide);\n\n // bridge.close() inside a plugin emits a global `plugin-close` event.\n // The legacy plugins overlay listens for this; we mirror that here so\n // surface-mounted plugins (auth-webview, etc.) actually dismiss themselves.\n useEffect(() => {\n const unsub = pluginCommandEmitter.on('plugin-close', ({ pluginId }: { pluginId?: string } = {}) => {\n if (!pluginId) return;\n const s = useSurfaceStore.getState();\n if (s.activeDrawer === pluginId || s.activeFullscreen === pluginId) {\n s.hide(pluginId);\n }\n });\n return unsub;\n }, []);\n\n const drawer = activeDrawer ? manifests[activeDrawer] : null;\n const fullscreen = activeFullscreen ? manifests[activeFullscreen] : null;\n const drawerProps = activeDrawer ? activeProps[activeDrawer] : undefined;\n const fullscreenProps = activeFullscreen ? activeProps[activeFullscreen] : undefined;\n\n // mountKey changes on every show() so React remounts the Component → the\n // plugin's data-fetching useEffects re-run → user sees fresh data each open.\n return (\n <>\n {drawer && drawer.type === 'drawer' && drawer.Component ? (\n <drawer.Component\n key={`drawer-${drawer.id}-${mountKey}`}\n dismiss={() => hide(drawer.id)}\n props={drawerProps}\n />\n ) : null}\n {fullscreen && fullscreen.type === 'fullscreen' && fullscreen.Component ? (\n <fullscreen.Component\n key={`fullscreen-${fullscreen.id}-${mountKey}`}\n dismiss={() => hide(fullscreen.id)}\n props={fullscreenProps}\n />\n ) : null}\n </>\n );\n}\n","/**\n * Pure-JS SHA-256 — used to verify integrity of downloaded plugin bundles.\n * Avoids pulling expo-crypto / a native module into the dependency graph for\n * what amounts to a one-shot post-download check.\n *\n * Hot path: hash a ~100KB-1MB bundle once after download. Performance is\n * acceptable on every supported device (sub-50ms).\n *\n * Algorithm reference: FIPS 180-4. Implementation derived from the public-\n * domain reference code; see https://en.wikipedia.org/wiki/SHA-2#Pseudocode.\n */\n\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\nconst rotr = (n: number, x: number) => (x >>> n) | (x << (32 - n));\n\n/** SHA-256 of a UTF-8 string. Returns the lowercase hex digest. */\nexport function sha256Hex(message: string): string {\n // 1. Encode to UTF-8 bytes\n const utf8 = unescape(encodeURIComponent(message));\n const bytes = new Uint8Array(utf8.length);\n for (let i = 0; i < utf8.length; i++) bytes[i] = utf8.charCodeAt(i);\n\n // 2. Pre-processing: append 0x80, pad with zeros, then append 64-bit big-endian length\n const bitLen = bytes.length * 8;\n const padLen = (56 - (bytes.length + 1) % 64 + 64) % 64;\n const buf = new Uint8Array(bytes.length + 1 + padLen + 8);\n buf.set(bytes);\n buf[bytes.length] = 0x80;\n // 64-bit big-endian length (high 32 bits zeroed — bundles are well under 2^32 bits)\n const len = buf.length;\n buf[len - 4] = (bitLen >>> 24) & 0xff;\n buf[len - 3] = (bitLen >>> 16) & 0xff;\n buf[len - 2] = (bitLen >>> 8) & 0xff;\n buf[len - 1] = bitLen & 0xff;\n\n const h = new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,\n 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n ]);\n const w = new Uint32Array(64);\n\n // 3. Process each 512-bit chunk\n for (let i = 0; i < buf.length; i += 64) {\n for (let t = 0; t < 16; t++) {\n const j = i + t * 4;\n w[t] = (buf[j] << 24) | (buf[j + 1] << 16) | (buf[j + 2] << 8) | buf[j + 3];\n }\n for (let t = 16; t < 64; t++) {\n const s0 = rotr(7, w[t - 15]) ^ rotr(18, w[t - 15]) ^ (w[t - 15] >>> 3);\n const s1 = rotr(17, w[t - 2]) ^ rotr(19, w[t - 2]) ^ (w[t - 2] >>> 10);\n w[t] = (w[t - 16] + s0 + w[t - 7] + s1) | 0;\n }\n\n let a = h[0], b = h[1], c = h[2], d = h[3], e = h[4], f = h[5], g = h[6], hh = h[7];\n for (let t = 0; t < 64; t++) {\n const S1 = rotr(6, e) ^ rotr(11, e) ^ rotr(25, e);\n const ch = (e & f) ^ (~e & g);\n const temp1 = (hh + S1 + ch + K[t] + w[t]) | 0;\n const S0 = rotr(2, a) ^ rotr(13, a) ^ rotr(22, a);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const temp2 = (S0 + maj) | 0;\n hh = g; g = f; f = e; e = (d + temp1) | 0; d = c; c = b; b = a; a = (temp1 + temp2) | 0;\n }\n\n h[0] = (h[0] + a) | 0; h[1] = (h[1] + b) | 0; h[2] = (h[2] + c) | 0; h[3] = (h[3] + d) | 0;\n h[4] = (h[4] + e) | 0; h[5] = (h[5] + f) | 0; h[6] = (h[6] + g) | 0; h[7] = (h[7] + hh) | 0;\n }\n\n // 4. Produce hex\n let out = '';\n for (let i = 0; i < 8; i++) {\n out += h[i].toString(16).padStart(8, '0');\n }\n return out;\n}\n","/**\n * R8 remote-bundle integrity — the fail-closed check run INLINE, immediately\n * before a remote bundle is evaluated with `new Function`.\n *\n * See docs/decisions/REMOTE_BUNDLE_INTEGRITY.md for the threat model and the\n * (declined) publisher-signature decision. This is INTEGRITY, not a sandbox:\n * it proves the bytes about to run are exactly the ones the trusted manifest\n * hash names; it does not isolate what they can do.\n */\nimport { sha256Hex } from '../utils/sha256';\n\n/**\n * Refuse to evaluate a bundle whose bytes do not match the SHA-256 that\n * gate-kept them. Fail-closed on a MISSING hash too — an unverifiable bundle is\n * treated exactly like a mismatched one. `verifiedHash` is the manifest hash for\n * a cache hit or the freshly-verified download hash; re-hashing `content` here\n * closes the disk-cache-tamper gap the download-time check leaves open.\n */\nexport function assertBundleIntegrity(content: string, verifiedHash: string | null, label: string): void {\n const digest = sha256Hex(content);\n if (!verifiedHash) {\n throw new Error(`[bundle-integrity] refusing to evaluate ${label}: no verified SHA-256 (fail closed).`);\n }\n if (digest !== verifiedHash.toLowerCase()) {\n throw new Error(\n `[bundle-integrity] integrity FAIL at eval for ${label}: content sha256 ${digest.slice(0, 12)}… ≠ verified ${verifiedHash.slice(0, 12)}…. Refusing to evaluate.`,\n );\n }\n}\n","/**\n * Bundle disk-cache adapter. The bundle manager persists downloaded plugin\n * bundles through this interface so the package stays free of Expo/RN\n * storage imports. @ateam-ai-mobile/expo ships a file-system implementation; the\n * default is in-memory (bundles re-download per app session — correct,\n * just slower on cold start).\n */\n\nexport interface BundleCacheEntry {\n localPath: string;\n version: string;\n timestamp: number;\n bundleUrl: string;\n /** SHA-256 (hex, lowercase) of the cached bundle bytes — integrity proof */\n bundleHash?: string;\n /**\n * Tenant whose session downloaded these bytes.\n *\n * A bundle URL is NOT tenant-independent: `/api/ui-plugins/<id>/bundle.js`\n * resolves per-tenant on the server, so the SAME url returns different code\n * for different tenants. On the normal load path the hash gate catches this\n * for free — the expected hash comes from the current tenant's manifest and\n * will not match another tenant's cached bytes. The disk-cache recovery path\n * has no manifest to check against, so it must discriminate by tenant.\n *\n * Absent on entries written before this field existed: unknown ownership, so\n * untrusted. Never read a missing tenant as \"mine\".\n */\n tenant?: string;\n}\n\n/**\n * Which cached entries belong to `tenant` and may therefore be re-evaluated.\n *\n * Lives here, beside the entry type, so \"may I run this cached code\" has ONE\n * owner rather than being re-answered by each caller. `loadIndex()` returns\n * every entry regardless of owner — it has to, since the manager looks entries\n * up by url and rewrites them — so any caller that EVALUATES cached code must\n * come through this function first.\n *\n * Fail-closed on both unknowns. An empty tenant owns nothing. An entry with no\n * recorded tenant has unknown ownership and is never assumed to be the current\n * one: every device already in the field has unstamped entries, so reading\n * \"missing\" as \"mine\" would keep the hole open exactly where it is hardest to\n * see.\n *\n * Compares the tenant field directly — it never builds a composite key, so\n * there is no separator a tenant name could forge across.\n */\nexport function selectOwnedCacheEntries<T extends { tenant?: string }>(\n entries: T[],\n tenant: string | null | undefined,\n): T[] {\n if (!tenant) return [];\n return (entries || []).filter((e) => !!e && e.tenant === tenant);\n}\n\nexport interface BundleStorage {\n loadIndex(): Promise<Record<string, BundleCacheEntry>>;\n saveIndex(index: Record<string, BundleCacheEntry>): Promise<void>;\n /** Read a cached bundle. Returns null when missing/unreadable. */\n readBundle(localPath: string): Promise<string | null>;\n /** Persist a bundle; returns the localPath to record in the index.\n * `key` is a filesystem-safe name derived from the bundle URL+version. */\n writeBundle(key: string, content: string): Promise<string>;\n deleteBundle(localPath: string): Promise<void>;\n /** Wipe everything (index + bundles). */\n clearAll(): Promise<void>;\n}\n\n/** Default storage: keeps bundles for the lifetime of the JS context only. */\nexport class MemoryBundleStorage implements BundleStorage {\n private index: Record<string, BundleCacheEntry> = {};\n private files = new Map<string, string>();\n\n async loadIndex() {\n return this.index;\n }\n async saveIndex(index: Record<string, BundleCacheEntry>) {\n this.index = index;\n }\n async readBundle(localPath: string) {\n return this.files.get(localPath) ?? null;\n }\n async writeBundle(key: string, content: string) {\n const localPath = `memory://${key}`;\n this.files.set(localPath, content);\n return localPath;\n }\n async deleteBundle(localPath: string) {\n this.files.delete(localPath);\n }\n async clearAll() {\n this.index = {};\n this.files.clear();\n }\n}\n\nlet _storage: BundleStorage = new MemoryBundleStorage();\n\n/** Install a persistent storage implementation (call before first plugin load). */\nexport function setBundleStorage(storage: BundleStorage): void {\n _storage = storage;\n}\n\nexport function getBundleStorage(): BundleStorage {\n return _storage;\n}\n","/**\n * Native bridge for React Native plugins.\n * Direct function calls — no postMessage, no serialization.\n *\n * Identity comes from @ateam-ai-mobile/core config (host-owned auth); tool calls go\n * through the same MCP layer as everything else.\n */\nimport { useCallback, useMemo, useRef, useEffect } from 'react';\nimport type { MutableRefObject } from 'react';\nimport {\n connectorCall,\n mcpFetch as mcpFetchApi,\n unwrapMcpResult,\n postCommandResult,\n getTenant,\n getUser,\n pluginCommandEmitter,\n useChatStore,\n} from '@ateam-ai-mobile/core';\nimport type { PluginBridge, PluginContext } from '../sdk/types';\n\ntype CommandListener = (type: string, payload: any) => void;\n\nfunction buildContext(pluginId: string, connectorId?: string): PluginContext {\n const user = getUser();\n return {\n tenant: getTenant(),\n pluginId,\n connectorId,\n user: user ? { id: user.actorId || '', name: user.name || '', roles: user.roles || [] } : undefined,\n };\n}\n\nexport function useNativeBridge(pluginId: string, connectorId?: string, commandBufferRef?: MutableRefObject<any[]>): PluginBridge {\n const initCallbackRef = useRef<((ctx: PluginContext) => void) | null>(null);\n const commandListenersRef = useRef<Set<CommandListener>>(new Set());\n const initializedRef = useRef(false);\n\n const fireInit = useCallback(() => {\n if (initializedRef.current || !initCallbackRef.current) return;\n initCallbackRef.current(buildContext(pluginId, connectorId));\n initializedRef.current = true;\n }, [pluginId, connectorId]);\n\n const onInit = useCallback((cb: (ctx: PluginContext) => void) => {\n initCallbackRef.current = cb;\n setTimeout(fireInit, 0);\n }, [fireInit]);\n\n const mcpCall = useCallback(async (toolOrConnector: string, argsOrTool: any, cIdOrArgs?: any): Promise<any> => {\n // Support BOTH argument orders:\n // (tool, args, connectorId?) — bridge standard\n // (connectorId, tool, args?) — plugin convenience (matches useApi pattern)\n // Detect: if 2nd arg is a string, caller used (connector, tool, args) order\n let tool: string;\n let args: any;\n let cId: string | undefined;\n\n if (typeof argsOrTool === 'string') {\n // (connectorId, tool, args) order\n cId = toolOrConnector;\n tool = argsOrTool;\n args = cIdOrArgs || {};\n } else {\n // Standard (tool, args, connectorId?) order\n tool = toolOrConnector;\n args = argsOrTool;\n cId = typeof cIdOrArgs === 'string' ? cIdOrArgs : undefined;\n }\n\n const targetConnector = cId || connectorId;\n if (!targetConnector) {\n console.warn(`[NativeBridge:${pluginId}] mcpCall failed — no connectorId. tool=${tool}`);\n throw new Error(`[NativeBridge:${pluginId}] mcpCall requires a connectorId`);\n }\n\n try {\n const data = await connectorCall(targetConnector, tool, args);\n\n if (!data.ok && data.error) {\n throw new Error(data.error);\n }\n return unwrapMcpResult(data.result);\n } catch (err) {\n console.warn(`[NativeBridge:${pluginId}] mcpCall failed → connector=${targetConnector} tool=${tool}:`, (err as any)?.message || err);\n throw err;\n }\n }, [pluginId, connectorId]);\n\n const mcpFetch = useCallback(async (body: any): Promise<any> => {\n return mcpFetchApi(body);\n }, []);\n\n const sendCommand = useCallback((type: string, payload: any) => {\n // Handle command results — mirror web PluginHost pattern\n if (type === 'plugin.command.result' && payload?.correlationId) {\n postCommandResult(payload.correlationId, payload.result, payload.error);\n return;\n }\n }, [pluginId]);\n\n const onCommand = useCallback((cb: CommandListener): (() => void) => {\n commandListenersRef.current.add(cb);\n // Flush buffered commands immediately when a listener registers —\n // the buffer may have commands that arrived before the plugin mounted.\n if (commandBufferRef) {\n const buf = commandBufferRef.current;\n const remaining: any[] = [];\n for (const cmd of buf) {\n if (cmd.pluginId === pluginId && cmd.command !== '__focus') {\n try { cb(cmd.command, { ...cmd.args, correlationId: cmd.correlationId }); } catch {}\n } else {\n remaining.push(cmd);\n }\n }\n commandBufferRef.current = remaining;\n }\n // Also drain the emitter's own recent-commands buffer (covers the\n // surface-dispatcher path which has no commandBufferRef).\n for (const cmd of pluginCommandEmitter.drainPluginCommands(pluginId)) {\n try { cb(cmd.command, { ...cmd.args, correlationId: cmd.correlationId }); } catch {}\n }\n return () => {\n commandListenersRef.current.delete(cb);\n };\n }, [pluginId, commandBufferRef]);\n\n // Dispatch live plugin commands to registered listeners\n useEffect(() => {\n const unsub = pluginCommandEmitter.on('plugin-command', (cmd: any) => {\n if (cmd.pluginId !== pluginId) return;\n if (cmd.command === '__focus') return; // Focus-only, no dispatch\n commandListenersRef.current.forEach(fn => {\n try { fn(cmd.command, { ...cmd.args, correlationId: cmd.correlationId }); } catch {}\n });\n });\n return unsub;\n }, [pluginId]);\n\n // Flush buffered commands on mount (commands that arrived before plugin\n // was ready). Two sources, both safe to drain:\n // 1. The parent-passed `commandBufferRef` (legacy overlay path).\n // 2. The emitter's own recent-commands buffer (surface-dispatcher path).\n useEffect(() => {\n const timer = setTimeout(() => {\n const dispatch = (cmd: any) => {\n commandListenersRef.current.forEach(fn => {\n try { fn(cmd.command, { ...cmd.args, correlationId: cmd.correlationId }); } catch {}\n });\n };\n\n if (commandBufferRef) {\n const remaining: any[] = [];\n for (const cmd of commandBufferRef.current) {\n if (cmd.pluginId === pluginId && cmd.command !== '__focus') dispatch(cmd);\n else remaining.push(cmd);\n }\n commandBufferRef.current = remaining;\n }\n\n // Always drain the emitter buffer too — the dispatcher path has no\n // parent buffer, and the legacy path may still have lost commands here\n // if they arrived before the parent's listener registered.\n for (const cmd of pluginCommandEmitter.drainPluginCommands(pluginId)) {\n dispatch(cmd);\n }\n }, 500); // Delay to let plugin register its onCommand listener\n return () => clearTimeout(timer);\n }, [pluginId, commandBufferRef]);\n\n useEffect(() => {\n return () => {\n commandListenersRef.current.clear();\n initializedRef.current = false;\n };\n }, []);\n\n const close = useCallback(() => {\n pluginCommandEmitter.emit('plugin-close', { pluginId });\n }, [pluginId]);\n\n /** Send a chat message into the user's thread (e.g. confirmed \"connect my\n * Gmail\"). Pair with bridge.close() to land the user on chat. */\n const sendMessage = useCallback((text: string) => {\n const t = (text || '').trim();\n if (!t) return;\n try {\n useChatStore.getState().sendMessage(t);\n } catch (err) {\n console.warn('[bridge.sendMessage] failed:', err instanceof Error ? err.message : String(err));\n }\n }, []);\n\n /** Prepare (pre-fill) the chat composer without sending. The host chat\n * screen listens for `prepare-chat-message` and stuffs `text` into its\n * input state. Pair with bridge.close(). */\n const prepareMessage = useCallback((text: string) => {\n const t = (text || '').trim();\n if (!t) return;\n pluginCommandEmitter.emit('prepare-chat-message', { text: t });\n }, []);\n\n // Memoize the bridge object to prevent child re-renders — a new object\n // every render → useApi recreates → fetch effects refire → flicker loop.\n return useMemo(\n () => ({ onInit, mcpCall, mcpFetch, sendCommand, onCommand, close, sendMessage, prepareMessage }),\n [onInit, mcpCall, mcpFetch, sendCommand, onCommand, close, sendMessage, prepareMessage],\n );\n}\n\n/**\n * Non-hook version for service plugins (no React lifecycle).\n */\nexport function createNativeBridge(pluginId: string, connectorId?: string): PluginBridge {\n const commandListeners = new Set<CommandListener>();\n\n return {\n onInit(cb) {\n setTimeout(() => {\n cb(buildContext(pluginId, connectorId));\n }, 0);\n },\n\n async mcpCall(tool: string, args: any, cId?: string) {\n const targetConnector = cId || connectorId;\n if (!targetConnector) {\n throw new Error(`[NativeBridge:${pluginId}] mcpCall requires a connectorId`);\n }\n const data = await connectorCall(targetConnector, tool, args);\n if (!data.ok && data.error) throw new Error(data.error);\n return unwrapMcpResult(data.result);\n },\n\n async mcpFetch(body: any) {\n return mcpFetchApi(body);\n },\n\n sendCommand(_type: string, _payload: any) {\n },\n\n onCommand(cb: CommandListener) {\n commandListeners.add(cb);\n return () => { commandListeners.delete(cb); };\n },\n\n close() {\n pluginCommandEmitter.emit('plugin-close', { pluginId });\n },\n\n sendMessage(text: string) {\n const t = (text || '').trim();\n if (!t) return;\n try {\n useChatStore.getState().sendMessage(t);\n } catch (err) {\n console.warn('[bridge.sendMessage] failed:', err instanceof Error ? err.message : String(err));\n }\n },\n\n prepareMessage(text: string) {\n const t = (text || '').trim();\n if (!t) return;\n pluginCommandEmitter.emit('prepare-chat-message', { text: t });\n },\n } as PluginBridge;\n}\n","/**\n * Host DI for the SEMANTIC layer — the `props.deviceState` counterpart of\n * `setPluginNativeProvider`.\n *\n * Kept in its own file rather than added to host.ts, for the same reason the\n * two layers have separate namespaces: the moment they share a module, the\n * next person adds a domain to `PluginNative` or a capability to\n * `stateDomains` and the boundary starts to blur.\n *\n * THE GATE IS NOT THE MECHANICAL ONE. `gatePluginNative` replaces an\n * undeclared capability with a proxy whose methods warn and return `undefined`\n * — so `await native.location.getCurrent()` resolves to `undefined`, and\n * `pos?.latitude` is `undefined`, which flows into a model answer as a\n * confident nothing. A silent undefined is a fabrication vector.\n *\n * Here, an undeclared domain returns a real snapshot in which everything is\n * explicitly `unknown` / `null`, with `freshness.state = 'unknown'`. The\n * plugin gets a well-formed answer that says \"I know nothing\", which no\n * reasonable code path can mistake for data.\n */\nimport type { DeviceBridgeDomain, DeviceState, StateQuality } from './sdk/device-state';\n\n// The `unknown` freshness/confidence shape is the canonical `neverObserved()` +\n// `{ level: 'unknown' }` (see sdk/device-state.ts). It is inlined here rather\n// than imported because this module is imported directly by node --test and the\n// harness resolves only the explicit entry, not a nested extensionless value\n// import. The golden snapshot test pins this shape === neverObserved()'s.\nconst UNKNOWN_QUALITY: StateQuality = {\n freshness: { state: 'unknown', observedAt: null, ageMs: null },\n confidence: { level: 'unknown' },\n};\n\n/**\n * The empty snapshot for a domain the plugin did not declare.\n *\n * Deliberately built per domain rather than one shared `{}`: each snapshot has\n * required fields, and a caller reading `snapshot.position` must get `null`,\n * not a TypeError. Domains not listed fall through to `{ quality }`, which is\n * the one field every snapshot in the design shares.\n */\nfunction deniedSnapshot(domain: DeviceBridgeDomain): any {\n const base = { quality: UNKNOWN_QUALITY };\n switch (domain) {\n case 'spatial':\n return {\n ...base,\n position: null,\n movement: { speedMps: null, bearingDeg: null, distanceRecentM: null, state: 'unknown' },\n orientation: { headingDeg: null },\n recentPath: [],\n };\n case 'visual':\n return {\n ...base,\n camera: { available: false, active: false, facing: 'unknown' },\n latest: null,\n recentTimeline: { windowMs: 0, frames: [] },\n };\n case 'deviceContext':\n return {\n ...base,\n power: { batteryLevel: null, charging: null, lowPowerMode: null },\n thermal: { state: 'unknown' },\n resources: { memoryPressure: 'unknown', storagePressure: 'unknown' },\n };\n case 'connectivity':\n return {\n ...base,\n reachability: 'unknown',\n transport: 'unknown',\n qualityClass: 'unknown',\n stability: 'unknown',\n latencyMs: null,\n };\n case 'interaction':\n return {\n ...base,\n lifecycle: { appState: 'unknown', screenOn: null },\n audio: { captureActive: null, playbackActive: null, route: 'unknown', interruption: 'unknown' },\n };\n case 'activity':\n return {\n ...base,\n // `confidence` is REQUIRED on both blocks in the freeze, precisely\n // because an inferred activity must never be handed over without\n // saying how sure the inference is. An empty snapshot is the least\n // sure of all.\n human: { state: 'unknown', since: null, confidence: { level: 'unknown' } },\n devicePose: { placement: 'unknown', orientation: 'unknown', confidence: { level: 'unknown' } },\n recentTransitions: [],\n };\n case 'environment':\n return {\n ...base,\n lighting: { level: 'unknown', lux: null },\n acoustics: { level: 'unknown', approximateDb: null },\n // 'unknown' rather than 'uncertain': uncertain means we looked and\n // could not decide, and nothing looked at all here.\n enclosure: { state: 'unknown' },\n proximity: { distanceClass: 'unknown' },\n nearbySignals: { bleAvailable: false, beaconCount: null, uwbAvailable: false },\n };\n case 'capability': {\n // Every axis unknown — and note this is NOT the same as `denied`.\n // \"I could not check\" and \"the user said no\" lead to different things\n // being said to the user, which is why the freeze keeps them apart.\n const unknownStatus = { support: 'unknown', permission: 'unknown', availability: 'unknown' };\n return {\n ...base,\n camera: unknownStatus,\n microphone: unknownStatus,\n location: { ...unknownStatus, precision: 'unknown', backgroundPermission: 'unknown' },\n motion: unknownStatus,\n bluetooth: unknownStatus,\n uwb: unknownStatus,\n nfc: unknownStatus,\n notifications: unknownStatus,\n health: unknownStatus,\n backgroundExecution: unknownStatus,\n };\n }\n default:\n return base;\n }\n}\n\n/**\n * A domain the plugin may not use, or that this build does not implement.\n *\n * Reads answer with explicit unknowns. Anything that ACTS — start, stop,\n * subscribe — throws, because there is no honest \"unknown\" for an action: a\n * silent no-op start would leave the caller believing a session is open, and a\n * subscription that never fires reads as \"nothing has changed\".\n */\nfunction deniedDomain(domain: DeviceBridgeDomain, why: string): any {\n return {\n async getSnapshot() { return deniedSnapshot(domain); },\n async start() { throw denial(domain, why); },\n async stop() { throw denial(domain, why); },\n subscribe() { throw denial(domain, why); },\n };\n}\n\nfunction denial(domain: DeviceBridgeDomain, why: string): Error {\n const err: any = new Error(`deviceState.${domain}: ${why}`);\n // Frozen vocabulary. A manifest gate IS a policy, so a manifest denial is\n // policyRestricted — no new error vocabulary needed.\n err.code = 'RESTRICTED';\n err.domain = domain;\n return err;\n}\n\nconst ALL_DOMAINS: DeviceBridgeDomain[] = [\n 'spatial', 'visual', 'activity', 'deviceContext',\n 'connectivity', 'capability', 'environment', 'interaction',\n];\n\nlet _provider: Partial<DeviceState> = {};\n\n/** Host DI: the app supplies the engines it has. Called once at startup. */\nexport function setDeviceStateProvider(state: Partial<DeviceState>): void {\n _provider = state || {};\n}\n\n/**\n * The `deviceState` a plugin receives, gated by what it declared.\n *\n * Every domain is always present — a plugin can call any of the eight without\n * an existence check. What differs is whether it answers with data, or with\n * an explicit \"I know nothing\" and a reason.\n */\nexport function gateDeviceState(declared?: readonly DeviceBridgeDomain[]): DeviceState {\n const allowed = new Set(declared || []);\n const out: any = {};\n\n for (const domain of ALL_DOMAINS) {\n if (!allowed.has(domain)) {\n out[domain] = deniedDomain(\n domain,\n `not declared in this plugin's stateDomains. Add '${domain}' to use it.`,\n );\n continue;\n }\n const engine = (_provider as any)[domain];\n out[domain] = engine ?? deniedDomain(\n domain,\n 'no engine in this build — the native side does not exist yet. See docs/DEVICE_API_STATUS.md.',\n );\n }\n\n return out as DeviceState;\n}\n\n/** Which domains this build can actually answer — for diagnostics. */\nexport function implementedStateDomains(): DeviceBridgeDomain[] {\n return ALL_DOMAINS.filter(d => !!(_provider as any)[d]);\n}\n","/**\n * Device tool registry.\n *\n * A solution's RN plugin may ship a `tools/` section alongside (or instead of)\n * its UI. Those tools are registered HERE, when the bundle is evaluated — not\n * when a screen mounts — so a caller can invoke one with nothing of the plugin\n * on screen.\n *\n * Lookup is by the tool's own domain name (e.g. \"guide.observe\"). Callers never\n * route on a name prefix: whether a tool runs locally is declared by the server\n * in the session payload, and resolved against this registry. The full LOCAL\n * reasoning path (discovery → call → result, and its independence from\n * relay/MCP) is documented in docs/architecture/LOCAL_REASONING_PATH.md (R13).\n */\nimport { createNativeBridge } from '../bridge/native';\nimport { getPluginNative, gatePluginNative } from '../host';\nimport { gateDeviceState } from '../deviceStateHost';\nimport type { DeviceToolContext, DeviceToolDefinition, NativeCapabilities } from '../sdk/types';\nimport type { DeviceBridgeDomain } from '../sdk/device-state';\n\nexport interface DeviceToolSummary {\n name: string;\n pluginId: string;\n description?: string;\n input_schema?: Record<string, unknown>;\n}\n\nexport type DeviceToolOutcome =\n | { ok: true; result: any }\n | { ok: false; error: string; reason: 'not_found' | 'no_context' | 'timeout' | 'failed' };\n\ninterface Entry {\n pluginId: string;\n tool: DeviceToolDefinition;\n capabilities?: NativeCapabilities;\n /** L3 DeviceState domains this plugin declared — gates ctx.deviceState. */\n stateDomains?: DeviceBridgeDomain[];\n}\n\n/** toolName → entry. One name, one implementation. */\nconst registry = new Map<string, Entry>();\n\n/** Optional host override; the SDK supplies a working default (see below). */\nlet contextProvider:\n | ((pluginId: string, capabilities?: NativeCapabilities, stateDomains?: DeviceBridgeDomain[]) => DeviceToolContext)\n | null = null;\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\n/**\n * Override how a device tool reaches the Device Bridge. Rarely needed — the\n * default below builds the same bridge/native pair a plugin gets when it\n * renders, gated by the capabilities the plugin declared.\n */\nexport function setDeviceToolContextProvider(\n fn: (pluginId: string, capabilities?: NativeCapabilities, stateDomains?: DeviceBridgeDomain[]) => DeviceToolContext,\n): void {\n contextProvider = fn;\n}\n\n/**\n * Default context: the plugin's own bridge + a capability-gated Device Bridge +\n * the L3 DeviceState gated to the domains the plugin declared. All three are the\n * SAME gated objects the plugin gets when it renders — a tool reaches nothing a\n * UI plugin couldn't.\n */\nfunction defaultContext(\n pluginId: string,\n capabilities?: NativeCapabilities,\n stateDomains?: DeviceBridgeDomain[],\n): DeviceToolContext {\n return {\n bridge: createNativeBridge(pluginId),\n native: gatePluginNative(getPluginNative(), capabilities, pluginId),\n deviceState: gateDeviceState(stateDomains),\n };\n}\n\n/**\n * Register a plugin's tools. Called from the bundle pipeline at load time.\n *\n * A name already taken by ANOTHER plugin is refused — a bundle loaded later\n * must not be able to take over \"guide.observe\" from the plugin that owns it.\n * Re-registering the same plugin (bundle reload) replaces its own entries.\n */\nexport function registerDeviceTools(\n pluginId: string,\n tools: DeviceToolDefinition[],\n capabilities?: NativeCapabilities,\n stateDomains?: DeviceBridgeDomain[],\n): string[] {\n const accepted: string[] = [];\n\n for (const tool of tools || []) {\n if (!tool || typeof tool.name !== 'string' || typeof tool.run !== 'function') {\n console.warn(`[deviceTools] ${pluginId}: skipping malformed tool entry`);\n continue;\n }\n const existing = registry.get(tool.name);\n if (existing && existing.pluginId !== pluginId) {\n console.warn(\n `[deviceTools] ${pluginId}: \"${tool.name}\" already registered by ${existing.pluginId} — refusing to override`,\n );\n continue;\n }\n registry.set(tool.name, { pluginId, tool, capabilities, stateDomains });\n accepted.push(tool.name);\n }\n\n if (accepted.length > 0) {\n console.log(`[deviceTools] ${pluginId} registered: ${accepted.join(', ')}`);\n }\n return accepted;\n}\n\n/** Drop every tool owned by a plugin (bundle eviction / plugin revoked). */\nexport function unregisterDeviceTools(pluginId: string): void {\n for (const [name, entry] of registry.entries()) {\n if (entry.pluginId === pluginId) registry.delete(name);\n }\n}\n\nexport function hasDeviceTool(name: string): boolean {\n return registry.has(name);\n}\n\nexport function listDeviceTools(): DeviceToolSummary[] {\n return Array.from(registry.entries()).map(([name, { pluginId, tool }]) => ({\n name,\n pluginId,\n description: tool.description,\n input_schema: tool.input_schema,\n }));\n}\n\n/**\n * Invoke a device tool. Never throws — every failure comes back as a typed\n * outcome, because the caller is usually a reasoning loop that has to say\n * something useful out loud rather than swallow an exception.\n */\nexport async function callDeviceTool(\n name: string,\n args: any = {},\n opts: { timeoutMs?: number; signal?: AbortSignal } = {},\n): Promise<DeviceToolOutcome> {\n const entry = registry.get(name);\n if (!entry) {\n return { ok: false, reason: 'not_found', error: `No device tool registered as \"${name}\"` };\n }\n const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n try {\n const build = contextProvider || defaultContext;\n const ctx: DeviceToolContext = {\n ...build(entry.pluginId, entry.capabilities, entry.stateDomains),\n signal: opts.signal,\n };\n\n const result = await Promise.race([\n Promise.resolve(entry.tool.run(args, ctx)),\n new Promise<never>((_, reject) => {\n timer = setTimeout(\n () => reject(new Error(`Device tool \"${name}\" timed out after ${timeoutMs}ms`)),\n timeoutMs,\n );\n }),\n ]);\n\n return { ok: true, result };\n } catch (err: any) {\n const message = err?.message || String(err);\n const timedOut = message.includes('timed out after');\n return { ok: false, reason: timedOut ? 'timeout' : 'failed', error: message };\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n\n/** Test/host reset. */\nexport function clearDeviceTools(): void {\n registry.clear();\n}\n","/**\n * Device tool loading.\n *\n * A device tool is only callable once its plugin bundle has been evaluated —\n * that is when the tools register (see `./registry`). Nothing else in the app\n * guarantees that: bundle prewarm runs on the home screen and is best-effort, so\n * a user who goes straight into a voice call can reach a tool the phone has\n * never loaded. The model then hears \"no such tool\" and improvises, which looks\n * exactly like a broken feature.\n *\n * So the voice path calls `ensureDeviceToolsLoaded()` before connecting.\n */\nimport { listPlugins, getPlugin, getNativeBundleUrl, getNativeBundleHash } from '../api/plugins';\nimport { bundleManager } from '../bundles/bundleManager';\nimport { listDeviceTools } from './registry';\nimport { getBundleStorage, selectOwnedCacheEntries } from '../bundles/storage';\nimport { getTenant } from '@ateam-ai-mobile/core';\n\nlet inflight: Promise<string[]> | null = null;\nlet loadedOnce = false;\n\n/**\n * Load every plugin that declares `capabilities.device_tools`, so its tools are\n * registered and callable. Best-effort and idempotent: safe to call on every\n * call start. Returns the tool names currently registered.\n *\n * Pass `force` after a plugin catalog change (a newly deployed connector).\n */\nexport async function ensureDeviceToolsLoaded({ force = false } = {}): Promise<string[]> {\n if (loadedOnce && !force) return listDeviceTools().map(t => t.name);\n if (inflight) return inflight;\n\n inflight = (async () => {\n try {\n const summaries = await listPlugins();\n\n // The list response is slim, so the manifest is the authority on whether a\n // plugin declares device tools. Fetched in parallel — a cold connector\n // that answers slowly must not hold up a call.\n const manifests = await Promise.all(\n (summaries || []).map(s =>\n getPlugin((s as any).id).catch(() => null),\n ),\n );\n\n const targets = manifests.filter((m: any) => {\n const declared = m?.capabilities?.device_tools;\n return Array.isArray(declared) && declared.length > 0;\n });\n\n if (targets.length === 0) {\n // The catalog can go blind: a solution connector is lazy, and while it\n // is not running its plugins are absent from the list entirely. That is\n // a fact about a server process, not about this phone — the bundle we\n // already downloaded still has the tools in it.\n //\n // So fall back to what is on disk. Re-evaluating a cached bundle\n // re-registers whatever it declares, and a bundle with no tools is a\n // no-op, so this is safe to do blind.\n const recovered = await loadFromDiskCache();\n if (recovered.length > 0) {\n console.log(`[deviceTools] catalog listed none — recovered from cache: ${recovered.join(', ')}`);\n return recovered;\n }\n // Do NOT latch: \"nothing yet\" is usually just \"not yet\".\n console.log('[deviceTools] no device tools available yet — will look again next call');\n return [];\n }\n\n await Promise.all(\n targets.map(async (m: any) => {\n const bundleUrl = getNativeBundleUrl(m);\n if (!bundleUrl) {\n console.warn(`[deviceTools] ${m.id} declares device_tools but has no native bundle`);\n return;\n }\n try {\n await bundleManager.loadTools(\n m.id,\n bundleUrl,\n m.version || '1.0.0',\n getNativeBundleHash(m) || undefined,\n );\n } catch (err: any) {\n console.warn(`[deviceTools] ${m.id} failed to load:`, err?.message || String(err));\n }\n }),\n );\n\n const names = listDeviceTools().map(t => t.name);\n // Only latch on success. An empty result is a cold read, not a fact —\n // same reasoning as the server-side discovery cache.\n loadedOnce = names.length > 0;\n console.log(`[deviceTools] ready: ${names.length > 0 ? names.join(', ') : '(none registered — will retry next call)'}`);\n return names;\n } finally {\n inflight = null;\n }\n })();\n\n return inflight;\n}\n\n/**\n * Re-evaluate the CURRENT TENANT'S bundles already cached on disk.\n *\n * Used when the plugin catalog comes back empty — which happens whenever the\n * owning connector is asleep. This is a local read, not a download.\n *\n * TENANT SCOPING IS LOAD-BEARING, NOT DEFENCE IN DEPTH.\n *\n * Every other load path is gated by the manifest hash: the expected hash comes\n * from the current tenant's server, so another tenant's cached bytes simply\n * fail to match and are re-downloaded. This path has no manifest — that is the\n * whole reason it exists — so it passes each entry's OWN stored hash as the\n * expected hash. That check compares an entry to itself and can never fail. It\n * is an integrity check against disk corruption, and it is not, and cannot be,\n * an authorisation check.\n *\n * Without the tenant filter below this loop re-evaluated EVERY cached bundle,\n * so a plugin cached during a session on tenant A registered its device tools\n * into a live session on tenant B, and subsequent tool calls ran tenant-A code\n * holding tenant-B credentials. No id collision was required: bundle urls are\n * identical across tenants and resolve per-tenant on the server, and the code\n * cache deliberately survives logout.\n *\n * An entry with no recorded tenant predates the stamp. Its owner is unknown,\n * which means untrusted — skip it and let the normal catalog path re-download\n * it under a real hash gate.\n */\nasync function loadFromDiskCache(): Promise<string[]> {\n try {\n const index = await getBundleStorage().loadIndex();\n const entries = Object.values(index || {});\n if (entries.length === 0) return [];\n\n const tenant = getTenant();\n if (!tenant) {\n // No active tenant: nothing can be proven to be ours.\n console.warn('[deviceTools] disk-cache recovery skipped — no active tenant');\n return [];\n }\n const mine = selectOwnedCacheEntries(entries, tenant);\n const skipped = entries.length - mine.length;\n if (skipped > 0) {\n console.log(`[deviceTools] disk-cache recovery: ${mine.length} for \"${tenant}\", skipped ${skipped} not owned by it`);\n }\n if (mine.length === 0) return [];\n\n await Promise.all(mine.map(async (e: any) => {\n try {\n await bundleManager.loadTools('cache:' + e.bundleUrl, e.bundleUrl, e.version, e.bundleHash);\n } catch {\n // A cached bundle that no longer loads is not worth failing a call over.\n }\n }));\n return listDeviceTools().map(t => t.name);\n } catch (err: any) {\n console.warn('[deviceTools] disk-cache recovery failed:', err?.message || String(err));\n return [];\n }\n}\n\n/** Forget that we loaded, so the next call re-reads the catalog. */\nexport function resetDeviceToolLoader(): void {\n loadedOnce = false;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAyFvB,SAAS,eAAe,UAAmC;AAChE,QAAM,OAAO,SAAS,QAAQ;AAC9B,SAAO,SAAS,kBAAkB,SAAS;AAC7C;AAKO,SAAS,qBAAqB,UAAyC;AAC5E,MAAI,SAAS,QAAQ,SAAS,eAAgB,QAAO,SAAS,OAAO;AACrE,MAAI,SAAS,QAAQ,SAAS,WAAY,QAAO,SAAS,OAAO,aAAa;AAC9E,SAAO;AACT;AAKO,SAAS,mBAAmB,UAAyC;AAE1E,QAAM,SAAU,SAAiB;AACjC,MAAI,OAAQ,QAAO;AAEnB,QAAM,SAAS,SAAS;AACxB,MAAI,OAAO,SAAS,eAAgB,QAAO,OAAO,aAAa;AAC/D,MAAI,OAAO,SAAS,WAAY,QAAO,OAAO,aAAa,aAAa;AAExE,SAAO;AACT;AAOO,SAAS,oBAAoB,UAAyC;AAC3E,QAAM,SAAU,SAAiB;AACjC,MAAI,OAAQ,QAAO;AACnB,QAAM,SAAS,SAAS;AACxB,MAAI,OAAO,SAAS,eAAgB,QAAQ,OAAe,cAAc;AACzE,MAAI,OAAO,SAAS,WAAY,QAAO,OAAO,aAAa,cAAc;AACzE,SAAO;AACT;AAKO,SAAS,gBAAgB,UAAmC;AACjE,SAAO,SAAS,QAAQ,SAAS,YAAY,SAAS,QAAQ,SAAS;AACzE;AAOA,eAAsB,cAAwC;AAC5D,QAAM,MAAM,MAAM,SAKf,QAAQ;AAAA,IACT,QAAQ;AAAA,IACR,MAAM,KAAK,UAAU;AAAA,MACnB,SAAS;AAAA,MACT,IAAI,KAAK,IAAI;AAAA,MACb,QAAQ;AAAA,MACR,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,WAAW,CAAC;AAAA,MACd;AAAA,IACF,C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AAK,MAAM,SAAS,MAAM,cAAc,OAAO,kBAAkB;AAAA,IACrH;AACA,QAAI,KAAK,WAAW,EAAG,QAAO,CAAC;AAE/B,UAAM,QAAQ,IAAI,KAAK,IAAI,OAAO,MAAW;AAC3C,UAAI;AACF,cAAM,cAAc,UAAU,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU;AAAA,MAC5F,QAAQ;AAAA,MAER;AAAA,IACF,CAAC,CAAC;AACF,WAAO,gBAAgB,EAAE,IAAI,OAAK,EAAE,IAAI;AAAA,EAC1C,SAAS,KAAU;AACjB,YAAQ,KAAK,6CAA6C,KAAK,WAAW,OAAO,GAAG,CAAC;AACrF,WAAO,CAAC;AAAA,EACV;AACF;AAGO,SAAS,wBAA8B;AAC5C,eAAa;AACf;","names":["React","useEffect","useCallback","useMemo","useRef","getTenant","View","Text","Pressable","TextInput","ActivityIndicator","StyleSheet","unavailable","useMemo","useEffect","View","Text","Pressable","StyleSheet","Animated","Platform","Svg","ada","View","StyleSheet","Animated","jsx","styles","jsx","jsxs","Platform","Animated","useEffect","styles","Pressable","StyleSheet","View","Text","Svg","ada","View","Text","Pressable","StyleSheet","Platform","ada","borderRadius","jsx","jsxs","fontFam","Platform","Pressable","styles","View","Text","StyleSheet","useEffect","useRef","View","Text","Pressable","StyleSheet","Animated","Platform","Svg","Path","ada","jsx","jsxs","fontFam","styles","cleanup","useEffect","jsx","jsxs","useEffect","useMemo","useRef","useEffect","pluginCommandEmitter","React","useEffect","useCallback","useMemo","useRef","getTenant","getTenant"]}
|