@ateam-ai-mobile/plugin-runtime 0.1.0 → 0.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sdk/index.ts","../src/sdk/registration.ts","../src/sdk/primitives.ts","../src/sdk/components.ts","../src/sdk/usePluginTheme.ts","../src/sdk/useApi.ts","../src/host.ts","../src/bundles/bundleManager.ts","../src/utils/sha256.ts","../src/bundles/storage.ts","../src/bridge/native.ts","../src/hooks/usePlugin.ts","../src/hooks/useRemotePlugins.ts","../src/api/plugins.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"],"sourcesContent":["/**\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 } from './registration';\nimport { register, registerService } from './registration';\nexport const PluginSDK = { register, registerService } 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 SharingAPI,\n ScannerAPI,\n NfcAPI,\n BiometricsAPI,\n BiometricsAPIv2,\n NativeCapabilities,\n PluginHooks,\n PluginManifest,\n RenderMode,\n RegisteredPlugin,\n RegisteredUIPlugin,\n RegisteredServicePlugin,\n} from './types';\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\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 NativeCapabilities,\n PluginHooks,\n PluginProps,\n RegisteredUIPlugin,\n RegisteredServicePlugin,\n} from './types';\n\n/**\n * Register a UI or hybrid plugin (has a visual component).\n */\nexport function register(\n id: string,\n config: {\n type?: 'ui' | 'hybrid';\n capabilities?: NativeCapabilities;\n Component: React.FC<PluginProps>;\n },\n): RegisteredUIPlugin {\n return {\n id,\n type: config.type || 'ui',\n capabilities: config.capabilities,\n Component: config.Component,\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 * 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 * 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 { 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;\nlet _isDark = false;\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 isDark = useSyncExternalStore(subscribe, () => _isDark);\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 * 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, 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: () => {} },\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};\n\nlet _pluginNative: PluginNative = noopNative;\n\n/** Install the device-capabilities implementation plugins receive as\n * `props.native`. 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// ── 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 * 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 } from '@ateam-ai-mobile/core';\nimport * as PluginSDKModule from '../sdk';\nimport { resolveBundleModule } from '../host';\nimport { sha256Hex } from '../utils/sha256';\nimport { getBundleStorage, type BundleCacheEntry } from './storage';\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()\nconst PluginSDKShim = Object.freeze({\n ...PluginSDKModule,\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\nclass BundleManager {\n /** In-memory module cache: bundleUrl → evaluated module.exports */\n private modules = new Map<string, any>();\n\n /** In-flight download deduplication: bundleUrl → Promise */\n private inflight = new Map<string, Promise<any>>();\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 // 1. In-memory cache — instant\n const cached = this.getComponentFromMemory(pluginId, bundleUrl);\n if (cached) return cached;\n\n // 2. Deduplicate in-flight downloads for same bundleUrl\n let modulePromise = this.inflight.get(bundleUrl);\n if (!modulePromise) {\n modulePromise = this.loadModule(bundleUrl, version, expectedHash);\n this.inflight.set(bundleUrl, modulePromise);\n // Swallow rejection on the cleanup chain — the original `await` below\n // still surfaces the error to the caller.\n modulePromise.catch(() => {}).finally(() => this.inflight.delete(bundleUrl));\n }\n\n await modulePromise;\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 * 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 this.modules.clear();\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 // ── Private: module loading pipeline ────────────────────────\n\n private async loadModule(bundleUrl: string, version: string, expectedHash?: string): Promise<void> {\n // Already in memory?\n if (this.modules.has(bundleUrl)) return;\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.\n let content: string | null = null;\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) 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 // Save with verified hash\n const safeName = bundleUrl.replace(/[^a-zA-Z0-9]/g, '_').slice(-80);\n try {\n const localPath = await storage.writeBundle(`${safeName}@${version}.js`, content);\n index[bundleUrl] = {\n localPath,\n version,\n timestamp: Date.now(),\n bundleUrl,\n bundleHash: downloaded.sha256,\n } satisfies BundleCacheEntry;\n await storage.saveIndex(index);\n } catch (err) {\n console.warn('[BundleManager] Cache write error:', err);\n }\n }\n\n // Evaluate\n const mod = this.evaluate(content, bundleUrl);\n this.modules.set(bundleUrl, mod);\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): any {\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 * 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 * 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\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: [] } : 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 * usePlugin — single hook for loading any plugin.\n *\n * Simple async load → done pattern over the global BundleManager singleton\n * (deduplication + caching) and the host's native plugin registry.\n *\n * Usage:\n * const { plugin, loading, error } = usePlugin(pluginId, manifest);\n * if (loading) return <Spinner />;\n * if (error) return <Error message={error} />;\n * return <plugin.Component bridge={bridge} native={native} theme={theme} context={context} />;\n */\nimport { useState, useEffect } from 'react';\nimport { bundleManager } from '../bundles/bundleManager';\nimport { nativePluginRegistry } from '../host';\nimport type { RegisteredUIPlugin } from '../sdk/types';\n\ninterface PluginManifestLike {\n version?: string;\n name?: string;\n render?: any;\n _connectorId?: string;\n}\n\ninterface UsePluginResult {\n plugin: RegisteredUIPlugin | null;\n loading: boolean;\n error: string | null;\n bundleMissing: boolean;\n}\n\n/**\n * Compute the bundle URL.\n *\n * **Policy:** bundle URLs are ALWAYS derived from the pluginId via the\n * canonical platform route /api/ui-plugins/{pluginId}/bundle.js.\n * Connector-supplied bundleUrl fields are IGNORED — the Builder strips them\n * at introspection time, but we treat any survivors as bugs and ignore them\n * here too (defense in depth vs \"hand-coded URL with bad encoding causes\n * silent iframe fallback\" bugs).\n */\ntype BundleUrlSource = 'derived-default' | 'ignored-explicit' | 'none';\nfunction extractBundleUrl(pluginId: string, manifest: PluginManifestLike): { url: string | null; source: BundleUrlSource; ignored?: string } {\n const render = manifest.render;\n if (!render || typeof render !== 'object') return { url: null, source: 'none' };\n\n // Detect (and refuse) any explicit bundle URL the connector tried to inject.\n const injected =\n (manifest as any).bundleUrl ||\n (render as any).bundleUrl ||\n render.reactNative?.bundleUrl ||\n null;\n\n // Mobile decides native vs web INDEPENDENT of render.mode. The server's\n // cp.getContextPlugin flattens mode to \"iframe\" whenever an iframeUrl is\n // available (for web-frontend compatibility) — even when a reactNative\n // component is also declared. So we derive the bundle URL whenever a\n // reactNative component is present, regardless of what `mode` says.\n const hasNativeComponent = !!(render.reactNative?.component || render.component);\n if (hasNativeComponent) {\n return {\n url: `/api/ui-plugins/${encodeURIComponent(pluginId)}/bundle.js`,\n source: injected ? 'ignored-explicit' : 'derived-default',\n ...(injected && { ignored: injected }),\n };\n }\n\n return { url: null, source: 'none' };\n}\n\n/**\n * Extract the SHA-256 integrity hash from the manifest (server-provided).\n * BundleManager refuses to evaluate a downloaded bundle whose bytes don't\n * hash to this value — defense vs MITM/CDN tampering.\n */\nfunction extractBundleHash(manifest: PluginManifestLike): string | undefined {\n if ((manifest as any).bundleHash) return (manifest as any).bundleHash;\n const render = manifest.render;\n if (!render || typeof render !== 'object') return undefined;\n if (render.bundleHash) return render.bundleHash;\n if (render.reactNative?.bundleHash) return render.reactNative.bundleHash;\n return undefined;\n}\n\n/**\n * Extract component name from manifest render field.\n */\nfunction extractComponentId(manifest: PluginManifestLike): string | null {\n const render = manifest.render;\n if (!render || typeof render !== 'object') return null;\n return render.component || render.reactNative?.component || null;\n}\n\nexport function usePlugin(pluginId: string, manifest: PluginManifestLike): UsePluginResult {\n const [plugin, setPlugin] = useState<RegisteredUIPlugin | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [bundleMissing, setBundleMissing] = useState(false);\n\n const version = manifest.version || '1.0.0';\n const { url: bundleUrl, ignored: ignoredUrl } = extractBundleUrl(pluginId, manifest);\n const bundleHash = extractBundleHash(manifest);\n const componentId = extractComponentId(manifest);\n const lookupId = componentId || pluginId;\n\n if (ignoredUrl) {\n console.warn(`[usePlugin] ${pluginId}: IGNORED connector-injected bundleUrl=\"${ignoredUrl}\". The host derives bundle URLs from pluginId via the canonical route.`);\n }\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n // Path 1: Local registry (host-bundled / dev plugins)\n if (nativePluginRegistry.has(lookupId)) {\n const registered = await nativePluginRegistry.get(lookupId);\n if (cancelled) return;\n\n if (!registered) {\n throw new Error(`Local plugin not found: ${lookupId}`);\n }\n if (registered.type === 'service') {\n throw new Error(`Plugin ${lookupId} is a service plugin and cannot be rendered`);\n }\n\n setPlugin(registered as RegisteredUIPlugin);\n setLoading(false);\n return;\n }\n\n // Path 2: Remote bundle (via global BundleManager)\n if (bundleUrl) {\n try {\n const component = await bundleManager.load(pluginId, bundleUrl, version, bundleHash);\n if (cancelled) return;\n setPlugin(component);\n setLoading(false);\n return;\n } catch (bundleErr) {\n const msg = bundleErr instanceof Error ? bundleErr.message : String(bundleErr);\n // warn (not error) — this is a handled path: we fall back to WebView.\n console.warn(`[usePlugin] ${pluginId}: Bundle load failed, falling back to WebView:`, msg);\n // RN bundle failed — connector declared a component but didn't\n // ship a usable bundle (404, eval error, integrity fail, etc).\n // Mark \"bundle missing\" so the parent renderer can fall back to\n // the WebView/iframe when the manifest also has an iframeUrl.\n if (!cancelled) {\n setBundleMissing(true);\n setLoading(false);\n }\n return;\n }\n }\n\n // No native source available. If the manifest also has an iframeUrl,\n // mark \"bundle missing\" so the parent falls back to the WebView.\n // Only throw when there's truly nothing renderable.\n const iframeUrl = manifest?.render?.iframeUrl\n || (manifest?.render?.mode === 'adaptive' && manifest?.render?.iframe?.iframeUrl);\n if (iframeUrl) {\n if (!cancelled) {\n setBundleMissing(true);\n setLoading(false);\n }\n return;\n }\n throw new Error(\n `Plugin \"${manifest.name || pluginId}\" has no bundle URL and is not in the local registry. ` +\n `Check that the solution definition includes a valid render.reactNative.bundleUrl.`\n );\n } catch (err) {\n if (cancelled) return;\n const msg = err instanceof Error ? err.message : String(err);\n console.error(`[usePlugin] Failed to load ${pluginId}:`, msg);\n setError(msg);\n setLoading(false);\n }\n })();\n\n return () => { cancelled = true; };\n }, [pluginId, lookupId, bundleUrl, bundleHash, version]);\n\n return { plugin, loading, error, bundleMissing };\n}\n","import { useEffect, useState, useCallback } from 'react';\nimport { apiFetch } from '@ateam-ai-mobile/core';\nimport type { PluginManifest } from '../sdk/types';\n\nexport interface RemotePlugin {\n id: string;\n name: string;\n version: string;\n manifest: PluginManifest;\n source: 'remote' | 'local'; // Where this plugin came from\n}\n\ninterface UseRemotePluginsResult {\n plugins: RemotePlugin[];\n loading: boolean;\n error: string | null;\n refreshing: boolean;\n refresh: () => Promise<void>;\n}\n\n/**\n * Fetches available UI plugins from A-Team Core for the current solution.\n * Uses apiFetch which auto-injects JWT + tenant headers.\n */\nexport function useRemotePlugins(solutionId?: string): UseRemotePluginsResult {\n const [plugins, setPlugins] = useState<RemotePlugin[]>([]);\n const [loading, setLoading] = useState(true);\n const [refreshing, setRefreshing] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const fetchRemotePlugins = useCallback(async () => {\n try {\n setError(null);\n\n const targetSolutionId = solutionId || 'current';\n\n let data: any;\n try {\n data = await apiFetch<any>(`/api/solutions/${targetSolutionId}/ui-plugins`);\n } catch (err: any) {\n if (err?.message?.includes('404')) {\n console.warn(`[useRemotePlugins] Solution ${targetSolutionId} not found or has no plugins`);\n setPlugins([]);\n return;\n }\n throw err;\n }\n const uiPlugins: RemotePlugin[] = (data.plugins || []).map((plugin: any) => ({\n id: plugin.id,\n name: plugin.name,\n version: plugin.version || '1.0.0',\n source: 'remote' as const,\n manifest: {\n id: plugin.id,\n name: plugin.name,\n version: plugin.version || '1.0.0',\n type: 'ui',\n description: plugin.description || '',\n capabilities: plugin.capabilities || {},\n channels: plugin.channels || ['default'],\n render: (plugin.render && typeof plugin.render === 'object') ? plugin.render : { mode: 'react-native' as const, component: plugin.name || plugin.id },\n entry_point: plugin.entry_point || plugin.name,\n sandbox: plugin.sandbox !== false,\n requires_auth: plugin.requires_auth !== false,\n } as PluginManifest,\n }));\n\n setPlugins(uiPlugins);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n console.error('[useRemotePlugins] Failed to fetch plugins:', message);\n setError(message);\n setPlugins([]); // Clear plugins on error\n } finally {\n setLoading(false);\n setRefreshing(false);\n }\n }, [solutionId]);\n\n const refresh = useCallback(async () => {\n setRefreshing(true);\n await fetchRemotePlugins();\n }, [fetchRemotePlugins]);\n\n useEffect(() => {\n setLoading(true);\n fetchRemotePlugins();\n }, [fetchRemotePlugins]);\n\n return {\n plugins,\n loading,\n error,\n refreshing,\n refresh,\n };\n}\n","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 * 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"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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,WAAW,EAAE,IAAI,QAAQ;AAAA,IAG9C,IACE;AAAA,KACN;AAEJ;","names":["View","Text","Pressable","TextInput","ActivityIndicator","StyleSheet","useMemo","React","useMemo","React","useMemo","useCallback","useMemo","useRef","useEffect","useState","useEffect","useState","useEffect","useEffect","useState","useCallback","apiFetch","useEffect","useRef","View","Text","Pressable","StyleSheet","Animated","Platform","Svg","ada","useEffect","View","StyleSheet","Animated","styles","jsx","jsxs","Platform","useRef","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","pluginCommandEmitter","jsx","jsxs","useEffect"]}
1
+ {"version":3,"sources":["../src/sdk/index.ts","../src/sdk/registration.ts","../src/sdk/primitives.ts","../src/sdk/components.ts","../src/sdk/usePluginTheme.ts","../src/sdk/useApi.ts","../src/host.ts","../src/bundles/bundleManager.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/storage.ts","../src/bridge/native.ts","../src/hooks/usePlugin.ts","../src/hooks/useRemotePlugins.ts","../src/api/plugins.ts"],"sourcesContent":["/**\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 } from './registration';\nimport { register, registerService } from './registration';\nexport const PluginSDK = { register, registerService } 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 SharingAPI,\n ScannerAPI,\n NfcAPI,\n BiometricsAPI,\n BiometricsAPIv2,\n NativeCapabilities,\n PluginHooks,\n PluginManifest,\n RenderMode,\n RegisteredPlugin,\n RegisteredUIPlugin,\n RegisteredServicePlugin,\n} from './types';\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\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 NativeCapabilities,\n PluginHooks,\n PluginProps,\n RegisteredUIPlugin,\n RegisteredServicePlugin,\n} from './types';\n\n/**\n * Register a UI or hybrid plugin (has a visual component).\n */\nexport function register(\n id: string,\n config: {\n type?: 'ui' | 'hybrid';\n capabilities?: NativeCapabilities;\n Component: React.FC<PluginProps>;\n },\n): RegisteredUIPlugin {\n return {\n id,\n type: config.type || 'ui',\n capabilities: config.capabilities,\n Component: config.Component,\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 * 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 * 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 * 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: () => {} },\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};\n\nlet _pluginNative: PluginNative = noopNative;\n\n/** Install the device-capabilities implementation plugins receive as\n * `props.native`. 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): 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 — 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): PluginNative {\n const caps = declared || {};\n return {\n camera: caps.camera ? native.camera : blocked('camera'),\n location: caps.location ? native.location : blocked('location'),\n storage: caps.offline ? native.storage : 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 ? native.fileSystem : 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 };\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 * 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 } 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 { getBundleStorage, type BundleCacheEntry } from './storage';\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\nclass BundleManager {\n /** In-memory module cache: bundleUrl → evaluated module.exports */\n private modules = new Map<string, any>();\n\n /** In-flight download deduplication: bundleUrl → Promise */\n private inflight = new Map<string, Promise<any>>();\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 // 1. In-memory cache — instant\n const cached = this.getComponentFromMemory(pluginId, bundleUrl);\n if (cached) return cached;\n\n // 2. Deduplicate in-flight downloads for same bundleUrl\n let modulePromise = this.inflight.get(bundleUrl);\n if (!modulePromise) {\n modulePromise = this.loadModule(bundleUrl, version, expectedHash);\n this.inflight.set(bundleUrl, modulePromise);\n // Swallow rejection on the cleanup chain — the original `await` below\n // still surfaces the error to the caller.\n modulePromise.catch(() => {}).finally(() => this.inflight.delete(bundleUrl));\n }\n\n await modulePromise;\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 * 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 this.modules.clear();\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 // ── Private: module loading pipeline ────────────────────────\n\n private async loadModule(bundleUrl: string, version: string, expectedHash?: string): Promise<void> {\n // Already in memory?\n if (this.modules.has(bundleUrl)) return;\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.\n let content: string | null = null;\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) 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 // Save with verified hash\n const safeName = bundleUrl.replace(/[^a-zA-Z0-9]/g, '_').slice(-80);\n try {\n const localPath = await storage.writeBundle(`${safeName}@${version}.js`, content);\n index[bundleUrl] = {\n localPath,\n version,\n timestamp: Date.now(),\n bundleUrl,\n bundleHash: downloaded.sha256,\n } satisfies BundleCacheEntry;\n await storage.saveIndex(index);\n } catch (err) {\n console.warn('[BundleManager] Cache write error:', err);\n }\n }\n\n // Evaluate\n const mod = this.evaluate(content, bundleUrl);\n this.modules.set(bundleUrl, mod);\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): any {\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 * 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 * 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\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 * usePlugin — single hook for loading any plugin.\n *\n * Simple async load → done pattern over the global BundleManager singleton\n * (deduplication + caching) and the host's native plugin registry.\n *\n * Usage:\n * const { plugin, loading, error } = usePlugin(pluginId, manifest);\n * if (loading) return <Spinner />;\n * if (error) return <Error message={error} />;\n * return <plugin.Component bridge={bridge} native={native} theme={theme} context={context} />;\n */\nimport { useState, useEffect } from 'react';\nimport { bundleManager } from '../bundles/bundleManager';\nimport { nativePluginRegistry } from '../host';\nimport type { RegisteredUIPlugin } from '../sdk/types';\n\ninterface PluginManifestLike {\n version?: string;\n name?: string;\n render?: any;\n _connectorId?: string;\n}\n\ninterface UsePluginResult {\n plugin: RegisteredUIPlugin | null;\n loading: boolean;\n error: string | null;\n bundleMissing: boolean;\n}\n\n/**\n * Compute the bundle URL.\n *\n * **Policy:** bundle URLs are ALWAYS derived from the pluginId via the\n * canonical platform route /api/ui-plugins/{pluginId}/bundle.js.\n * Connector-supplied bundleUrl fields are IGNORED — the Builder strips them\n * at introspection time, but we treat any survivors as bugs and ignore them\n * here too (defense in depth vs \"hand-coded URL with bad encoding causes\n * silent iframe fallback\" bugs).\n */\ntype BundleUrlSource = 'derived-default' | 'ignored-explicit' | 'none';\nfunction extractBundleUrl(pluginId: string, manifest: PluginManifestLike): { url: string | null; source: BundleUrlSource; ignored?: string } {\n const render = manifest.render;\n if (!render || typeof render !== 'object') return { url: null, source: 'none' };\n\n // Detect (and refuse) any explicit bundle URL the connector tried to inject.\n const injected =\n (manifest as any).bundleUrl ||\n (render as any).bundleUrl ||\n render.reactNative?.bundleUrl ||\n null;\n\n // Mobile decides native vs web INDEPENDENT of render.mode. The server's\n // cp.getContextPlugin flattens mode to \"iframe\" whenever an iframeUrl is\n // available (for web-frontend compatibility) — even when a reactNative\n // component is also declared. So we derive the bundle URL whenever a\n // reactNative component is present, regardless of what `mode` says.\n const hasNativeComponent = !!(render.reactNative?.component || render.component);\n if (hasNativeComponent) {\n return {\n url: `/api/ui-plugins/${encodeURIComponent(pluginId)}/bundle.js`,\n source: injected ? 'ignored-explicit' : 'derived-default',\n ...(injected && { ignored: injected }),\n };\n }\n\n return { url: null, source: 'none' };\n}\n\n/**\n * Extract the SHA-256 integrity hash from the manifest (server-provided).\n * BundleManager refuses to evaluate a downloaded bundle whose bytes don't\n * hash to this value — defense vs MITM/CDN tampering.\n */\nfunction extractBundleHash(manifest: PluginManifestLike): string | undefined {\n if ((manifest as any).bundleHash) return (manifest as any).bundleHash;\n const render = manifest.render;\n if (!render || typeof render !== 'object') return undefined;\n if (render.bundleHash) return render.bundleHash;\n if (render.reactNative?.bundleHash) return render.reactNative.bundleHash;\n return undefined;\n}\n\n/**\n * Extract component name from manifest render field.\n */\nfunction extractComponentId(manifest: PluginManifestLike): string | null {\n const render = manifest.render;\n if (!render || typeof render !== 'object') return null;\n return render.component || render.reactNative?.component || null;\n}\n\nexport function usePlugin(pluginId: string, manifest: PluginManifestLike): UsePluginResult {\n const [plugin, setPlugin] = useState<RegisteredUIPlugin | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [bundleMissing, setBundleMissing] = useState(false);\n\n const version = manifest.version || '1.0.0';\n const { url: bundleUrl, ignored: ignoredUrl } = extractBundleUrl(pluginId, manifest);\n const bundleHash = extractBundleHash(manifest);\n const componentId = extractComponentId(manifest);\n const lookupId = componentId || pluginId;\n\n if (ignoredUrl) {\n console.warn(`[usePlugin] ${pluginId}: IGNORED connector-injected bundleUrl=\"${ignoredUrl}\". The host derives bundle URLs from pluginId via the canonical route.`);\n }\n\n useEffect(() => {\n let cancelled = false;\n\n (async () => {\n try {\n // Path 1: Local registry (host-bundled / dev plugins)\n if (nativePluginRegistry.has(lookupId)) {\n const registered = await nativePluginRegistry.get(lookupId);\n if (cancelled) return;\n\n if (!registered) {\n throw new Error(`Local plugin not found: ${lookupId}`);\n }\n if (registered.type === 'service') {\n throw new Error(`Plugin ${lookupId} is a service plugin and cannot be rendered`);\n }\n\n setPlugin(registered as RegisteredUIPlugin);\n setLoading(false);\n return;\n }\n\n // Path 2: Remote bundle (via global BundleManager)\n if (bundleUrl) {\n try {\n const component = await bundleManager.load(pluginId, bundleUrl, version, bundleHash);\n if (cancelled) return;\n setPlugin(component);\n setLoading(false);\n return;\n } catch (bundleErr) {\n const msg = bundleErr instanceof Error ? bundleErr.message : String(bundleErr);\n // warn (not error) — this is a handled path: we fall back to WebView.\n console.warn(`[usePlugin] ${pluginId}: Bundle load failed, falling back to WebView:`, msg);\n // RN bundle failed — connector declared a component but didn't\n // ship a usable bundle (404, eval error, integrity fail, etc).\n // Mark \"bundle missing\" so the parent renderer can fall back to\n // the WebView/iframe when the manifest also has an iframeUrl.\n if (!cancelled) {\n setBundleMissing(true);\n setLoading(false);\n }\n return;\n }\n }\n\n // No native source available. If the manifest also has an iframeUrl,\n // mark \"bundle missing\" so the parent falls back to the WebView.\n // Only throw when there's truly nothing renderable.\n const iframeUrl = manifest?.render?.iframeUrl\n || (manifest?.render?.mode === 'adaptive' && manifest?.render?.iframe?.iframeUrl);\n if (iframeUrl) {\n if (!cancelled) {\n setBundleMissing(true);\n setLoading(false);\n }\n return;\n }\n throw new Error(\n `Plugin \"${manifest.name || pluginId}\" has no bundle URL and is not in the local registry. ` +\n `Check that the solution definition includes a valid render.reactNative.bundleUrl.`\n );\n } catch (err) {\n if (cancelled) return;\n const msg = err instanceof Error ? err.message : String(err);\n console.error(`[usePlugin] Failed to load ${pluginId}:`, msg);\n setError(msg);\n setLoading(false);\n }\n })();\n\n return () => { cancelled = true; };\n }, [pluginId, lookupId, bundleUrl, bundleHash, version]);\n\n return { plugin, loading, error, bundleMissing };\n}\n","import { useEffect, useState, useCallback } from 'react';\nimport { apiFetch } from '@ateam-ai-mobile/core';\nimport type { PluginManifest } from '../sdk/types';\n\nexport interface RemotePlugin {\n id: string;\n name: string;\n version: string;\n manifest: PluginManifest;\n source: 'remote' | 'local'; // Where this plugin came from\n}\n\ninterface UseRemotePluginsResult {\n plugins: RemotePlugin[];\n loading: boolean;\n error: string | null;\n refreshing: boolean;\n refresh: () => Promise<void>;\n}\n\n/**\n * Fetches available UI plugins from A-Team Core for the current solution.\n * Uses apiFetch which auto-injects JWT + tenant headers.\n */\nexport function useRemotePlugins(solutionId?: string): UseRemotePluginsResult {\n const [plugins, setPlugins] = useState<RemotePlugin[]>([]);\n const [loading, setLoading] = useState(true);\n const [refreshing, setRefreshing] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const fetchRemotePlugins = useCallback(async () => {\n try {\n setError(null);\n\n const targetSolutionId = solutionId || 'current';\n\n let data: any;\n try {\n data = await apiFetch<any>(`/api/solutions/${targetSolutionId}/ui-plugins`);\n } catch (err: any) {\n if (err?.message?.includes('404')) {\n console.warn(`[useRemotePlugins] Solution ${targetSolutionId} not found or has no plugins`);\n setPlugins([]);\n return;\n }\n throw err;\n }\n const uiPlugins: RemotePlugin[] = (data.plugins || []).map((plugin: any) => ({\n id: plugin.id,\n name: plugin.name,\n version: plugin.version || '1.0.0',\n source: 'remote' as const,\n manifest: {\n id: plugin.id,\n name: plugin.name,\n version: plugin.version || '1.0.0',\n type: 'ui',\n description: plugin.description || '',\n capabilities: plugin.capabilities || {},\n channels: plugin.channels || ['default'],\n render: (plugin.render && typeof plugin.render === 'object') ? plugin.render : { mode: 'react-native' as const, component: plugin.name || plugin.id },\n entry_point: plugin.entry_point || plugin.name,\n sandbox: plugin.sandbox !== false,\n requires_auth: plugin.requires_auth !== false,\n } as PluginManifest,\n }));\n\n setPlugins(uiPlugins);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n console.error('[useRemotePlugins] Failed to fetch plugins:', message);\n setError(message);\n setPlugins([]); // Clear plugins on error\n } finally {\n setLoading(false);\n setRefreshing(false);\n }\n }, [solutionId]);\n\n const refresh = useCallback(async () => {\n setRefreshing(true);\n await fetchRemotePlugins();\n }, [fetchRemotePlugins]);\n\n useEffect(() => {\n setLoading(true);\n fetchRemotePlugins();\n }, [fetchRemotePlugins]);\n\n return {\n plugins,\n loading,\n error,\n refreshing,\n refresh,\n };\n}\n","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"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,SACd,IACA,QAKoB;AACpB,SAAO;AAAA,IACL;AAAA,IACA,MAAM,OAAO,QAAQ;AAAA,IACrB,cAAc,OAAO;AAAA,IACrB,WAAW,OAAO;AAAA,EACpB;AACF;AAKO,SAAS,gBACd,IACA,QAMyB;AACzB,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,IACN,cAAc,OAAO;AAAA,IACrB,OAAO,OAAO;AAAA,IACd,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,EACjB;AACF;;;AC/CA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACjBP,OAAO,WAAW;AAClB;AAAA,EACE,QAAAA;AAAA,EAC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AAAA,IACT;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AASO,SAAS,iBAAiB,UAA0B,QAAyB;AAIlF,QAAM,SAAS,SAAS;AACxB,MAAI;AACJ,MAAI,QAAQ,SAAS,UAAU;AAC7B,UAAM,OAAO;AAAA,EACf,WAAW,QAAQ,SAAS,YAAY;AACtC,UAAM,OAAO,aAAa,OAAO,QAAQ;AAAA,EAC3C;AAEA,MAAI,CAAC,IAAK,QAAO;AAGjB,MAAI,IAAI,WAAW,MAAM,GAAG;AAC1B,UAAM,MAAM,IAAI,SAAS,GAAG,IAAI,MAAM;AACtC,WAAO,SAAS,GAAG,GAAG,GAAG,GAAG,UAAU,mBAAmB,MAAM,CAAC,KAAK;AAAA,EACvE;AAGA,MAAI,UAAU,IAAI,WAAW,UAAU,GAAG;AACxC,UAAM,YAAY,IAAI,QAAQ,YAAY,WAAW,mBAAmB,MAAM,CAAC,GAAG;AAClF,WAAO,GAAG,cAAc,CAAC,GAAG,SAAS;AAAA,EACvC;AAGA,SAAO,GAAG,cAAc,CAAC,GAAG,GAAG;AACjC;","names":["View","Text","Pressable","TextInput","ActivityIndicator","StyleSheet","useMemo","React","useEffect","useMemo","useRef","useEffect","View","Text","Pressable","StyleSheet","Animated","Platform","Svg","ada","View","StyleSheet","Animated","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","React","useEffect","useMemo","useRef","useCallback","useMemo","useRef","useEffect","pluginCommandEmitter","useState","useEffect","useState","useEffect","useEffect","useState","useCallback","apiFetch"]}