@gr33n-ai/jade-sdk-rn-client 0.1.0 → 0.1.3

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 CHANGED
@@ -20,17 +20,17 @@ cd ios && pod install
20
20
 
21
21
  ```tsx
22
22
  import {
23
- RNAgentProvider,
23
+ JadeProvider,
24
24
  useJadeSession,
25
25
  createAsyncStorageAdapter,
26
- } from '@gr33n-ai/jade-sdk-rn-client/react-native';
26
+ } from '@gr33n-ai/jade-sdk-rn-client';
27
27
  import AsyncStorage from '@react-native-async-storage/async-storage';
28
28
 
29
29
  const storage = createAsyncStorageAdapter(AsyncStorage);
30
30
 
31
31
  function App() {
32
32
  return (
33
- <RNAgentProvider
33
+ <JadeProvider
34
34
  config={{
35
35
  endpoint: 'https://api.jade.gr33n.ai',
36
36
  getAuthToken: async () => await AsyncStorage.getItem('@gr33n-ai/api-key'),
@@ -38,7 +38,7 @@ function App() {
38
38
  storage={storage}
39
39
  >
40
40
  <Chat />
41
- </RNAgentProvider>
41
+ </JadeProvider>
42
42
  );
43
43
  }
44
44
 
@@ -85,12 +85,12 @@ Full documentation available at [docs.gr33n.ai](https://docs.gr33n.ai)
85
85
 
86
86
  ## API
87
87
 
88
- ### RNAgentProvider
88
+ ### JadeProvider
89
89
 
90
- Wrap your app with `RNAgentProvider`:
90
+ Wrap your app with `JadeProvider`:
91
91
 
92
92
  ```tsx
