@appilots/sdk 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-QMSMXTED.mjs → chunk-4GUPZDWT.mjs} +1439 -51
- package/dist/{chunk-MCY5YFYD.js → chunk-J75B2HWG.js} +1447 -57
- package/dist/{chunk-BKFO4DHW.mjs → chunk-L2A4EZ6V.mjs} +325 -1480
- package/dist/{chunk-DUSYQXAQ.mjs → chunk-P2BR4DFF.mjs} +1 -1
- package/dist/{chunk-XNKPS7W3.js → chunk-YSLDAQV7.js} +398 -1553
- package/dist/{chunk-N2I3CA7Q.js → chunk-ZWPABTLA.js} +5 -5
- package/dist/hooks/index.d.mts +1 -2
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/index.js +11 -11
- package/dist/hooks/index.mjs +2 -2
- package/dist/index-Cb0D6uKH.d.mts +1543 -0
- package/dist/index-Cb0D6uKH.d.ts +1543 -0
- package/dist/index.d.mts +5 -282
- package/dist/index.d.ts +5 -282
- package/dist/index.js +65 -65
- package/dist/index.mjs +5 -5
- package/dist/navigation/index.js +13 -13
- package/dist/navigation/index.mjs +2 -2
- package/hooks/package.json +9 -0
- package/metro.d.ts +49 -0
- package/metro.js +0 -37
- package/navigation/package.json +9 -0
- package/package.json +31 -12
- package/dist/index-BYVRBzjJ.d.mts +0 -619
- package/dist/index-BYVRBzjJ.d.ts +0 -619
package/dist/index-BYVRBzjJ.d.ts
DELETED
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
import * as React$1 from 'react';
|
|
2
|
-
import React__default from 'react';
|
|
3
|
-
import * as _appilots_client_core from '@appilots/client-core';
|
|
4
|
-
import { AgentPermissions, AppilotsUser, AppilotsClient, AppilotsEventHandler, AppilotsEvent, RemotePersonalization, ChatMessage, AgentAction, EscalationState } from '@appilots/client-core';
|
|
5
|
-
|
|
6
|
-
interface AppilotsConfig {
|
|
7
|
-
/** Project ID from the Appilots dashboard */
|
|
8
|
-
projectId: string;
|
|
9
|
-
/** API base URL (defaults to Appilots cloud) */
|
|
10
|
-
apiBaseUrl?: string;
|
|
11
|
-
/** SDK API key (ak_...) for authenticating with the backend */
|
|
12
|
-
apiKey?: string;
|
|
13
|
-
/** Agent permissions for this app instance */
|
|
14
|
-
permissions?: AgentPermissions;
|
|
15
|
-
/** Enable debug logging */
|
|
16
|
-
debug?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Host app version (e.g. package.json version). Forwarded to the API
|
|
19
|
-
* as `X-App-Version` so the server can serve the MCP document matching
|
|
20
|
-
* this app build (OTA fleets run several versions at once).
|
|
21
|
-
*/
|
|
22
|
-
appVersion?: string;
|
|
23
|
-
/** Version of the MCP doc bundled with this build (stale-doc telemetry). */
|
|
24
|
-
mcpVersion?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Who the app's current user is. Sessions carry `user.id` as
|
|
27
|
-
* externalUserId, and name/identifiers are upserted into the
|
|
28
|
-
* end-users registry so the support queue shows a person instead of
|
|
29
|
-
* "Usuário anônimo". Identifiers never reach the LLM.
|
|
30
|
-
*/
|
|
31
|
-
user?: AppilotsUser;
|
|
32
|
-
/**
|
|
33
|
-
* Fetch the dashboard-configured personalization (theme, branding,
|
|
34
|
-
* FAB color, locale...) once on provider mount and apply it as a
|
|
35
|
-
* fallback for AppilotsChat props not set explicitly in code.
|
|
36
|
-
*
|
|
37
|
-
* Set to `false` to opt out — this is the SDK's only automatic
|
|
38
|
-
* network call before the user interacts, so apps with strict
|
|
39
|
-
* network/privacy posture can keep today's 100%-manual behavior.
|
|
40
|
-
* @default true
|
|
41
|
-
*/
|
|
42
|
-
fetchPersonalization?: boolean;
|
|
43
|
-
}
|
|
44
|
-
interface AppilotsProviderProps {
|
|
45
|
-
/**
|
|
46
|
-
* SDK config. If omitted, auto-loads from `.appilotsrc` via the Metro
|
|
47
|
-
* resolver (requires `withAppilots()` in metro.config.js).
|
|
48
|
-
*/
|
|
49
|
-
config?: AppilotsConfig;
|
|
50
|
-
children: React__default.ReactNode;
|
|
51
|
-
/** Optional custom client instance (if not provided, one is auto-created from config) */
|
|
52
|
-
client?: AppilotsClient;
|
|
53
|
-
}
|
|
54
|
-
interface AppilotsContextValue {
|
|
55
|
-
config: AppilotsConfig;
|
|
56
|
-
client: AppilotsClient;
|
|
57
|
-
subscribe: (handler: AppilotsEventHandler) => () => void;
|
|
58
|
-
emit: (event: AppilotsEvent) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Dashboard-configured personalization fetched on mount. `null` until
|
|
61
|
-
* the fetch resolves — and forever, if it fails or is opted out
|
|
62
|
-
* (`fetchPersonalization: false`). Consumers must treat `null` as
|
|
63
|
-
* "use props/defaults"; the chat renders immediately with defaults
|
|
64
|
-
* and re-renders once this lands (accepted cold-start flash).
|
|
65
|
-
*/
|
|
66
|
-
remotePersonalization: RemotePersonalization | null;
|
|
67
|
-
}
|
|
68
|
-
declare function AppilotsProvider({ config: configProp, children, client: externalClient }: AppilotsProviderProps): React__default.JSX.Element;
|
|
69
|
-
declare function useAppilotsContext(): AppilotsContextValue;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Convenience hook that combines all Appilots hooks into a single return value.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```tsx
|
|
76
|
-
* const { messages, sendMessage, currentScreen, pendingActions } = useAppilots();
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
declare function useAppilots(): {
|
|
80
|
-
config: AppilotsConfig;
|
|
81
|
-
client: _appilots_client_core.AppilotsClient;
|
|
82
|
-
messages: _appilots_client_core.ChatMessage[];
|
|
83
|
-
isLoading: boolean;
|
|
84
|
-
error: string | null;
|
|
85
|
-
sendMessage: (content: string) => Promise<void>;
|
|
86
|
-
clearMessages: () => void;
|
|
87
|
-
clearError: () => void;
|
|
88
|
-
currentScreen: string | null;
|
|
89
|
-
navigationHistory: string[];
|
|
90
|
-
setCurrentScreen: (screenName: string) => void;
|
|
91
|
-
navigationRef: React$1.MutableRefObject<any>;
|
|
92
|
-
pendingActions: _appilots_client_core.AgentAction[];
|
|
93
|
-
executingActions: _appilots_client_core.AgentAction[];
|
|
94
|
-
completedActions: _appilots_client_core.AgentAction[];
|
|
95
|
-
approveAction: (actionId: string) => Promise<boolean>;
|
|
96
|
-
rejectAction: (actionId: string) => Promise<void>;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
interface UseAppilotsNavigationReturn {
|
|
100
|
-
currentScreen: string | null;
|
|
101
|
-
navigationHistory: string[];
|
|
102
|
-
setCurrentScreen: (screenName: string) => void;
|
|
103
|
-
/** Navigation ref setter — attach to your NavigationContainer */
|
|
104
|
-
navigationRef: React.MutableRefObject<any>;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Hook for tracking navigation state and enabling agent-driven navigation.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* ```tsx
|
|
111
|
-
* const { currentScreen, navigationRef } = useAppilotsNavigation();
|
|
112
|
-
*
|
|
113
|
-
* return (
|
|
114
|
-
* <NavigationContainer ref={navigationRef}>
|
|
115
|
-
* <Stack.Navigator />
|
|
116
|
-
* </NavigationContainer>
|
|
117
|
-
* );
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
declare function useAppilotsNavigation(): UseAppilotsNavigationReturn;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Localized copy for escalation system messages, injected by the chat
|
|
124
|
-
* surface (the hook has no i18n access — same pattern as errorPrefix).
|
|
125
|
-
* When omitted, no system messages are appended but the state machine
|
|
126
|
-
* still works.
|
|
127
|
-
*/
|
|
128
|
-
interface EscalationStrings {
|
|
129
|
-
/** Appended right after the escalation is created. */
|
|
130
|
-
requested: string;
|
|
131
|
-
/** Appended when an operator claims the conversation. */
|
|
132
|
-
connected: string;
|
|
133
|
-
/** Appended when the operator resolves — AI takes over again. */
|
|
134
|
-
resolved: string;
|
|
135
|
-
/** Content of the offer chip message appended when the agent gives up. */
|
|
136
|
-
offer: string;
|
|
137
|
-
}
|
|
138
|
-
interface UseAppilotsChatReturn {
|
|
139
|
-
messages: ChatMessage[];
|
|
140
|
-
isLoading: boolean;
|
|
141
|
-
loadingStatusKey: 'thinking' | 'statusAnalyzing' | 'statusWaitingApp' | 'statusAdjusting';
|
|
142
|
-
error: string | null;
|
|
143
|
-
pendingActions: AgentAction[];
|
|
144
|
-
/**
|
|
145
|
-
* Open escalation, or null. While set, `sendMessage` routes to the
|
|
146
|
-
* human channel — the agent session itself is never interrupted.
|
|
147
|
-
*/
|
|
148
|
-
escalation: EscalationState | null;
|
|
149
|
-
/**
|
|
150
|
-
* Hand the conversation to a human operator (docs/human-escalation.md).
|
|
151
|
-
* Idempotent while an escalation is open. `agent_gave_up` is used by
|
|
152
|
-
* the auto-offer chip; the header button sends `user_requested`.
|
|
153
|
-
*/
|
|
154
|
-
requestHuman: (reason?: 'user_requested' | 'agent_gave_up') => Promise<void>;
|
|
155
|
-
sendMessage: (content: string) => Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* Cancels the in-flight generation (OKR-008 KR4). Streamed partial
|
|
158
|
-
* text is kept in the transcript; a no-op when nothing is in flight.
|
|
159
|
-
* Cancellation only covers the generation phase — once actions start
|
|
160
|
-
* executing on-device they run to completion (interrupting a half-done
|
|
161
|
-
* form fill would leave the app in a worse state than finishing it).
|
|
162
|
-
*/
|
|
163
|
-
cancelMessage: () => void;
|
|
164
|
-
clearMessages: () => void;
|
|
165
|
-
clearError: () => void;
|
|
166
|
-
}
|
|
167
|
-
interface UseAppilotsChatOptions {
|
|
168
|
-
/** User-facing prefix for client-side failures before the relay can answer. */
|
|
169
|
-
errorPrefix?: string;
|
|
170
|
-
/**
|
|
171
|
-
* Stream assistant replies token-by-token via SSE (default true).
|
|
172
|
-
* When the streaming transport fails before any output, the hook
|
|
173
|
-
* falls back to the non-streaming endpoint transparently.
|
|
174
|
-
*/
|
|
175
|
-
streaming?: boolean;
|
|
176
|
-
/** Localized escalation copy — see EscalationStrings. */
|
|
177
|
-
escalationStrings?: EscalationStrings;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Hook for managing chat state and sending messages to the Appilots agent.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```tsx
|
|
184
|
-
* const { messages, sendMessage, isLoading } = useAppilotsChat();
|
|
185
|
-
*
|
|
186
|
-
* const handleSend = () => {
|
|
187
|
-
* sendMessage('Navigate to settings');
|
|
188
|
-
* };
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
declare function useAppilotsChat(options?: UseAppilotsChatOptions): UseAppilotsChatReturn;
|
|
192
|
-
|
|
193
|
-
interface UseAppilotsActionsOptions {
|
|
194
|
-
/**
|
|
195
|
-
* Navigation ref from useAppilotsNavigation().
|
|
196
|
-
* Required for navigate actions to work.
|
|
197
|
-
*/
|
|
198
|
-
navigationRef?: React.MutableRefObject<any>;
|
|
199
|
-
/**
|
|
200
|
-
* If true, actions are executed automatically without user approval.
|
|
201
|
-
* Confirm actions always require approval regardless of this setting.
|
|
202
|
-
* @default false
|
|
203
|
-
*/
|
|
204
|
-
autoExecute?: boolean;
|
|
205
|
-
}
|
|
206
|
-
interface UseAppilotsActionsReturn {
|
|
207
|
-
pendingActions: AgentAction[];
|
|
208
|
-
executingActions: AgentAction[];
|
|
209
|
-
completedActions: AgentAction[];
|
|
210
|
-
approveAction: (actionId: string) => Promise<boolean>;
|
|
211
|
-
rejectAction: (actionId: string) => Promise<void>;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Hook for monitoring and controlling agent actions.
|
|
215
|
-
*
|
|
216
|
-
* Now integrates with the ActionExecutor to actually execute actions
|
|
217
|
-
* against live UI components via the ComponentRegistry.
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* ```tsx
|
|
221
|
-
* const { navigationRef } = useAppilotsNavigation();
|
|
222
|
-
* const { pendingActions, approveAction, rejectAction } = useAppilotsActions({
|
|
223
|
-
* navigationRef,
|
|
224
|
-
* autoExecute: false,
|
|
225
|
-
* });
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
228
|
-
declare function useAppilotsActions(options?: UseAppilotsActionsOptions): UseAppilotsActionsReturn;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* ComponentRegistry — Central registry mapping component IDs to their
|
|
232
|
-
* refs, callbacks, and metadata so the ActionExecutor can find and
|
|
233
|
-
* interact with live UI elements.
|
|
234
|
-
*
|
|
235
|
-
* Screens register their interactive components via hooks
|
|
236
|
-
* (useAppilotsField, useAppilotsTarget, useAppilotsToggle).
|
|
237
|
-
* When the AI agent returns an action (e.g. form_fill with fieldId "plate"),
|
|
238
|
-
* the executor looks up "plate" here and calls the associated setter.
|
|
239
|
-
*/
|
|
240
|
-
type ComponentKind = 'field' | 'target' | 'toggle' | 'slider';
|
|
241
|
-
interface FieldEntry {
|
|
242
|
-
kind: 'field';
|
|
243
|
-
/** Current value of the field */
|
|
244
|
-
getValue: () => string;
|
|
245
|
-
/** Set the field value programmatically */
|
|
246
|
-
setValue: (value: string) => void;
|
|
247
|
-
/** Optional: focus the input */
|
|
248
|
-
focus?: () => void;
|
|
249
|
-
/** Field type hint for the executor */
|
|
250
|
-
fieldType?: 'text' | 'select' | 'toggle' | 'date' | 'number' | 'custom';
|
|
251
|
-
/** Human-readable label */
|
|
252
|
-
label?: string;
|
|
253
|
-
/** Screen where this field is registered */
|
|
254
|
-
screen?: string;
|
|
255
|
-
}
|
|
256
|
-
interface TargetEntry {
|
|
257
|
-
kind: 'target';
|
|
258
|
-
/** Execute the primary action (press) */
|
|
259
|
-
press: () => void;
|
|
260
|
-
/** Optional: long press */
|
|
261
|
-
longPress?: () => void;
|
|
262
|
-
/** Optional: scroll to this element */
|
|
263
|
-
scrollTo?: () => void;
|
|
264
|
-
/** Human-readable label */
|
|
265
|
-
label?: string;
|
|
266
|
-
/** Screen where this target is registered */
|
|
267
|
-
screen?: string;
|
|
268
|
-
}
|
|
269
|
-
interface ToggleEntry {
|
|
270
|
-
kind: 'toggle';
|
|
271
|
-
/** Current value */
|
|
272
|
-
getValue: () => boolean;
|
|
273
|
-
/** Set the toggle value */
|
|
274
|
-
setValue: (value: boolean) => void;
|
|
275
|
-
/** Human-readable label */
|
|
276
|
-
label?: string;
|
|
277
|
-
/** Screen where this toggle is registered */
|
|
278
|
-
screen?: string;
|
|
279
|
-
}
|
|
280
|
-
interface SliderEntry {
|
|
281
|
-
kind: 'slider';
|
|
282
|
-
/** Current numeric value */
|
|
283
|
-
getValue: () => number;
|
|
284
|
-
/**
|
|
285
|
-
* Set the slider value. The executor clamps to [min, max] and snaps
|
|
286
|
-
* to `step` BEFORE calling this, so implementations can trust the
|
|
287
|
-
* value — but re-validating is harmless.
|
|
288
|
-
*/
|
|
289
|
-
setValue: (value: number) => void;
|
|
290
|
-
/** Lower bound (inclusive) */
|
|
291
|
-
min: number;
|
|
292
|
-
/** Upper bound (inclusive) */
|
|
293
|
-
max: number;
|
|
294
|
-
/** Step to snap to (omitted = continuous) */
|
|
295
|
-
step?: number;
|
|
296
|
-
/** Human-readable label */
|
|
297
|
-
label?: string;
|
|
298
|
-
/** Screen where this slider is registered */
|
|
299
|
-
screen?: string;
|
|
300
|
-
}
|
|
301
|
-
type ComponentEntry = FieldEntry | TargetEntry | ToggleEntry | SliderEntry;
|
|
302
|
-
type Listener = (id: string, entry: ComponentEntry | null) => void;
|
|
303
|
-
/**
|
|
304
|
-
* Public type for a registry instance. Both the singleton and any
|
|
305
|
-
* instance returned by `createComponentRegistry()` satisfy this.
|
|
306
|
-
*
|
|
307
|
-
* The class itself stays internal — devs construct via the factory
|
|
308
|
-
* to keep the surface minimal and future-proof.
|
|
309
|
-
*/
|
|
310
|
-
type ComponentRegistry = ComponentRegistryImpl;
|
|
311
|
-
declare class ComponentRegistryImpl {
|
|
312
|
-
private components;
|
|
313
|
-
private listeners;
|
|
314
|
-
/**
|
|
315
|
-
* Register a component. If an entry with the same ID already exists,
|
|
316
|
-
* it is replaced (this handles re-renders / hot-reload).
|
|
317
|
-
*/
|
|
318
|
-
register(id: string, entry: ComponentEntry): void;
|
|
319
|
-
/**
|
|
320
|
-
* Unregister a component (typically on unmount).
|
|
321
|
-
*/
|
|
322
|
-
unregister(id: string): void;
|
|
323
|
-
/**
|
|
324
|
-
* Look up a component by its ID.
|
|
325
|
-
*/
|
|
326
|
-
get(id: string): ComponentEntry | undefined;
|
|
327
|
-
/**
|
|
328
|
-
* Get a typed entry or undefined.
|
|
329
|
-
*/
|
|
330
|
-
getField(id: string): FieldEntry | undefined;
|
|
331
|
-
getTarget(id: string): TargetEntry | undefined;
|
|
332
|
-
getToggle(id: string): ToggleEntry | undefined;
|
|
333
|
-
getSlider(id: string): SliderEntry | undefined;
|
|
334
|
-
/**
|
|
335
|
-
* Get all components on a given screen.
|
|
336
|
-
*/
|
|
337
|
-
getByScreen(screen: string): Map<string, ComponentEntry>;
|
|
338
|
-
/**
|
|
339
|
-
* Get all components of a given kind.
|
|
340
|
-
*/
|
|
341
|
-
getByKind(kind: ComponentKind): Map<string, ComponentEntry>;
|
|
342
|
-
/**
|
|
343
|
-
* List all registered component IDs with their kind and screen.
|
|
344
|
-
* Useful for debugging and for the AI to know what's available.
|
|
345
|
-
*/
|
|
346
|
-
snapshot(): Array<{
|
|
347
|
-
id: string;
|
|
348
|
-
kind: ComponentKind;
|
|
349
|
-
screen?: string;
|
|
350
|
-
label?: string;
|
|
351
|
-
}>;
|
|
352
|
-
/**
|
|
353
|
-
* Subscribe to registry changes.
|
|
354
|
-
* Returns an unsubscribe function.
|
|
355
|
-
*/
|
|
356
|
-
subscribe(listener: Listener): () => void;
|
|
357
|
-
/**
|
|
358
|
-
* Clear all entries (useful for testing or full reset).
|
|
359
|
-
*/
|
|
360
|
-
clear(): void;
|
|
361
|
-
/** Number of registered components */
|
|
362
|
-
get size(): number;
|
|
363
|
-
private notify;
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Singleton registry instance shared across the entire SDK by default.
|
|
367
|
-
*
|
|
368
|
-
* Apps with a single Appilots session (the overwhelmingly common case)
|
|
369
|
-
* never need anything else — hooks, handlers, and auto-tracking all
|
|
370
|
-
* read from this singleton.
|
|
371
|
-
*
|
|
372
|
-
* For multi-tenant or micro-front-end setups where two Appilots
|
|
373
|
-
* sessions might coexist in the same JS process, use
|
|
374
|
-
* `createComponentRegistry()` to obtain a fresh instance and pass it
|
|
375
|
-
* via `<AppilotsRegistryProvider value={...}>`. Hooks resolve via
|
|
376
|
-
* context first, falling back to this singleton.
|
|
377
|
-
*
|
|
378
|
-
* The singleton stays in place to keep the existing public API stable
|
|
379
|
-
* — pré-mortem 2.8 is "future risk", not "current bug".
|
|
380
|
-
*/
|
|
381
|
-
declare const componentRegistry: ComponentRegistry;
|
|
382
|
-
/**
|
|
383
|
-
* Create a fresh, isolated ComponentRegistry instance. Pair with
|
|
384
|
-
* `<AppilotsRegistryProvider value={...}>` to scope auto-tracking and
|
|
385
|
-
* hooks to that registry instead of the global singleton.
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```tsx
|
|
389
|
-
* const tenantRegistry = createComponentRegistry();
|
|
390
|
-
* <AppilotsRegistryProvider value={tenantRegistry}>
|
|
391
|
-
* <TenantApp />
|
|
392
|
-
* </AppilotsRegistryProvider>
|
|
393
|
-
* ```
|
|
394
|
-
*/
|
|
395
|
-
declare function createComponentRegistry(): ComponentRegistry;
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* useAppilotsField — Register a text input (or similar field) with the
|
|
399
|
-
* ComponentRegistry so the AI agent can fill it via form_fill actions.
|
|
400
|
-
*
|
|
401
|
-
* Usage:
|
|
402
|
-
* ```tsx
|
|
403
|
-
* const [plate, setPlate] = useState('');
|
|
404
|
-
* const plateRef = useRef<TextInput>(null);
|
|
405
|
-
*
|
|
406
|
-
* useAppilotsField('plate', {
|
|
407
|
-
* value: plate,
|
|
408
|
-
* onChangeText: setPlate,
|
|
409
|
-
* ref: plateRef, // optional — enables focus()
|
|
410
|
-
* fieldType: 'text', // optional — hint for executor
|
|
411
|
-
* label: 'License Plate', // optional — human-readable name
|
|
412
|
-
* screen: 'VehicleForm', // optional — scoped to screen
|
|
413
|
-
* });
|
|
414
|
-
*
|
|
415
|
-
* return <TextInput ref={plateRef} value={plate} onChangeText={setPlate} />;
|
|
416
|
-
* ```
|
|
417
|
-
*/
|
|
418
|
-
|
|
419
|
-
interface UseAppilotsFieldOptions {
|
|
420
|
-
/** Current value of the field */
|
|
421
|
-
value: string;
|
|
422
|
-
/** Callback to update the value (same signature as TextInput.onChangeText) */
|
|
423
|
-
onChangeText: (text: string) => void;
|
|
424
|
-
/** Optional ref to the TextInput for focus support */
|
|
425
|
-
ref?: React.RefObject<any>;
|
|
426
|
-
/** Field type hint */
|
|
427
|
-
fieldType?: FieldEntry['fieldType'];
|
|
428
|
-
/** Human-readable label */
|
|
429
|
-
label?: string;
|
|
430
|
-
/** Screen name this field belongs to */
|
|
431
|
-
screen?: string;
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Register a field with the Appilots ComponentRegistry.
|
|
435
|
-
* Automatically unregisters on unmount.
|
|
436
|
-
*
|
|
437
|
-
* @param id - Unique identifier for this field (e.g. "plate", "customerName")
|
|
438
|
-
* @param options - Field configuration
|
|
439
|
-
*/
|
|
440
|
-
declare function useAppilotsField(id: string, options: UseAppilotsFieldOptions): void;
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* useAppilotsTarget — Register a pressable UI element (button, card, link)
|
|
444
|
-
* with the ComponentRegistry so the AI agent can interact with it.
|
|
445
|
-
*
|
|
446
|
-
* Usage:
|
|
447
|
-
* ```tsx
|
|
448
|
-
* const handleSubmit = () => { ... };
|
|
449
|
-
*
|
|
450
|
-
* useAppilotsTarget('submitVehicle', {
|
|
451
|
-
* onPress: handleSubmit,
|
|
452
|
-
* label: 'Submit Vehicle',
|
|
453
|
-
* screen: 'VehicleForm',
|
|
454
|
-
* });
|
|
455
|
-
*
|
|
456
|
-
* return <Button title="Submit" onPress={handleSubmit} />;
|
|
457
|
-
* ```
|
|
458
|
-
*/
|
|
459
|
-
interface UseAppilotsTargetOptions {
|
|
460
|
-
/** Primary press handler */
|
|
461
|
-
onPress: () => void;
|
|
462
|
-
/** Optional long-press handler */
|
|
463
|
-
onLongPress?: () => void;
|
|
464
|
-
/** Optional scroll-to handler (scroll this element into view) */
|
|
465
|
-
onScrollTo?: () => void;
|
|
466
|
-
/** Human-readable label */
|
|
467
|
-
label?: string;
|
|
468
|
-
/** Screen name this target belongs to */
|
|
469
|
-
screen?: string;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Register a pressable target with the Appilots ComponentRegistry.
|
|
473
|
-
* Automatically unregisters on unmount.
|
|
474
|
-
*
|
|
475
|
-
* @param id - Unique identifier (e.g. "submitVehicle", "openSettings")
|
|
476
|
-
* @param options - Target configuration
|
|
477
|
-
*/
|
|
478
|
-
declare function useAppilotsTarget(id: string, options: UseAppilotsTargetOptions): void;
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* useAppilotsToggle — Register a toggle/switch with the ComponentRegistry
|
|
482
|
-
* so the AI agent can flip it via ui_interaction actions.
|
|
483
|
-
*
|
|
484
|
-
* Usage:
|
|
485
|
-
* ```tsx
|
|
486
|
-
* const [pushEnabled, setPushEnabled] = useState(false);
|
|
487
|
-
*
|
|
488
|
-
* useAppilotsToggle('pushNotifications', {
|
|
489
|
-
* value: pushEnabled,
|
|
490
|
-
* onValueChange: setPushEnabled,
|
|
491
|
-
* label: 'Push Notifications',
|
|
492
|
-
* screen: 'Settings',
|
|
493
|
-
* });
|
|
494
|
-
*
|
|
495
|
-
* return <Switch value={pushEnabled} onValueChange={setPushEnabled} />;
|
|
496
|
-
* ```
|
|
497
|
-
*/
|
|
498
|
-
interface UseAppilotsToggleOptions {
|
|
499
|
-
/** Current toggle value */
|
|
500
|
-
value: boolean;
|
|
501
|
-
/** Callback when value changes */
|
|
502
|
-
onValueChange: (value: boolean) => void;
|
|
503
|
-
/** Human-readable label */
|
|
504
|
-
label?: string;
|
|
505
|
-
/** Screen name this toggle belongs to */
|
|
506
|
-
screen?: string;
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Register a toggle with the Appilots ComponentRegistry.
|
|
510
|
-
* Automatically unregisters on unmount.
|
|
511
|
-
*
|
|
512
|
-
* @param id - Unique identifier (e.g. "pushNotifications", "darkMode")
|
|
513
|
-
* @param options - Toggle configuration
|
|
514
|
-
*/
|
|
515
|
-
declare function useAppilotsToggle(id: string, options: UseAppilotsToggleOptions): void;
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* useAppilotsSlider — Register a slider / adjustable numeric control with
|
|
519
|
-
* the ComponentRegistry so the AI agent can set it via
|
|
520
|
-
* `ui_interaction action="set_value"` actions.
|
|
521
|
-
*
|
|
522
|
-
* Registration is what makes a slider agent-operable end to end:
|
|
523
|
-
* captureSnapshot() reads this entry to advertise the slider (with
|
|
524
|
-
* min/max/step) in the observation, and the executor dispatches
|
|
525
|
-
* set_value through the same entry — clamping to [min, max] and
|
|
526
|
-
* snapping to `step` before calling onValueChange.
|
|
527
|
-
*
|
|
528
|
-
* Usage:
|
|
529
|
-
* ```tsx
|
|
530
|
-
* const [mileage, setMileage] = useState(0);
|
|
531
|
-
*
|
|
532
|
-
* useAppilotsSlider('quilometragem', {
|
|
533
|
-
* value: mileage,
|
|
534
|
-
* onValueChange: setMileage,
|
|
535
|
-
* min: 0,
|
|
536
|
-
* max: 300000,
|
|
537
|
-
* step: 500,
|
|
538
|
-
* label: 'Quilometragem',
|
|
539
|
-
* screen: 'VehicleCreate',
|
|
540
|
-
* });
|
|
541
|
-
*
|
|
542
|
-
* return <MySlider value={mileage} onChange={setMileage} min={0} max={300000} />;
|
|
543
|
-
* ```
|
|
544
|
-
*/
|
|
545
|
-
interface UseAppilotsSliderOptions {
|
|
546
|
-
/** Current slider value */
|
|
547
|
-
value: number;
|
|
548
|
-
/** Callback when value changes */
|
|
549
|
-
onValueChange: (value: number) => void;
|
|
550
|
-
/** Lower bound (inclusive) — advertised in the observation and enforced by the executor */
|
|
551
|
-
min: number;
|
|
552
|
-
/** Upper bound (inclusive) — advertised in the observation and enforced by the executor */
|
|
553
|
-
max: number;
|
|
554
|
-
/** Step the executor snaps to (omit for a continuous slider) */
|
|
555
|
-
step?: number;
|
|
556
|
-
/** Human-readable label */
|
|
557
|
-
label?: string;
|
|
558
|
-
/** Screen name this slider belongs to */
|
|
559
|
-
screen?: string;
|
|
560
|
-
}
|
|
561
|
-
/**
|
|
562
|
-
* Register a slider with the Appilots ComponentRegistry.
|
|
563
|
-
* Automatically unregisters on unmount.
|
|
564
|
-
*
|
|
565
|
-
* @param id - Unique identifier (e.g. "quilometragem", "volume")
|
|
566
|
-
* @param options - Slider configuration
|
|
567
|
-
*/
|
|
568
|
-
declare function useAppilotsSlider(id: string, options: UseAppilotsSliderOptions): void;
|
|
569
|
-
|
|
570
|
-
interface SuggestedPrompt {
|
|
571
|
-
/** Display label shown on the chip and inserted into the input on tap. */
|
|
572
|
-
text: string;
|
|
573
|
-
/** Where this prompt came from. Useful for analytics or theming. */
|
|
574
|
-
source: 'dev-defined' | 'screen-popular' | 'global-popular';
|
|
575
|
-
}
|
|
576
|
-
interface UseSuggestedPromptsOptions {
|
|
577
|
-
/**
|
|
578
|
-
* Whether the chat is currently open. Hook only fetches while open, so
|
|
579
|
-
* suggestions don't waste a roundtrip when the chat is minimised.
|
|
580
|
-
*/
|
|
581
|
-
enabled: boolean;
|
|
582
|
-
/** Max chips to return. Default 4. */
|
|
583
|
-
limit?: number;
|
|
584
|
-
}
|
|
585
|
-
interface UseSuggestedPromptsReturn {
|
|
586
|
-
prompts: SuggestedPrompt[];
|
|
587
|
-
isLoading: boolean;
|
|
588
|
-
/** Re-runs the fetch — call after navigation so chips refresh. */
|
|
589
|
-
refetch: () => void;
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Returns ranked suggested prompts to render as chips in the chat
|
|
593
|
-
* empty-state. Three sources are merged in priority order:
|
|
594
|
-
*
|
|
595
|
-
* 1. **Dev-defined** — from `registerScreen({ suggestedPrompts })` in the
|
|
596
|
-
* current app, read synchronously from the local screen registry.
|
|
597
|
-
* First-class signal, always wins.
|
|
598
|
-
*
|
|
599
|
-
* 2. **Screen-popular** — historical user prompts sent FROM this screen,
|
|
600
|
-
* mined server-side from agentMessages history.
|
|
601
|
-
*
|
|
602
|
-
* 3. **Global-popular** — historical user prompts across the project.
|
|
603
|
-
* Fallback for screens with no history yet.
|
|
604
|
-
*
|
|
605
|
-
* The hook re-fetches whenever the active screen changes so chips always
|
|
606
|
-
* match where the user is right now. Server response is cached 1h, so
|
|
607
|
-
* fetches are cheap.
|
|
608
|
-
*
|
|
609
|
-
* @example
|
|
610
|
-
* ```tsx
|
|
611
|
-
* const { prompts } = useSuggestedPrompts({ enabled: chatVisible });
|
|
612
|
-
* return prompts.map((p) => (
|
|
613
|
-
* <Chip key={p.text} onPress={() => setInput(p.text)}>{p.text}</Chip>
|
|
614
|
-
* ));
|
|
615
|
-
* ```
|
|
616
|
-
*/
|
|
617
|
-
declare function useSuggestedPrompts(options: UseSuggestedPromptsOptions): UseSuggestedPromptsReturn;
|
|
618
|
-
|
|
619
|
-
export { type AppilotsConfig as A, type ComponentRegistry as C, type FieldEntry as F, type SliderEntry as S, type TargetEntry as T, type UseAppilotsFieldOptions as U, AppilotsProvider as a, type AppilotsProviderProps as b, type ComponentEntry as c, type ComponentKind as d, type SuggestedPrompt as e, type ToggleEntry as f, type UseAppilotsSliderOptions as g, type UseAppilotsTargetOptions as h, type UseAppilotsToggleOptions as i, type UseSuggestedPromptsOptions as j, type UseSuggestedPromptsReturn as k, componentRegistry as l, createComponentRegistry as m, useAppilotsActions as n, useAppilotsChat as o, useAppilotsContext as p, useAppilotsField as q, useAppilotsNavigation as r, useAppilotsSlider as s, useAppilotsTarget as t, useAppilots as u, useAppilotsToggle as v, useSuggestedPrompts as w };
|