@mobileai/react-native 0.1.0

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.
Files changed (65) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +190 -0
  3. package/lib/module/components/AIAgent.js +149 -0
  4. package/lib/module/components/AIAgent.js.map +1 -0
  5. package/lib/module/components/AgentChatBar.js +120 -0
  6. package/lib/module/components/AgentChatBar.js.map +1 -0
  7. package/lib/module/components/AgentOverlay.js +53 -0
  8. package/lib/module/components/AgentOverlay.js.map +1 -0
  9. package/lib/module/core/AgentRuntime.js +498 -0
  10. package/lib/module/core/AgentRuntime.js.map +1 -0
  11. package/lib/module/core/FiberTreeWalker.js +308 -0
  12. package/lib/module/core/FiberTreeWalker.js.map +1 -0
  13. package/lib/module/core/MCPBridge.js +98 -0
  14. package/lib/module/core/MCPBridge.js.map +1 -0
  15. package/lib/module/core/ScreenDehydrator.js +46 -0
  16. package/lib/module/core/ScreenDehydrator.js.map +1 -0
  17. package/lib/module/core/types.js +2 -0
  18. package/lib/module/core/types.js.map +1 -0
  19. package/lib/module/hooks/useAction.js +32 -0
  20. package/lib/module/hooks/useAction.js.map +1 -0
  21. package/lib/module/index.js +17 -0
  22. package/lib/module/index.js.map +1 -0
  23. package/lib/module/package.json +1 -0
  24. package/lib/module/providers/GeminiProvider.js +178 -0
  25. package/lib/module/providers/GeminiProvider.js.map +1 -0
  26. package/lib/module/utils/logger.js +17 -0
  27. package/lib/module/utils/logger.js.map +1 -0
  28. package/lib/typescript/package.json +1 -0
  29. package/lib/typescript/src/components/AIAgent.d.ts +57 -0
  30. package/lib/typescript/src/components/AIAgent.d.ts.map +1 -0
  31. package/lib/typescript/src/components/AgentChatBar.d.ts +14 -0
  32. package/lib/typescript/src/components/AgentChatBar.d.ts.map +1 -0
  33. package/lib/typescript/src/components/AgentOverlay.d.ts +10 -0
  34. package/lib/typescript/src/components/AgentOverlay.d.ts.map +1 -0
  35. package/lib/typescript/src/core/AgentRuntime.d.ts +37 -0
  36. package/lib/typescript/src/core/AgentRuntime.d.ts.map +1 -0
  37. package/lib/typescript/src/core/FiberTreeWalker.d.ts +26 -0
  38. package/lib/typescript/src/core/FiberTreeWalker.d.ts.map +1 -0
  39. package/lib/typescript/src/core/MCPBridge.d.ts +23 -0
  40. package/lib/typescript/src/core/MCPBridge.d.ts.map +1 -0
  41. package/lib/typescript/src/core/ScreenDehydrator.d.ts +20 -0
  42. package/lib/typescript/src/core/ScreenDehydrator.d.ts.map +1 -0
  43. package/lib/typescript/src/core/types.d.ts +138 -0
  44. package/lib/typescript/src/core/types.d.ts.map +1 -0
  45. package/lib/typescript/src/hooks/useAction.d.ts +13 -0
  46. package/lib/typescript/src/hooks/useAction.d.ts.map +1 -0
  47. package/lib/typescript/src/index.d.ts +10 -0
  48. package/lib/typescript/src/index.d.ts.map +1 -0
  49. package/lib/typescript/src/providers/GeminiProvider.d.ts +23 -0
  50. package/lib/typescript/src/providers/GeminiProvider.d.ts.map +1 -0
  51. package/lib/typescript/src/utils/logger.d.ts +7 -0
  52. package/lib/typescript/src/utils/logger.d.ts.map +1 -0
  53. package/package.json +143 -0
  54. package/src/components/AIAgent.tsx +222 -0
  55. package/src/components/AgentChatBar.tsx +136 -0
  56. package/src/components/AgentOverlay.tsx +48 -0
  57. package/src/core/AgentRuntime.ts +505 -0
  58. package/src/core/FiberTreeWalker.ts +349 -0
  59. package/src/core/MCPBridge.ts +110 -0
  60. package/src/core/ScreenDehydrator.ts +53 -0
  61. package/src/core/types.ts +185 -0
  62. package/src/hooks/useAction.ts +40 -0
  63. package/src/index.ts +22 -0
  64. package/src/providers/GeminiProvider.ts +210 -0
  65. package/src/utils/logger.ts +21 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohamed Salah
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # @mobileai/react-native
2
+
3
+ > **Autonomous AI agent for React Native** — Your app gets an AI copilot that can see, understand, and interact with your UI. Zero wrappers, zero view rewriting.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@mobileai/react-native)](https://www.npmjs.com/package/@mobileai/react-native)
6
+ [![license](https://img.shields.io/npm/l/@mobileai/react-native)](https://github.com/mohamed2m2018/react-native-ai-agent/blob/main/LICENSE)
7
+ [![platform](https://img.shields.io/badge/platform-iOS%20%7C%20Android-brightgreen)]()
8
+
9
+ Wrap your navigation with `<AIAgent>`. The AI automatically understands your entire screen — every button, every input, every label — and acts on it.
10
+
11
+ ## ✨ Features
12
+
13
+ - 🤖 **Zero-config UI understanding** — No need to annotate your views. The AI reads your UI automatically.
14
+ - 🧭 **Auto-navigation** — Navigates between screens to complete multi-step tasks.
15
+ - 🔒 **Production-grade security** — Element gating, content masking, lifecycle hooks, human-in-the-loop confirmation.
16
+ - 🧩 **Custom actions** — Expose any business logic (checkout, API calls) as AI-callable tools with `useAction`.
17
+ - 🌐 **MCP bridge** — Let external AI agents (OpenClaw, Claude Desktop) control your app remotely.
18
+ - 🌍 **Bilingual** — English and Arabic support built-in.
19
+
20
+ ## 📦 Installation
21
+
22
+ ```bash
23
+ npm install @mobileai/react-native
24
+ ```
25
+
26
+ No native modules required. Works with Expo managed workflow out of the box — **no eject needed**.
27
+
28
+ ## 🚀 Quick Start
29
+
30
+ ```tsx
31
+ import { AIAgent } from '@mobileai/react-native';
32
+ import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
33
+
34
+ export default function App() {
35
+ const navRef = useNavigationContainerRef();
36
+
37
+ return (
38
+ <AIAgent apiKey="YOUR_GEMINI_API_KEY" navRef={navRef}>
39
+ <NavigationContainer ref={navRef}>
40
+ {/* Your existing screens — zero changes needed */}
41
+ </NavigationContainer>
42
+ </AIAgent>
43
+ );
44
+ }
45
+ ```
46
+
47
+ A floating chat bar appears automatically. Ask the AI to navigate, tap buttons, fill forms — it reads your live UI and acts.
48
+
49
+ ## 🔌 API Reference
50
+
51
+ ### `<AIAgent>` Component
52
+
53
+ The root provider. Wrap your app once at the top level.
54
+
55
+ | Prop | Type | Default | Description |
56
+ |------|------|---------|-------------|
57
+ | `apiKey` | `string` | — | **Required.** Gemini API key. |
58
+ | `model` | `string` | `'gemini-2.5-flash'` | Gemini model name. |
59
+ | `navRef` | `NavigationContainerRef` | — | Navigation ref for auto-navigation. |
60
+ | `language` | `'en' \| 'ar'` | `'en'` | UI language. |
61
+ | `maxSteps` | `number` | `10` | Max steps per task. |
62
+ | `showChatBar` | `boolean` | `true` | Show the floating chat bar. |
63
+ | `onResult` | `(result) => void` | — | Called when the agent finishes. |
64
+
65
+ ### `useAction(name, description, params, handler)`
66
+
67
+ Register a **non-UI action** the AI can call — for business logic that isn't a visible button.
68
+
69
+ ```tsx
70
+ import { useAction } from '@mobileai/react-native';
71
+
72
+ function CartScreen() {
73
+ const { clearCart, getTotal } = useCart();
74
+
75
+ useAction('checkout', 'Place the order', {}, async () => {
76
+ const total = getTotal();
77
+ clearCart();
78
+ return { success: true, message: `Order placed! Total: $${total}` };
79
+ });
80
+ }
81
+ ```
82
+
83
+ | Param | Type | Description |
84
+ |-------|------|-------------|
85
+ | `name` | `string` | Unique action name. |
86
+ | `description` | `string` | Natural language description for the AI. |
87
+ | `parameters` | `Record<string, string>` | Parameter schema (e.g., `{ itemName: 'string' }`). |
88
+ | `handler` | `(args) => any` | Execution handler. Can be sync or async. |
89
+
90
+ ## 🔒 Security
91
+
92
+ ### Element Gating
93
+
94
+ Hide specific elements from the AI:
95
+
96
+ ```tsx
97
+ // Per-element: add aiIgnore prop
98
+ <Pressable aiIgnore={true} onPress={handleAdmin}>
99
+ <Text>Admin Panel</Text>
100
+ </Pressable>
101
+
102
+ // Per-ref: blacklist by reference
103
+ const secretRef = useRef(null);
104
+ <AIAgent interactiveBlacklist={[secretRef]}>
105
+ <Pressable ref={secretRef}>Hidden from AI</Pressable>
106
+ </AIAgent>
107
+ ```
108
+
109
+ ### Content Masking
110
+
111
+ Sanitize sensitive data before the LLM sees it:
112
+
113
+ ```tsx
114
+ <AIAgent
115
+ transformScreenContent={(content) =>
116
+ content.replace(/\b\d{13,16}\b/g, '****-****-****-****')
117
+ }
118
+ />
119
+ ```
120
+
121
+ ### Screen-Specific Instructions
122
+
123
+ Guide the AI's behavior on sensitive screens:
124
+
125
+ ```tsx
126
+ <AIAgent
127
+ instructions={{
128
+ system: 'You are a food delivery assistant.',
129
+ getScreenInstructions: (screenName) => {
130
+ if (screenName === 'Cart') {
131
+ return 'Always confirm the total with the user before checkout.';
132
+ }
133
+ },
134
+ }}
135
+ />
136
+ ```
137
+
138
+ ### Human-in-the-Loop
139
+
140
+ Force native confirmation before critical actions:
141
+
142
+ ```tsx
143
+ useAction('checkout', 'Place the order', {}, () => {
144
+ return new Promise((resolve) => {
145
+ Alert.alert('Confirm?', 'Place this order?', [
146
+ { text: 'Cancel', onPress: () => resolve({ success: false }) },
147
+ { text: 'Yes', onPress: () => resolve({ success: true }) },
148
+ ]);
149
+ });
150
+ });
151
+ ```
152
+
153
+ ### Lifecycle Hooks
154
+
155
+ | Prop | Description |
156
+ |------|-------------|
157
+ | `onBeforeStep` | Called before each agent step. |
158
+ | `onAfterStep` | Called after each step with full history. |
159
+ | `onBeforeTask` | Called before task execution starts. |
160
+ | `onAfterTask` | Called after task completes. |
161
+
162
+ ## 🌐 MCP Bridge
163
+
164
+ Connect external AI agents to your app via the Model Context Protocol:
165
+
166
+ ```tsx
167
+ <AIAgent apiKey="..." mcpServerUrl="ws://localhost:3101" />
168
+ ```
169
+
170
+ See the `mcp-server/` directory for the companion Node.js server setup.
171
+
172
+ ## 🛠️ Built-in Tools
173
+
174
+ | Tool | Description |
175
+ |------|-------------|
176
+ | `tap(index)` | Tap an interactive element. |
177
+ | `type(index, text)` | Type text into an input. |
178
+ | `navigate(screen)` | Navigate to a screen. |
179
+ | `done(text)` | Complete the task. |
180
+ | `ask_user(question)` | Ask the user for clarification. |
181
+
182
+ ## 📋 Requirements
183
+
184
+ - React Native 0.72+
185
+ - Expo SDK 49+ (or bare React Native)
186
+ - Gemini API key — [Get one free](https://aistudio.google.com/apikey)
187
+
188
+ ## 📄 License
189
+
190
+ MIT © [Mohamed Salah](https://github.com/mohamed2m2018)
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * AIAgent — Root provider component for the AI agent.
5
+ *
6
+ * Wraps the app and provides:
7
+ * - Fiber tree root ref for element auto-detection
8
+ * - Navigation ref for auto-navigation
9
+ * - Floating chat bar for user input
10
+ * - Agent runtime context for useAction hooks
11
+ */
12
+
13
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
14
+ import { View, StyleSheet } from 'react-native';
15
+ import { AgentRuntime } from "../core/AgentRuntime.js";
16
+ import { GeminiProvider } from "../providers/GeminiProvider.js";
17
+ import { AgentContext } from "../hooks/useAction.js";
18
+ import { AgentChatBar } from "./AgentChatBar.js";
19
+ import { AgentOverlay } from "./AgentOverlay.js";
20
+ import { logger } from "../utils/logger.js";
21
+ import { MCPBridge } from "../core/MCPBridge.js";
22
+
23
+ // ─── Context ───────────────────────────────────────────────────
24
+
25
+ // ─── Props ─────────────────────────────────────────────────────
26
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
27
+ // ─── Component ─────────────────────────────────────────────────
28
+
29
+ export function AIAgent({
30
+ apiKey,
31
+ model = 'gemini-2.5-flash',
32
+ navRef,
33
+ language = 'en',
34
+ maxSteps = 10,
35
+ showChatBar = true,
36
+ children,
37
+ onResult,
38
+ // Security props
39
+ interactiveBlacklist,
40
+ interactiveWhitelist,
41
+ onBeforeStep,
42
+ onAfterStep,
43
+ onBeforeTask,
44
+ onAfterTask,
45
+ transformScreenContent,
46
+ customTools,
47
+ instructions,
48
+ stepDelay,
49
+ mcpServerUrl
50
+ }) {
51
+ const rootViewRef = useRef(null);
52
+ const [isThinking, setIsThinking] = useState(false);
53
+ const [statusText, setStatusText] = useState('');
54
+ const [lastResult, setLastResult] = useState(null);
55
+
56
+ // ─── Create Runtime ──────────────────────────────────────────
57
+
58
+ const config = useMemo(() => ({
59
+ apiKey,
60
+ model,
61
+ language,
62
+ maxSteps,
63
+ interactiveBlacklist,
64
+ interactiveWhitelist,
65
+ onBeforeStep,
66
+ onAfterStep,
67
+ onBeforeTask,
68
+ onAfterTask,
69
+ transformScreenContent,
70
+ customTools,
71
+ instructions,
72
+ stepDelay,
73
+ mcpServerUrl
74
+ }), [apiKey, model, language, maxSteps, interactiveBlacklist, interactiveWhitelist, onBeforeStep, onAfterStep, onBeforeTask, onAfterTask, transformScreenContent, customTools, instructions, stepDelay, mcpServerUrl]);
75
+ const provider = useMemo(() => new GeminiProvider(apiKey, model), [apiKey, model]);
76
+ const runtime = useMemo(() => new AgentRuntime(provider, config, rootViewRef.current, navRef),
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
+ [provider, config]);
79
+
80
+ // Update refs when they change
81
+ useEffect(() => {
82
+ runtime.updateRefs(rootViewRef.current, navRef);
83
+ }, [runtime, navRef]);
84
+
85
+ // ─── MCP Bridge ──────────────────────────────────────────────
86
+
87
+ useEffect(() => {
88
+ if (!mcpServerUrl) return;
89
+ logger.info('AIAgent', `Setting up MCP bridge at ${mcpServerUrl}`);
90
+ const bridge = new MCPBridge(mcpServerUrl, runtime);
91
+ return () => {
92
+ bridge.destroy();
93
+ };
94
+ }, [mcpServerUrl, runtime]);
95
+
96
+ // ─── Execute ──────────────────────────────────────────────────
97
+
98
+ const handleSend = useCallback(async message => {
99
+ if (!message.trim()) return;
100
+ logger.info('AIAgent', `User message: "${message}"`);
101
+ setIsThinking(true);
102
+ setStatusText('Thinking...');
103
+ setLastResult(null);
104
+ try {
105
+ // Ensure we have the latest Fiber tree ref
106
+ runtime.updateRefs(rootViewRef.current, navRef);
107
+ const result = await runtime.execute(message);
108
+ setLastResult(result);
109
+ onResult?.(result);
110
+ logger.info('AIAgent', `Result: ${result.success ? '✅' : '❌'} ${result.message}`);
111
+ } catch (error) {
112
+ logger.error('AIAgent', 'Execution failed:', error);
113
+ setLastResult({
114
+ success: false,
115
+ message: `Error: ${error.message}`,
116
+ steps: []
117
+ });
118
+ } finally {
119
+ setIsThinking(false);
120
+ setStatusText('');
121
+ }
122
+ }, [runtime, navRef, onResult]);
123
+
124
+ // ─── Render ──────────────────────────────────────────────────
125
+
126
+ return /*#__PURE__*/_jsxs(AgentContext.Provider, {
127
+ value: runtime,
128
+ children: [/*#__PURE__*/_jsx(View, {
129
+ ref: rootViewRef,
130
+ style: styles.root,
131
+ collapsable: false,
132
+ children: children
133
+ }), /*#__PURE__*/_jsx(AgentOverlay, {
134
+ visible: isThinking,
135
+ statusText: statusText
136
+ }), showChatBar && /*#__PURE__*/_jsx(AgentChatBar, {
137
+ onSend: handleSend,
138
+ isThinking: isThinking,
139
+ lastResult: lastResult,
140
+ language: language
141
+ })]
142
+ });
143
+ }
144
+ const styles = StyleSheet.create({
145
+ root: {
146
+ flex: 1
147
+ }
148
+ });
149
+ //# sourceMappingURL=AIAgent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","useMemo","useRef","useState","View","StyleSheet","AgentRuntime","GeminiProvider","AgentContext","AgentChatBar","AgentOverlay","logger","MCPBridge","jsx","_jsx","jsxs","_jsxs","AIAgent","apiKey","model","navRef","language","maxSteps","showChatBar","children","onResult","interactiveBlacklist","interactiveWhitelist","onBeforeStep","onAfterStep","onBeforeTask","onAfterTask","transformScreenContent","customTools","instructions","stepDelay","mcpServerUrl","rootViewRef","isThinking","setIsThinking","statusText","setStatusText","lastResult","setLastResult","config","provider","runtime","current","updateRefs","info","bridge","destroy","handleSend","message","trim","result","execute","success","error","steps","Provider","value","ref","style","styles","root","collapsable","visible","onSend","create","flex"],"sourceRoot":"../../../src","sources":["components/AIAgent.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAC/C,SAASC,YAAY,QAAQ,yBAAsB;AACnD,SAASC,cAAc,QAAQ,gCAA6B;AAC5D,SAASC,YAAY,QAAQ,uBAAoB;AACjD,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,MAAM,QAAQ,oBAAiB;AACxC,SAASC,SAAS,QAAQ,sBAAmB;;AAG7C;;AAGA;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAiDA;;AAEA,OAAO,SAASC,OAAOA,CAAC;EACtBC,MAAM;EACNC,KAAK,GAAG,kBAAkB;EAC1BC,MAAM;EACNC,QAAQ,GAAG,IAAI;EACfC,QAAQ,GAAG,EAAE;EACbC,WAAW,GAAG,IAAI;EAClBC,QAAQ;EACRC,QAAQ;EACR;EACAC,o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AAE,mBAAmB,EAAEA,KAAK,CAAC;MACnDf,aAAa,CAAC;QACZc,OAAO,EAAE,KAAK;QACdJ,OAAO,EAAE,UAAUK,KAAK,CAACL,OAAO,EAAE;QAClCM,KAAK,EAAE;MACT,CAAC,CAAC;IACJ,CAAC,SAAS;MACRpB,aAAa,CAAC,KAAK,CAAC;MACpBE,aAAa,CAAC,EAAE,CAAC;IACnB;EACF,CAAC,EAAE,CAACK,OAAO,EAAE1B,MAAM,EAAEK,QAAQ,CAAC,CAAC;;EAE/B;;EAEA,oBACET,KAAA,CAACR,YAAY,CAACoD,QAAQ;IAACC,KAAK,EAAEf,OAAQ;IAAAtB,QAAA,gBACpCV,IAAA,CAACV,IAAI;MAAC0D,GAAG,EAAEzB,WAAY;MAAC0B,KAAK,EAAEC,MAAM,CAACC,IAAK;MAACC,WAAW,EAAE,KAAM;MAAA1C,QAAA,EAC5DA;IAAQ,CACL,CAAC,eAGPV,IAAA,CAACJ,YAAY;MAACyD,OAAO,EAAE7B,UAAW;MAACE,UAAU,EAAEA;IAAW,CAAE,CAAC,EAG5DjB,WAAW,iBACVT,IAAA,CAACL,YAAY;MACX2D,MAAM,EAAEhB,UAAW;MACnBd,UAAU,EAAEA,UAAW;MACvBI,UAAU,EAAEA,UAAW;MACvBrB,QAAQ,EAAEA;IAAS,CACpB,CACF;EAAA,CACoB,CAAC;AAE5B;AAEA,MAAM2C,MAAM,GAAG3D,UAAU,CAACgE,MAAM,CAAC;EAC/BJ,IAAI,EAAE;IACJK,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * AgentChatBar — Floating chat input at the bottom of the screen.
5
+ * User sends messages here, and results are shown inline.
6
+ */
7
+
8
+ import { useState } from 'react';
9
+ import { View, TextInput, Pressable, Text, StyleSheet, KeyboardAvoidingView, Platform } from 'react-native';
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ export function AgentChatBar({
12
+ onSend,
13
+ isThinking,
14
+ lastResult,
15
+ language
16
+ }) {
17
+ const [text, setText] = useState('');
18
+ const isArabic = language === 'ar';
19
+ const handleSend = () => {
20
+ if (text.trim() && !isThinking) {
21
+ onSend(text.trim());
22
+ setText('');
23
+ }
24
+ };
25
+ return /*#__PURE__*/_jsxs(KeyboardAvoidingView, {
26
+ behavior: Platform.OS === 'ios' ? 'padding' : undefined,
27
+ style: styles.container,
28
+ children: [lastResult && /*#__PURE__*/_jsx(View, {
29
+ style: [styles.resultBubble, lastResult.success ? styles.resultSuccess : styles.resultError],
30
+ children: /*#__PURE__*/_jsx(Text, {
31
+ style: styles.resultText,
32
+ children: lastResult.message
33
+ })
34
+ }), /*#__PURE__*/_jsxs(View, {
35
+ style: styles.inputRow,
36
+ children: [/*#__PURE__*/_jsx(TextInput, {
37
+ style: [styles.input, isArabic && styles.inputRTL],
38
+ placeholder: isArabic ? 'اكتب طلبك...' : 'Ask the AI agent...',
39
+ placeholderTextColor: "#999",
40
+ value: text,
41
+ onChangeText: setText,
42
+ onSubmitEditing: handleSend,
43
+ returnKeyType: "send",
44
+ editable: !isThinking,
45
+ multiline: false
46
+ }), /*#__PURE__*/_jsx(Pressable, {
47
+ style: [styles.sendButton, isThinking && styles.sendButtonDisabled],
48
+ onPress: handleSend,
49
+ disabled: isThinking || !text.trim(),
50
+ children: /*#__PURE__*/_jsx(Text, {
51
+ style: styles.sendButtonText,
52
+ children: isThinking ? '⏳' : '🚀'
53
+ })
54
+ })]
55
+ })]
56
+ });
57
+ }
58
+ const styles = StyleSheet.create({
59
+ container: {
60
+ position: 'absolute',
61
+ bottom: 0,
62
+ left: 0,
63
+ right: 0,
64
+ paddingHorizontal: 12,
65
+ paddingBottom: Platform.OS === 'ios' ? 34 : 12,
66
+ paddingTop: 8,
67
+ backgroundColor: 'rgba(26, 26, 46, 0.95)',
68
+ borderTopLeftRadius: 20,
69
+ borderTopRightRadius: 20
70
+ },
71
+ resultBubble: {
72
+ borderRadius: 12,
73
+ padding: 12,
74
+ marginBottom: 8
75
+ },
76
+ resultSuccess: {
77
+ backgroundColor: 'rgba(40, 167, 69, 0.2)'
78
+ },
79
+ resultError: {
80
+ backgroundColor: 'rgba(220, 53, 69, 0.2)'
81
+ },
82
+ resultText: {
83
+ color: '#fff',
84
+ fontSize: 14,
85
+ lineHeight: 20
86
+ },
87
+ inputRow: {
88
+ flexDirection: 'row',
89
+ alignItems: 'center',
90
+ gap: 8
91
+ },
92
+ input: {
93
+ flex: 1,
94
+ backgroundColor: 'rgba(255, 255, 255, 0.1)',
95
+ borderRadius: 24,
96
+ paddingHorizontal: 16,
97
+ paddingVertical: 12,
98
+ color: '#fff',
99
+ fontSize: 16
100
+ },
101
+ inputRTL: {
102
+ textAlign: 'right',
103
+ writingDirection: 'rtl'
104
+ },
105
+ sendButton: {
106
+ width: 44,
107
+ height: 44,
108
+ borderRadius: 22,
109
+ backgroundColor: 'rgba(255, 255, 255, 0.15)',
110
+ justifyContent: 'center',
111
+ alignItems: 'center'
112
+ },
113
+ sendButtonDisabled: {
114
+ opacity: 0.5
115
+ },
116
+ sendButtonText: {
117
+ fontSize: 20
118
+ }
119
+ });
120
+ //# sourceMappingURL=AgentChatBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useState","View","TextInput","Pressable","Text","StyleSheet","KeyboardAvoidingView","Platform","jsx","_jsx","jsxs","_jsxs","AgentChatBar","onSend","isThinking","lastResult","language","text","setText","isArabic","handleSend","trim","behavior","OS","undefined","style","styles","container","children","resultBubble","success","resultSuccess","resultError","resultText","message","inputRow","input","inputRTL","placeholder","placeholderTextColor","value","onChangeText","onSubmitEditing","returnKeyType","editable","multiline","sendButton","sendButtonDisabled","onPress","disabled","sendButtonText","create","position","bottom","left","right","paddingHorizontal","paddingBottom","paddingTop","backgroundColor","borderTopLeftRadius","borderTopRightRadius","borderRadius","padding","marginBottom","color","fontSize","lineHeight","flexDirection","alignItems","gap","flex","paddingVertical","textAlign","writingDirection","width","height","justifyContent","opacity"],"sourceRoot":"../../../src","sources":["components/AgentChatBar.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SACEC,IAAI,EACJC,SAAS,EACTC,SAAS,EACTC,IAAI,EACJC,UAAU,EACVC,oBAAoB,EACpBC,QAAQ,QACH,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAUtB,OAAO,SAASC,YAAYA,CAAC;EAAEC,MAAM;EAAEC,UAAU;EAAEC,UAAU;EAAEC;AAA4B,CAAC,EAAE;EAC5F,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGlB,QAAQ,CAAC,EAAE,CAAC;EACpC,MAAMmB,QAAQ,GAAGH,QAAQ,KAAK,IAAI;EAElC,MAAMI,UAAU,GAAGA,CAAA,KAAM;IACvB,IAAIH,IAAI,CAACI,IAAI,CAAC,CAAC,IAAI,CAACP,UAAU,EAAE;MAC9BD,MAAM,CAACI,IAAI,CAACI,IAAI,CAAC,CAAC,CAAC;MACnBH,OAAO,CAAC,EAAE,CAAC;IACb;EACF,CAAC;EAED,oBACEP,KAAA,CAACL,oBAAoB;IACnBgB,QAAQ,EAAEf,QAAQ,CAACgB,EAAE,KAAK,KAAK,GAAG,SAAS,GAAGC,SAAU;IACxDC,KAAK,EAAEC,MAAM,CAACC,SAAU;IAAAC,QAAA,GAGvBb,UAAU,iBACTN,IAAA,CAACR,IAAI;MAACwB,KAAK,EAAE,CAACC,MAAM,CAACG,YAAY,EAAEd,UAAU,CAACe,OAAO,GAAGJ,MAAM,CAACK,aAAa,GAAGL,MAAM,CAACM,WAAW,CAAE;MAAAJ,QAAA,eACjGnB,IAAA,CAACL,IAAI;QAACqB,KAAK,EAAEC,MAAM,CAACO,UAAW;QAAAL,QAAA,EAAEb,UAAU,CAACmB;MAAO,CAAO;IAAC,CACvD,CACP,eAGDvB,KAAA,CAACV,IAAI;MAACwB,KA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EACxB,CAAC;EACDhC,YAAY,EAAE;IACZiC,YAAY,EAAE,EAAE;IAChBC,OAAO,EAAE,EAAE;IACXC,YAAY,EAAE;EAChB,CAAC;EACDjC,aAAa,EAAE;IACb4B,eAAe,EAAE;EACnB,CAAC;EACD3B,WAAW,EAAE;IACX2B,eAAe,EAAE;EACnB,CAAC;EACD1B,UAAU,EAAE;IACVgC,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDhC,QAAQ,EAAE;IACRiC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,GAAG,EAAE;EACP,CAAC;EACDlC,KAAK,EAAE;IACLmC,IAAI,EAAE,CAAC;IACPZ,eAAe,EAAE,0BAA0B;IAC3CG,YAAY,EAAE,EAAE;IAChBN,iBAAiB,EAAE,EAAE;IACrBgB,eAAe,EAAE,EAAE;IACnBP,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE;EACZ,CAAC;EACD7B,QAAQ,EAAE;IACRoC,SAAS,EAAE,OAAO;IAClBC,gBAAgB,EAAE;EACpB,CAAC;EACD5B,UAAU,EAAE;IACV6B,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,EAAE;IACVd,YAAY,EAAE,EAAE;IAChBH,eAAe,EAAE,2BAA2B;IAC5CkB,cAAc,EAAE,QAAQ;IACxBR,UAAU,EAAE;EACd,CAAC;EACDtB,kBAAkB,EAAE;IAClB+B,OAAO,EAAE;EACX,CAAC;EACD5B,cAAc,EAAE;IACdgB,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * AgentOverlay — Subtle thinking indicator shown while the AI agent is processing.
5
+ */
6
+
7
+ import { View, Text, StyleSheet, ActivityIndicator } from 'react-native';
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ export function AgentOverlay({
10
+ visible,
11
+ statusText
12
+ }) {
13
+ if (!visible) return null;
14
+ return /*#__PURE__*/_jsx(View, {
15
+ style: styles.overlay,
16
+ pointerEvents: "none",
17
+ children: /*#__PURE__*/_jsxs(View, {
18
+ style: styles.pill,
19
+ children: [/*#__PURE__*/_jsx(ActivityIndicator, {
20
+ size: "small",
21
+ color: "#fff"
22
+ }), /*#__PURE__*/_jsx(Text, {
23
+ style: styles.text,
24
+ children: statusText || 'Thinking...'
25
+ })]
26
+ })
27
+ });
28
+ }
29
+ const styles = StyleSheet.create({
30
+ overlay: {
31
+ position: 'absolute',
32
+ top: 60,
33
+ left: 0,
34
+ right: 0,
35
+ alignItems: 'center',
36
+ zIndex: 9999
37
+ },
38
+ pill: {
39
+ flexDirection: 'row',
40
+ alignItems: 'center',
41
+ gap: 8,
42
+ backgroundColor: 'rgba(26, 26, 46, 0.9)',
43
+ paddingHorizontal: 16,
44
+ paddingVertical: 10,
45
+ borderRadius: 20
46
+ },
47
+ text: {
48
+ color: '#fff',
49
+ fontSize: 14,
50
+ fontWeight: '500'
51
+ }
52
+ });
53
+ //# sourceMappingURL=AgentOverlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["View","Text","StyleSheet","ActivityIndicator","jsx","_jsx","jsxs","_jsxs","AgentOverlay","visible","statusText","style","styles","overlay","pointerEvents","children","pill","size","color","text","create","position","top","left","right","alignItems","zIndex","flexDirection","gap","backgroundColor","paddingHorizontal","paddingVertical","borderRadius","fontSize","fontWeight"],"sourceRoot":"../../../src","sources":["components/AgentOverlay.tsx"],"mappings":";;AAAA;AACA;AACA;;AAEA,SAASA,IAAI,EAAEC,IAAI,EAAEC,UAAU,EAAEC,iBAAiB,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAOzE,OAAO,SAASC,YAAYA,CAAC;EAAEC,OAAO;EAAEC;AAA8B,CAAC,EAAE;EACvE,IAAI,CAACD,OAAO,EAAE,OAAO,IAAI;EAEzB,oB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