@sagepilot-ai/react-native-sdk 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -32
- package/android/build.gradle +13 -4
- package/android/src/main/java/ai/sagepilot/reactnativesdk/SagepilotReactNativeSdkPackage.java +2 -0
- package/dist/index.d.mts +25 -12
- package/dist/index.d.ts +25 -12
- package/dist/index.js +604 -138
- package/dist/index.mjs +573 -112
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -12,13 +12,21 @@ The SDK opens the Sagepilot-hosted chat experience inside a React Native WebView
|
|
|
12
12
|
- A Sagepilot workspace id and chat channel id
|
|
13
13
|
- Secure token storage for production apps
|
|
14
14
|
|
|
15
|
-
## Install
|
|
15
|
+
## Install And Configure
|
|
16
|
+
|
|
17
|
+
### 1. Install The Base Chat SDK
|
|
18
|
+
|
|
19
|
+
Use this install when your app wants Sagepilot chat without Sagepilot's Android CameraX implementation:
|
|
16
20
|
|
|
17
21
|
```bash
|
|
18
22
|
npm install @sagepilot-ai/react-native-sdk react-native-webview
|
|
19
23
|
```
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
This installs the base SDK only. It includes `SagepilotChat.configure`, hosted chat WebView, auth/session handling, the native bridge, attachment bridge protocol, `SagepilotFilePickerAdapter`, and custom picker support. It does not include CameraX or Android CameraX Gradle dependencies.
|
|
26
|
+
|
|
27
|
+
### 2. Add Secure Session Storage
|
|
28
|
+
|
|
29
|
+
For production apps, install one secure storage library so Sagepilot customer sessions survive app restarts.
|
|
22
30
|
|
|
23
31
|
```bash
|
|
24
32
|
npm install react-native-keychain
|
|
@@ -30,6 +38,92 @@ Expo apps can use `expo-secure-store` instead:
|
|
|
30
38
|
npx expo install expo-secure-store
|
|
31
39
|
```
|
|
32
40
|
|
|
41
|
+
### 3. Configure The SDK
|
|
42
|
+
|
|
43
|
+
Configure Sagepilot once when your app starts. The minimum working setup is:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { SagepilotChat } from "@sagepilot-ai/react-native-sdk";
|
|
47
|
+
|
|
48
|
+
await SagepilotChat.configure({
|
|
49
|
+
key: "workspace_id:channel_id"
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For production, pass secure token storage:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import * as Keychain from "react-native-keychain";
|
|
57
|
+
import {
|
|
58
|
+
SagepilotChat,
|
|
59
|
+
createKeychainTokenStorage
|
|
60
|
+
} from "@sagepilot-ai/react-native-sdk";
|
|
61
|
+
|
|
62
|
+
await SagepilotChat.configure({
|
|
63
|
+
key: "workspace_id:channel_id",
|
|
64
|
+
tokenStorage: createKeychainTokenStorage(Keychain)
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Then mount `SagepilotChatProvider` once near the top of your app so the SDK can render the hosted chat WebView when you open it:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { useEffect, type ReactNode } from "react";
|
|
72
|
+
import * as Keychain from "react-native-keychain";
|
|
73
|
+
import {
|
|
74
|
+
SagepilotChat,
|
|
75
|
+
SagepilotChatProvider,
|
|
76
|
+
createKeychainTokenStorage
|
|
77
|
+
} from "@sagepilot-ai/react-native-sdk";
|
|
78
|
+
|
|
79
|
+
function SagepilotProvider({ children }: { children: ReactNode }) {
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
void SagepilotChat.configure({
|
|
82
|
+
key: "workspace_id:channel_id",
|
|
83
|
+
tokenStorage: createKeychainTokenStorage(Keychain)
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return () => {
|
|
87
|
+
SagepilotChat.destroy();
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
90
|
+
|
|
91
|
+
return <SagepilotChatProvider>{children}</SagepilotChatProvider>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function App() {
|
|
95
|
+
return (
|
|
96
|
+
<SagepilotProvider>
|
|
97
|
+
<RootNavigator />
|
|
98
|
+
</SagepilotProvider>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 4. Optional: Add Sagepilot Android CameraX
|
|
104
|
+
|
|
105
|
+
Install this addon only when you want Sagepilot's Android in-app CameraX picker. Apps that skip this step keep the smaller base SDK install.
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm install @sagepilot-ai/react-native-camera-addon
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
After installing the addon, run a fresh native Android build. A Metro reload is not enough for React Native autolinking to register `NativeModules.SagepilotInAppCamera`.
|
|
112
|
+
|
|
113
|
+
Then pass the addon picker into `SagepilotChat.configure`:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { SagepilotChat } from "@sagepilot-ai/react-native-sdk";
|
|
117
|
+
import { createSagepilotCameraXFilePicker } from "@sagepilot-ai/react-native-camera-addon";
|
|
118
|
+
|
|
119
|
+
await SagepilotChat.configure({
|
|
120
|
+
key: "workspace_id:channel_id",
|
|
121
|
+
filePicker: createSagepilotCameraXFilePicker()
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
With this setup, the base SDK still owns chat configuration, hosted WebView rendering, auth/session, and the bridge. The camera addon owns CameraX dependencies, native module registration, camera activity, overlay, and image processing.
|
|
126
|
+
|
|
33
127
|
## Configuration Values
|
|
34
128
|
|
|
35
129
|
You configure the SDK with:
|
|
@@ -69,9 +163,6 @@ These options are part of the supported React Native SDK configuration contract.
|
|
|
69
163
|
| `headers` | Additional headers for SDK service requests. Do not pass server API keys or long-lived secrets from a mobile app. |
|
|
70
164
|
| `fetch` | Custom fetch implementation for runtimes that need one. |
|
|
71
165
|
| `tokenStorage` | Secure storage adapter for SDK-created customer session tokens. |
|
|
72
|
-
| `cacheStorage` | Optional durable cache adapter used by SDK features such as native file-picker batch recovery. |
|
|
73
|
-
| `filePicker` | Optional native picker adapter created with `createSagepilotFilePicker(...)` for camera, gallery, and document attachments. |
|
|
74
|
-
| `fileStore` | Optional native file-store adapter created with `createSagepilotFileStore(...)` for durable picked-file bytes. |
|
|
75
166
|
| `anonymousId` | Optional stable anonymous identifier sent when the SDK creates a customer session. |
|
|
76
167
|
| `metadata` | Optional app metadata merged into the session creation payload. |
|
|
77
168
|
| `deviceInfo` | Optional adapter that returns device metadata to include during session creation. |
|
|
@@ -181,50 +272,66 @@ export function ChatLauncher() {
|
|
|
181
272
|
}
|
|
182
273
|
```
|
|
183
274
|
|
|
184
|
-
##
|
|
275
|
+
## Native File Picker
|
|
185
276
|
|
|
186
|
-
|
|
277
|
+
By default, the hosted chat widget's attach button uses the WebView's `<input type="file">`. On low-RAM Android devices this is unreliable: while the system camera is in the foreground, Android can kill the WebView render process, leaving a dead white screen and losing the captured photo.
|
|
278
|
+
|
|
279
|
+
Configure `filePicker` so the attach button uses native pickers instead. Captured files are delivered to the widget over a hardened bridge (protocol v2): they are held in app memory **and** mirrored to `cacheStorage`, then **re-delivered until the widget acknowledges them** — surviving the WebView hydration race, renderer crashes, and (for small batches) full app-process death. Pending batches are pinned to the hosted chat route that requested them, so a recovered photo is re-delivered to the originating thread. On Android the SDK also runs a liveness watchdog on app-resume that repaints and, if the widget is confirmed dead, remounts the WebView.
|
|
187
280
|
|
|
188
|
-
|
|
281
|
+
The base package does not include CameraX. Apps that want the smallest install can use only:
|
|
189
282
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
4. Send the push notification from your backend through APNs, FCM, or your notification provider.
|
|
283
|
+
```bash
|
|
284
|
+
npm install @sagepilot-ai/react-native-sdk react-native-webview
|
|
285
|
+
```
|
|
194
286
|
|
|
195
|
-
|
|
287
|
+
### Optional Android CameraX Addon
|
|
196
288
|
|
|
197
|
-
|
|
289
|
+
Install the CameraX addon only when you want Sagepilot's Android in-app camera implementation:
|
|
198
290
|
|
|
199
|
-
|
|
291
|
+
```bash
|
|
292
|
+
npm install @sagepilot-ai/react-native-camera-addon
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Run a clean native Android rebuild after installing the addon. If you only Metro-reload, the native module is not linked yet and `createSagepilotCameraXFilePicker()` returns `undefined`, so the hosted widget falls back to the WebView file input.
|
|
296
|
+
|
|
297
|
+
Then configure the addon adapter:
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
import { SagepilotChat } from "@sagepilot-ai/react-native-sdk";
|
|
301
|
+
import { createSagepilotCameraXFilePicker } from "@sagepilot-ai/react-native-camera-addon";
|
|
302
|
+
|
|
303
|
+
await SagepilotChat.configure({
|
|
304
|
+
key: "workspace_id:channel_id",
|
|
305
|
+
filePicker: createSagepilotCameraXFilePicker()
|
|
306
|
+
});
|
|
307
|
+
```
|
|
200
308
|
|
|
201
|
-
|
|
309
|
+
The addon owns the Android CameraX Gradle dependencies, `CAMERA` permission merge, native module, camera activity, overlay, and image processing. The base SDK continues to own the hosted chat WebView, auth/session, bridge, attachment protocol, and `SagepilotFilePickerAdapter` type.
|
|
202
310
|
|
|
203
|
-
For the strongest resilience (a photo captured right before the OS kills the app survives the restart,
|
|
311
|
+
For the strongest resilience (a photo captured right before the OS kills the app survives the restart, at any size), pass BOTH `cacheStorage` (stores the tiny manifest) and `fileStore` (stores the bytes on disk). `cacheStorage` alone keeps only small (≤~2MB) batches durable, because Android's AsyncStorage caps a single row near 2MB; `fileStore` lifts that limit by writing bytes to an app-private file and persisting only file keys in the manifest:
|
|
204
312
|
|
|
205
313
|
```ts
|
|
206
314
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
207
|
-
import * as imagePicker from "react-native-image-picker";
|
|
208
|
-
import * as documentsPicker from "@react-native-documents/picker";
|
|
209
315
|
import ReactNativeBlobUtil from "react-native-blob-util";
|
|
210
|
-
import {
|
|
211
|
-
|
|
212
|
-
createSagepilotFilePicker,
|
|
213
|
-
createSagepilotFileStore
|
|
214
|
-
} from "@sagepilot-ai/react-native-sdk";
|
|
316
|
+
import { createAsyncStorageCacheStorage, createSagepilotFileStore } from "@sagepilot-ai/react-native-sdk";
|
|
317
|
+
import { createSagepilotCameraXFilePicker } from "@sagepilot-ai/react-native-camera-addon";
|
|
215
318
|
|
|
216
319
|
await SagepilotChat.configure({
|
|
217
320
|
key: "workspace_id:channel_id",
|
|
218
321
|
cacheStorage: createAsyncStorageCacheStorage(AsyncStorage),
|
|
219
322
|
fileStore: createSagepilotFileStore(ReactNativeBlobUtil),
|
|
220
|
-
filePicker:
|
|
323
|
+
filePicker: createSagepilotCameraXFilePicker()
|
|
221
324
|
});
|
|
222
325
|
```
|
|
223
326
|
|
|
327
|
+
### Host-Provided Pickers
|
|
328
|
+
|
|
329
|
+
You can also provide your own picker modules to the base SDK. Modules are passed in rather than imported by the SDK, so Metro never resolves packages your app did not install.
|
|
330
|
+
|
|
224
331
|
Install the optional dependencies your app needs:
|
|
225
332
|
|
|
226
333
|
```sh
|
|
227
|
-
# Camera
|
|
334
|
+
# Camera/gallery through react-native-image-picker
|
|
228
335
|
npm install react-native-image-picker
|
|
229
336
|
|
|
230
337
|
# Document/file picking (optional)
|
|
@@ -257,11 +364,11 @@ await SagepilotChat.configure({
|
|
|
257
364
|
|
|
258
365
|
Notes:
|
|
259
366
|
|
|
260
|
-
-
|
|
261
|
-
- The
|
|
262
|
-
-
|
|
367
|
+
- Android CameraX images are captured by `@sagepilot-ai/react-native-camera-addon` and downscaled natively (1920px longest edge, JPEG quality 0.8 by default; override with `imageMaxDimension` / `imageQuality`). This keeps memory and upload sizes low on constrained devices.
|
|
368
|
+
- The CameraX addon can also expose Android Photo Picker and document sources from its native module. The base `createSagepilotFilePicker(...)` helper uses only the host-provided modules you pass into it.
|
|
369
|
+
- Gallery multi-select is capped at 5 by default (`imageSelectionLimit`); documents are rejected above 20MB (`documentMaxFileSizeBytes`) and images above 15MB (`imageMaxFileSizeBytes`) **before** they are read into memory, preventing out-of-memory crashes on large files.
|
|
263
370
|
- Failures are never silent: the picker distinguishes user-cancel from real errors and surfaces a typed `code` (`permission_denied`, `camera_unavailable`, `encode_failed`, `file_too_large`, `read_failed`) to the widget.
|
|
264
|
-
- Android apps that
|
|
371
|
+
- Android apps that install the CameraX addon must grant `CAMERA` at runtime; the addon requests it automatically before opening the camera and surfaces a clear message (with a Settings hint) when it is denied. iOS apps using `react-native-image-picker` need `NSCameraUsageDescription` and `NSPhotoLibraryUsageDescription` in `Info.plist`.
|
|
265
372
|
- Apps that skip `filePicker` keep the WebView file input. The SDK still recovers from WebView renderer crashes by reloading the widget, but a photo captured at crash time cannot be restored in that mode.
|
|
266
373
|
|
|
267
374
|
## Secure Session Storage
|
|
@@ -311,7 +418,7 @@ Configure the SDK after your app knows the current workspace/channel and, if ava
|
|
|
311
418
|
|
|
312
419
|
```tsx
|
|
313
420
|
import * as Keychain from "react-native-keychain";
|
|
314
|
-
import { useEffect } from "react";
|
|
421
|
+
import { useEffect, type ReactNode } from "react";
|
|
315
422
|
import {
|
|
316
423
|
SagepilotChat,
|
|
317
424
|
SagepilotChatProvider,
|
|
@@ -320,7 +427,7 @@ import {
|
|
|
320
427
|
|
|
321
428
|
const tokenStorage = createKeychainTokenStorage(Keychain);
|
|
322
429
|
|
|
323
|
-
export function SagepilotProvider({ children }: { children:
|
|
430
|
+
export function SagepilotProvider({ children }: { children: ReactNode }) {
|
|
324
431
|
useEffect(() => {
|
|
325
432
|
let cancelled = false;
|
|
326
433
|
|
package/android/build.gradle
CHANGED
|
@@ -3,18 +3,23 @@ buildscript {
|
|
|
3
3
|
google()
|
|
4
4
|
mavenCentral()
|
|
5
5
|
}
|
|
6
|
+
dependencies {
|
|
7
|
+
classpath "com.android.tools.build:gradle:8.5.0"
|
|
8
|
+
}
|
|
6
9
|
}
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
id "com.android.library"
|
|
10
|
-
}
|
|
11
|
+
apply plugin: "com.android.library"
|
|
11
12
|
|
|
12
13
|
def isNewArchitectureEnabled() {
|
|
13
14
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
if (isNewArchitectureEnabled()) {
|
|
17
|
-
|
|
18
|
+
try {
|
|
19
|
+
apply plugin: "com.facebook.react"
|
|
20
|
+
} catch (e) {
|
|
21
|
+
logger.warn("Could not apply 'com.facebook.react' plugin. This is expected if syncing the library standalone.")
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
def safeExtGet(prop, fallback) {
|
|
@@ -31,6 +36,10 @@ android {
|
|
|
31
36
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
buildFeatures {
|
|
40
|
+
buildConfig true
|
|
41
|
+
}
|
|
42
|
+
|
|
34
43
|
compileOptions {
|
|
35
44
|
sourceCompatibility JavaVersion.VERSION_17
|
|
36
45
|
targetCompatibility JavaVersion.VERSION_17
|
package/android/src/main/java/ai/sagepilot/reactnativesdk/SagepilotReactNativeSdkPackage.java
CHANGED
|
@@ -8,11 +8,13 @@ import java.util.Collections;
|
|
|
8
8
|
import java.util.List;
|
|
9
9
|
|
|
10
10
|
public class SagepilotReactNativeSdkPackage implements ReactPackage {
|
|
11
|
+
/** Registers SDK-owned native modules exposed to JavaScript. */
|
|
11
12
|
@Override
|
|
12
13
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
13
14
|
return Collections.emptyList();
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
/** Registers the existing SDK view managers without changing their surface. */
|
|
16
18
|
@Override
|
|
17
19
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
18
20
|
return Collections.singletonList(new SagepilotInsetsViewManager());
|
package/dist/index.d.mts
CHANGED
|
@@ -11,6 +11,21 @@ type SagepilotPickedFile = {
|
|
|
11
11
|
size: number;
|
|
12
12
|
data_base64: string;
|
|
13
13
|
};
|
|
14
|
+
type SagepilotFilePickerErrorCode = "permission_denied" | "camera_unavailable" | "encode_failed" | "file_too_large" | "read_failed" | "unknown";
|
|
15
|
+
/**
|
|
16
|
+
* Structured picker failure. The provider maps `.code` to a user-facing message
|
|
17
|
+
* and surfaces it via sagepilot:file_picker_error so a failed capture is never
|
|
18
|
+
* silently swallowed.
|
|
19
|
+
*/
|
|
20
|
+
declare class SagepilotFilePickerError extends Error {
|
|
21
|
+
readonly code: SagepilotFilePickerErrorCode;
|
|
22
|
+
/** Creates a typed picker error that can be surfaced over the widget bridge. */
|
|
23
|
+
constructor(code: SagepilotFilePickerErrorCode, message: string);
|
|
24
|
+
}
|
|
25
|
+
declare const SAGEPILOT_DEFAULT_IMAGE_MAX_DIMENSION = 1920;
|
|
26
|
+
declare const SAGEPILOT_DEFAULT_IMAGE_QUALITY = 0.8;
|
|
27
|
+
declare const SAGEPILOT_DEFAULT_IMAGE_MAX_FILE_SIZE_BYTES: number;
|
|
28
|
+
|
|
14
29
|
type SagepilotFilePickerSource = "camera" | "library" | "documents";
|
|
15
30
|
type SagepilotFilePickerRequest = {
|
|
16
31
|
source: SagepilotFilePickerSource;
|
|
@@ -97,18 +112,15 @@ type SagepilotCreateFilePickerOptions = {
|
|
|
97
112
|
/** Reject camera/library images larger than this (bytes). */
|
|
98
113
|
imageMaxFileSizeBytes?: number;
|
|
99
114
|
};
|
|
100
|
-
|
|
115
|
+
/** Shows an actionable Android settings prompt after permanent camera denial. */
|
|
116
|
+
declare function promptOpenSagepilotCameraSettings(): Promise<void>;
|
|
101
117
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* from a real user cancel).
|
|
118
|
+
* Android apps that declare the CAMERA permission must also hold it at runtime
|
|
119
|
+
* before the SDK-owned camera screen can open. Request it defensively; apps
|
|
120
|
+
* that never declared it are unaffected and native launch can surface the real
|
|
121
|
+
* failure.
|
|
107
122
|
*/
|
|
108
|
-
declare
|
|
109
|
-
readonly code: SagepilotFilePickerErrorCode;
|
|
110
|
-
constructor(code: SagepilotFilePickerErrorCode, message: string);
|
|
111
|
-
}
|
|
123
|
+
declare function ensureSagepilotAndroidCameraPermission(): Promise<void>;
|
|
112
124
|
/**
|
|
113
125
|
* Builds the SDK file picker adapter from host-app-installed native modules.
|
|
114
126
|
* Modules are passed in (rather than required by the SDK) so Metro never
|
|
@@ -300,7 +312,8 @@ type SagepilotMobileConfig = {
|
|
|
300
312
|
* Native file picker used by the hosted chat widget's attach button.
|
|
301
313
|
* Strongly recommended: in-WebView camera capture is unreliable on
|
|
302
314
|
* low-RAM Android devices (the OS can kill the WebView render process
|
|
303
|
-
* while the camera is open). Build with createSagepilotFilePicker()
|
|
315
|
+
* while the camera is open). Build with createSagepilotFilePicker() or
|
|
316
|
+
* the optional @sagepilot-ai/react-native-camera-addon package.
|
|
304
317
|
*/
|
|
305
318
|
filePicker?: SagepilotFilePickerAdapter;
|
|
306
319
|
/**
|
|
@@ -543,4 +556,4 @@ declare function SagepilotChatProvider({ children, closeLabel, loadingLabel }: S
|
|
|
543
556
|
|
|
544
557
|
declare function useSagepilotChat(): SagepilotChatHookState;
|
|
545
558
|
|
|
546
|
-
export { type SagepilotBiometricsAdapter, type SagepilotBlobUtilLike, type SagepilotBootstrapChannelResponse, type SagepilotCacheStorage, SagepilotChat, SagepilotChatError, type SagepilotChatErrorCode, type SagepilotChatHookState, SagepilotChatProvider, type SagepilotChatProviderProps, type SagepilotConversationCreatedEvent, type SagepilotCreateFilePickerOptions, type SagepilotCreateFileStoreOptions, type SagepilotDeviceInfo, type SagepilotDeviceInfoAdapter, type SagepilotDocumentsPickerModule, type SagepilotFilePickerAdapter, SagepilotFilePickerError, type SagepilotFilePickerErrorCode, type SagepilotFilePickerRequest, type SagepilotFilePickerSource, type SagepilotFileReaderModule, type SagepilotIdentifyResult, type SagepilotIdentity, type SagepilotIdentityState, type SagepilotImagePickerModule, type SagepilotImagePickerResult, type SagepilotLifecycleState, type SagepilotLogoutResponse, type SagepilotMessageComposerOptions, type SagepilotMobileBehaviorConfig, type SagepilotMobileColorScheme, type SagepilotMobileConfig, type SagepilotMobileConfigureResult, type SagepilotMobileLauncherConfig, type SagepilotMobilePresentationConfig, type SagepilotMobilePresentationStyle, type SagepilotMobileResolvedLauncherConfig, type SagepilotMobileState, type SagepilotMobileSubscription, type SagepilotMobileThemeConfig, type SagepilotMobileThemeState, type SagepilotPersistedFileStore, type SagepilotPickedFile, type SagepilotSessionState, type SagepilotTokenStorage, type SagepilotUnreadState, createAsyncStorageCacheStorage, createKeychainTokenStorage, createSagepilotFilePicker, createSagepilotFileStore, useSagepilotChat };
|
|
559
|
+
export { SAGEPILOT_DEFAULT_IMAGE_MAX_DIMENSION, SAGEPILOT_DEFAULT_IMAGE_MAX_FILE_SIZE_BYTES, SAGEPILOT_DEFAULT_IMAGE_QUALITY, type SagepilotBiometricsAdapter, type SagepilotBlobUtilLike, type SagepilotBootstrapChannelResponse, type SagepilotCacheStorage, SagepilotChat, SagepilotChatError, type SagepilotChatErrorCode, type SagepilotChatHookState, SagepilotChatProvider, type SagepilotChatProviderProps, type SagepilotConversationCreatedEvent, type SagepilotCreateFilePickerOptions, type SagepilotCreateFileStoreOptions, type SagepilotDeviceInfo, type SagepilotDeviceInfoAdapter, type SagepilotDocumentsPickerModule, type SagepilotFilePickerAdapter, SagepilotFilePickerError, type SagepilotFilePickerErrorCode, type SagepilotFilePickerRequest, type SagepilotFilePickerSource, type SagepilotFileReaderModule, type SagepilotIdentifyResult, type SagepilotIdentity, type SagepilotIdentityState, type SagepilotImagePickerModule, type SagepilotImagePickerResult, type SagepilotLifecycleState, type SagepilotLogoutResponse, type SagepilotMessageComposerOptions, type SagepilotMobileBehaviorConfig, type SagepilotMobileColorScheme, type SagepilotMobileConfig, type SagepilotMobileConfigureResult, type SagepilotMobileLauncherConfig, type SagepilotMobilePresentationConfig, type SagepilotMobilePresentationStyle, type SagepilotMobileResolvedLauncherConfig, type SagepilotMobileState, type SagepilotMobileSubscription, type SagepilotMobileThemeConfig, type SagepilotMobileThemeState, type SagepilotPersistedFileStore, type SagepilotPickedFile, type SagepilotSessionState, type SagepilotTokenStorage, type SagepilotUnreadState, createAsyncStorageCacheStorage, createKeychainTokenStorage, createSagepilotFilePicker, createSagepilotFileStore, ensureSagepilotAndroidCameraPermission, promptOpenSagepilotCameraSettings, useSagepilotChat };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,21 @@ type SagepilotPickedFile = {
|
|
|
11
11
|
size: number;
|
|
12
12
|
data_base64: string;
|
|
13
13
|
};
|
|
14
|
+
type SagepilotFilePickerErrorCode = "permission_denied" | "camera_unavailable" | "encode_failed" | "file_too_large" | "read_failed" | "unknown";
|
|
15
|
+
/**
|
|
16
|
+
* Structured picker failure. The provider maps `.code` to a user-facing message
|
|
17
|
+
* and surfaces it via sagepilot:file_picker_error so a failed capture is never
|
|
18
|
+
* silently swallowed.
|
|
19
|
+
*/
|
|
20
|
+
declare class SagepilotFilePickerError extends Error {
|
|
21
|
+
readonly code: SagepilotFilePickerErrorCode;
|
|
22
|
+
/** Creates a typed picker error that can be surfaced over the widget bridge. */
|
|
23
|
+
constructor(code: SagepilotFilePickerErrorCode, message: string);
|
|
24
|
+
}
|
|
25
|
+
declare const SAGEPILOT_DEFAULT_IMAGE_MAX_DIMENSION = 1920;
|
|
26
|
+
declare const SAGEPILOT_DEFAULT_IMAGE_QUALITY = 0.8;
|
|
27
|
+
declare const SAGEPILOT_DEFAULT_IMAGE_MAX_FILE_SIZE_BYTES: number;
|
|
28
|
+
|
|
14
29
|
type SagepilotFilePickerSource = "camera" | "library" | "documents";
|
|
15
30
|
type SagepilotFilePickerRequest = {
|
|
16
31
|
source: SagepilotFilePickerSource;
|
|
@@ -97,18 +112,15 @@ type SagepilotCreateFilePickerOptions = {
|
|
|
97
112
|
/** Reject camera/library images larger than this (bytes). */
|
|
98
113
|
imageMaxFileSizeBytes?: number;
|
|
99
114
|
};
|
|
100
|
-
|
|
115
|
+
/** Shows an actionable Android settings prompt after permanent camera denial. */
|
|
116
|
+
declare function promptOpenSagepilotCameraSettings(): Promise<void>;
|
|
101
117
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* from a real user cancel).
|
|
118
|
+
* Android apps that declare the CAMERA permission must also hold it at runtime
|
|
119
|
+
* before the SDK-owned camera screen can open. Request it defensively; apps
|
|
120
|
+
* that never declared it are unaffected and native launch can surface the real
|
|
121
|
+
* failure.
|
|
107
122
|
*/
|
|
108
|
-
declare
|
|
109
|
-
readonly code: SagepilotFilePickerErrorCode;
|
|
110
|
-
constructor(code: SagepilotFilePickerErrorCode, message: string);
|
|
111
|
-
}
|
|
123
|
+
declare function ensureSagepilotAndroidCameraPermission(): Promise<void>;
|
|
112
124
|
/**
|
|
113
125
|
* Builds the SDK file picker adapter from host-app-installed native modules.
|
|
114
126
|
* Modules are passed in (rather than required by the SDK) so Metro never
|
|
@@ -300,7 +312,8 @@ type SagepilotMobileConfig = {
|
|
|
300
312
|
* Native file picker used by the hosted chat widget's attach button.
|
|
301
313
|
* Strongly recommended: in-WebView camera capture is unreliable on
|
|
302
314
|
* low-RAM Android devices (the OS can kill the WebView render process
|
|
303
|
-
* while the camera is open). Build with createSagepilotFilePicker()
|
|
315
|
+
* while the camera is open). Build with createSagepilotFilePicker() or
|
|
316
|
+
* the optional @sagepilot-ai/react-native-camera-addon package.
|
|
304
317
|
*/
|
|
305
318
|
filePicker?: SagepilotFilePickerAdapter;
|
|
306
319
|
/**
|
|
@@ -543,4 +556,4 @@ declare function SagepilotChatProvider({ children, closeLabel, loadingLabel }: S
|
|
|
543
556
|
|
|
544
557
|
declare function useSagepilotChat(): SagepilotChatHookState;
|
|
545
558
|
|
|
546
|
-
export { type SagepilotBiometricsAdapter, type SagepilotBlobUtilLike, type SagepilotBootstrapChannelResponse, type SagepilotCacheStorage, SagepilotChat, SagepilotChatError, type SagepilotChatErrorCode, type SagepilotChatHookState, SagepilotChatProvider, type SagepilotChatProviderProps, type SagepilotConversationCreatedEvent, type SagepilotCreateFilePickerOptions, type SagepilotCreateFileStoreOptions, type SagepilotDeviceInfo, type SagepilotDeviceInfoAdapter, type SagepilotDocumentsPickerModule, type SagepilotFilePickerAdapter, SagepilotFilePickerError, type SagepilotFilePickerErrorCode, type SagepilotFilePickerRequest, type SagepilotFilePickerSource, type SagepilotFileReaderModule, type SagepilotIdentifyResult, type SagepilotIdentity, type SagepilotIdentityState, type SagepilotImagePickerModule, type SagepilotImagePickerResult, type SagepilotLifecycleState, type SagepilotLogoutResponse, type SagepilotMessageComposerOptions, type SagepilotMobileBehaviorConfig, type SagepilotMobileColorScheme, type SagepilotMobileConfig, type SagepilotMobileConfigureResult, type SagepilotMobileLauncherConfig, type SagepilotMobilePresentationConfig, type SagepilotMobilePresentationStyle, type SagepilotMobileResolvedLauncherConfig, type SagepilotMobileState, type SagepilotMobileSubscription, type SagepilotMobileThemeConfig, type SagepilotMobileThemeState, type SagepilotPersistedFileStore, type SagepilotPickedFile, type SagepilotSessionState, type SagepilotTokenStorage, type SagepilotUnreadState, createAsyncStorageCacheStorage, createKeychainTokenStorage, createSagepilotFilePicker, createSagepilotFileStore, useSagepilotChat };
|
|
559
|
+
export { SAGEPILOT_DEFAULT_IMAGE_MAX_DIMENSION, SAGEPILOT_DEFAULT_IMAGE_MAX_FILE_SIZE_BYTES, SAGEPILOT_DEFAULT_IMAGE_QUALITY, type SagepilotBiometricsAdapter, type SagepilotBlobUtilLike, type SagepilotBootstrapChannelResponse, type SagepilotCacheStorage, SagepilotChat, SagepilotChatError, type SagepilotChatErrorCode, type SagepilotChatHookState, SagepilotChatProvider, type SagepilotChatProviderProps, type SagepilotConversationCreatedEvent, type SagepilotCreateFilePickerOptions, type SagepilotCreateFileStoreOptions, type SagepilotDeviceInfo, type SagepilotDeviceInfoAdapter, type SagepilotDocumentsPickerModule, type SagepilotFilePickerAdapter, SagepilotFilePickerError, type SagepilotFilePickerErrorCode, type SagepilotFilePickerRequest, type SagepilotFilePickerSource, type SagepilotFileReaderModule, type SagepilotIdentifyResult, type SagepilotIdentity, type SagepilotIdentityState, type SagepilotImagePickerModule, type SagepilotImagePickerResult, type SagepilotLifecycleState, type SagepilotLogoutResponse, type SagepilotMessageComposerOptions, type SagepilotMobileBehaviorConfig, type SagepilotMobileColorScheme, type SagepilotMobileConfig, type SagepilotMobileConfigureResult, type SagepilotMobileLauncherConfig, type SagepilotMobilePresentationConfig, type SagepilotMobilePresentationStyle, type SagepilotMobileResolvedLauncherConfig, type SagepilotMobileState, type SagepilotMobileSubscription, type SagepilotMobileThemeConfig, type SagepilotMobileThemeState, type SagepilotPersistedFileStore, type SagepilotPickedFile, type SagepilotSessionState, type SagepilotTokenStorage, type SagepilotUnreadState, createAsyncStorageCacheStorage, createKeychainTokenStorage, createSagepilotFilePicker, createSagepilotFileStore, ensureSagepilotAndroidCameraPermission, promptOpenSagepilotCameraSettings, useSagepilotChat };
|