@mobileai/react-native 0.9.4 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -131
- package/ios/MobileAIPilotIntents.swift +51 -0
- package/lib/module/__cli_tmp__.js +21 -0
- package/lib/module/__cli_tmp__.js.map +1 -0
- package/lib/module/components/AIAgent.js.map +1 -1
- package/lib/module/components/AgentChatBar.js +2 -3
- package/lib/module/components/AgentChatBar.js.map +1 -1
- package/lib/module/components/HighlightOverlay.js +1 -0
- package/lib/module/components/HighlightOverlay.js.map +1 -1
- package/lib/module/core/ActionRegistry.js +102 -0
- package/lib/module/core/ActionRegistry.js.map +1 -0
- package/lib/module/core/AgentRuntime.js +25 -22
- package/lib/module/core/AgentRuntime.js.map +1 -1
- package/lib/module/core/MCPBridge.js +77 -14
- package/lib/module/core/MCPBridge.js.map +1 -1
- package/lib/module/hooks/useAction.js +47 -11
- package/lib/module/hooks/useAction.js.map +1 -1
- package/lib/module/index.js +3 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugin/withAppIntents.js +71 -0
- package/lib/module/plugin/withAppIntents.js.map +1 -0
- package/lib/module/services/AudioInputService.js +2 -2
- package/lib/module/services/AudioInputService.js.map +1 -1
- package/lib/module/services/AudioOutputService.js +3 -2
- package/lib/module/services/AudioOutputService.js.map +1 -1
- package/lib/module/tools/guideTool.js +11 -2
- package/lib/module/tools/guideTool.js.map +1 -1
- package/lib/module/tools/typeTool.js +53 -63
- package/lib/module/tools/typeTool.js.map +1 -1
- package/lib/typescript/src/__cli_tmp__.d.ts +2 -0
- package/lib/typescript/src/__cli_tmp__.d.ts.map +1 -0
- package/lib/typescript/src/components/AIAgent.d.ts +0 -3
- package/lib/typescript/src/components/AIAgent.d.ts.map +1 -1
- package/lib/typescript/src/components/AgentChatBar.d.ts.map +1 -1
- package/lib/typescript/src/core/ActionRegistry.d.ts +43 -0
- package/lib/typescript/src/core/ActionRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/AgentRuntime.d.ts +2 -4
- package/lib/typescript/src/core/AgentRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/MCPBridge.d.ts.map +1 -1
- package/lib/typescript/src/core/types.d.ts +20 -2
- package/lib/typescript/src/core/types.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useAction.d.ts +34 -2
- package/lib/typescript/src/hooks/useAction.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugin/withAppIntents.d.ts +10 -0
- package/lib/typescript/src/plugin/withAppIntents.d.ts.map +1 -0
- package/lib/typescript/src/services/AudioOutputService.d.ts.map +1 -1
- package/lib/typescript/src/tools/guideTool.d.ts.map +1 -1
- package/lib/typescript/src/tools/typeTool.d.ts +9 -18
- package/lib/typescript/src/tools/typeTool.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/__cli_tmp__.tsx +9 -0
- package/src/cli/generate-intents.ts +140 -0
- package/src/cli/generate-swift.ts +116 -0
- package/src/components/AIAgent.tsx +1 -4
- package/src/components/AgentChatBar.tsx +2 -3
- package/src/components/HighlightOverlay.tsx +1 -1
- package/src/core/ActionRegistry.ts +105 -0
- package/src/core/AgentRuntime.ts +23 -25
- package/src/core/MCPBridge.ts +68 -15
- package/src/core/types.ts +23 -2
- package/src/hooks/useAction.ts +51 -10
- package/src/index.ts +7 -9
- package/src/plugin/withAppIntents.ts +82 -0
- package/src/services/AudioInputService.ts +2 -2
- package/src/services/AudioOutputService.ts +3 -2
- package/src/tools/guideTool.ts +11 -2
- package/src/tools/typeTool.ts +55 -67
|
@@ -86,8 +86,16 @@ export interface AgentConfig {
|
|
|
86
86
|
* Optional specific headers for voiceProxyUrl.
|
|
87
87
|
*/
|
|
88
88
|
voiceProxyHeaders?: Record<string, string>;
|
|
89
|
-
model?: string;
|
|
89
|
+
model?: string;
|
|
90
|
+
/** Maximum steps per task */
|
|
90
91
|
maxSteps?: number;
|
|
92
|
+
/**
|
|
93
|
+
* MCP server mode — controls whether external agents can discover and invoke actions.
|
|
94
|
+
* 'auto' (default): enabled in __DEV__, disabled in production
|
|
95
|
+
* 'enabled': always on (opt-in for production)
|
|
96
|
+
* 'disabled': always off
|
|
97
|
+
*/
|
|
98
|
+
mcpServerMode?: 'auto' | 'enabled' | 'disabled';
|
|
91
99
|
/**
|
|
92
100
|
* React refs of elements the AI must NOT interact with.
|
|
93
101
|
* Refs of elements the AI must NOT interact with.
|
|
@@ -228,10 +236,20 @@ export interface ToolParam {
|
|
|
228
236
|
required?: boolean;
|
|
229
237
|
enum?: string[];
|
|
230
238
|
}
|
|
239
|
+
export interface ActionParameterDef {
|
|
240
|
+
/** The primitive type of the parameter. Maps to MCP schemas and native iOS/Android types. */
|
|
241
|
+
type: 'string' | 'number' | 'boolean';
|
|
242
|
+
/** A clear description of what the parameter is for (read by the AI). */
|
|
243
|
+
description: string;
|
|
244
|
+
/** Whether the AI must provide this parameter. Defaults to true. */
|
|
245
|
+
required?: boolean;
|
|
246
|
+
/** If provided, the AI is restricted to these specific string values. */
|
|
247
|
+
enum?: string[];
|
|
248
|
+
}
|
|
231
249
|
export interface ActionDefinition {
|
|
232
250
|
name: string;
|
|
233
251
|
description: string;
|
|
234
|
-
parameters: Record<string, string>;
|
|
252
|
+
parameters: Record<string, string | ActionParameterDef>;
|
|
235
253
|
handler: (args: Record<string, any>) => any;
|
|
236
254
|
}
|
|
237
255
|
/** A single knowledge entry the AI can retrieve. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAIzC,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAIjD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,YAAY,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MAAM,CAAC;IACnB,wGAAwG;IACxG,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CACrD"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Both hooks consume AgentContext, which is provided by <AIAgent>.
|
|
6
6
|
*/
|
|
7
|
+
import React from 'react';
|
|
7
8
|
import type { AgentRuntime } from '../core/AgentRuntime';
|
|
8
9
|
import type { ExecutionResult, AIMessage } from '../core/types';
|
|
9
10
|
export interface AgentContextValue {
|
|
@@ -25,8 +26,39 @@ export interface AgentContextValue {
|
|
|
25
26
|
/** Cancel the currently running task. */
|
|
26
27
|
cancel: () => void;
|
|
27
28
|
}
|
|
28
|
-
export declare const AgentContext:
|
|
29
|
-
|
|
29
|
+
export declare const AgentContext: React.Context<AgentContextValue>;
|
|
30
|
+
import type { ActionParameterDef } from '../core/types';
|
|
31
|
+
/**
|
|
32
|
+
* Register a non-UI action that the AI agent can call by name.
|
|
33
|
+
*
|
|
34
|
+
* The handler is always kept fresh via an internal ref — no stale closure bugs,
|
|
35
|
+
* even when it captures mutable state like cart contents or form values.
|
|
36
|
+
*
|
|
37
|
+
* The optional `deps` array controls when the action is *re-registered* (i.e. when
|
|
38
|
+
* `name`, `description`, or `parameters` need to change at runtime). You rarely
|
|
39
|
+
* need this — the handler is always up-to-date regardless.
|
|
40
|
+
*
|
|
41
|
+
* @example Basic (handler always fresh — no deps needed)
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const { cart } = useCart();
|
|
44
|
+
* useAction('checkout', 'Place the order', {}, async () => {
|
|
45
|
+
* if (cart.length === 0) return { success: false, message: 'Cart is empty' };
|
|
46
|
+
* // cart is always current — no stale closure
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example Dynamic description (re-register when item count changes)
|
|
51
|
+
* ```tsx
|
|
52
|
+
* useAction(
|
|
53
|
+
* 'checkout',
|
|
54
|
+
* `Place the order (${cart.length} items in cart)`,
|
|
55
|
+
* {},
|
|
56
|
+
* handler,
|
|
57
|
+
* [cart.length], // re-register so the AI sees the updated description
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function useAction(name: string, description: string, parameters: Record<string, string | ActionParameterDef>, handler: (args: Record<string, any>) => any, deps?: React.DependencyList): void;
|
|
30
62
|
/**
|
|
31
63
|
* Bridge hook — reads the parent <AIAgent>'s state.
|
|
32
64
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAction.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useAction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"useAction.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useAction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAIhE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,yEAAyE;IACzE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5F,kFAAkF;IAClF,SAAS,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,yDAAyD;IACzD,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,sCAAsC;IACtC,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,yCAAyC;IACzC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAaD,eAAO,MAAM,YAAY,kCAAoD,CAAC;AAG9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC,EACvD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,EAC3C,IAAI,CAAC,EAAE,KAAK,CAAC,cAAc,GAC1B,IAAI,CA0BN;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;CAC9C;IA2BG,sCAAsC;oBALL,MAAM;IAOvC,gDAAgD;;IAEhD,0DAA0D;;IAE1D,8CAA8C;;IAE9C,qCAAqC;;IAErC,sCAAsC;yBAtJnB,IAAI;IAwJvB,yFAAyF;kBAtJ7E,IAAI;EAyJnB"}
|
|
@@ -16,9 +16,11 @@ export { VoiceService } from './services/VoiceService';
|
|
|
16
16
|
export { AudioInputService } from './services/AudioInputService';
|
|
17
17
|
export { AudioOutputService } from './services/AudioOutputService';
|
|
18
18
|
export { KnowledgeBaseService } from './services/KnowledgeBaseService';
|
|
19
|
+
export { MobileAI } from './services/telemetry';
|
|
19
20
|
export { logger } from './utils/logger';
|
|
20
21
|
export type { AgentConfig, AgentMode, ExecutionResult, InteractiveElement, DehydratedScreen, ToolDefinition, ActionDefinition, TokenUsage, KnowledgeEntry, KnowledgeRetriever, KnowledgeBaseConfig, ChatBarTheme, AIMessage, AIProviderName, ScreenMap, ScreenMapEntry, } from './core/types';
|
|
21
22
|
export type { VoiceServiceConfig, VoiceServiceCallbacks, VoiceStatus, } from './services/VoiceService';
|
|
22
|
-
export {
|
|
23
|
+
export type { TelemetryConfig, TelemetryEvent, } from './services/telemetry';
|
|
24
|
+
export { SupportGreeting, CSATSurvey, buildSupportPrompt, createEscalateTool, EscalationSocket } from './support';
|
|
23
25
|
export type { SupportModeConfig, QuickReply, EscalationConfig, EscalationContext, CSATConfig, CSATRating, BusinessHoursConfig, } from './support';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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AAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,mBAAmB,GACpB,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ConfigPlugin } from 'expo/config-plugins';
|
|
2
|
+
interface PluginOptions {
|
|
3
|
+
/** The source directory to scan for useAction calls. Defaults to 'src' */
|
|
4
|
+
scanDirectory?: string;
|
|
5
|
+
/** App scheme for deep links. Defaults to the scheme in app.json */
|
|
6
|
+
appScheme?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const withAppIntents: ConfigPlugin<PluginOptions | void>;
|
|
9
|
+
export default withAppIntents;
|
|
10
|
+
//# sourceMappingURL=withAppIntents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withAppIntents.d.ts","sourceRoot":"","sources":["../../../../src/plugin/withAppIntents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOxD,UAAU,aAAa;IACrB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,cAAc,EAAE,YAAY,CAAC,aAAa,GAAG,IAAI,CAiEtD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioOutputService.d.ts","sourceRoot":"","sources":["../../../../src/services/AudioOutputService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAID,qBAA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"file":"guideTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/guideTool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"guideTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/guideTool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAsEpE"}
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type Tool — Reliable multi-strategy text input.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* For uncontrolled TextInputs (defaultValue, no onChangeText):
|
|
5
|
+
* 1. Walk fiber subtree (BFS) to find the native host view whose
|
|
6
|
+
* memoizedProps has `onChange` — this is RN's internal `_onChange`.
|
|
7
|
+
* 2. ALSO walk to find the native stateNode with `setNativeProps` to
|
|
8
|
+
* update the VISUAL text in the native view.
|
|
5
9
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
10
|
+
* Both steps are needed:
|
|
11
|
+
* - `onChange` → updates React's internal lastNativeText state
|
|
12
|
+
* - `setNativeProps` → updates what the user sees on screen
|
|
8
13
|
*
|
|
9
|
-
*
|
|
10
|
-
* React Native's TextInput.js always creates an internal `_onChange` handler
|
|
11
|
-
* and passes it as `onChange` to the native host view (RCTTextInputView /
|
|
12
|
-
* AndroidTextInput). That `_onChange` internally calls `props.onChangeText`
|
|
13
|
-
* and updates native text state.
|
|
14
|
-
*
|
|
15
|
-
* We walk the fiber subtree (behavior-based, no tag numbers) to find any
|
|
16
|
-
* descendant node whose memoizedProps.onChange is a function. Then we call
|
|
17
|
-
* it with a synthetic TextInputChangeEvent. This triggers RN's internal
|
|
18
|
-
* `_onChange` which calls `setLastNativeText` and updates the native view.
|
|
19
|
-
*
|
|
20
|
-
* Why this is robust:
|
|
21
|
-
* - No hardcoded fiber tag numbers (host component tags can change across versions)
|
|
22
|
-
* - No dependency on setNativeProps (deprecated in New Architecture / Fabric)
|
|
23
|
-
* - Uses the same code path as a real user typing — RN's own _onChange handler
|
|
14
|
+
* No hardcoded fiber tag numbers. Detection is purely behavior-based.
|
|
24
15
|
*/
|
|
25
16
|
import type { AgentTool, ToolContext } from './types';
|
|
26
17
|
export declare function createTypeTool(context: ToolContext): AgentTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/typeTool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"typeTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/typeTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAgBtD,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CA+E9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobileai/react-native",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "Build autonomous AI agents for React Native and Expo apps. Provides AI-native UI traversal, tool calling, and structured reasoning.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -169,6 +169,9 @@
|
|
|
169
169
|
},
|
|
170
170
|
"jest": {
|
|
171
171
|
"preset": "react-native",
|
|
172
|
+
"setupFilesAfterEnv": [
|
|
173
|
+
"<rootDir>/src/__tests__/setup.ts"
|
|
174
|
+
],
|
|
172
175
|
"testMatch": [
|
|
173
176
|
"**/?(*.)+(spec|test).[jt]s?(x)"
|
|
174
177
|
],
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useAction } from './hooks/useAction';
|
|
2
|
+
|
|
3
|
+
export function CheckoutScreen() {
|
|
4
|
+
useAction('checkout_cart', 'Process checkout', {
|
|
5
|
+
amount: { type: 'number', description: 'Total amount' },
|
|
6
|
+
currency: { type: 'string', description: 'Currency code', enum: ['USD', 'EUR'] },
|
|
7
|
+
isExpress: { type: 'boolean', description: 'Express checkout' }
|
|
8
|
+
}, async () => {});
|
|
9
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { parse } from '@babel/parser';
|
|
6
|
+
import traverse from '@babel/traverse';
|
|
7
|
+
// @ts-ignore - no types installed
|
|
8
|
+
import glob from 'glob';
|
|
9
|
+
|
|
10
|
+
// Define the schema format for our extracted intents
|
|
11
|
+
export interface ExtractedIntent {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
parameters: Record<string, any>;
|
|
15
|
+
sourceFile: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validates and statically extracts `useAction` and `registerAction` definitions
|
|
20
|
+
* from a target directory by parsing the AST of all TS/JS files.
|
|
21
|
+
*/
|
|
22
|
+
export function extractIntentsFromAST(sourceDir: string): ExtractedIntent[] {
|
|
23
|
+
const files = glob.sync(`${sourceDir}/**/*.{ts,tsx,js,jsx}`, {
|
|
24
|
+
ignore: ['**/node_modules/**', '**/*.d.ts', '**/__tests__/**']
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const intents: ExtractedIntent[] = [];
|
|
28
|
+
|
|
29
|
+
for (const file of files) {
|
|
30
|
+
const code = fs.readFileSync(file, 'utf-8');
|
|
31
|
+
|
|
32
|
+
// Quick heuristic: ignore files that don't even talk about useAction
|
|
33
|
+
if (!code.includes('useAction') && !code.includes('registerAction')) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const ast = parse(code, {
|
|
39
|
+
sourceType: 'module',
|
|
40
|
+
plugins: ['jsx', 'typescript'],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
traverse(ast, {
|
|
44
|
+
CallExpression(pathNode: any) {
|
|
45
|
+
const callee = pathNode.node.callee;
|
|
46
|
+
if (
|
|
47
|
+
callee.type === 'Identifier' &&
|
|
48
|
+
(callee.name === 'useAction' || callee.name === 'registerAction')
|
|
49
|
+
) {
|
|
50
|
+
const args = pathNode.node.arguments;
|
|
51
|
+
if (args.length >= 2) {
|
|
52
|
+
const nameArg = args[0];
|
|
53
|
+
const descArg = args[1];
|
|
54
|
+
const schemaArg = args[2];
|
|
55
|
+
|
|
56
|
+
// We only process if name and desc are static string literals
|
|
57
|
+
if (nameArg.type === 'StringLiteral' && descArg.type === 'StringLiteral') {
|
|
58
|
+
const name = nameArg.value;
|
|
59
|
+
const description = descArg.value;
|
|
60
|
+
let parameters: Record<string, any> = {};
|
|
61
|
+
|
|
62
|
+
// Parse schema object if provided
|
|
63
|
+
if (schemaArg && schemaArg.type === 'ObjectExpression') {
|
|
64
|
+
parameters = parseObjectExpression(schemaArg);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
intents.push({
|
|
68
|
+
name,
|
|
69
|
+
description,
|
|
70
|
+
parameters,
|
|
71
|
+
sourceFile: path.relative(process.cwd(), file)
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} catch (error: any) {
|
|
79
|
+
console.warn(`[WARN] Skipping file ${file} due to parse error: ${error.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return intents;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Naively converts an AST ObjectExpression back to a JS Runtime object.
|
|
88
|
+
* Assumes the schema is statically defined (no variables/computed keys).
|
|
89
|
+
*/
|
|
90
|
+
function parseObjectExpression(node: any): any {
|
|
91
|
+
const result: any = {};
|
|
92
|
+
for (const prop of node.properties) {
|
|
93
|
+
if (prop.type === 'ObjectProperty' && prop.key.type === 'Identifier') {
|
|
94
|
+
const key = prop.key.name;
|
|
95
|
+
|
|
96
|
+
if (prop.value.type === 'StringLiteral') {
|
|
97
|
+
result[key] = prop.value.value;
|
|
98
|
+
} else if (prop.value.type === 'NumericLiteral') {
|
|
99
|
+
result[key] = prop.value.value;
|
|
100
|
+
} else if (prop.value.type === 'BooleanLiteral') {
|
|
101
|
+
result[key] = prop.value.value;
|
|
102
|
+
} else if (prop.value.type === 'ObjectExpression') {
|
|
103
|
+
result[key] = parseObjectExpression(prop.value);
|
|
104
|
+
} else if (prop.value.type === 'ArrayExpression') {
|
|
105
|
+
result[key] = prop.value.elements.map((el: any) => {
|
|
106
|
+
if (el.type === 'StringLiteral') return el.value;
|
|
107
|
+
if (el.type === 'NumericLiteral') return el.value;
|
|
108
|
+
return null;
|
|
109
|
+
}).filter(Boolean);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function main() {
|
|
117
|
+
const sourceDir = process.argv[2] || 'src';
|
|
118
|
+
const outPath = process.argv[3] || 'intent-manifest.json';
|
|
119
|
+
|
|
120
|
+
const absoluteSource = path.resolve(process.cwd(), sourceDir);
|
|
121
|
+
const absoluteOut = path.resolve(process.cwd(), outPath);
|
|
122
|
+
|
|
123
|
+
console.log(`Scanning ${absoluteSource} for AI Actions...`);
|
|
124
|
+
|
|
125
|
+
const intents = extractIntentsFromAST(absoluteSource);
|
|
126
|
+
|
|
127
|
+
console.log(`Found ${intents.length} actions.`);
|
|
128
|
+
intents.forEach(i => console.log(` - ${i.name} (from ${i.sourceFile})`));
|
|
129
|
+
|
|
130
|
+
fs.writeFileSync(absoluteOut, JSON.stringify(intents, null, 2));
|
|
131
|
+
console.log(`\n✅ Wrote intent manifest to ${outPath}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Run if called directly
|
|
135
|
+
if (require.main === module) {
|
|
136
|
+
main().catch(err => {
|
|
137
|
+
console.error(err);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
|
|
6
|
+
export function generateSwiftCode(manifestPath: string, appScheme: string): string {
|
|
7
|
+
const manifests = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
8
|
+
|
|
9
|
+
let swiftCode = `import AppIntents
|
|
10
|
+
import UIKit
|
|
11
|
+
|
|
12
|
+
// Auto-generated by react-native-ai-agent
|
|
13
|
+
// Do not edit manually.
|
|
14
|
+
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
for (const intent of manifests) {
|
|
18
|
+
// Convert snake_case to CamelCaseIntent
|
|
19
|
+
const structName = intent.name
|
|
20
|
+
.split('_')
|
|
21
|
+
.map((w: string) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
22
|
+
.join('') + 'Intent';
|
|
23
|
+
|
|
24
|
+
swiftCode += `@available(iOS 16.0, *)\n`;
|
|
25
|
+
swiftCode += `struct ${structName}: AppIntent {\n`;
|
|
26
|
+
swiftCode += ` static var title: LocalizedStringResource = "${intent.name}"\n`;
|
|
27
|
+
swiftCode += ` static var description = IntentDescription("${intent.description.replace(/"/g, '\\"')}")\n`;
|
|
28
|
+
swiftCode += ` static var openAppWhenRun: Bool = true\n\n`;
|
|
29
|
+
|
|
30
|
+
// Parameters
|
|
31
|
+
const params = intent.parameters || {};
|
|
32
|
+
for (const [key, param] of Object.entries<any>(params)) {
|
|
33
|
+
let swiftType = 'String';
|
|
34
|
+
if (param.type === 'number') swiftType = 'Double';
|
|
35
|
+
if (param.type === 'boolean') swiftType = 'Bool';
|
|
36
|
+
|
|
37
|
+
swiftCode += ` @Parameter(title: "${param.description || key}")\n`;
|
|
38
|
+
swiftCode += ` var ${key}: ${swiftType}?\n\n`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Perform function
|
|
42
|
+
swiftCode += ` @MainActor\n`;
|
|
43
|
+
swiftCode += ` func perform() async throws -> some IntentResult {\n`;
|
|
44
|
+
swiftCode += ` var components = URLComponents()\n`;
|
|
45
|
+
swiftCode += ` components.scheme = "${appScheme}"\n`;
|
|
46
|
+
swiftCode += ` components.host = "ai-action"\n`;
|
|
47
|
+
swiftCode += ` components.path = "/${intent.name}"\n`;
|
|
48
|
+
|
|
49
|
+
if (Object.keys(params).length > 0) {
|
|
50
|
+
swiftCode += ` var queryItems: [URLQueryItem] = []\n`;
|
|
51
|
+
for (const [key, _param] of Object.entries<any>(params)) {
|
|
52
|
+
swiftCode += ` if let val = ${key} {\n`;
|
|
53
|
+
swiftCode += ` queryItems.append(URLQueryItem(name: "${key}", value: String(describing: val)))\n`;
|
|
54
|
+
swiftCode += ` }\n`;
|
|
55
|
+
}
|
|
56
|
+
swiftCode += ` components.queryItems = queryItems\n`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
swiftCode += ` if let url = components.url {\n`;
|
|
60
|
+
swiftCode += ` await UIApplication.shared.open(url)\n`;
|
|
61
|
+
swiftCode += ` }\n`;
|
|
62
|
+
swiftCode += ` return .result()\n`;
|
|
63
|
+
swiftCode += ` }\n`;
|
|
64
|
+
swiftCode += `}\n\n`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// AppShortcuts provider (exposes intents to Siri automatically)
|
|
68
|
+
if (manifests.length > 0) {
|
|
69
|
+
swiftCode += `@available(iOS 16.0, *)\n`;
|
|
70
|
+
swiftCode += `struct MobileAIAppShortcuts: AppShortcutsProvider {\n`;
|
|
71
|
+
swiftCode += ` static var appShortcuts: [AppShortcut] {\n`;
|
|
72
|
+
for (const intent of manifests) {
|
|
73
|
+
const structName = intent.name.split('_').map((w: string) => w.charAt(0).toUpperCase() + w.slice(1)).join('') + 'Intent';
|
|
74
|
+
// Generate a basic short phrase mapping
|
|
75
|
+
swiftCode += ` AppShortcut(intent: ${structName}(), phrases: ["\\\\(.applicationName) ${intent.name.replace(/_/g, ' ')}"])\n`;
|
|
76
|
+
}
|
|
77
|
+
swiftCode += ` }\n`;
|
|
78
|
+
swiftCode += `}\n`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return swiftCode;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function main() {
|
|
85
|
+
const manifestPath = process.argv[2] || 'intent-manifest.json';
|
|
86
|
+
const appScheme = process.argv[3] || 'mobileai';
|
|
87
|
+
const outPath = process.argv[4] || 'ios/MobileAIPilotIntents.swift';
|
|
88
|
+
|
|
89
|
+
const absoluteManifest = path.resolve(process.cwd(), manifestPath);
|
|
90
|
+
const absoluteOut = path.resolve(process.cwd(), outPath);
|
|
91
|
+
|
|
92
|
+
if (!fs.existsSync(absoluteManifest)) {
|
|
93
|
+
console.error(`❌ Manifest file not found at ${absoluteManifest}`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
console.log(`Generating Swift code for schema ${appScheme}...`);
|
|
98
|
+
const swiftCode = generateSwiftCode(absoluteManifest, appScheme);
|
|
99
|
+
|
|
100
|
+
// Ensure dir exists
|
|
101
|
+
const targetDir = path.dirname(absoluteOut);
|
|
102
|
+
if (!fs.existsSync(targetDir)) {
|
|
103
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
fs.writeFileSync(absoluteOut, swiftCode);
|
|
107
|
+
console.log(`✅ Wrote Swift AppIntents to ${outPath}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Run if called directly
|
|
111
|
+
if (require.main === module) {
|
|
112
|
+
main().catch(err => {
|
|
113
|
+
console.error(err);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
@@ -171,20 +171,17 @@ interface AIAgentProps {
|
|
|
171
171
|
*/
|
|
172
172
|
useScreenMap?: boolean;
|
|
173
173
|
|
|
174
|
-
// ── Analytics (opt-in) ──
|
|
174
|
+
// ── Analytics (opt-in) ──
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
* @internal Requires api.mobileai.dev — not yet available.
|
|
178
177
|
* Publishable analytics key (mobileai_pub_xxx).
|
|
179
178
|
*/
|
|
180
179
|
analyticsKey?: string;
|
|
181
180
|
/**
|
|
182
|
-
* @internal Requires api.mobileai.dev — not yet available.
|
|
183
181
|
* Proxy URL for enterprise customers — routes events through your backend.
|
|
184
182
|
*/
|
|
185
183
|
analyticsProxyUrl?: string;
|
|
186
184
|
/**
|
|
187
|
-
* @internal Requires api.mobileai.dev — not yet available.
|
|
188
185
|
* Custom headers for analyticsProxyUrl (e.g., auth tokens).
|
|
189
186
|
*/
|
|
190
187
|
analyticsProxyHeaders?: Record<string, string>;
|
|
@@ -150,9 +150,8 @@ function AudioControlButton({
|
|
|
150
150
|
*/
|
|
151
151
|
let SpeechModule: any = null;
|
|
152
152
|
try {
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
SpeechModule = require(speechModuleName);
|
|
153
|
+
// Static require — Metro needs a literal string for bundling.
|
|
154
|
+
SpeechModule = require('expo-speech-recognition');
|
|
156
155
|
} catch {
|
|
157
156
|
// Not installed — dictation button won't appear
|
|
158
157
|
}
|
|
@@ -53,7 +53,7 @@ export function HighlightOverlay() {
|
|
|
53
53
|
return (
|
|
54
54
|
<View style={StyleSheet.absoluteFill} pointerEvents="box-none">
|
|
55
55
|
{/* Invisible pressable to dismiss on tap anywhere */}
|
|
56
|
-
<Pressable style={StyleSheet.absoluteFill} onPress={() => setHighlight(null)} />
|
|
56
|
+
<Pressable testID="highlight-close-zone" style={StyleSheet.absoluteFill} onPress={() => setHighlight(null)} />
|
|
57
57
|
|
|
58
58
|
{/* The Animated Ring */}
|
|
59
59
|
<Animated.View
|