react-native-agentic-ai 0.0.2 → 0.3.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 (70) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +252 -14
  3. package/lib/module/components/AIAgent.js +185 -0
  4. package/lib/module/components/AIAgent.js.map +1 -0
  5. package/lib/module/components/AgentChatBar.js +268 -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 +640 -0
  10. package/lib/module/core/AgentRuntime.js.map +1 -0
  11. package/lib/module/core/FiberTreeWalker.js +362 -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/systemPrompt.js +164 -0
  18. package/lib/module/core/systemPrompt.js.map +1 -0
  19. package/lib/module/core/types.js +2 -0
  20. package/lib/module/core/types.js.map +1 -0
  21. package/lib/module/hooks/useAction.js +32 -0
  22. package/lib/module/hooks/useAction.js.map +1 -0
  23. package/lib/module/index.js +17 -0
  24. package/lib/module/index.js.map +1 -0
  25. package/lib/module/package.json +1 -0
  26. package/lib/module/providers/GeminiProvider.js +294 -0
  27. package/lib/module/providers/GeminiProvider.js.map +1 -0
  28. package/lib/module/utils/logger.js +17 -0
  29. package/lib/module/utils/logger.js.map +1 -0
  30. package/lib/typescript/package.json +1 -0
  31. package/lib/typescript/src/components/AIAgent.d.ts +65 -0
  32. package/lib/typescript/src/components/AIAgent.d.ts.map +1 -0
  33. package/lib/typescript/src/components/AgentChatBar.d.ts +15 -0
  34. package/lib/typescript/src/components/AgentChatBar.d.ts.map +1 -0
  35. package/lib/typescript/src/components/AgentOverlay.d.ts +10 -0
  36. package/lib/typescript/src/components/AgentOverlay.d.ts.map +1 -0
  37. package/lib/typescript/src/core/AgentRuntime.d.ts +53 -0
  38. package/lib/typescript/src/core/AgentRuntime.d.ts.map +1 -0
  39. package/lib/typescript/src/core/FiberTreeWalker.d.ts +31 -0
  40. package/lib/typescript/src/core/FiberTreeWalker.d.ts.map +1 -0
  41. package/lib/typescript/src/core/MCPBridge.d.ts +23 -0
  42. package/lib/typescript/src/core/MCPBridge.d.ts.map +1 -0
  43. package/lib/typescript/src/core/ScreenDehydrator.d.ts +20 -0
  44. package/lib/typescript/src/core/ScreenDehydrator.d.ts.map +1 -0
  45. package/lib/typescript/src/core/systemPrompt.d.ts +9 -0
  46. package/lib/typescript/src/core/systemPrompt.d.ts.map +1 -0
  47. package/lib/typescript/src/core/types.d.ts +176 -0
  48. package/lib/typescript/src/core/types.d.ts.map +1 -0
  49. package/lib/typescript/src/hooks/useAction.d.ts +13 -0
  50. package/lib/typescript/src/hooks/useAction.d.ts.map +1 -0
  51. package/lib/typescript/src/index.d.ts +10 -0
  52. package/lib/typescript/src/index.d.ts.map +1 -0
  53. package/lib/typescript/src/providers/GeminiProvider.d.ts +43 -0
  54. package/lib/typescript/src/providers/GeminiProvider.d.ts.map +1 -0
  55. package/lib/typescript/src/utils/logger.d.ts +7 -0
  56. package/lib/typescript/src/utils/logger.d.ts.map +1 -0
  57. package/package.json +135 -12
  58. package/src/components/AIAgent.tsx +262 -0
  59. package/src/components/AgentChatBar.tsx +258 -0
  60. package/src/components/AgentOverlay.tsx +48 -0
  61. package/src/core/AgentRuntime.ts +661 -0
  62. package/src/core/FiberTreeWalker.ts +404 -0
  63. package/src/core/MCPBridge.ts +110 -0
  64. package/src/core/ScreenDehydrator.ts +53 -0
  65. package/src/core/systemPrompt.ts +162 -0
  66. package/src/core/types.ts +233 -0
  67. package/src/hooks/useAction.ts +40 -0
  68. package/src/index.ts +22 -0
  69. package/src/providers/GeminiProvider.ts +283 -0
  70. 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 CHANGED
@@ -1,23 +1,261 @@
1
- # react-native-agentic-ai
1
+ # MobileAI — React Native AI Agent
2
2
 
3
- > The AI Agent Runtime for React Native
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
4
 
