@mobileai/react-native 0.1.0 → 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 (35) hide show
  1. package/README.md +78 -7
  2. package/lib/module/components/AIAgent.js +40 -4
  3. package/lib/module/components/AIAgent.js.map +1 -1
  4. package/lib/module/components/AgentChatBar.js +177 -29
  5. package/lib/module/components/AgentChatBar.js.map +1 -1
  6. package/lib/module/core/AgentRuntime.js +268 -126
  7. package/lib/module/core/AgentRuntime.js.map +1 -1
  8. package/lib/module/core/FiberTreeWalker.js +74 -20
  9. package/lib/module/core/FiberTreeWalker.js.map +1 -1
  10. package/lib/module/core/systemPrompt.js +164 -0
  11. package/lib/module/core/systemPrompt.js.map +1 -0
  12. package/lib/module/providers/GeminiProvider.js +189 -73
  13. package/lib/module/providers/GeminiProvider.js.map +1 -1
  14. package/lib/typescript/src/components/AIAgent.d.ts +9 -1
  15. package/lib/typescript/src/components/AIAgent.d.ts.map +1 -1
  16. package/lib/typescript/src/components/AgentChatBar.d.ts +4 -3
  17. package/lib/typescript/src/components/AgentChatBar.d.ts.map +1 -1
  18. package/lib/typescript/src/core/AgentRuntime.d.ts +16 -0
  19. package/lib/typescript/src/core/AgentRuntime.d.ts.map +1 -1
  20. package/lib/typescript/src/core/FiberTreeWalker.d.ts +5 -0
  21. package/lib/typescript/src/core/FiberTreeWalker.d.ts.map +1 -1
  22. package/lib/typescript/src/core/systemPrompt.d.ts +9 -0
  23. package/lib/typescript/src/core/systemPrompt.d.ts.map +1 -0
  24. package/lib/typescript/src/core/types.d.ts +51 -13
  25. package/lib/typescript/src/core/types.d.ts.map +1 -1
  26. package/lib/typescript/src/providers/GeminiProvider.d.ts +33 -13
  27. package/lib/typescript/src/providers/GeminiProvider.d.ts.map +1 -1
  28. package/package.json +16 -14
  29. package/src/components/AIAgent.tsx +41 -1
  30. package/src/components/AgentChatBar.tsx +150 -28
  31. package/src/core/AgentRuntime.ts +287 -131
  32. package/src/core/FiberTreeWalker.ts +74 -19
  33. package/src/core/systemPrompt.ts +162 -0
  34. package/src/core/types.ts +58 -10
  35. package/src/providers/GeminiProvider.ts +174 -101
@@ -23,6 +23,54 @@ const SWITCH_TYPES = new Set(['Switch', 'RCTSwitch']);
23
23
  const TEXT_TYPES = new Set(['Text', 'RCTText']);
24
24
  // ScrollView/FlatList/SectionList detection can be added later for scroll tool
25
25
 
26
+ // ─── State Extraction (mirrors page-agent DEFAULT_INCLUDE_ATTRIBUTES) ──
27
+
28
+ /** Props to extract as state attributes — covers lazy devs who skip accessibility */
29
+ const STATE_PROPS = ['value', 'checked', 'selected', 'active', 'on', 'isOn', 'toggled', 'enabled'];
30
+
31
+ /**
32
+ * Extract state attributes from a fiber node's props.
33
+ * Mirrors page-agent's DEFAULT_INCLUDE_ATTRIBUTES extraction.
34
+ * Priority: accessibilityState > accessibilityRole > direct scalar props.
35
+ */
36
+ function extractStateAttributes(props) {
37
+ const parts = [];
38
+
39
+ // Priority 1: accessibilityState (proper ARIA equivalent)
40
+ if (props.accessibilityState && typeof props.accessibilityState === 'object') {
41
+ for (const [k, v] of Object.entries(props.accessibilityState)) {
42
+ if (v !== undefined) parts.push(`${k}="${v}"`);
43
+ }
44
+ }
45
+
46
+ // Priority 2: accessibilityRole
47
+ if (props.accessibilityRole) {
48
+ parts.push(`role="${props.accessibilityRole}"`);
49
+ }
50
+
51
+ // Priority 3: Direct scalar props fallback (lazy developer support)
52
+ for (const key of STATE_PROPS) {
53
+ if (props[key] !== undefined && typeof props[key] !== 'function' && typeof props[key] !== 'object') {
54
+ parts.push(`${key}="${props[key]}"`);
55
+ }
56
+ }
57
+ return parts.join(' ');
58
+ }
59
+
60
+ /**
61
+ * Check if a node has ANY event handler prop (on* function).
62
+ * Mirrors RNTL's getEventHandlerFromProps pattern.
63
+ */
64
+ export function hasAnyEventHandler(props) {
65
+ if (!props || typeof props !== 'object') return false;
66
+ for (const key of Object.keys(props)) {
67
+ if (key.startsWith('on') && typeof props[key] === 'function') {
68
+ return true;
69
+ }
70
+ }
71
+ return false;
72
+ }
73
+
26
74
  // ─── Fiber Node Helpers ────────────────────────────────────────
