@gr33n-ai/jade-sdk-rn-client 0.1.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 +168 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2824 -0
- package/dist/index.mjs +2792 -0
- package/dist/react-native/index.d.mts +339 -0
- package/dist/react-native/index.d.ts +339 -0
- package/dist/react-native/index.js +2795 -0
- package/dist/react-native/index.mjs +2784 -0
- package/package.json +80 -0
package/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# @gr33n-ai/jade-sdk-rn-client
|
|
2
|
+
|
|
3
|
+
React Native client for [Jade AI](https://jade.gr33n.ai) - generate images, videos, and audio on mobile.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gr33n-ai/jade-sdk-rn-client @react-native-async-storage/async-storage
|
|
9
|
+
# or
|
|
10
|
+
yarn add @gr33n-ai/jade-sdk-rn-client @react-native-async-storage/async-storage
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### iOS
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd ios && pod install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
RNAgentProvider,
|
|
24
|
+
useJadeSession,
|
|
25
|
+
createAsyncStorageAdapter,
|
|
26
|
+
} from '@gr33n-ai/jade-sdk-rn-client/react-native';
|
|
27
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
28
|
+
|
|
29
|
+
const storage = createAsyncStorageAdapter(AsyncStorage);
|
|
30
|
+
|
|
31
|
+
function App() {
|
|
32
|
+
return (
|
|
33
|
+
<RNAgentProvider
|
|
34
|
+
config={{
|
|
35
|
+
endpoint: 'https://api.jade.gr33n.ai',
|
|
36
|
+
getAuthToken: async () => await AsyncStorage.getItem('@gr33n-ai/api-key'),
|
|
37
|
+
}}
|
|
38
|
+
storage={storage}
|
|
39
|
+
>
|
|
40
|
+
<Chat />
|
|
41
|
+
</RNAgentProvider>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Chat() {
|
|
46
|
+
const { processedConversation, sendMessage, media, isStreaming } = useJadeSession();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<View>
|
|
50
|
+
<FlatList
|
|
51
|
+
data={processedConversation}
|
|
52
|
+
renderItem={({ item }) => (
|
|
53
|
+
<View>
|
|
54
|
+
<Text>{item.entry.text}</Text>
|
|
55
|
+
{item.mediaUrls?.map(url => (
|
|
56
|
+
<Image key={url} source={{ uri: url }} style={{ width: 200, height: 200 }} />
|
|
57
|
+
))}
|
|
58
|
+
</View>
|
|
59
|
+
)}
|
|
60
|
+
/>
|
|
61
|
+
<Button
|
|
62
|
+
title="Generate"
|
|
63
|
+
onPress={() => sendMessage('Generate an image of a sunset')}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Features
|
|
71
|
+
|
|
72
|
+
- **Native SSE Streaming**: Uses `react-native-sse` for reliable streaming
|
|
73
|
+
- **Media Generation**: Generate images, videos, and audio
|
|
74
|
+
- **Persistent Storage**: Support for AsyncStorage, MMKV, and custom adapters
|
|
75
|
+
- **Background Handling**: Automatic pause/resume on app state changes
|
|
76
|
+
- **Type-Safe**: Full TypeScript support
|
|
77
|
+
|
|
78
|
+
## Documentation
|
|
79
|
+
|
|
80
|
+
Full documentation available at [docs.gr33n.ai](https://docs.gr33n.ai)
|
|
81
|
+
|
|
82
|
+
- [React Native Quickstart](https://docs.gr33n.ai/quickstart/react-native)
|
|
83
|
+
- [Storage Adapters](https://docs.gr33n.ai/react-native/storage)
|
|
84
|
+
- [App State Handling](https://docs.gr33n.ai/react-native/app-state)
|
|
85
|
+
|
|
86
|
+
## API
|
|
87
|
+
|
|
88
|
+
### RNAgentProvider
|
|
89
|
+
|
|
90
|
+
Wrap your app with `RNAgentProvider`:
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
<RNAgentProvider
|
|
94
|
+
config={{
|
|
95
|
+
endpoint: 'https://api.jade.gr33n.ai',
|
|
96
|
+
getAuthToken: async () => await getApiKey(),
|
|
97
|
+
}}
|
|
98
|
+
storage={storage}
|
|
99
|
+
pauseOnBackground={true}
|
|
100
|
+
>
|
|
101
|
+
<App />
|
|
102
|
+
</RNAgentProvider>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### useJadeSession
|
|
106
|
+
|
|
107
|
+
Main hook for chat functionality:
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
const {
|
|
111
|
+
processedConversation,
|
|
112
|
+
media,
|
|
113
|
+
isStreaming,
|
|
114
|
+
sessionId,
|
|
115
|
+
sendMessage,
|
|
116
|
+
cancel,
|
|
117
|
+
clear,
|
|
118
|
+
loadSession,
|
|
119
|
+
reconnect,
|
|
120
|
+
} = useJadeSession();
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Storage Adapters
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import {
|
|
127
|
+
createAsyncStorageAdapter,
|
|
128
|
+
createMMKVAdapter,
|
|
129
|
+
createMemoryStorageAdapter,
|
|
130
|
+
} from '@gr33n-ai/jade-sdk-rn-client/react-native';
|
|
131
|
+
|
|
132
|
+
// AsyncStorage (recommended)
|
|
133
|
+
const storage = createAsyncStorageAdapter(AsyncStorage);
|
|
134
|
+
|
|
135
|
+
// MMKV (high performance)
|
|
136
|
+
const storage = createMMKVAdapter(mmkv);
|
|
137
|
+
|
|
138
|
+
// In-memory (testing)
|
|
139
|
+
const storage = createMemoryStorageAdapter();
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Hooks
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import {
|
|
146
|
+
useRNAgentClient, // Access the client
|
|
147
|
+
useStorage, // Access storage adapter
|
|
148
|
+
useAppState, // Monitor app state
|
|
149
|
+
} from '@gr33n-ai/jade-sdk-rn-client/react-native';
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Requirements
|
|
153
|
+
|
|
154
|
+
- React Native 0.72+
|
|
155
|
+
- React 18+
|
|
156
|
+
- iOS 13+ / Android 6+
|
|
157
|
+
|
|
158
|
+
## Expo Support
|
|
159
|
+
|
|
160
|
+
Works with Expo. Install using:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npx expo install @gr33n-ai/jade-sdk-rn-client @react-native-async-storage/async-storage
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from '@gr33n-ai/jade-sdk-client';
|
|
2
|
+
export { ConversationEntry, MediaInfo, ProcessedEntry, ProcessingOptions, SessionMetadata, SkillMetadata, StreamingToolCall } from '@gr33n-ai/jade-sdk-client';
|
|
3
|
+
export { R as AgentClient, R as RNAgentClient, RNAgentProvider, RNAgentProviderProps, STORAGE_KEYS, StorageAdapter, UseJadeSessionOptions, UseJadeSessionReturn, UseRNAgentSessionOptions, UseRNAgentSessionReturn, createAsyncStorageAdapter, createMMKVAdapter, createMemoryStorageAdapter, useAppState, useJadeSession, useRNAgentClient, useRNAgentSession, useStorage } from './react-native/index.mjs';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'react-native';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from '@gr33n-ai/jade-sdk-client';
|
|
2
|
+
export { ConversationEntry, MediaInfo, ProcessedEntry, ProcessingOptions, SessionMetadata, SkillMetadata, StreamingToolCall } from '@gr33n-ai/jade-sdk-client';
|
|
3
|
+
export { R as AgentClient, R as RNAgentClient, RNAgentProvider, RNAgentProviderProps, STORAGE_KEYS, StorageAdapter, UseJadeSessionOptions, UseJadeSessionReturn, UseRNAgentSessionOptions, UseRNAgentSessionReturn, createAsyncStorageAdapter, createMMKVAdapter, createMemoryStorageAdapter, useAppState, useJadeSession, useRNAgentClient, useRNAgentSession, useStorage } from './react-native/index.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'react-native';
|