5
- Give Gemini (or any LLM) the ability to **see, understand, and control** your React Native app screens.
5
+ **Two names, one package install either:**
6
6
 
7
- 🚧 **Under active development** first stable release coming soon.
7
+ | | Package | npm |
8
+ |---|---|---|
9
+ | 📦 | `@mobileai/react-native` | [![npm](https://img.shields.io/npm/v/@mobileai/react-native?label=latest)](https://www.npmjs.com/package/@mobileai/react-native) |
10
+ | 📦 | `react-native-agentic-ai` | [![npm](https://img.shields.io/npm/v/react-native-agentic-ai?label=latest)](https://www.npmjs.com/package/react-native-agentic-ai) |
8
11
 
9
- ## Concept
12
+ [![license](https://img.shields.io/npm/l/@mobileai/react-native)](https://github.com/mohamed2m2018/mobileai-react-native/blob/main/LICENSE)
13
+ [![platform](https://img.shields.io/badge/platform-iOS%20%7C%20Android-brightgreen)]()
10
14
 
11
- Instead of screenshot-based computer vision, `react-native-agentic-ai` builds a **Semantic Screen Graph** — a structured JSON representation of your app's interactive elements. This gives AI models a fast, precise, and secure "god view" of your app.
15
+ Wrap your navigation with `<AIAgent>`. The AI automatically understands your entire screen every button, every input, every label and acts on it.
12
16
 
13
- ## Features (Coming Soon)
17
+ ## Features
14
18
 
15
- - 📱 **Screen Registration** — Declaratively expose screens to the AI agent
16
- - 🎯 **Action System** — Built-in + custom actions (navigate, tap, type, scroll)
17
- - 🤖 **Gemini Integration** — Native function calling support
18
- - 🔒 **Safety Layer** — Confirmation dialogs, rate limiting, scope control
19
- - 🌍 **i18n** — English & Arabic support
19
+ - 🤖 **Zero-config UI understanding** — No need to annotate your views. The AI reads your UI automatically.
20
+ - 🧭 **Auto-navigation** — Navigates between screens to complete multi-step tasks.
21
+ - 🔒 **Production-grade security** — Element gating, content masking, lifecycle hooks, human-in-the-loop confirmation.
22
+ - 🧩 **Custom actions** — Expose any business logic (checkout, API calls) as AI-callable tools with `useAction`.
23
+ - 🌐 **MCP bridge** — Let external AI agents (OpenClaw, Claude Desktop) control your app remotely.
24
+ - 🌍 **Bilingual** — English and Arabic support built-in.
20
25
 
21
- ## License
26
+ ## 📦 Installation
22
27
 
23
- MIT
28
+ ```bash
29
+ npm install @mobileai/react-native
30
+ # — or —
31
+ npm install react-native-agentic-ai
32
+ ```
33
+
34
+ No native modules required. Works with Expo managed workflow out of the box — **no eject needed**.
35
+
36
+ ## 🚀 Quick Start
37
+
38
+ ```tsx
39
+ import { AIAgent } from '@mobileai/react-native';
40
+ // or: import { AIAgent } from 'react-native-agentic-ai';
41
+ import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
42
+
43
+ export default function App() {
44
+ const navRef = useNavigationContainerRef();
45
+
46
+ return (
47
+ <AIAgent apiKey="YOUR_GEMINI_API_KEY" navRef={navRef}>
48
+ <NavigationContainer ref={navRef}>
49
+ {/* Your existing screens — zero changes needed */}
50
+ </NavigationContainer>
51
+ </AIAgent>
52
+ );
53
+ }
54
+ ```
55
+
56
+ A floating chat bar appears automatically. Ask the AI to navigate, tap buttons, fill forms — it reads your live UI and acts.
57
+
58
+ ## 🔌 API Reference
59
+
60
+ ### `<AIAgent>` Component
61
+
62
+ The root provider. Wrap your app once at the top level.
63
+
64
+ | Prop | Type | Default | Description |
65
+ |------|------|---------|-------------|
66
+ | `apiKey` | `string` | — | **Required.** Gemini API key. |
67
+ | `model` | `string` | `'gemini-2.5-flash'` | Gemini model name. |
68
+ | `navRef` | `NavigationContainerRef` | — | Navigation ref for auto-navigation. |
69
+ | `language` | `'en' \| 'ar'` | `'en'` | UI language. |
70
+ | `maxSteps` | `number` | `10` | Max steps per task. |
71
+ | `showChatBar` | `boolean` | `true` | Show the floating chat bar. |
72
+ | `onResult` | `(result) => void` | — | Called when the agent finishes. |
73
+
74
+ ### `useAction(name, description, params, handler)`
75
+
76
+ Register a **non-UI action** the AI can call — for business logic that isn't a visible button.
77
+
78
+ ```tsx
79
+ import { useAction } from '@mobileai/react-native';
80
+ // or: import { useAction } from 'react-native-agentic-ai';
81
+
82
+ function CartScreen() {
83
+ const { clearCart, getTotal } = useCart();
84
+
85
+ useAction('checkout', 'Place the order', {}, async () => {
86
+ const total = getTotal();
87
+ clearCart();
88
+ return { success: true, message: `Order placed! Total: $${total}` };
89
+ });
90
+ }
91
+ ```
92
+
93
+ | Param | Type | Description |
94
+ |-------|------|-------------|
95
+ | `name` | `string` | Unique action name. |
96
+ | `description` | `string` | Natural language description for the AI. |
97
+ | `parameters` | `Record<string, string>` | Parameter schema (e.g., `{ itemName: 'string' }`). |
98
+ | `handler` | `(args) => any` | Execution handler. Can be sync or async. |
99
+
100
+ ## 🔒 Security
101
+
102
+ ### Element Gating
103
+
104
+ Hide specific elements from the AI:
105
+
106
+ ```tsx
107
+ // Per-element: add aiIgnore prop
108
+ <Pressable aiIgnore={true} onPress={handleAdmin}>
109
+ <Text>Admin Panel</Text>
110
+ </Pressable>
111
+
112
+ // Per-ref: blacklist by reference
113
+ const secretRef = useRef(null);
114
+ <AIAgent interactiveBlacklist={[secretRef]}>
115
+ <Pressable ref={secretRef}>Hidden from AI</Pressable>
116
+ </AIAgent>
117
+ ```
118
+
119
+ ### Content Masking
120
+
121
+ Sanitize sensitive data before the LLM sees it:
122
+
123
+ ```tsx
124
+ <AIAgent
125
+ transformScreenContent={(content) =>
126
+ content.replace(/\b\d{13,16}\b/g, '****-****-****-****')
127
+ }
128
+ />
129
+ ```
130
+
131
+ ### Screen-Specific Instructions
132
+
133
+ Guide the AI's behavior on sensitive screens:
134
+
135
+ ```tsx
136
+ <AIAgent
137
+ instructions={{
138
+ system: 'You are a food delivery assistant.',
139
+ getScreenInstructions: (screenName) => {
140
+ if (screenName === 'Cart') {
141
+ return 'Always confirm the total with the user before checkout.';
142
+ }
143
+ },
144
+ }}
145
+ />
146
+ ```
147
+
148
+ ### Human-in-the-Loop
149
+
150
+ Force native confirmation before critical actions:
151
+
152
+ ```tsx
153
+ useAction('checkout', 'Place the order', {}, () => {
154
+ return new Promise((resolve) => {
155
+ Alert.alert('Confirm?', 'Place this order?', [
156
+ { text: 'Cancel', onPress: () => resolve({ success: false }) },
157
+ { text: 'Yes', onPress: () => resolve({ success: true }) },
158
+ ]);
159
+ });
160
+ });
161
+ ```
162
+
163
+ ### Lifecycle Hooks
164
+
165
+ | Prop | Description |
166
+ |------|-------------|
167
+ | `onBeforeStep` | Called before each agent step. |
168
+ | `onAfterStep` | Called after each step with full history. |
169
+ | `onBeforeTask` | Called before task execution starts. |
170
+ | `onAfterTask` | Called after task completes. |
171
+
172
+ ## 🌐 MCP Bridge (Control Your App from Desktop AI)
173
+
174
+ The MCP (Model Context Protocol) bridge lets **external AI agents** — like Claude Desktop, OpenClaw, or any MCP-compatible client — remotely control your React Native app through natural language.
175
+
176
+ ### Architecture
177
+
178
+ ```
179
+ ┌──────────────────┐ SSE/HTTP ┌──────────────────┐ WebSocket ┌──────────────────┐
180
+ │ Claude Desktop │ ◄──────────────► │ MCP Server │ ◄─────────────► │ Your React │
181
+ │ or any MCP │ (port 3100) │ (Node.js) │ (port 3101) │ Native App │
182
+ │ compatible AI │ │ │ │ │
183
+ └──────────────────┘ └──────────────────┘ └──────────────────┘
184
+ ```
185
+
186
+ ### How It Works
187
+
188
+ 1. The **MCP server** (included in `mcp-server/`) runs on your machine as a Node.js process
189
+ 2. Your **React Native app** connects to the server via WebSocket (`ws://localhost:3101`)
190
+ 3. An **external AI** (e.g., Claude Desktop) connects to the MCP server via SSE (`http://localhost:3100/mcp/sse`)
191
+ 4. When Claude sends a command like *"Order 2 lemonades"*, the MCP server forwards it to your app
192
+ 5. Your app's `AgentRuntime` executes the task autonomously and sends back the result
193
+
194
+ ### Setup
195
+
196
+ **1. Start the MCP server:**
197
+
198
+ ```bash
199
+ cd mcp-server
200
+ npm install
201
+ npm start
202
+ ```
203
+
204
+ This starts two servers:
205
+ - **HTTP/SSE** on `http://localhost:3100` — for AI clients (Claude, OpenClaw)
206
+ - **WebSocket** on `ws://localhost:3101` — for your React Native app
207
+
208
+ **2. Connect your app:**
209
+
210
+ ```tsx
211
+ <AIAgent
212
+ apiKey="YOUR_GEMINI_KEY"
213
+ mcpServerUrl="ws://localhost:3101"
214
+ />
215
+ ```
216
+
217
+ **3. Connect Claude Desktop** — add this to your Claude config (`~/Library/Application Support/Claude/claude_desktop_config.json`):
218
+
219
+ ```json
220
+ {
221
+ "mcpServers": {
222
+ "mobile-app": {
223
+ "url": "http://localhost:3100/mcp/sse"
224
+ }
225
+ }
226
+ }
227
+ ```
228
+
229
+ ### Available MCP Tools
230
+
231
+ | Tool | Description |
232
+ |------|-------------|
233
+ | `execute_task(command)` | Send a natural language task to the app (e.g., *"Add a burger to cart"*) |
234
+ | `get_app_status()` | Check if the React Native app is currently connected |
235
+
236
+ ### Environment Variables
237
+
238
+ | Variable | Default | Description |
239
+ |----------|---------|-------------|
240
+ | `MCP_PORT` | `3100` | HTTP/SSE port for AI clients |
241
+ | `WS_PORT` | `3101` | WebSocket port for the React Native app |
242
+
243
+ ## 🛠️ Built-in Tools
244
+
245
+ | Tool | Description |
246
+ |------|-------------|
247
+ | `tap(index)` | Tap an interactive element. |
248
+ | `type(index, text)` | Type text into an input. |
249
+ | `navigate(screen)` | Navigate to a screen. |
250
+ | `done(text)` | Complete the task. |
251
+ | `ask_user(question)` | Ask the user for clarification. |
252
+
253
+ ## 📋 Requirements
254
+
255
+ - React Native 0.72+
256
+ - Expo SDK 49+ (or bare React Native)
257
+ - Gemini API key — [Get one free](https://aistudio.google.com/apikey)
258
+
259
+ ## 📄 License
260
+
261
+ MIT © [Mohamed Salah](https://github.com/mohamed2m2018)
@@ -0,0 +1,185 @@
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
+ router,
51
+ pathname
52
+ }) {
53
+ const rootViewRef = useRef(null);
54
+ const [isThinking, setIsThinking] = useState(false);
55
+ const [statusText, setStatusText] = useState('');
56
+ const [lastResult, setLastResult] = useState(null);
57
+
58
+ // Ref-based resolver for ask_user — stays alive across renders
59
+ const askUserResolverRef = useRef(null);
60
+
61
+ // ─── Create Runtime ──────────────────────────────────────────
62
+
63
+ const config = useMemo(() => ({
64
+ apiKey,
65
+ model,
66
+ language,
67
+ maxSteps,
68
+ interactiveBlacklist,
69
+ interactiveWhitelist,
70
+ onBeforeStep,
71
+ onAfterStep,
72
+ onBeforeTask,
73
+ onAfterTask,
74
+ transformScreenContent,
75
+ customTools,
76
+ instructions,
77
+ stepDelay,
78
+ mcpServerUrl,
79
+ router,
80
+ pathname,
81
+ onStatusUpdate: setStatusText,
82
+ // Page-agent pattern: block the agent loop until user responds
83
+ onAskUser: question => {
84
+ return new Promise(resolve => {
85
+ askUserResolverRef.current = resolve;
86
+ // Show question in chat bar, allow user input
87
+ setLastResult({
88
+ success: true,
89
+ message: `❓ ${question}`,
90
+ steps: []
91
+ });
92
+ setIsThinking(false);
93
+ setStatusText('');
94
+ });
95
+ }
96
+ }), [apiKey, model, language, maxSteps, interactiveBlacklist, interactiveWhitelist, onBeforeStep, onAfterStep, onBeforeTask, onAfterTask, transformScreenContent, customTools, instructions, stepDelay, mcpServerUrl, router, pathname]);
97
+ const provider = useMemo(() => new GeminiProvider(apiKey, model), [apiKey, model]);
98
+ const runtime = useMemo(() => new AgentRuntime(provider, config, rootViewRef.current, navRef),
99
+ // eslint-disable-next-line react-hooks/exhaustive-deps
100
+ [provider, config]);
101
+
102
+ // Update refs when they change
103
+ useEffect(() => {
104
+ runtime.updateRefs(rootViewRef.current, navRef);
105
+ }, [runtime, navRef]);
106
+
107
+ // ─── MCP Bridge ──────────────────────────────────────────────
108
+
109
+ useEffect(() => {
110
+ if (!mcpServerUrl) return;
111
+ logger.info('AIAgent', `Setting up MCP bridge at ${mcpServerUrl}`);
112
+ const bridge = new MCPBridge(mcpServerUrl, runtime);
113
+ return () => {
114
+ bridge.destroy();
115
+ };
116
+ }, [mcpServerUrl, runtime]);
117
+
118
+ // ─── Execute ──────────────────────────────────────────────────
119
+
120
+ const handleSend = useCallback(async message => {
121
+ if (!message.trim()) return;
122
+ logger.info('AIAgent', `User message: "${message}"`);
123
+
124
+ // If there's a pending ask_user, resolve it instead of starting a new execution
125
+ if (askUserResolverRef.current) {
126
+ const resolver = askUserResolverRef.current;
127
+ askUserResolverRef.current = null;
128
+ setIsThinking(true);
129
+ setStatusText('Processing your answer...');
130
+ setLastResult(null);
131
+ resolver(message);
132
+ return;
133
+ }
134
+
135
+ // Normal execution — new task
136
+ setIsThinking(true);
137
+ setStatusText('Thinking...');
138
+ setLastResult(null);
139
+ try {
140
+ // Ensure we have the latest Fiber tree ref
141
+ runtime.updateRefs(rootViewRef.current, navRef);
142
+ const result = await runtime.execute(message);
143
+ setLastResult(result);
144
+ onResult?.(result);
145
+ logger.info('AIAgent', `Result: ${result.success ? '✅' : '❌'} ${result.message}`);
146
+ } catch (error) {
147
+ logger.error('AIAgent', 'Execution failed:', error);
148
+ setLastResult({
149
+ success: false,
150
+ message: `Error: ${error.message}`,
151
+ steps: []
152
+ });
153
+ } finally {
154
+ setIsThinking(false);
155
+ setStatusText('');
156
+ }
157
+ }, [runtime, navRef, onResult]);
158
+
159
+ // ─── Render ──────────────────────────────────────────────────
160
+
161
+ return /*#__PURE__*/_jsxs(AgentContext.Provider, {
162
+ value: runtime,
163
+ children: [/*#__PURE__*/_jsx(View, {
164
+ ref: rootViewRef,
165
+ style: styles.root,
166
+ collapsable: false,
167
+ children: children
168
+ }), /*#__PURE__*/_jsx(AgentOverlay, {
169
+ visible: isThinking,
170
+ statusText: statusText
171
+ }), showChatBar && /*#__PURE__*/_jsx(AgentChatBar, {
172
+ onSend: handleSend,
173
+ isThinking: isThinking,
174
+ lastResult: lastResult,
175
+ language: language,
176
+ onDismiss: () => setLastResult(null)
177
+ })]
178
+ });
179
+ }
180
+ const styles = StyleSheet.create({
181
+ root: {
182
+ flex: 1
183
+ }
184
+ });
185
+ //# 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","router","pathname","rootViewRef","isThinking","setIsThinking","statusText","setStatusText","lastResult","setLastResult","askUserResolverRef","config","onStatusUpdate","onAskUser","question","Promise","resolve","current","success","message","steps","provider","runtime","updateRefs","info","bridge","destroy","handleSend","trim","resolver","result","execute","error","Provider","value","ref","style","styles","root","collapsable","visible","onSend","onDismiss","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;AAC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