@appilots/sdk 0.2.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.
@@ -0,0 +1,1156 @@
1
+ import { P as PartialThemeTokens, A as AppilotsThemeTokens, a as AppilotsLocale, b as AgentAction, C as ComponentRegistry, c as AgentPermissions, d as AppilotsTraceEntry, F as FieldEntry, e as AppilotsEvent } from './index-BDb1WVNo.mjs';
2
+ export { f as AgentActionType, g as AgentMessage, h as AppilotsClient, i as AppilotsClientOptions, j as AppilotsConfig, k as AppilotsEventHandler, l as AppilotsEventType, m as AppilotsI18nProvider, n as AppilotsI18nProviderProps, o as AppilotsProvider, p as AppilotsProviderProps, q as AppilotsStringKey, r as AppilotsStrings, s as AppilotsUser, t as ChatMessage, u as ComponentEntry, v as ComponentKind, E as EscalationState, w as FormFillPayload, M as MessageRole, N as NavigationPayload, R as RemotePersonalization, S as SliderEntry, x as SuggestedPrompt, T as TargetEntry, y as ToggleEntry, U as UIInteractionPayload, z as UseAppilotsFieldOptions, B as UseAppilotsSliderOptions, D as UseAppilotsTargetOptions, G as UseAppilotsToggleOptions, H as UseSuggestedPromptsOptions, I as UseSuggestedPromptsReturn, J as componentRegistry, K as createComponentRegistry, L as defaultDarkTheme, O as defaultLightTheme, Q as detectDeviceLocale, V as mergeThemeTokens, W as resolveLocale, X as useAppilots, Y as useAppilotsActions, Z as useAppilotsChat, _ as useAppilotsContext, $ as useAppilotsField, a0 as useAppilotsI18n, a1 as useAppilotsNavigation, a2 as useAppilotsSlider, a3 as useAppilotsTarget, a4 as useAppilotsToggle, a5 as useSuggestedPrompts } from './index-BDb1WVNo.mjs';
3
+ import * as React$1 from 'react';
4
+ import React__default from 'react';
5
+ export { A as AppilotsNavigationContainer, N as NavigationConfig, b as ScreenMetadata, r as registerScreen } from './registerScreen-D1oGm28T.mjs';
6
+
7
+ interface AppilotsThemeProviderProps {
8
+ /**
9
+ * Partial token overrides — merged on top of the resolved base
10
+ * (default light or dark). Accepts the same shape as the dashboard
11
+ * `theme` JSON, so configs round-trip without translation.
12
+ */
13
+ theme?: PartialThemeTokens | null;
14
+ /**
15
+ * `auto` (default) — follow `useColorScheme()` from React Native.
16
+ * `light` / `dark` — force the theme regardless of device setting.
17
+ * Useful when the host app is itself locked to one mode.
18
+ */
19
+ mode?: 'auto' | 'light' | 'dark';
20
+ children: React__default.ReactNode;
21
+ }
22
+ declare function AppilotsThemeProvider({ theme, mode, children, }: AppilotsThemeProviderProps): React__default.JSX.Element;
23
+ /**
24
+ * Read the resolved theme tokens from context. Components MUST use this
25
+ * hook (or accept an explicit `theme` prop forwarded from a parent that
26
+ * called it) instead of importing `defaultLightTheme` directly — that
27
+ * import would defeat the dev's overrides.
28
+ */
29
+ declare function useAppilotsTheme(): AppilotsThemeTokens;
30
+
31
+ /**
32
+ * Tailwind → Appilots theme bridge (BACKLOG 4.1).
33
+ *
34
+ * Purpose: a developer who already has a Tailwind config in their app
35
+ * shouldn't have to manually copy hex codes into the Appilots `theme`
36
+ * prop. They can pass their resolved Tailwind config and we'll
37
+ * extract the closest-named tokens.
38
+ *
39
+ * This is intentionally fuzzy: Tailwind's color tree is `{primary:
40
+ * {500: "#..."}}` shaped while ours is flat. We pick the 500 shade for
41
+ * a named color (Tailwind's de-facto "default" shade) and fall back to
42
+ * the closest available shade if 500 is missing. Anything we can't
43
+ * confidently map is left out, so the SDK falls back to its bundled
44
+ * defaults for that token.
45
+ *
46
+ * Not a runtime dependency on tailwindcss — the developer passes the
47
+ * resolved config object in. (`require('tailwindcss/resolveConfig')`
48
+ * runs in the dev's app, not here, so this package stays Metro-safe.)
49
+ */
50
+
51
+ /**
52
+ * Loose shape of a resolved Tailwind config. We only read what we
53
+ * need; the rest of the keys (variants, plugins, content) are ignored.
54
+ */
55
+ interface TailwindResolvedConfig {
56
+ theme?: {
57
+ colors?: Record<string, string | Record<string, string>>;
58
+ fontFamily?: Record<string, string | string[]>;
59
+ fontSize?: Record<string, string | [string, string | {
60
+ lineHeight?: string;
61
+ }]>;
62
+ borderRadius?: Record<string, string>;
63
+ };
64
+ }
65
+ /**
66
+ * Build a `PartialThemeTokens` from a (resolved) Tailwind config.
67
+ *
68
+ * Only fields the dev clearly defined make it across — everything else
69
+ * stays unset so the Appilots defaults take over. This is "best effort":
70
+ * unmapped tokens are NOT an error.
71
+ */
72
+ declare function appilotsThemeFromTailwind(config: TailwindResolvedConfig): PartialThemeTokens;
73
+ /**
74
+ * Convenience namespace so dashboard docs can show `appilotsTheme.fromTailwind(...)`
75
+ * exactly as the backlog spec writes it.
76
+ */
77
+ declare const appilotsTheme: {
78
+ fromTailwind: typeof appilotsThemeFromTailwind;
79
+ };
80
+
81
+ /**
82
+ * Layout modes for the chat (BACKLOG 4.1).
83
+ * - `bubble` — floating action button + bottom sheet modal (default)
84
+ * - `fullscreen` — full-screen modal, no FAB
85
+ * - `sidebar` — half-width modal pinned to one side (tablet/web RN)
86
+ * - `inline` — render inline where it's mounted, no modal at all
87
+ */
88
+ type AppilotsChatMode = 'bubble' | 'fullscreen' | 'sidebar' | 'inline';
89
+ type AppilotsChatPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
90
+ interface AppilotsChatProps {
91
+ /** Controlled visibility — when set, the FAB is hidden. */
92
+ visible?: boolean;
93
+ onClose?: () => void;
94
+ /** Override the input placeholder text. Falls back to the i18n bundle. */
95
+ placeholder?: string;
96
+ /** Override the chat header title. Falls back to assistantName, then i18n bundle. */
97
+ headerTitle?: string;
98
+ /** @deprecated Action traces are debug-only; confirmation prompts remain visible. */
99
+ showActionPreviews?: boolean;
100
+ /**
101
+ * Auto-execute non-confirm actions without user approval.
102
+ * @default true
103
+ */
104
+ autoExecute?: boolean;
105
+ /**
106
+ * Partial token overrides — merged on top of the resolved
107
+ * default-light or default-dark theme. See `@appilots/sdk/theme`.
108
+ *
109
+ * Backwards-compatible: the legacy {primaryColor, backgroundColor,
110
+ * textColor, inputBackgroundColor, borderRadius, fontFamily} shape
111
+ * still works, transparently mapped onto the new tokens.
112
+ */
113
+ theme?: PartialThemeTokens | LegacyThemeShape;
114
+ /** `auto` (default) follows the device color scheme; `light`/`dark` force. */
115
+ themeMode?: 'auto' | 'light' | 'dark';
116
+ /** Display name for the agent (overrides headerTitle's i18n fallback). */
117
+ assistantName?: string;
118
+ /** URL or local require()-able image for the avatar shown next to the title. */
119
+ assistantAvatar?: string | number | React__default.ReactNode;
120
+ /**
121
+ * Icon shown in the empty-state badge — an emoji/string (rendered
122
+ * literally inside the tinted circle) or an image (URL string starting
123
+ * with `http(s)://`, or a local `require()`-d asset, rendered without
124
+ * the tint). Falls back to the default `ChatIcon` bubble glyph.
125
+ */
126
+ emptyStateIcon?: string | number;
127
+ /** Optional hint shown under the empty-state title (replaces the default subtitle). */
128
+ welcomeMessage?: string;
129
+ /** Show the "Powered by Appilots" footer line. Defaults to true. */
130
+ poweredByVisible?: boolean;
131
+ mode?: AppilotsChatMode;
132
+ /** Only honoured when mode='bubble'. Positions the floating button. */
133
+ position?: AppilotsChatPosition;
134
+ /** Fully replace the floating button. `'none'` hides it entirely. */
135
+ triggerButton?: React__default.ReactNode | 'default' | 'none';
136
+ /**
137
+ * Replace ONLY the icon rendered inside the default FAB, keeping the
138
+ * default shape/size/background. Use this for a custom SVG without
139
+ * having to rebuild the entire button. Ignored when `triggerButton`
140
+ * is set to a ReactNode (the whole button is replaced anyway).
141
+ * Takes priority over `triggerButtonImage` when both are set.
142
+ */
143
+ triggerIcon?: React__default.ReactNode;
144
+ /**
145
+ * Background color of the default FAB. Falls back to
146
+ * `theme.colors.primary` when unset — same as the SDK's behavior
147
+ * before this prop existed.
148
+ */
149
+ triggerButtonColor?: string;
150
+ /**
151
+ * Image (URL or local `require()`-d asset) rendered inside the
152
+ * default FAB instead of the built-in chat-bubble icon — e.g. a
153
+ * company logo. Rendered with `resizeMode="contain"` and no forced
154
+ * tint (unlike the default icon, which is intentionally white).
155
+ * Ignored when `triggerIcon` is set.
156
+ */
157
+ triggerButtonImage?: string | number;
158
+ /** Force a locale. Falls through to device detection when omitted. */
159
+ locale?: AppilotsLocale;
160
+ }
161
+ /**
162
+ * Legacy theme shape used by the SDK before BACKLOG 4.1. Kept as an
163
+ * accepted union variant of the `theme` prop so existing apps don't
164
+ * need to change a single line.
165
+ */
166
+ interface LegacyThemeShape {
167
+ primaryColor?: string;
168
+ backgroundColor?: string;
169
+ textColor?: string;
170
+ inputBackgroundColor?: string;
171
+ borderRadius?: number;
172
+ fontFamily?: string;
173
+ }
174
+ /**
175
+ * Outer wrapper — sets up Theme + i18n providers so the inner component
176
+ * (and the ConfirmDialog) all read from the same resolved tokens. This
177
+ * lets a developer mount AppilotsChat without also wrapping their app
178
+ * in a `<AppilotsThemeProvider>` manually.
179
+ */
180
+ declare function AppilotsChat(props: AppilotsChatProps): React__default.JSX.Element;
181
+ /**
182
+ * Re-exports kept for backwards compatibility — the legacy
183
+ * `AppilotsChatTheme` type used to live on this module. Prefer
184
+ * `import { type AppilotsThemeTokens } from '@appilots/sdk/theme'`.
185
+ */
186
+ type AppilotsChatTheme = LegacyThemeShape;
187
+
188
+ /**
189
+ * @deprecated Inline confirm cards (rendered by ActionBreadcrumb) have
190
+ * replaced the modal/overlay confirmation flow. This component is kept
191
+ * as an empty export only so existing import sites compile while
192
+ * consumers migrate.
193
+ *
194
+ * Why it went away:
195
+ * - The original `<Modal>` flavor couldn't open on iOS while
196
+ * AppilotsChat itself was in a Modal (RN refuses two concurrent
197
+ * modals; the dialog silently never appeared).
198
+ * - The user's choice (confirm / cancel) had no permanent surface
199
+ * in the chat — the modal dismissed and the breadcrumb only
200
+ * showed a transient "Aguardando confirmação..." badge.
201
+ *
202
+ * The replacement is the `ConfirmCard` rendered inside
203
+ * `ActionBreadcrumb` when an action of type `confirm` is in `pending`
204
+ * state. Approve/reject route through the standard
205
+ * `useAppilotsActions.approveAction(id)` / `rejectAction(id)`. Once
206
+ * resolved, the row stays in the chat as a permanent record
207
+ * ("Você confirmou" / "Você cancelou").
208
+ *
209
+ * To customise the inline card visually, theme it via the same
210
+ * `primaryColor` / `colors` props that `AppilotsChat` already accepts
211
+ * — the card inherits from those.
212
+ */
213
+
214
+ interface ConfirmDialogProps {
215
+ primaryColor?: string;
216
+ destructiveColor?: string;
217
+ }
218
+ /** @deprecated No-op. See file header. */
219
+ declare function ConfirmDialog(_props?: ConfirmDialogProps): React__default.ReactElement | null;
220
+
221
+ /**
222
+ * Human-readable labels and error messages for the action breadcrumb.
223
+ *
224
+ * Strings are PT-BR hardcoded for now. i18n is planned for backlog item
225
+ * 4.1 (Personalização) — when that lands, these strings move into the
226
+ * locale bundles.
227
+ *
228
+ * Two responsibilities:
229
+ * 1. `describeAction(action)` — turns a typed AgentAction into a label
230
+ * that varies by lifecycle state (pending/running/done/failed).
231
+ * 2. `humanizeError(raw, action)` — sanitises the raw error string from
232
+ * the executor into a short user-facing reason. Stack traces and
233
+ * protocol errors are collapsed into "algo deu errado" so users
234
+ * aren't shown technical noise.
235
+ */
236
+
237
+ type BreadcrumbState = 'pending' | 'running' | 'success' | 'failed';
238
+ interface BreadcrumbItem {
239
+ /** What to render on the line. */
240
+ label: string;
241
+ /** Lifecycle state — drives icon + colour in the breadcrumb. */
242
+ state: BreadcrumbState;
243
+ }
244
+ /**
245
+ * Map an AgentAction + its current status to a breadcrumb item ready to
246
+ * render. The function is intentionally defensive — both the native-tools
247
+ * and JSON-fallback code paths feed actions through here, and the JSON
248
+ * path is loose with payload shapes, so every field access has to assume
249
+ * `unknown`.
250
+ */
251
+ declare function describeAction(action: AgentAction): BreadcrumbItem;
252
+ /**
253
+ * Convert the executor's raw error string into a short, user-facing
254
+ * reason that fits inside parentheses on the breadcrumb line. Returns
255
+ * `undefined` when there's no useful information to show — caller can
256
+ * then drop the parenthetical entirely.
257
+ *
258
+ * Heuristics:
259
+ * - Apply known-pattern rewrites (rejected, not found, network, etc.)
260
+ * - If the result looks technical (stack frame, HTTP status, JSON
261
+ * dump) or is suspiciously long, fall back to "algo deu errado".
262
+ * - Trim and lowercase the first letter so it reads naturally inside
263
+ * the parens after the action verb.
264
+ */
265
+ declare function humanizeError(raw: string | undefined, _action?: AgentAction): string | undefined;
266
+
267
+ /**
268
+ * Pure presentation logic for ActionBreadcrumb, extracted from the RN
269
+ * component (same pattern as `humanizeAction.ts` / `chatTimeline.ts`)
270
+ * so it can be unit tested without a renderer:
271
+ * - lifecycle state → tone (colors) and icon glyph;
272
+ * - destructive detection (payload flag or action-level flag);
273
+ * - confirm-card copy + colors derivation (title / message / button
274
+ * labels / accent color / surface / border) with the
275
+ * destructive-aware defaults.
276
+ *
277
+ * BACKLOG 4.2 — theming: this module used to hardcode every color
278
+ * (`#FFFFFF` card background, `#DC2626` destructive red, etc.), which is
279
+ * why the theme's `secondary`/`success`/`warning`/`error` tokens had no
280
+ * effect on the chat at all — nothing consumed them. Every color now
281
+ * comes from a `BreadcrumbPalette` the caller passes in (ultimately
282
+ * `useAppilotsTheme()` in AppilotsChat). `DEFAULT_BREADCRUMB_PALETTE` is
283
+ * built from the SDK's bundled `defaultLightTheme`, and `tokens.ts` picks
284
+ * its `success`/`warning`/`error` defaults to exactly reproduce the OLD
285
+ * hardcoded hex values below — so a caller on the default theme renders
286
+ * pixel-identical to before.
287
+ */
288
+
289
+ /**
290
+ * The subset of theme tokens the breadcrumb (rows + confirm card)
291
+ * actually renders with. Every field is required here — callers (i.e.
292
+ * `ActionBreadcrumb`) fill gaps from `DEFAULT_BREADCRUMB_PALETTE` before
293
+ * calling into this module, so the pure functions never have to guess.
294
+ */
295
+ interface BreadcrumbPalette {
296
+ /** Running-state tone + spinner/circle tint. Same value as `primaryColor`. */
297
+ primary: string;
298
+ /** High-contrast text — confirm-card title (non-destructive), row labels. */
299
+ text: string;
300
+ /** Muted text — confirm-card body copy, cancel button label. */
301
+ textSecondary: string;
302
+ /** Confirm-card background. */
303
+ surface: string;
304
+ /** Confirm-card border (non-destructive) and the cancel button fill. */
305
+ border: string;
306
+ /** "completed" tone. */
307
+ success: string;
308
+ /** "pending" (queued, not-yet-run) tone. See the token doc in `theme/tokens.ts`. */
309
+ warning: string;
310
+ /** "failed" tone AND every destructive badge/CTA (confirm card, reject button). */
311
+ error: string;
312
+ }
313
+
314
+ /**
315
+ * ActionBreadcrumb — compact, line-per-action progress UI.
316
+ *
317
+ * Replaces the per-action "card" UI with something closer to a CI build
318
+ * log: each action is one line, stamped with an icon that reflects its
319
+ * lifecycle state. Spinners on running actions, checks on success, ✗
320
+ * on failure. Failures show a humanised reason in parens.
321
+ *
322
+ * Why a separate component (instead of leaving render code inline in
323
+ * AppilotsChat.tsx): the lifecycle state animation is non-trivial and
324
+ * the same UI is now also rendered in three places (Mailing the spec
325
+ * — empty state, between message bubbles, and inline footer). Keeping
326
+ * it in one file makes the styling consistent.
327
+ *
328
+ * The component does NOT decide approve/reject visibility on its own —
329
+ * the caller passes `requireApprovalFor(action)` so this component stays
330
+ * presentational and the policy lives where the rest of the auto-execute
331
+ * config does (AppilotsChat).
332
+ */
333
+
334
+ interface ActionBreadcrumbProps {
335
+ /** Actions to render, ordered by emission. Caller dedupes / groups. */
336
+ actions: AgentAction[];
337
+ /** Theme tokens — only the few colours the breadcrumb actually uses. */
338
+ primaryColor: string;
339
+ textColor: string;
340
+ fontFamily: string;
341
+ /**
342
+ * Extra theme tokens used for lifecycle tones (pending/success/failed)
343
+ * and the confirm-card surface/border/destructive accents. Optional —
344
+ * unset fields fall back to the SDK's bundled light theme, so callers
345
+ * that only ever passed `primaryColor`/`textColor`/`fontFamily` (the
346
+ * pre-4.2 shape of this prop set) keep rendering exactly as before.
347
+ */
348
+ palette?: Partial<Omit<BreadcrumbPalette, 'primary' | 'text'>>;
349
+ /**
350
+ * Approve/reject inline buttons appear when this returns true for an
351
+ * action in `pending` state. `confirm`-type actions are normally
352
+ * handled by ConfirmDialog (modal), so callers pass false for those.
353
+ */
354
+ requireApprovalFor?: (action: AgentAction) => boolean;
355
+ /** Required when `requireApprovalFor` returns true for any action. */
356
+ onApprove?: (actionId: string) => void;
357
+ onReject?: (actionId: string) => void;
358
+ }
359
+ declare function ActionBreadcrumb({ actions, primaryColor, textColor, fontFamily, palette, requireApprovalFor, onApprove, onReject, }: ActionBreadcrumbProps): React__default.JSX.Element | null;
360
+
361
+ interface ChatIconProps {
362
+ /** Outer width/height in points. Default 24. */
363
+ size?: number;
364
+ /** Fill color of the bubble. Default white. */
365
+ color?: string;
366
+ }
367
+ /**
368
+ * Default chat-bubble icon used by the AppilotsChat FAB.
369
+ *
370
+ * Designed to be edited:
371
+ * - tweak `size` / `color` via props at the call site
372
+ * - edit the SVG `d` path below to customize the shape
373
+ * - or pass your own React node via the AppilotsChat `triggerIcon`
374
+ * prop and this component is never rendered
375
+ *
376
+ * Implemented with react-native-svg so the result is crisp at any
377
+ * size and works consistently across iOS / Android. The previous
378
+ * emoji-based icon (💬) was unreliable when the device's emoji font
379
+ * did not have the glyph or when an enclosing fontFamily blocked the
380
+ * Apple Color Emoji fallback — it rendered as a `?`-in-box tofu.
381
+ */
382
+ declare function ChatIcon({ size, color }: ChatIconProps): React$1.JSX.Element;
383
+
384
+ interface HeadsetIconProps {
385
+ /** Outer width/height in points. Default 18. */
386
+ size?: number;
387
+ /** Fill color. Default white. */
388
+ color?: string;
389
+ }
390
+ /**
391
+ * Headset glyph for the "talk to a human" header button
392
+ * (docs/human-escalation.md). Same react-native-svg approach as
393
+ * ChatIcon — crisp at any size, no emoji-font tofu.
394
+ */
395
+ declare function HeadsetIcon({ size, color }: HeadsetIconProps): React$1.JSX.Element;
396
+
397
+ /**
398
+ * ListRegistry — runtime metadata for list/collection components.
399
+ *
400
+ * Fiber walking can see currently-mounted rows, but list components
401
+ * know facts the visible subtree may not expose: total item count,
402
+ * refreshing/empty state, and a stable collection id. Auto-tracking
403
+ * registers that metadata here so snapshots can describe collections
404
+ * without relying only on structural guesses.
405
+ */
406
+ interface ListDataPreviewEntry$1 {
407
+ /** 0-based index in the list's backing data. */
408
+ index: number;
409
+ /** Stable key from keyExtractor / item.id when available. */
410
+ key?: string;
411
+ /** Short human-readable projection of the item (capped length). */
412
+ text: string;
413
+ }
414
+ interface ListScrollMetrics {
415
+ /** Current vertical scroll offset in px. */
416
+ offset: number;
417
+ /** Viewport length in px. */
418
+ visibleLength: number;
419
+ /** Total scrollable content length in px. */
420
+ contentLength: number;
421
+ }
422
+ interface ListEntry {
423
+ kind: 'list';
424
+ /** Stable runtime id assigned from testID/accessibilityLabel or generated. */
425
+ id: string;
426
+ /** Component name: FlatList, SectionList, VirtualizedList, FlashList, etc. */
427
+ component: string;
428
+ /** Total items in the backing data set when the component exposes it. */
429
+ itemCount?: number;
430
+ /** Human-readable label if the app supplied one. */
431
+ label?: string;
432
+ /** Screen where this list is registered, when available. */
433
+ screen?: string;
434
+ /** Loading/refreshing state exposed by RN list props. */
435
+ refreshing?: boolean;
436
+ /** True when itemCount is known and zero. */
437
+ empty?: boolean;
438
+ /**
439
+ * Lightweight text projection of the FULL data set (capped). Built by
440
+ * the auto-tracking wrapper from `props.data` so the agent can see
441
+ * rows that virtualization keeps unmounted.
442
+ */
443
+ dataPreview?: ListDataPreviewEntry$1[];
444
+ /** Scroll so the 0-based data index becomes visible. Returns false when unsupported. */
445
+ scrollToIndex?: (index: number) => boolean;
446
+ /** Scroll to an absolute pixel offset. Returns false when unsupported. */
447
+ scrollToOffset?: (offset: number) => boolean;
448
+ /** Read live scroll metrics off the component instance, when possible. */
449
+ getScrollMetrics?: () => ListScrollMetrics | undefined;
450
+ }
451
+ type Listener$1 = (id: string, entry: ListEntry | null) => void;
452
+ type ListRegistry = ListRegistryImpl;
453
+ declare class ListRegistryImpl {
454
+ private lists;
455
+ private listeners;
456
+ register(id: string, entry: ListEntry): void;
457
+ unregister(id: string): void;
458
+ get(id: string): ListEntry | undefined;
459
+ snapshot(): ListEntry[];
460
+ subscribe(listener: Listener$1): () => void;
461
+ clear(): void;
462
+ get size(): number;
463
+ private notify;
464
+ }
465
+ declare const listRegistry: ListRegistry;
466
+ declare function createListRegistry(): ListRegistry;
467
+
468
+ /**
469
+ * Snapshot types — the shape of data captured from the React fiber tree.
470
+ *
471
+ * This is the runtime "view model" of what the user is currently seeing
472
+ * on screen, sent to the AI agent so it has accurate visible state.
473
+ */
474
+ interface InputSnapshot {
475
+ /** Best identifier — testID, accessibilityLabel, or placeholder */
476
+ id?: string;
477
+ /** Human-readable label inferred from accessibilityLabel, label prop, or sibling Text */
478
+ label?: string;
479
+ /** Current value (only present for controlled inputs) */
480
+ value?: string;
481
+ /** Placeholder text */
482
+ placeholder?: string;
483
+ /** Whether the input is editable */
484
+ editable?: boolean;
485
+ /** Whether the input is secure (password field) */
486
+ secure?: boolean;
487
+ /** Inferred type based on keyboardType / secureTextEntry */
488
+ type?: 'text' | 'email' | 'number' | 'phone' | 'password';
489
+ /**
490
+ * True when this input lives inside a currently-visible Modal. When a
491
+ * modal is open, only inModal elements can actually receive touches —
492
+ * everything else is behind the overlay.
493
+ */
494
+ inModal?: boolean;
495
+ }
496
+ interface ButtonSnapshot {
497
+ /** Best identifier — testID, accessibilityLabel, or inferred from child text */
498
+ id?: string;
499
+ /** Human-readable label — usually the visible text inside the button */
500
+ label?: string;
501
+ /** Whether the button is disabled */
502
+ disabled?: boolean;
503
+ /**
504
+ * Whether the button currently appears selected/active — read from
505
+ * `accessibilityState.selected`. Set by grouped, mutually-exclusive
506
+ * controls (SegmentedControl, RadioGroup) where each option is its
507
+ * own pressable target; absent/false for ordinary buttons.
508
+ */
509
+ selected?: boolean;
510
+ /** True when this button lives inside a currently-visible Modal. */
511
+ inModal?: boolean;
512
+ }
513
+ interface ToggleSnapshot {
514
+ /** Best identifier — testID or accessibilityLabel */
515
+ id?: string;
516
+ /** Human-readable label */
517
+ label?: string;
518
+ /** Current on/off state */
519
+ value?: boolean;
520
+ /** True when this toggle lives inside a currently-visible Modal. */
521
+ inModal?: boolean;
522
+ }
523
+ interface SliderSnapshot {
524
+ /** Registry id (the id apps pass to useAppilotsSlider) — the executable handle. */
525
+ id?: string;
526
+ /** Human-readable label */
527
+ label?: string;
528
+ /** Current numeric value */
529
+ value?: number;
530
+ /** Lower bound the executor clamps to */
531
+ min?: number;
532
+ /** Upper bound the executor clamps to */
533
+ max?: number;
534
+ /** Step the executor snaps to (omitted = continuous) */
535
+ step?: number;
536
+ /** Whether the slider is currently disabled */
537
+ disabled?: boolean;
538
+ /** True when this slider lives inside a currently-visible Modal. */
539
+ inModal?: boolean;
540
+ }
541
+ interface ListItemSnapshot {
542
+ /** 1-indexed position within the parent list (matches "selecione o terceiro"). */
543
+ index: number;
544
+ /**
545
+ * 0-based index of this row in the list's backing DATA, when the
546
+ * auto-tracking wrapper stamped it (`__appilotsItemIndex`). For
547
+ * scrolled/virtualized lists this differs from `index`: the first
548
+ * MOUNTED row might be data item 42. Lets the prompt show absolute
549
+ * positions ("#43 of 100") so ordinal references stay correct.
550
+ */
551
+ dataIndex?: number;
552
+ /**
553
+ * React key of the cell, if present (typically the item's domain id
554
+ * from keyExtractor). Useful for the LLM when the user references an
555
+ * item by name and we want to surface a deterministic handle for
556
+ * future tap-by-ordinal resolution (Phase B).
557
+ */
558
+ reactKey?: string;
559
+ /** Runtime key supplied by auto-tracked list renderItem, if available. */
560
+ itemKey?: string;
561
+ /**
562
+ * Texts captured from this item's subtree (vehicle name, plate,
563
+ * tags, etc.). Per-item to preserve row association — the flat
564
+ * `snapshot.texts` lost it.
565
+ */
566
+ texts: string[];
567
+ /** Buttons inside this item — e.g. an inline "Edit" button on a row. */
568
+ buttons: ButtonSnapshot[];
569
+ /** Inputs inside this item — rare but possible (inline edit row). */
570
+ inputs: InputSnapshot[];
571
+ /** Toggles inside this item. */
572
+ toggles: ToggleSnapshot[];
573
+ /**
574
+ * Synthetic id assigned by the walker. Stable within a single
575
+ * snapshot; format `list-<L>-item-<I>` (0-indexed L, 1-indexed I).
576
+ * Used by Phase B's tap-by-ordinal resolution in uiInteractionHandler.
577
+ */
578
+ syntheticId: string;
579
+ }
580
+ interface ListSnapshot {
581
+ /** 0-indexed list ordinal — multiple lists on one screen get 0, 1, 2... */
582
+ index: number;
583
+ /** Runtime list id when auto-tracking or explicit props provide one. */
584
+ id?: string;
585
+ /**
586
+ * The container component name as observed in the fiber tree.
587
+ * Common values: 'FlatList', 'SectionList', 'VirtualizedList',
588
+ * 'FlashList', 'ScrollView' (when detected by N≥2 keyed children).
589
+ */
590
+ containerType: string;
591
+ /** Source that identified this list. */
592
+ source?: 'fiber' | 'auto-tracked' | 'registry';
593
+ /** Total data-set count when the list component exposes it. */
594
+ itemCount?: number;
595
+ /** Number of row items captured in this snapshot. */
596
+ visibleItemCount?: number;
597
+ /** True when the list reports a refresh/loading state. */
598
+ refreshing?: boolean;
599
+ /** True when total item count is known and zero. */
600
+ empty?: boolean;
601
+ /** Human-readable label if the app supplied one. */
602
+ label?: string;
603
+ /**
604
+ * Items in visible order. Real list components may expose one mounted
605
+ * item when virtualization or an overlay limits the visible window;
606
+ * heuristic ScrollView lists still require at least two list-like items.
607
+ */
608
+ items: ListItemSnapshot[];
609
+ /**
610
+ * Lightweight text projection of the list's FULL data set (capped),
611
+ * captured by the auto-tracking wrapper from `props.data`. Lets the
612
+ * agent see/search rows that virtualization keeps unmounted. Each
613
+ * entry: 0-based data index, stable key (keyExtractor), short text.
614
+ */
615
+ dataPreview?: ListDataPreviewEntry[];
616
+ /** Current vertical scroll offset in px, when the SDK could read it. */
617
+ scrollOffsetY?: number;
618
+ /** True when there is scrollable content above the viewport. */
619
+ canScrollUp?: boolean;
620
+ /** True when there is scrollable content below the viewport. */
621
+ canScrollDown?: boolean;
622
+ }
623
+ interface ListDataPreviewEntry {
624
+ /** 0-based index in the list's backing data. */
625
+ index: number;
626
+ /** Stable key from keyExtractor / item.id when available. */
627
+ key?: string;
628
+ /** Short human-readable projection of the item (capped length). */
629
+ text: string;
630
+ }
631
+ interface ChoiceOptionSnapshot {
632
+ /** 1-indexed option position within this group. */
633
+ index: number;
634
+ /** Stable-enough id for the current snapshot/action turn. */
635
+ syntheticId: string;
636
+ /** Best target id if this option is backed by a pressable component. */
637
+ targetId?: string;
638
+ /** Human-readable option label. */
639
+ label?: string;
640
+ /** Text segments that belong to this option. */
641
+ texts: string[];
642
+ /** Whether this option appears selected. */
643
+ selected?: boolean;
644
+ /** Whether this option appears disabled. */
645
+ disabled?: boolean;
646
+ }
647
+ interface ChoiceGroupSnapshot {
648
+ /** 0-indexed group ordinal on the current screen. */
649
+ index: number;
650
+ /** Runtime id when known, usually inherited from a list/collection. */
651
+ id?: string;
652
+ /** Human-readable label when known. */
653
+ label?: string;
654
+ /** Source that produced this choice group. */
655
+ source?: 'list' | 'buttons' | 'heuristic';
656
+ /** Visible options in order. */
657
+ options: ChoiceOptionSnapshot[];
658
+ }
659
+ interface InteractionElementListContext {
660
+ listIndex?: number;
661
+ listId?: string;
662
+ listLabel?: string;
663
+ itemIndex?: number;
664
+ itemKey?: string;
665
+ reactKey?: string;
666
+ syntheticId?: string;
667
+ }
668
+ interface InteractionElementSnapshot {
669
+ /** Stable id for the current screen/content, preferred for tool calls. */
670
+ id: string;
671
+ /** Semantic UI role. */
672
+ role: 'option' | 'button' | 'input' | 'toggle' | 'slider' | 'listItem';
673
+ /** Human-readable label. */
674
+ label?: string;
675
+ /** Text segments associated with this element. */
676
+ texts: string[];
677
+ /** Actions supported by this element. */
678
+ actions: Array<'press' | 'focus' | 'toggle' | 'setValue'>;
679
+ /** Whether the element is currently disabled. */
680
+ disabled?: boolean;
681
+ /** Whether the element appears selected. */
682
+ selected?: boolean;
683
+ /** Source that produced the element. */
684
+ source?: 'list' | 'button' | 'input' | 'toggle' | 'slider' | 'choice';
685
+ /** Legacy/fallback target id, if any. */
686
+ targetId?: string;
687
+ /** Context for row/list options. */
688
+ listContext?: InteractionElementListContext;
689
+ /**
690
+ * True when the underlying component lives inside a currently-visible
691
+ * Modal — the only targets actually touchable while the overlay is up.
692
+ */
693
+ inModal?: boolean;
694
+ }
695
+ interface ScreenSnapshot {
696
+ /** The currently active route name, if known */
697
+ route: string | null;
698
+ /** All visible static text (text content of <Text> components) */
699
+ texts: string[];
700
+ /** All TextInput components currently rendered (and visible) */
701
+ inputs: InputSnapshot[];
702
+ /** All button-like components (TouchableOpacity, Pressable, etc.) */
703
+ buttons: ButtonSnapshot[];
704
+ /** All Switch components */
705
+ toggles: ToggleSnapshot[];
706
+ /**
707
+ * Sliders / adjustable numeric controls. Populated from the
708
+ * ComponentRegistry (useAppilotsSlider) by captureSnapshot — the
709
+ * registry is the only source that knows min/max/step AND can
710
+ * execute set_value, so observation and execution stay in contract.
711
+ */
712
+ sliders: SliderSnapshot[];
713
+ /** Whether an ActivityIndicator is visible (signals loading state) */
714
+ loading: boolean;
715
+ /** Whether a Modal is currently open */
716
+ modalOpen: boolean;
717
+ /**
718
+ * Lists detected in the visible tree. Each list's items have their
719
+ * own per-item texts/buttons/inputs/toggles, NOT duplicated in the
720
+ * flat top-level arrays — that's the whole reason this field exists,
721
+ * to preserve row association the flat shape destroys.
722
+ */
723
+ lists: ListSnapshot[];
724
+ /**
725
+ * Choice groups detected from visible cards/rows/chips/buttons.
726
+ * These are used for select-like flows where no TextInput exists:
727
+ * choose an option by pressing a row/card, then advance.
728
+ */
729
+ choiceGroups: ChoiceGroupSnapshot[];
730
+ /**
731
+ * Interaction graph: visible actionable elements with stable ids,
732
+ * semantic roles, labels, and execution fallbacks. Agents should
733
+ * prefer these ids over synthetic ordinal handles.
734
+ */
735
+ elements: InteractionElementSnapshot[];
736
+ /** Diagnostic counts for debugging */
737
+ stats?: {
738
+ visitedFibers: number;
739
+ skippedHidden: number;
740
+ };
741
+ }
742
+
743
+ type InteractionElementEntry = InteractionElementSnapshot;
744
+ type Listener = (id: string, entry: InteractionElementEntry | null) => void;
745
+ type ElementRegistry = ElementRegistryImpl;
746
+ declare class ElementRegistryImpl {
747
+ private elements;
748
+ private listeners;
749
+ replaceAll(elements: InteractionElementEntry[]): void;
750
+ register(id: string, entry: InteractionElementEntry): void;
751
+ unregister(id: string): void;
752
+ get(id: string): InteractionElementEntry | undefined;
753
+ snapshot(): InteractionElementEntry[];
754
+ subscribe(listener: Listener): () => void;
755
+ clear(): void;
756
+ get size(): number;
757
+ private notify;
758
+ }
759
+ declare const elementRegistry: ElementRegistry;
760
+ declare function createElementRegistry(): ElementRegistry;
761
+
762
+ /**
763
+ * AppilotsRegistryProvider + useResolvedRegistry — opt-in scoping of
764
+ * the ComponentRegistry for multi-tenant / micro-front-end setups.
765
+ *
766
+ * Apps with a single Appilots session don't need this — the global
767
+ * `componentRegistry` singleton works exactly as before. Pré-mortem
768
+ * 2.8 flagged the singleton as a future risk when two Appilots
769
+ * sessions might run in the same JS process; this Provider lets that
770
+ * case isolate without breaking the existing API.
771
+ */
772
+
773
+ /**
774
+ * Scope all child Appilots hooks, auto-tracked components, and action
775
+ * handlers to a specific ComponentRegistry instance instead of the
776
+ * global singleton.
777
+ *
778
+ * Pass the result of `createComponentRegistry()` as `value`. Anything
779
+ * rendered inside this Provider that uses Appilots hooks
780
+ * (useAppilotsField/Target/Toggle) or that is auto-tracked will
781
+ * register here.
782
+ */
783
+ declare function AppilotsRegistryProvider({ value, children, }: {
784
+ value: ComponentRegistry;
785
+ children: React__default.ReactNode;
786
+ }): React__default.ReactElement;
787
+ /**
788
+ * Resolve the active ComponentRegistry. Returns the one provided by
789
+ * the nearest `<AppilotsRegistryProvider>` if any, otherwise the
790
+ * module-level singleton. Safe to call outside of React (e.g. from
791
+ * action handlers) — context lookup is best-effort.
792
+ *
793
+ * Used internally by the SDK; most app code should not need this.
794
+ */
795
+ declare function useResolvedRegistry(): ComponentRegistry;
796
+
797
+ /**
798
+ * initAppilots — SDK initialisation & auto-config resolution.
799
+ *
800
+ * The preferred setup is fully automatic:
801
+ *
802
+ * 1. Add `withAppilots()` to your metro.config.js (one-time):
803
+ * ```js
804
+ * const { withAppilots } = require('@appilots/sdk/metro');
805
+ * module.exports = withAppilots(mergeConfig(defaultConfig, config));
806
+ * ```
807
+ *
808
+ * 2. Create a `.appilotsrc` JSON file at the project root.
809
+ *
810
+ * 3. Use AppilotsProvider with zero props — config is loaded automatically:
811
+ * ```tsx
812
+ * <AppilotsProvider>
813
+ * <App />
814
+ * <AppilotsChat />
815
+ * </AppilotsProvider>
816
+ * ```
817
+ *
818
+ * You can also call initAppilots() manually if you prefer explicit control:
819
+ * ```tsx
820
+ * initAppilots({ projectId: 'my-app', apiKey: 'ak_...' });
821
+ * ```
822
+ */
823
+
824
+ interface AppilotsRC {
825
+ /** Project ID from the Appilots dashboard */
826
+ projectId: string;
827
+ /** SDK API key (ak_...) */
828
+ apiKey?: string;
829
+ /** API base URL (defaults to https://api.appilots.com) */
830
+ apiBaseUrl?: string;
831
+ /** Alias for apiBaseUrl (supported for convenience) */
832
+ apiUrl?: string;
833
+ /** Agent permissions */
834
+ permissions?: Partial<AgentPermissions>;
835
+ /** Enable debug logging */
836
+ debug?: boolean;
837
+ /** Auto-tracking options */
838
+ autoTracking?: {
839
+ /** Enable auto-tracking (default: true) */
840
+ enabled?: boolean;
841
+ /** Also track Pressable components */
842
+ trackPressable?: boolean;
843
+ };
844
+ }
845
+ /**
846
+ * Initialize the Appilots SDK manually. Call once at app startup.
847
+ *
848
+ * @param config - Config object (inline or from require('./.appilotsrc'))
849
+ */
850
+ declare function initAppilots(config: AppilotsRC): void;
851
+ /**
852
+ * Get the global config set by initAppilots() or auto-config.
853
+ * Used internally by AppilotsProvider when no config prop is passed.
854
+ */
855
+ declare function getGlobalConfig(): AppilotsRC | null;
856
+
857
+ /**
858
+ * enableAppilotsAutoTracking — Zero-config auto-registration of UI components.
859
+ *
860
+ * Call this ONCE at app startup (before any rendering). It patches
861
+ * React.createElement to automatically wrap TextInput, Switch, and
862
+ * TouchableOpacity/Pressable with ComponentRegistry registration.
863
+ *
864
+ * Components are identified by their `testID`, `accessibilityLabel`,
865
+ * or `placeholder` props. No changes needed in any component file.
866
+ *
867
+ * Usage:
868
+ * ```tsx
869
+ * // App.tsx — just this ONE line at the top
870
+ * import { enableAppilotsAutoTracking } from '@appilots/sdk';
871
+ * enableAppilotsAutoTracking();
872
+ * ```
873
+ *
874
+ * That's it. Every TextInput with a testID/accessibilityLabel/placeholder
875
+ * in your entire app will auto-register with the AI agent.
876
+ */
877
+
878
+ /**
879
+ * Enable automatic tracking of all UI components in the app.
880
+ * Call once at app startup, before any rendering.
881
+ *
882
+ * @param options - Optional configuration
883
+ */
884
+ declare function enableAppilotsAutoTracking(options?: {
885
+ /** Also track Pressable components (default: true) */
886
+ trackPressable?: boolean;
887
+ /** Debug mode — log registrations to console */
888
+ debug?: boolean;
889
+ }): void;
890
+ /**
891
+ * Patch JSX runtime modules from the app context.
892
+ * Called by the metro.js shim because the SDK's compiled require()
893
+ * may not resolve react/jsx-runtime correctly (tsup __require issue).
894
+ *
895
+ * @internal — not part of the public API
896
+ */
897
+ declare function _patchJsxRuntimes(jsxRuntime: any, jsxDevRuntime: any): void;
898
+ /**
899
+ * Check if auto-tracking is enabled.
900
+ */
901
+ declare function isAutoTrackingEnabled(): boolean;
902
+
903
+ type TraceListener = (entries: AppilotsTraceEntry[]) => void;
904
+ declare function recordAppilotsDebugTrace(entry: Omit<AppilotsTraceEntry, 'id'> & {
905
+ id?: string;
906
+ }): void;
907
+ declare function getAppilotsDebugTraces(): AppilotsTraceEntry[];
908
+ declare function clearAppilotsDebugTraces(): void;
909
+ declare function subscribeAppilotsDebugTraces(listener: TraceListener): () => void;
910
+
911
+ /**
912
+ * captureSnapshot — the public entry point for runtime UI introspection.
913
+ *
914
+ * Call this just before sending a message to the AI agent. It walks
915
+ * the React fiber tree starting from AppilotsProvider's children and
916
+ * returns a structured snapshot of everything currently rendered and
917
+ * visible on screen.
918
+ *
919
+ * Combined with the MCP document (design-time structure) and the
920
+ * navigation state (which route is active), this gives the AI model
921
+ * full awareness of the user's current view.
922
+ */
923
+
924
+ declare function captureSnapshot(): ScreenSnapshot;
925
+
926
+ /**
927
+ * createAppilotsInput — HOC factory that wraps any TextInput-like component
928
+ * and auto-registers it with the ComponentRegistry.
929
+ *
930
+ * Usage (ONE TIME in the component definition file):
931
+ * ```tsx
932
+ * // components/Input.tsx
933
+ * import { createAppilotsInput } from '@appilots/sdk';
934
+ *
935
+ * function BaseInput({ label, value, onChangeText, ...rest }) {
936
+ * return <TextInput value={value} onChangeText={onChangeText} {...rest} />;
937
+ * }
938
+ *
939
+ * // Wrap it — that's it!
940
+ * export const Input = createAppilotsInput(BaseInput);
941
+ * ```
942
+ *
943
+ * Now every usage auto-registers:
944
+ * ```tsx
945
+ * <Input label="E-mail" value={email} onChangeText={setEmail} />
946
+ * // Auto-registered as field "email" (normalized from label)
947
+ * ```
948
+ *
949
+ * Optional explicit ID:
950
+ * ```tsx
951
+ * <Input appilotsId="userEmail" label="E-mail" value={email} onChangeText={setEmail} />
952
+ * ```
953
+ */
954
+
955
+ /** Props that the HOC adds to the wrapped component */
956
+ interface AppilotsInputProps {
957
+ /** Explicit Appilots field ID. If omitted, auto-derived from `label` prop. */
958
+ appilotsId?: string;
959
+ /** Screen name for scoping. If omitted, registers globally. */
960
+ appilotsScreen?: string;
961
+ /** Field type hint. Default: 'text' */
962
+ appilotsFieldType?: FieldEntry['fieldType'];
963
+ /** Set to false to disable auto-registration for this instance. */
964
+ appilotsEnabled?: boolean;
965
+ /**
966
+ * Marks this field's value as sensitive (password/PIN/CVV/API key/etc.)
967
+ * for inputs that can't rely on `secureTextEntry` — e.g. a custom-styled
968
+ * masked field, or a credential entered via a non-password keyboard.
969
+ * Forces `secure: true` on the runtime snapshot, which every downstream
970
+ * redaction layer (prompt serialization, persisted-payload redaction,
971
+ * breadcrumb) already honors. Requires `WrappedComponent` to forward
972
+ * unknown props (including this one) down to its underlying `TextInput`.
973
+ */
974
+ appilotsSensitive?: boolean;
975
+ }
976
+ /**
977
+ * Creates an enhanced Input component that auto-registers with Appilots.
978
+ *
979
+ * The wrapped component MUST accept these props:
980
+ * - `label` (string) — used as auto-ID source
981
+ * - `value` (string) — current field value
982
+ * - `onChangeText` (function) — value setter
983
+ *
984
+ * @param WrappedComponent - Your existing Input component
985
+ * @returns Enhanced component with auto-registration
986
+ */
987
+ declare function createAppilotsInput<P extends {
988
+ label?: string;
989
+ value?: string;
990
+ onChangeText?: (text: string) => void;
991
+ }>(WrappedComponent: React__default.ComponentType<P>): React__default.ComponentType<P & AppilotsInputProps>;
992
+
993
+ /**
994
+ * createAppilotsButton — HOC factory that wraps any Button/Pressable component
995
+ * and auto-registers it as a target in the ComponentRegistry.
996
+ *
997
+ * Usage:
998
+ * ```tsx
999
+ * import { createAppilotsButton } from '@appilots/sdk';
1000
+ *
1001
+ * function BaseButton({ title, onPress, ...rest }) {
1002
+ * return <TouchableOpacity onPress={onPress}><Text>{title}</Text></TouchableOpacity>;
1003
+ * }
1004
+ *
1005
+ * export const Button = createAppilotsButton(BaseButton);
1006
+ * ```
1007
+ *
1008
+ * Now every usage auto-registers:
1009
+ * ```tsx
1010
+ * <Button title="Cadastrar Veículo" onPress={handleSubmit} />
1011
+ * // Auto-registered as target "cadastrarVeiculo"
1012
+ * ```
1013
+ */
1014
+
1015
+ interface AppilotsButtonProps {
1016
+ /** Explicit Appilots target ID. If omitted, auto-derived from `title` prop. */
1017
+ appilotsId?: string;
1018
+ /** Screen name for scoping. */
1019
+ appilotsScreen?: string;
1020
+ /** Set to false to disable auto-registration. */
1021
+ appilotsEnabled?: boolean;
1022
+ }
1023
+ declare function createAppilotsButton<P extends {
1024
+ title?: string;
1025
+ onPress?: () => void;
1026
+ }>(WrappedComponent: React__default.ComponentType<P>): React__default.ComponentType<P & AppilotsButtonProps>;
1027
+
1028
+ /**
1029
+ * createAppilotsSwitch — HOC factory that wraps any Switch/Toggle component
1030
+ * and auto-registers it in the ComponentRegistry.
1031
+ *
1032
+ * Usage:
1033
+ * ```tsx
1034
+ * import { createAppilotsSwitch } from '@appilots/sdk';
1035
+ *
1036
+ * function BaseToggle({ label, value, onValueChange, ...rest }) {
1037
+ * return <Switch value={value} onValueChange={onValueChange} />;
1038
+ * }
1039
+ *
1040
+ * export const Toggle = createAppilotsSwitch(BaseToggle);
1041
+ * ```
1042
+ *
1043
+ * Auto-registers using `label` prop:
1044
+ * ```tsx
1045
+ * <Toggle label="Push Notifications" value={push} onValueChange={setPush} />
1046
+ * // Registered as toggle "pushNotifications"
1047
+ * ```
1048
+ */
1049
+
1050
+ interface AppilotsSwitchProps {
1051
+ /** Explicit Appilots toggle ID. If omitted, auto-derived from `label` prop. */
1052
+ appilotsId?: string;
1053
+ /** Screen name for scoping. */
1054
+ appilotsScreen?: string;
1055
+ /** Set to false to disable auto-registration. */
1056
+ appilotsEnabled?: boolean;
1057
+ }
1058
+ declare function createAppilotsSwitch<P extends {
1059
+ label?: string;
1060
+ value?: boolean;
1061
+ onValueChange?: (value: boolean) => void;
1062
+ }>(WrappedComponent: React__default.ComponentType<P>): React__default.ComponentType<P & AppilotsSwitchProps>;
1063
+
1064
+ /**
1065
+ * navigateHandler — Executes navigation actions using the React Navigation ref.
1066
+ *
1067
+ * Supports: navigate, push, replace, goBack, reset.
1068
+ */
1069
+
1070
+ /**
1071
+ * Structured diagnosis attached to a failed action result (BACKLOG 3.2).
1072
+ * Travels through the executor → useAppilotsChat → /agent/continue so the
1073
+ * server can build a recovery-flavored observation for the model.
1074
+ *
1075
+ * This shape is intentionally a subset of @appilots/shared's
1076
+ * `actionDiagnoseSchema`; we duplicate the literal types here to
1077
+ * avoid forcing the SDK to pull a Zod runtime dep just for this.
1078
+ */
1079
+ type ActionFailureCategory = 'component-not-found' | 'disabled' | 'validation' | 'network-5xx' | 'network-4xx' | 'screen-timeout' | 'ambiguous-target' | 'unknown';
1080
+ interface ActionDiagnose {
1081
+ category: ActionFailureCategory;
1082
+ /** Visible validation message read off the screen, when available */
1083
+ visibleMessage?: string;
1084
+ /** Field id (form_fill failures) */
1085
+ fieldId?: string;
1086
+ /** Component id (ui_interaction failures) */
1087
+ targetId?: string;
1088
+ /** Route name when the failure happened */
1089
+ screen?: string;
1090
+ /** HTTP status when category is `network-*` */
1091
+ httpStatus?: number;
1092
+ /**
1093
+ * When resolution failed because MULTIPLE on-screen targets matched
1094
+ * with equal confidence, the candidate ids/labels are listed here so
1095
+ * the server's recovery hop can offer the model a concrete choice
1096
+ * instead of a blind retry. Capped at 8 entries.
1097
+ */
1098
+ candidates?: string[];
1099
+ /** Optional generic recovery signal; omitted means server derives it. */
1100
+ recoverable?: boolean;
1101
+ /** True when safe continuation needs more user-provided information. */
1102
+ requiresUserInput?: boolean;
1103
+ }
1104
+ interface ActionResult {
1105
+ success: boolean;
1106
+ error?: string;
1107
+ /**
1108
+ * Structured failure detail. Populated by handlers when they can
1109
+ * tell *why* a call failed (registry miss, disabled button, etc.)
1110
+ * — feeds the recovery loop on the server side.
1111
+ */
1112
+ diagnose?: ActionDiagnose;
1113
+ /**
1114
+ * Optional visible effect signal. Older handlers omit it; the server
1115
+ * still falls back to success + toolWithoutEffect.
1116
+ */
1117
+ effect?: 'unknown' | 'none' | 'partial' | 'changed' | 'completed';
1118
+ /** Optional localized status key for UI surfaces that support it. */
1119
+ userVisibleStatusKey?: string;
1120
+ }
1121
+
1122
+ /**
1123
+ * ActionExecutor — Central dispatcher that routes agent actions
1124
+ * to the appropriate handler based on action type.
1125
+ *
1126
+ * Used by useAppilotsActions.approveAction() to actually execute
1127
+ * the action against the live UI.
1128
+ */
1129
+
1130
+ interface ExecutorContext {
1131
+ /** React Navigation ref for navigate actions */
1132
+ navigationRef: React.MutableRefObject<any>;
1133
+ /** SDK permissions from AppilotsConfig */
1134
+ permissions: AgentPermissions;
1135
+ /** Event emitter from AppilotsProvider */
1136
+ emit: (event: AppilotsEvent) => void;
1137
+ /**
1138
+ * Optional component registry override. When the SDK is used in a
1139
+ * multi-tenant / micro-front-end setup, the caller passes the
1140
+ * registry obtained from `<AppilotsRegistryProvider>` here so action
1141
+ * handlers operate on the correct registry instance. When omitted,
1142
+ * handlers use the global singleton (`getDefaultRegistry()`) — the
1143
+ * historical behavior.
1144
+ */
1145
+ registry?: ComponentRegistry;
1146
+ }
1147
+ declare function executeAction(action: AgentAction, context: ExecutorContext): Promise<ActionResult>;
1148
+
1149
+ /**
1150
+ * SDK version — bumped by changesets on release. Lives in its own module
1151
+ * so runtime code (AppilotsClient) can import it without pulling the whole
1152
+ * public barrel in and creating an import cycle.
1153
+ */
1154
+ declare const SDK_VERSION = "0.1.0";
1155
+
1156
+ export { ActionBreadcrumb, type ActionBreadcrumbProps, type ActionResult, AgentAction, AgentPermissions, type AppilotsButtonProps, AppilotsChat, type AppilotsChatMode, type AppilotsChatPosition, type AppilotsChatProps, type AppilotsChatTheme, AppilotsEvent, type AppilotsInputProps, AppilotsLocale, type AppilotsRC, AppilotsRegistryProvider, type AppilotsSwitchProps, AppilotsThemeProvider, type AppilotsThemeProviderProps, AppilotsThemeTokens, AppilotsTraceEntry, type BreadcrumbItem, type BreadcrumbState, type ButtonSnapshot, ChatIcon, type ChatIconProps, type ChoiceGroupSnapshot, type ChoiceOptionSnapshot, ComponentRegistry, ConfirmDialog, type ConfirmDialogProps, type ElementRegistry, type ExecutorContext, FieldEntry, HeadsetIcon, type HeadsetIconProps, type InputSnapshot, type InteractionElementEntry, type InteractionElementListContext, type InteractionElementSnapshot, type ListEntry, type ListItemSnapshot, type ListRegistry, type ListSnapshot, PartialThemeTokens, SDK_VERSION, type ScreenSnapshot, type TailwindResolvedConfig, type ToggleSnapshot, _patchJsxRuntimes, appilotsTheme, appilotsThemeFromTailwind, captureSnapshot, clearAppilotsDebugTraces, createAppilotsButton, createAppilotsInput, createAppilotsSwitch, createElementRegistry, createListRegistry, describeAction, elementRegistry, enableAppilotsAutoTracking, executeAction, getAppilotsDebugTraces, getGlobalConfig, humanizeError, initAppilots, isAutoTrackingEnabled, listRegistry, recordAppilotsDebugTrace, subscribeAppilotsDebugTraces, useAppilotsTheme, useResolvedRegistry };