27
75
 
28
76
  /**
@@ -51,22 +99,26 @@ function getElementType(fiber) {
51
99
  const name = getComponentName(fiber);
52
100
  const props = fiber.memoizedProps || {};
53
101
 
54
- // Check by component name
102
+ // Check by component name (known React Native types)
55
103
  if (name && PRESSABLE_TYPES.has(name)) return 'pressable';
56
104
  if (name && TEXT_INPUT_TYPES.has(name)) return 'text-input';
57
105
  if (name && SWITCH_TYPES.has(name)) return 'switch';
58
106
 
59
- // Check by props any component with onPress is interactive
60
- if (props.onPress && typeof props.onPress === 'function') return 'pressable';
61
-
62
- // Check by accessibility role
107
+ // Check by accessibilityRole (covers custom components with proper ARIA)
63
108
  const role = props.accessibilityRole || props.role;
109
+ if (role === 'switch') return 'switch';
64
110
  if (role === 'button' || role === 'link' || role === 'checkbox' || role === 'radio') {
65
- if (props.onPress) return 'pressable';
111
+ return 'pressable';
66
112
  }
67
113
 
114
+ // Check by props — any component with onPress is interactive
115
+ if (props.onPress && typeof props.onPress === 'function') return 'pressable';
116
+
68
117
  // TextInput detection by props
69
118
  if (props.onChangeText && typeof props.onChangeText === 'function') return 'text-input';
119
+
120
+ // Switch detection by props (custom switches with onValueChange)
121
+ if (props.onValueChange && typeof props.onValueChange === 'function') return 'switch';
70
122
  return null;
71
123
  }
72
124
 
@@ -230,35 +282,34 @@ export function walkFiberTree(rootRef, config) {
230
282
  const interactives = [];
231
283
  let currentIndex = 0;
232
284
  const hasWhitelist = config?.interactiveWhitelist && (config.interactiveWhitelist.length ?? 0) > 0;
233
- function processNode(node, depth = 0) {
285
+ function processNode(node, depth = 0, isInsideInteractive = false) {
234
286
  if (!node) return '';
235
287
  const props = node.memoizedProps || {};
236
288
 
237
289
  // ── Security Constraints ──
238
290
  if (props.aiIgnore === true) return '';
239
291
  if (matchesRefList(node, config?.interactiveBlacklist)) {
240
- // Blacklisted nodes themselves aren't interactive, but we still walk children for structure
241
292
  let childText = '';
242
293
  let currentChild = node.child;
243
294
  while (currentChild) {
244
- childText += processNode(currentChild, depth);
295
+ childText += processNode(currentChild, depth, isInsideInteractive);
245
296
  currentChild = currentChild.sibling;
246
297
  }
247
298
  return childText;
248
299
  }
249
300
 
250
- // Process all children first
301
+ // Interactive check skip if already inside an interactive ancestor (dedup nested TextInput layers)
302
+ const isWhitelisted = matchesRefList(node, config?.interactiveWhitelist);
303
+ const elementType = getElementType(node);
304
+ const shouldInclude = !isInsideInteractive && (hasWhitelist ? isWhitelisted : elementType && !isDisabled(node));
305
+
306
+ // Process children — if this node IS interactive, children won't register as separate interactives
251
307
  let childrenText = '';
252
308
  let currentChild = node.child;
253
309
  while (currentChild) {
254
- childrenText += processNode(currentChild, depth + 1);
310
+ childrenText += processNode(currentChild, depth + 1, isInsideInteractive || !!shouldInclude);
255
311
  currentChild = currentChild.sibling;
256
312
  }
257
-
258
- // Interactive Check
259
- const isWhitelisted = matchesRefList(node, config?.interactiveWhitelist);
260
- const elementType = getElementType(node);
261
- const shouldInclude = hasWhitelist ? isWhitelisted : elementType && !isDisabled(node);
262
313
  const indent = ' '.repeat(depth);
263
314
  if (shouldInclude) {
264
315
  const resolvedType = elementType || 'pressable';
@@ -266,8 +317,6 @@ export function walkFiberTree(rootRef, config) {
266
317
  if (!label && resolvedType === 'text-input' && props.placeholder) {
267
318
  label = props.placeholder;
268
319
  }
269
-
270
- // Record interactive element
271
320
  interactives.push({
272
321
  index: currentIndex,
273
322
  type: resolvedType,
@@ -275,9 +324,14 @@ export function walkFiberTree(rootRef, config) {
275
324
  fiberNode: node,
276
325
  props: {
277
326
  ...props
278
- } // snapshot
327
+ }
279
328
  });
280
- const elementOutput = `${indent}[${currentIndex}]<${resolvedType}>${label ? label + ' ' : ''}${childrenText.trim() ? childrenText.trim() : ''}</>\n`;
329
+
330
+ // Build output tag with state attributes (mirrors page-agent format)
331
+ const stateAttrs = extractStateAttributes(props);
332
+ const attrStr = stateAttrs ? ` ${stateAttrs}` : '';
333
+ const textContent = label || '';
334
+ const elementOutput = `${indent}[${currentIndex}]<${resolvedType}${attrStr}>${textContent} />${childrenText.trim() ? '\n' + childrenText : ''}\n`;
281
335
  currentIndex++;
282
336
  return elementOutput;
283
337
  }
@@ -1 +1 @@
1
- {"version":3,"names":["logger","PRESSABLE_TYPES","Set","TEXT_INPUT_TYPES","SWITCH_TYPES","TEXT_TYPES","getComponentName","fiber","type","displayName","name","render","getElementType","props","memoizedProps","has","onPress","role","accessibilityRole","onChangeText","isDisabled","disabled","editable","extractTextContent","maxDepth","parts","child","childName","childProps","sibling","text","extractRawText","children","push","nestedText","join","trim","String","Array","isArray","map","filter","Boolean","getFiberRoot","hook","globalThis","__REACT_DEVTOOLS_GLOBAL_HOOK__","renderers","size","rendererId","roots","getFiberRoots","fiberRoot","values","next","value","current","debug","e","getFiberFromRef","ref","rootFiber","_reactInternals","_reactInternalInstance","keys","Object","fiberKey","find","key","startsWith","warn","matchesRefList","node","refs","length","stateNode","walkFiberTree","rootRef","config","elementsText","interactives","currentIndex","hasWhitelist","interactiveWhitelist","processNode","depth","aiIgnore","interactiveBlacklist","childText","currentChild","childrenText","isWhitelisted","elementType","shouldInclude","indent","repeat","resolvedType","label","accessibilityLabel","placeholder","index","fiberNode","elementOutput","typeStr","textContent","replace","info"],"sourceRoot":"../../../src","sources":["core/FiberTreeWalker.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,oBAAiB;;AAGxC;;AASA;;AAEA;AACA,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAC9B,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,QAAQ,CACT,CAAC;AAEF,MAAMC,gBAAgB,GAAG,IAAID,GAAG,CAAC,CAAC,WAAW,EAAE,4BAA4B,EAAE,2BAA2B,CAAC,CAAC;AAC1G,MAAME,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WAAW;MACxD;IACF;IAEA,IAAIsD,YAAY,CAACtD,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;MAC9B,OAAO,GAAG0D,MAAM,WAAWJ,YAAY,GAAGI,MAAM,WAAW;IAC7D;IAEA,OAAO,EAAE;EACX;EAEA,IAAIf,YAAY,GAAGK,WAAW,CAAC7E,KAAK,EAAE,CAAC,CAAC;;EAExC;EACAwE,YAAY,GAAGA,YAAY,CAAC0B,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;EAEhEzG,MAAM,CAAC0G,IAAI,CAAC,iBAAiB,EAAE,SAAS1B,YAAY,CAACN,MAAM,uBAAuB,CAAC;EACnF,OAAO;IAAEK,YAAY,EAAEA,YAAY,CAAC3C,IAAI,CAAC,CAAC;IAAE4C;EAAa,CAAC;AAC5D","ignoreList":[]}
1
+ {"version":3,"names":["logger","PRESSABLE_TYPES","Set","TEXT_INPUT_TYPES","SWITCH_TYPES","TEXT_TYPES","STATE_PROPS","extractStateAttributes","props","parts","accessibilityState","k","v","Object","entries","undefined","push","accessibilityRole","key","join","hasAnyEventHandler","keys","startsWith","getComponentName","fiber","type","displayName","name","render","getElementType","memoizedProps","has","role","onPress","onChangeText","onValueChange","isDisabled","disabled","editable","extractTextContent","maxDepth","child","childName","childProps","sibling","text","extractRawText","children","nestedText","trim","String","Array","isArray","map","filter","Boolean","getFiberRoot","hook","globalThis","__REACT_DEVTOOLS_GLOBAL_HOOK__","renderers","size","rendererId","roots","getFiberRoots","fiberRoot","values","next","value","current","debug","e","getFiberFromRef","ref","rootFiber","_reactInternals","_reactInternalInstance","fiberKey","find","warn","matchesRefList","node","refs","length","stateNode","walkFiberTree","rootRef","config","elementsText","interactives","currentIndex","hasWhitelist","interactiveWhitelist","processNode","depth","isInsideInteractive","aiIgnore","interactiveBlacklist","childText","currentChild","isWhitelisted","elementType","shouldInclude","childrenText","indent","repeat","resolvedType","label","accessibilityLabel","placeholder","index","fiberNode","stateAttrs","attrStr","textContent","elementOutput","typ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AE,CAAC,CAAC;;EAExC;EACAgE,YAAY,GAAGA,YAAY,CAAC6B,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;EAEhErH,MAAM,CAACsH,IAAI,CAAC,iBAAiB,EAAE,SAAS7B,YAAY,CAACN,MAAM,uBAAuB,CAAC;EACnF,OAAO;IAAEK,YAAY,EAAEA,YAAY,CAACvC,IAAI,CAAC,CAAC;IAAEwC;EAAa,CAAC;AAC5D","ignoreList":[]}
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * System prompt for the AI agent — adapted from page-agent reference.
5
+ *
6
+ * Separated into its own file for maintainability.
7
+ * The prompt uses XML-style tags (matching page-agent's structure)
8
+ * to give the LLM clear, structured instructions.
9
+ */
10
+
11
+ export function buildSystemPrompt(language) {
12
+ const isArabic = language === 'ar';
13
+ return `You are an AI agent designed to operate in an iterative loop to automate tasks in a React Native mobile app. Your ultimate goal is accomplishing the task provided in <user_request>.
14
+
15
+ <intro>
16
+ You excel at the following tasks:
17
+ 1. Reading and understanding mobile app screens to extract precise information
18
+ 2. Automating UI interactions like tapping buttons and filling forms
19
+ 3. Gathering information from the screen and reporting it to the user
20
+ 4. Operating effectively in an agent loop
21
+ 5. Answering user questions based on what is visible on screen
22
+ </intro>
23
+
24
+ <language_settings>
25
+ ${isArabic ? '- Working language: **Arabic**. Respond in Arabic.' : '- Working language: **English**. Respond in English.'}
26
+ - Use the language that the user is using. Return in user's language.
27
+ </language_settings>
28
+
29
+ <input>
30
+ At every step, your input will consist of:
31
+ 1. <agent_history>: Your previous steps and their results.
32
+ 2. <user_request>: The user's original request.
33
+ 3. <screen_state>: Current screen name, available screens, and interactive elements indexed for actions.
34
+
35
+ Agent history uses the following format per step:
36
+ <step_N>
37
+ Previous Goal Eval: Assessment of last action
38
+ Memory: Key facts to remember
39
+ Plan: What you did next
40
+ Action Result: Result of the action
41
+ </step_N>
42
+
43
+ System messages may appear as <sys>...</sys> between steps.
44
+ </input>
45
+
46
+ <screen_state>
47
+ Interactive elements are listed as [index]<type attrs>label />
48
+ - index: numeric identifier for interaction
49
+ - type: element type (pressable, text-input, switch)
50
+ - attrs: state attributes like value="true", checked="false", role="switch"
51
+ - label: visible text content of the element
52
+
53
+ Only elements with [index] are interactive. Use the index to tap or type into them.
54
+ Pure text elements without [] are NOT interactive — they are informational content you can read.
55
+ </screen_state>
56
+
57
+ <tools>
58
+ Available tools:
59
+ - tap(index): Tap an interactive element by its index. Works universally on buttons, switches, and custom components. For switches, this toggles their state.
60
+ - type(index, text): Type text into a text-input element by its index.
61
+ - navigate(screen, params): Navigate to a specific screen. params is optional JSON object.
62
+ - done(text, success): Complete task. Text is your final response to the user — keep it concise unless the user explicitly asks for detail.
63
+ - ask_user(question): Ask the user for clarification ONLY when you cannot determine what action to take.
64
+ </tools>
65
+
66
+ <rules>
67
+ - There are 2 types of requests — always determine which type BEFORE acting:
68
+ 1. Information requests (e.g. "what's available?", "how much is X?", "list the items"):
69
+ Read the screen content and call done() with the answer. Do NOT perform any tap/type/navigate actions.
70
+ 2. Action requests (e.g. "add margherita to cart", "go to checkout", "fill in my name"):
71
+ Execute the required UI interactions using tap/type/navigate tools.
72
+ - For action requests, determine whether the user gave specific step-by-step instructions or an open-ended task:
73
+ 1. Specific instructions: Follow each step precisely, do not skip.
74
+ 2. Open-ended tasks: Plan the steps yourself.
75
+ - Only interact with elements that have an [index].
76
+ - After tapping an element, the screen may change. Wait for the next step to see updated elements.
77
+ - If the current screen doesn't have what you need, use navigate() to go to another screen.
78
+ - If a tap navigates to another screen, the next step will show the new screen's elements.
79
+ - Do not repeat one action for more than 3 times unless some conditions changed.
80
+ - After typing into a text input, check if the screen changed (e.g., suggestions or autocomplete appeared). If so, interact with the new elements.
81
+ - After typing into a search field, you may need to tap a search button, press enter, or select from a dropdown to complete the search.
82
+ - If the user request includes specific details (product type, price, category), use available filters or search to be more efficient.
83
+ - Do not fill in login/signup forms unless the user provides credentials. If asked to log in, use ask_user to request their email and password first.
84
+ - Do not guess or auto-fill sensitive data (passwords, payment info, personal details). Always ask the user.
85
+ - Trying too hard can be harmful. If stuck, call done() with partial results rather than repeating failed actions.
86
+ - If you do not know how to proceed with the current screen, use ask_user to request specific instructions from the user.
87
+ </rules>
88
+
89
+ <task_completion_rules>
90
+ You must call the done action in one of these cases:
91
+ - When you have fully completed the USER REQUEST.
92
+ - When the user asked for information and you can see the answer on screen.
93
+ - When you reach the final allowed step, even if the task is incomplete.
94
+ - When you feel stuck or unable to solve the user request.
95
+
96
+ BEFORE calling done() for action requests that changed state (added items, submitted forms, etc.):
97
+ 1. First, navigate to the result screen (e.g., Cart, confirmation, order summary) so the user can see the outcome.
98
+ 2. Wait for the next step to see the result screen content.
99
+ 3. THEN call done() with a summary of what you did.
100
+ Do NOT call done() immediately after the last action — the user needs to SEE the result.
101
+
102
+ The done action is your opportunity to communicate findings and provide a coherent reply to the user:
103
+ - Set success to true only if the full USER REQUEST has been completed.
104
+ - Use the text field to answer questions, summarize what you found, or explain what you did.
105
+ - You are ONLY ALLOWED to call done as a single action. Do not call it together with other actions.
106
+
107
+ The ask_user action should ONLY be used when the user gave an action request but you lack specific information to execute it (e.g., user says "order a pizza" but there are multiple options and you don't know which one).
108
+ - Do NOT use ask_user to confirm actions the user explicitly requested. If they said "place my order", just do it.
109
+ - NEVER ask for the same confirmation twice. If the user already answered, proceed with their answer.
110
+ - For destructive/purchase actions (place order, delete, pay), tap the button exactly ONCE. Do not repeat the same action — the user could be charged multiple times.
111
+ </task_completion_rules>
112
+
113
+ <capability>
114
+ - It is ok to just provide information without performing any actions.
115
+ - User can ask questions about what's on screen — answer them directly via done().
116
+ - It is ok to fail the task. User would rather you report failure than repeat failed actions endlessly.
117
+ - The user can be wrong. If the request is not achievable, tell the user via done().
118
+ - The app can have bugs. If something is not working as expected, report it to the user.
119
+ </capability>
120
+
121
+ <ux_rules>
122
+ UX best practices for mobile agent interactions:
123
+ - Confirm what you did: When completing actions, summarize exactly what happened (e.g., "Added 2x Margherita ($10 each) to your cart. Total: $20").
124
+ - Be transparent about errors: If an action fails, explain what failed and why — do not silently skip it or pretend it succeeded.
125
+ - Track multi-item progress: For requests involving multiple items, keep track and report which ones succeeded and which did not.
126
+ - Stay on the user's screen: For information requests, read from the current screen. Only navigate away if the needed information is on another screen.
127
+ - Fail gracefully: If stuck after multiple attempts, call done() with what you accomplished and what remains, rather than repeating failed actions.
128
+ - Be concise: Keep responses short and actionable. Users are on mobile — avoid walls of text.
129
+ - Suggest next steps: After completing an action, briefly suggest what the user might want to do next (e.g., "Added to cart. Would you like to checkout or add more items?").
130
+ - When a request is ambiguous, pick the most common interpretation rather than always asking. State your assumption in the done() text.
131
+ </ux_rules>
132
+
133
+ <reasoning_rules>
134
+ Exhibit the following reasoning patterns to successfully achieve the <user_request>:
135
+ - Reason about <agent_history> to track progress and context toward <user_request>.
136
+ - Analyze the most recent action result in <agent_history> and clearly state what you previously tried to achieve.
137
+ - Explicitly judge success/failure of the last action. If the expected change is missing, mark the last action as failed and plan a recovery.
138
+ - Analyze whether you are stuck, e.g. when you repeat the same actions multiple times without any progress. Then consider alternative approaches.
139
+ - If you see information relevant to <user_request>, include it in your response via done().
140
+ - Always compare the current trajectory with the user request — make sure every action moves you closer to the goal.
141
+ - Save important information to memory: field values you collected, items found, pages visited, etc.
142
+ </reasoning_rules>
143
+
144
+ <output>
145
+ You MUST call the agent_step tool on every step. Provide:
146
+
147
+ 1. previous_goal_eval: "One-sentence result of your last action — success, failure, or uncertain. Skip on first step."
148
+ 2. memory: "Key facts to persist: values collected, items found, progress so far. Be specific."
149
+ 3. plan: "Your immediate next goal — what action you will take and why."
150
+ 4. action_name: Choose one action to execute
151
+ 5. Action parameters (index, text, screen, etc. depending on the action)
152
+
153
+ Examples:
154
+
155
+ previous_goal_eval: "Typed email into field [0]. Verdict: Success"
156
+ memory: "Email: user@test.com entered. Still need password."
157
+ plan: "Ask the user for their password using ask_user."
158
+
159
+ previous_goal_eval: "Navigated to Cart screen. Verdict: Success"
160
+ memory: "Added 2x Margherita pizza. Cart total visible."
161
+ plan: "Call done to report the cart contents to the user."
162
+ </output>`;
163
+ }
164
+ //# sourceMappingURL=systemPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["buildSystemPrompt","language","isArabic"],"sourceRoot":"../../../src","sources":["core/systemPrompt.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASA,iBAAiBA,CAACC,QAAgB,EAAU;EAC1D,MAAMC,QAAQ,GAAGD,QAAQ,KAAK,IAAI;EAElC,OAAO;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAEC,QAAQ,GAAG,oDAAoD,GAAG,sDAAsD;AAC1H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV","ignoreList":[]}