93
- <RNAgentProvider
93
+ <JadeProvider
94
94
  config={{
95
95
  endpoint: 'https://api.jade.gr33n.ai',
96
96
  getAuthToken: async () => await getApiKey(),
@@ -99,7 +99,7 @@ Wrap your app with `RNAgentProvider`:
99
99
  pauseOnBackground={true}
100
100
  >
101
101
  <App />
102
- </RNAgentProvider>
102
+ </JadeProvider>
103
103
  ```
104
104
 
105
105
  ### useJadeSession
@@ -127,7 +127,7 @@ import {
127
127
  createAsyncStorageAdapter,
128
128
  createMMKVAdapter,
129
129
  createMemoryStorageAdapter,
130
- } from '@gr33n-ai/jade-sdk-rn-client/react-native';
130
+ } from '@gr33n-ai/jade-sdk-rn-client';
131
131
 
132
132
  // AsyncStorage (recommended)
133
133
  const storage = createAsyncStorageAdapter(AsyncStorage);
@@ -143,10 +143,10 @@ const storage = createMemoryStorageAdapter();
143
143
 
144
144
  ```tsx
145
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';
146
+ useJadeClient, // Access the client
147
+ useStorage, // Access storage adapter
148
+ useAppState, // Monitor app state
149
+ } from '@gr33n-ai/jade-sdk-rn-client';
150
150
  ```
151
151
 
152
152
  ## Requirements
package/dist/index.d.mts CHANGED
@@ -1,6 +1,339 @@
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';
1
+ import { AgentClientConfig, MessagesRequest, AgentEventEmitter, SessionListResponse, SessionConversationResponse, SessionContentResponse, SessionStatusResponse, UpdateSessionRequest, SuccessResponse, CancelResponse, SkillListResponse, SaveSkillRequest, PluginManifestResponse, PluginBundleResponse, ConversationEntry, StreamingToolCall, ProcessingOptions, ProcessedEntry, MediaInfo } from '@gr33n-ai/jade-sdk-client';
2
+ export { AgentClientConfig, AgentEventEmitter, CancelResponse, ConversationEntry, MediaInfo, MessagesRequest, ParsedSuggestion, ParsedToolInput, ParsedToolResult, PluginBundleResponse, PluginManifestResponse, ProcessedEntry, ProcessingOptions, SaveSkillRequest, SessionContentResponse, SessionConversationResponse, SessionListResponse, SessionMetadata, SessionStatusResponse, SkillListResponse, SkillMetadata, StreamingToolCall, SuccessResponse, TOOL_REGISTRY, TextSegment, ToolDefinition, UpdateSessionRequest, extractMedia, getToolDefinition, processConversation } from '@gr33n-ai/jade-sdk-client';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import React from 'react';
5
+ import { AppStateStatus } from 'react-native';
6
+
7
+ /**
8
+ * JadeClient - React Native client for the Jade SDK API.
9
+ * Uses react-native-sse for streaming instead of @microsoft/fetch-event-source.
10
+ */
11
+
12
+ declare class JadeClient {
13
+ private config;
14
+ private baseClient;
15
+ private activeStreams;
16
+ constructor(config: AgentClientConfig);
17
+ /** Whether org context is configured (orgId is set) */
18
+ get hasOrgContext(): boolean;
19
+ private get baseUrl();
20
+ private getHeaders;
21
+ /**
22
+ * Send a message and stream responses using React Native SSE.
23
+ * @returns Object with event emitter and abort function
24
+ */
25
+ stream(request: MessagesRequest): {
26
+ emitter: AgentEventEmitter;
27
+ abort: () => void;
28
+ };
29
+ /**
30
+ * Reconnect to an active streaming session using React Native SSE.
31
+ * @returns Object with event emitter and abort function
32
+ */
33
+ reconnect(sessionId: string, lastEventId?: number): {
34
+ emitter: AgentEventEmitter;
35
+ abort: () => void;
36
+ };
37
+ /**
38
+ * List all sessions for the authenticated user.
39
+ */
40
+ listSessions(): Promise<SessionListResponse>;
41
+ /**
42
+ * Get session content in display format.
43
+ */
44
+ getSession(sessionId: string): Promise<SessionConversationResponse>;
45
+ /**
46
+ * Get session content as raw JSONL.
47
+ */
48
+ getSessionRaw(sessionId: string): Promise<SessionContentResponse>;
49
+ /**
50
+ * Check if a session is actively streaming.
51
+ */
52
+ getSessionStatus(sessionId: string): Promise<SessionStatusResponse>;
53
+ /**
54
+ * Update session metadata (name).
55
+ */
56
+ updateSession(sessionId: string, updates: UpdateSessionRequest): Promise<SuccessResponse>;
57
+ /**
58
+ * Delete a session.
59
+ */
60
+ deleteSession(sessionId: string): Promise<SuccessResponse>;
61
+ /**
62
+ * Cancel an active session query.
63
+ */
64
+ cancelSession(sessionId: string): Promise<CancelResponse>;
65
+ /**
66
+ * List personal skills.
67
+ */
68
+ listSkills(): Promise<SkillListResponse>;
69
+ /**
70
+ * Get personal skill content.
71
+ */
72
+ getSkill(name: string): Promise<Uint8Array>;
73
+ /**
74
+ * Create or update a personal skill.
75
+ */
76
+ saveSkill(skill: SaveSkillRequest): Promise<SuccessResponse>;
77
+ /**
78
+ * Delete a personal skill.
79
+ */
80
+ deleteSkill(name: string): Promise<SuccessResponse>;
81
+ /**
82
+ * List organization skills.
83
+ */
84
+ listOrgSkills(): Promise<SkillListResponse>;
85
+ /**
86
+ * Get organization skill content.
87
+ */
88
+ getOrgSkill(name: string): Promise<Uint8Array>;
89
+ /**
90
+ * Create or update an organization skill.
91
+ */
92
+ saveOrgSkill(skill: SaveSkillRequest): Promise<SuccessResponse>;
93
+ /**
94
+ * Delete an organization skill.
95
+ */
96
+ deleteOrgSkill(name: string): Promise<SuccessResponse>;
97
+ /**
98
+ * Get plugin manifest for client sync.
99
+ */
100
+ getPluginManifest(): Promise<PluginManifestResponse>;
101
+ /**
102
+ * Download plugin bundle.
103
+ */
104
+ getPluginBundle(skills?: string[]): Promise<PluginBundleResponse>;
105
+ }
106
+
107
+ /**
108
+ * Storage adapter for React Native.
109
+ * Provides AsyncStorage and MMKV implementations.
110
+ */
111
+ interface StorageAdapter {
112
+ getItem(key: string): Promise<string | null>;
113
+ setItem(key: string, value: string): Promise<void>;
114
+ removeItem(key: string): Promise<void>;
115
+ }
116
+ /**
117
+ * Create a storage adapter using @react-native-async-storage/async-storage.
118
+ * AsyncStorage must be passed in to avoid requiring it as a direct dependency.
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import AsyncStorage from '@react-native-async-storage/async-storage';
123
+ * const storage = createAsyncStorageAdapter(AsyncStorage);
124
+ * ```
125
+ */
126
+ declare function createAsyncStorageAdapter(asyncStorage: {
127
+ getItem: (key: string) => Promise<string | null>;
128
+ setItem: (key: string, value: string) => Promise<void>;
129
+ removeItem: (key: string) => Promise<void>;
130
+ }): StorageAdapter;
131
+ /**
132
+ * Create a storage adapter using react-native-mmkv.
133
+ * MMKV instance must be passed in to avoid requiring it as a direct dependency.
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * import { MMKV } from 'react-native-mmkv';
138
+ * const mmkv = new MMKV();
139
+ * const storage = createMMKVAdapter(mmkv);
140
+ * ```
141
+ */
142
+ declare function createMMKVAdapter(mmkv: {
143
+ getString: (key: string) => string | undefined;
144
+ set: (key: string, value: string) => void;
145
+ delete: (key: string) => void;
146
+ }): StorageAdapter;
147
+ /**
148
+ * Create an in-memory storage adapter for testing.
149
+ */
150
+ declare function createMemoryStorageAdapter(): StorageAdapter;
151
+ /**
152
+ * Standard storage keys used by the Jade SDK.
153
+ */
154
+ declare const STORAGE_KEYS: {
155
+ readonly AUTH_TOKEN: "@gr33n-ai/auth-token";
156
+ readonly ENDPOINT: "@gr33n-ai/endpoint";
157
+ readonly ORG_ID: "@gr33n-ai/org-id";
158
+ readonly LAST_SESSION_ID: "@gr33n-ai/last-session-id";
159
+ readonly USER_PREFERENCES: "@gr33n-ai/user-preferences";
160
+ };
161
+
162
+ interface JadeProviderProps {
163
+ children: React.ReactNode;
164
+ /** Client configuration */
165
+ config: AgentClientConfig;
166
+ /** Optional storage adapter for persisting auth tokens, etc. */
167
+ storage?: StorageAdapter;
168
+ /** Pause streaming when app goes to background (default: true) */
169
+ pauseOnBackground?: boolean;
170
+ }
171
+ /**
172
+ * Provider component for the React Native Jade SDK client.
173
+ * Wrap your app with this to use the Jade hooks.
174
+ *
175
+ * Features:
176
+ * - AppState-aware (tracks foreground/background)
177
+ * - Optional storage adapter for persistence
178
+ *
179
+ * @example
180
+ * ```tsx
181
+ * import AsyncStorage from '@react-native-async-storage/async-storage';
182
+ * import { createAsyncStorageAdapter } from '@gr33n-ai/jade-sdk-rn-client';
183
+ *
184
+ * const storage = createAsyncStorageAdapter(AsyncStorage);
185
+ *
186
+ * <JadeProvider
187
+ * config={{
188
+ * endpoint: 'https://api.example.com',
189
+ * getAuthToken: async () => storage.getItem('@gr33n-ai/auth-token'),
190
+ * }}
191
+ * storage={storage}
192
+ * >
193
+ * <App />
194
+ * </JadeProvider>
195
+ * ```
196
+ */
197
+ declare function JadeProvider({ children, config, storage, pauseOnBackground, }: JadeProviderProps): react_jsx_runtime.JSX.Element;
198
+ /**
199
+ * Get the Jade SDK client instance.
200
+ * Must be used within a JadeProvider.
201
+ *
202
+ * @example
203
+ * ```tsx
204
+ * const client = useJadeClient();
205
+ * const sessions = await client.listSessions();
206
+ * ```
207
+ */
208
+ declare function useJadeClient(): JadeClient;
209
+ /**
210
+ * Get the storage adapter instance.
211
+ * Must be used within a JadeProvider.
212
+ *
213
+ * @example
214
+ * ```tsx
215
+ * const storage = useStorage();
216
+ * if (storage) {
217
+ * await storage.setItem('@gr33n-ai/last-session', sessionId);
218
+ * }
219
+ * ```
220
+ */
221
+ declare function useStorage(): StorageAdapter | undefined;
222
+ /**
223
+ * Get the current app state (active, background, inactive).
224
+ * Useful for pausing/resuming operations based on app visibility.
225
+ *
226
+ * @example
227
+ * ```tsx
228
+ * const appState = useAppState();
229
+ * useEffect(() => {
230
+ * if (appState === 'active') {
231
+ * // Resume operations
232
+ * }
233
+ * }, [appState]);
234
+ * ```
235
+ */
236
+ declare function useAppState(): AppStateStatus;
237
+
238
+ /**
239
+ * useJadeSessionCore hook for React Native.
240
+ * Manages Jade sessions with streaming support using the JadeClient.
241
+ */
242
+
243
+ interface UseJadeSessionCoreOptions {
244
+ /** Initial session ID */
245
+ initialSessionId?: string;
246
+ /** Initial conversation entries */
247
+ initialConversation?: ConversationEntry[];
248
+ /** Callback when media is generated (image/video/audio) */
249
+ onMediaGenerated?: (urls: string[], type: 'image' | 'video' | 'audio') => void;
250
+ /** Pause streaming when app goes to background (default: true) */
251
+ pauseOnBackground?: boolean;
252
+ }
253
+ interface UseJadeSessionCoreReturn {
254
+ sessionId: string | undefined;
255
+ conversation: ConversationEntry[];
256
+ isStreaming: boolean;
257
+ streamingText: string | undefined;
258
+ streamingToolCall: StreamingToolCall | undefined;
259
+ showTinkering: boolean;
260
+ sendMessage: (prompt: string, skills?: string[]) => Promise<void>;
261
+ cancel: () => Promise<void>;
262
+ clear: () => void;
263
+ reconnect: (sessionId: string, freshConversation?: ConversationEntry[], streamingPrompt?: string) => Promise<void>;
264
+ setSessionId: (id: string | undefined) => void;
265
+ setConversation: (entries: ConversationEntry[], sessionId?: string) => void;
266
+ loadSession: (sessionId: string) => Promise<ConversationEntry[]>;
267
+ }
268
+ /**
269
+ * Hook for managing Jade sessions with streaming support in React Native.
270
+ *
271
+ * Features:
272
+ * - Streaming with RN-specific SSE implementation
273
+ * - AppState-aware (can pause on background)
274
+ * - Same API as useAgentSession from agent-sdk-client
275
+ *
276
+ * @example
277
+ * ```tsx
278
+ * const {
279
+ * conversation,
280
+ * isStreaming,
281
+ * streamingText,
282
+ * sendMessage,
283
+ * cancel,
284
+ * } = useJadeSessionCore();
285
+ *
286
+ * await sendMessage('Hello!');
287
+ * ```
288
+ */
289
+ declare function useJadeSessionCore(options?: UseJadeSessionCoreOptions): UseJadeSessionCoreReturn;
290
+
291
+ /**
292
+ * useJadeSession hook for React Native.
293
+ * Extends useJadeSessionCore with processed conversation and media extraction.
294
+ */
295
+
296
+ interface UseJadeSessionOptions extends UseJadeSessionCoreOptions {
297
+ /** Skip Skill context injection entries (default: true) */
298
+ skipSkillContext?: boolean;
299
+ /** Processing options */
300
+ processingOptions?: ProcessingOptions;
301
+ }
302
+ interface UseJadeSessionReturn extends UseJadeSessionCoreReturn {
303
+ /** Processed conversation entries with tool pairing and parsing */
304
+ processedConversation: ProcessedEntry[];
305
+ /** All media extracted from conversation (deduplicated, sorted by timestamp) */
306
+ media: MediaInfo[];
307
+ }
308
+ /**
309
+ * Hook for managing Jade sessions with enhanced conversation processing.
310
+ * React Native version using JadeClient for streaming.
311
+ *
312
+ * Extends useJadeSessionCore with:
313
+ * - Processed conversation (tool call/result pairing, parsed inputs/results)
314
+ * - Media extraction from generated content
315
+ *
316
+ * @example
317
+ * ```tsx
318
+ * const {
319
+ * conversation,
320
+ * processedConversation,
321
+ * media,
322
+ * isStreaming,
323
+ * sendMessage,
324
+ * } = useJadeSession();
325
+ *
326
+ * // Render processed entries
327
+ * {processedConversation.map((entry, i) => (
328
+ * <MessageRenderer key={i} entry={entry} />
329
+ * ))}
330
+ *
331
+ * // Show media gallery
332
+ * {media.map((item) => (
333
+ * <MediaThumbnail key={item.url} {...item} />
334
+ * ))}
335
+ * ```
336
+ */
337
+ declare function useJadeSession(options?: UseJadeSessionOptions): UseJadeSessionReturn;
338
+
339
+ export { JadeClient, JadeProvider, type JadeProviderProps, STORAGE_KEYS, type StorageAdapter, type UseJadeSessionCoreOptions, type UseJadeSessionCoreReturn, type UseJadeSessionOptions, type UseJadeSessionReturn, createAsyncStorageAdapter, createMMKVAdapter, createMemoryStorageAdapter, useAppState, useJadeClient, useJadeSession, useJadeSessionCore, useStorage };