@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 +13 -13
- package/dist/index.d.mts +339 -6
- package/dist/index.d.ts +339 -6
- package/dist/index.js +30 -55
- package/dist/index.mjs +27 -36
- package/package.json +2 -8
- package/dist/react-native/index.d.mts +0 -339
- package/dist/react-native/index.d.ts +0 -339
- package/dist/react-native/index.js +0 -2795
- package/dist/react-native/index.mjs +0 -2784
|
@@ -1,339 +0,0 @@
|
|
|
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 { ConversationEntry, MediaInfo, ProcessedEntry, ProcessingOptions, SessionMetadata, SkillMetadata, StreamingToolCall } 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
|
-
* RNAgentClient - React Native client for the Agent SDK API.
|
|
9
|
-
* Uses react-native-sse for streaming instead of @microsoft/fetch-event-source.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
declare class RNAgentClient {
|
|
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 RNAgentProviderProps {
|
|
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 agent 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/react-native';
|
|
183
|
-
*
|
|
184
|
-
* const storage = createAsyncStorageAdapter(AsyncStorage);
|
|
185
|
-
*
|
|
186
|
-
* <RNAgentProvider
|
|
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
|
-
* </RNAgentProvider>
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
declare function RNAgentProvider({ children, config, storage, pauseOnBackground, }: RNAgentProviderProps): react_jsx_runtime.JSX.Element;
|
|
198
|
-
/**
|
|
199
|
-
* Get the React Native Agent SDK client instance.
|
|
200
|
-
* Must be used within an RNAgentProvider.
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```tsx
|
|
204
|
-
* const client = useRNAgentClient();
|
|
205
|
-
* const sessions = await client.listSessions();
|
|
206
|
-
* ```
|
|
207
|
-
*/
|
|
208
|
-
declare function useRNAgentClient(): RNAgentClient;
|
|
209
|
-
/**
|
|
210
|
-
* Get the storage adapter instance.
|
|
211
|
-
* Must be used within an RNAgentProvider.
|
|
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
|
-
* useRNAgentSession hook for React Native.
|
|
240
|
-
* Manages agent sessions with streaming support using the RNAgentClient.
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
|
-
interface UseRNAgentSessionOptions {
|
|
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 UseRNAgentSessionReturn {
|
|
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 agent 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
|
-
* } = useRNAgentSession();
|
|
285
|
-
*
|
|
286
|
-
* await sendMessage('Hello!');
|
|
287
|
-
* ```
|
|
288
|
-
*/
|
|
289
|
-
declare function useRNAgentSession(options?: UseRNAgentSessionOptions): UseRNAgentSessionReturn;
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* useJadeSession hook for React Native.
|
|
293
|
-
* Extends useRNAgentSession with processed conversation and media extraction.
|
|
294
|
-
*/
|
|
295
|
-
|
|
296
|
-
interface UseJadeSessionOptions extends UseRNAgentSessionOptions {
|
|
297
|
-
/** Skip Skill context injection entries (default: true) */
|
|
298
|
-
skipSkillContext?: boolean;
|
|
299
|
-
/** Processing options */
|
|
300
|
-
processingOptions?: ProcessingOptions;
|
|
301
|
-
}
|
|
302
|
-
interface UseJadeSessionReturn extends UseRNAgentSessionReturn {
|
|
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 agent sessions with enhanced conversation processing.
|
|
310
|
-
* React Native version using RNAgentClient for streaming.
|
|
311
|
-
*
|
|
312
|
-
* Extends useRNAgentSession 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 { RNAgentClient as R, RNAgentProvider, type RNAgentProviderProps, STORAGE_KEYS, type StorageAdapter, type UseJadeSessionOptions, type UseJadeSessionReturn, type UseRNAgentSessionOptions, type UseRNAgentSessionReturn, createAsyncStorageAdapter, createMMKVAdapter, createMemoryStorageAdapter, useAppState, useJadeSession, useRNAgentClient, useRNAgentSession, useStorage };
|