@sybil-studio-devs/sdk 0.1.1 → 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.
package/README.md CHANGED
@@ -1,135 +1,447 @@
1
- # @sybil-studio/sdk
1
+ # @sybil-studio-devs/sdk
2
2
 
3
- Official TypeScript/JavaScript SDK for Sybil AI - Document processing, YouTube analysis, and AI-powered knowledge management.
3
+ Official TypeScript/JavaScript SDK for Sybil AI - Embeddable wiki (Atlas), file storage (Nexus), document processing, YouTube analysis, and AI-powered knowledge management.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- # npm
9
- npm install @sybil-studio/sdk
8
+ npm install @sybil-studio-devs/sdk
9
+ # or
10
+ pnpm add @sybil-studio-devs/sdk
11
+ # or
12
+ yarn add @sybil-studio-devs/sdk
13
+ ```
10
14
 
11
- # pnpm
12
- pnpm add @sybil-studio/sdk
15
+ ## Features
13
16
 
14
- # yarn
15
- yarn add @sybil-studio/sdk
16
- ```
17
+ - **Atlas** - Embeddable Notion-like wiki with full editing capabilities
18
+ - **Nexus** - Embeddable Google Drive-like file storage
19
+ - **Documents** - AI-powered document processing and analysis
20
+ - **YouTube** - Video transcript extraction and analysis
21
+ - **Chat** - RAG-powered Q&A with your documents
22
+ - **Pages** - Programmatic page management
17
23
 
18
24
  ## Quick Start
19
25
 
26
+ ### Embed Atlas (Wiki)
27
+
20
28
  ```typescript
21
- import { SybilSDK } from '@sybil-studio/sdk';
29
+ import { embedAtlas } from '@sybil-studio-devs/sdk';
22
30
 
23
- const sybil = new SybilSDK('sk_live_YOUR_API_KEY');
31
+ const atlas = embedAtlas({
32
+ apiKey: 'sk_live_YOUR_API_KEY',
33
+ workspaceId: 'your-workspace-id',
34
+ container: '#wiki-container',
35
+ theme: 'dark',
36
+ showSidebar: true,
37
+ onPageChange: (page) => console.log('Page changed:', page),
38
+ onError: (error) => console.error('Error:', error),
39
+ });
24
40
 
25
- // Process a YouTube video
26
- const video = await sybil.youtube.process('https://youtube.com/watch?v=...');
41
+ // Navigate programmatically
42
+ atlas.navigateTo('page-id');
27
43
 
28
- // Chat with a document
29
- const response = await sybil.chat.send(video.document.id, 'Summarize the main points');
44
+ // Create a new page
45
+ const page = await atlas.createPage({ title: 'New Page' });
30
46
 
31
- // Create a page
32
- const page = await sybil.pages.create({
33
- title: 'My Notes',
34
- blocks: [
35
- { type: 'paragraph', content: [{ type: 'text', text: 'Hello world' }] }
36
- ]
37
- });
47
+ // Export page
48
+ const pdf = await atlas.exportPage('page-id', 'pdf');
38
49
  ```
39
50
 
40
- ## Configuration
51
+ ### Embed Nexus (File Storage)
41
52
 
42
53
  ```typescript
43
- // Simple - just API key (uses default base URL)
44
- const sybil = new SybilSDK('sk_live_YOUR_API_KEY');
54
+ import { embedNexus } from '@sybil-studio-devs/sdk';
45
55
 
46
- // Full configuration
47
- const sybil = new SybilSDK({
56
+ const nexus = embedNexus({
48
57
  apiKey: 'sk_live_YOUR_API_KEY',
49
- baseUrl: 'https://your-domain.com/api/sdk/v1', // Optional
50
- timeout: 30000, // Optional, in milliseconds
58
+ workspaceId: 'your-workspace-id',
59
+ container: '#storage-container',
60
+ viewMode: 'grid',
61
+ allowUpload: true,
62
+ onFileSelect: (file) => console.log('Selected:', file),
63
+ onFileUpload: (file) => console.log('Uploaded:', file),
51
64
  });
65
+
66
+ // Upload a file
67
+ const file = await nexus.uploadFile(fileBlob, 'folder-id');
68
+
69
+ // Navigate to folder
70
+ nexus.navigateTo('folder-id');
71
+
72
+ // Search files
73
+ const results = await nexus.search('quarterly report');
74
+ ```
75
+
76
+ ### React Components
77
+
78
+ ```tsx
79
+ import { SybilAtlas, SybilNexus } from '@sybil-studio-devs/sdk/react';
80
+
81
+ function App() {
82
+ return (
83
+ <div style={{ display: 'flex', height: '100vh' }}>
84
+ {/* Embedded Wiki */}
85
+ <SybilAtlas
86
+ apiKey="sk_live_xxx"
87
+ workspaceId="workspace-id"
88
+ showSidebar={true}
89
+ theme="dark"
90
+ onPageChange={(page) => console.log(page)}
91
+ style={{ flex: 1 }}
92
+ />
93
+
94
+ {/* Embedded File Storage */}
95
+ <SybilNexus
96
+ apiKey="sk_live_xxx"
97
+ workspaceId="workspace-id"
98
+ viewMode="list"
99
+ onFileUpload={(file) => console.log(file)}
100
+ style={{ flex: 1 }}
101
+ />
102
+ </div>
103
+ );
104
+ }
52
105
  ```
53
106
 
54
- ## API Reference
107
+ ### React Hooks
108
+
109
+ ```tsx
110
+ import { useAtlas, useNexus } from '@sybil-studio-devs/sdk/react';
111
+
112
+ function WikiManager() {
113
+ const {
114
+ sidebar,
115
+ currentPage,
116
+ loading,
117
+ fetchSidebar,
118
+ createPage,
119
+ updatePage,
120
+ getLogs,
121
+ } = useAtlas({
122
+ apiKey: 'sk_live_xxx',
123
+ workspaceId: 'workspace-id',
124
+ logging: { enabled: true, level: 'debug' },
125
+ });
126
+
127
+ // Use the hook data...
128
+ }
55
129
 
56
- ### Pages
130
+ function FileManager() {
131
+ const {
132
+ files,
133
+ folders,
134
+ uploadFile,
135
+ createFolder,
136
+ navigateTo,
137
+ getLogs,
138
+ } = useNexus({
139
+ apiKey: 'sk_live_xxx',
140
+ workspaceId: 'workspace-id',
141
+ });
142
+
143
+ // Use the hook data...
144
+ }
145
+ ```
146
+
147
+ ## Atlas Configuration
57
148
 
58
149
  ```typescript
59
- // List pages
60
- const { pages, pagination } = await sybil.pages.list({
61
- limit: 20,
62
- offset: 0,
63
- parent_id: 'root', // or specific page ID
64
- is_published: true
150
+ embedAtlas({
151
+ // Required
152
+ apiKey: string,
153
+ workspaceId: string,
154
+ container: HTMLElement | string,
155
+
156
+ // Optional - Theming
157
+ baseUrl?: string, // Default: 'https://app.sybil.studio'
158
+ theme?: 'light' | 'dark' | {
159
+ background?: string,
160
+ backgroundSecondary?: string,
161
+ text?: string,
162
+ textSecondary?: string,
163
+ textMuted?: string,
164
+ border?: string,
165
+ accent?: string,
166
+ sidebarBackground?: string,
167
+ },
168
+
169
+ // Optional - Layout
170
+ showSidebar?: boolean, // Default: true
171
+ sidebarWidth?: number, // Default: 260
172
+ sidebarCollapsible?: boolean, // Default: true
173
+
174
+ // Optional - Permissions
175
+ readOnly?: boolean, // Default: false
176
+ allowCreate?: boolean, // Default: true
177
+ allowDelete?: boolean, // Default: true
178
+ allowExport?: boolean, // Default: true
179
+
180
+ // Optional - Features
181
+ features?: {
182
+ favorites?: boolean,
183
+ teamspaces?: boolean,
184
+ search?: boolean,
185
+ export?: boolean,
186
+ coverImages?: boolean,
187
+ icons?: boolean,
188
+ minimap?: boolean,
189
+ floatingToolbar?: boolean,
190
+ aiAssist?: boolean,
191
+ },
192
+
193
+ // Optional - Logging (for debugging)
194
+ logging?: {
195
+ enabled: boolean,
196
+ level?: 'debug' | 'info' | 'warn' | 'error',
197
+ onLog?: (entry: AtlasLogEntry) => void,
198
+ },
199
+
200
+ // Optional - Navigation
201
+ defaultPageId?: string,
202
+
203
+ // Callbacks
204
+ onReady?: (instance: AtlasInstance) => void,
205
+ onPageChange?: (page: AtlasPage) => void,
206
+ onPageCreate?: (page: AtlasPage) => void,
207
+ onPageDelete?: (pageId: string) => void,
208
+ onPageUpdate?: (page: AtlasPage) => void,
209
+ onNavigate?: (pageId: string) => void,
210
+ onError?: (error: AtlasError) => void,
65
211
  });
212
+ ```
66
213
 
67
- // Create page
68
- const { page } = await sybil.pages.create({
69
- title: 'New Page',
70
- description: 'Optional description',
71
- blocks: [
72
- { type: 'heading', attrs: { level: 1 }, content: [{ type: 'text', text: 'Title' }] },
73
- { type: 'paragraph', content: [{ type: 'text', text: 'Content here' }] },
74
- { type: 'image', attrs: { src: 'https://...' } }
75
- ],
76
- parent_id: 'optional-parent-uuid'
214
+ ## Nexus Configuration
215
+
216
+ ```typescript
217
+ embedNexus({
218
+ // Required
219
+ apiKey: string,
220
+ workspaceId: string,
221
+ container: HTMLElement | string,
222
+
223
+ // Optional - Theming
224
+ baseUrl?: string,
225
+ theme?: 'light' | 'dark' | NexusTheme,
226
+
227
+ // Optional - Layout
228
+ initialFolderId?: string | null,
229
+ viewMode?: 'list' | 'grid', // Default: 'list'
230
+ showSidebar?: boolean, // Default: true
231
+ showActivityFeed?: boolean, // Default: true
232
+ showBreadcrumbs?: boolean, // Default: true
233
+ showSearch?: boolean, // Default: true
234
+
235
+ // Optional - Permissions
236
+ allowUpload?: boolean, // Default: true
237
+ allowDownload?: boolean, // Default: true
238
+ allowDelete?: boolean, // Default: true
239
+ allowMove?: boolean, // Default: true
240
+ allowRename?: boolean, // Default: true
241
+ allowCreateFolder?: boolean, // Default: true
242
+ allowMultiSelect?: boolean, // Default: true
243
+
244
+ // Optional - Upload constraints
245
+ maxUploadSize?: number, // In bytes
246
+ acceptedFileTypes?: string[], // e.g. ['image/*', 'application/pdf']
247
+
248
+ // Optional - Features
249
+ features?: {
250
+ aiAnalysis?: boolean,
251
+ labels?: boolean,
252
+ starring?: boolean,
253
+ trash?: boolean,
254
+ preview?: boolean,
255
+ thumbnails?: boolean,
256
+ dragAndDrop?: boolean,
257
+ keyboardShortcuts?: boolean,
258
+ commandMenu?: boolean,
259
+ bulkActions?: boolean,
260
+ },
261
+
262
+ // Optional - Logging
263
+ logging?: {
264
+ enabled: boolean,
265
+ level?: 'debug' | 'info' | 'warn' | 'error',
266
+ onLog?: (entry: NexusLogEntry) => void,
267
+ },
268
+
269
+ // Callbacks
270
+ onReady?: (instance: NexusInstance) => void,
271
+ onNavigate?: (folderId: string | null) => void,
272
+ onFileSelect?: (file: NexusFile) => void,
273
+ onFileOpen?: (file: NexusFile) => void,
274
+ onFileUpload?: (file: NexusFile) => void,
275
+ onFileDelete?: (fileId: string) => void,
276
+ onFolderCreate?: (folder: NexusFolder) => void,
277
+ onFolderDelete?: (folderId: string) => void,
278
+ onSelectionChange?: (items: NexusItem[]) => void,
279
+ onError?: (error: NexusError) => void,
77
280
  });
281
+ ```
78
282
 
79
- // Get page
80
- const { page } = await sybil.pages.get('page-id');
283
+ ## Instance Methods
81
284
 
82
- // Update page
83
- const { page } = await sybil.pages.update('page-id', {
84
- title: 'Updated Title',
85
- blocks: [...],
86
- is_published: true
87
- });
285
+ ### Atlas Instance
286
+
287
+ ```typescript
288
+ const atlas = embedAtlas({ ... });
289
+
290
+ // Page management
291
+ await atlas.getPages(); // Get sidebar data
292
+ await atlas.getPage('page-id'); // Get single page
293
+ await atlas.createPage({ title: 'New' }); // Create page
294
+ await atlas.updatePage('id', { title: 'Updated' }); // Update page
295
+ await atlas.deletePage('page-id'); // Delete page
296
+ await atlas.exportPage('id', 'pdf'); // Export as PDF/DOCX/MD
297
+
298
+ // Navigation
299
+ atlas.navigateTo('page-id');
300
+ atlas.getCurrentPage();
301
+
302
+ // UI controls
303
+ atlas.toggleSidebar();
304
+ atlas.setSidebarWidth(300);
305
+ atlas.setTheme('light');
306
+ atlas.refresh();
307
+
308
+ // Debugging
309
+ atlas.getLogs();
310
+ atlas.clearLogs();
311
+
312
+ // Cleanup
313
+ atlas.destroy();
314
+ ```
88
315
 
89
- // Delete page
90
- await sybil.pages.delete('page-id');
316
+ ### Nexus Instance
91
317
 
92
- // Upload file (for use in pages)
93
- const upload = await sybil.pages.upload(file);
94
- console.log(upload.url); // Use this URL in image blocks
318
+ ```typescript
319
+ const nexus = embedNexus({ ... });
320
+
321
+ // File operations
322
+ await nexus.getFiles('folder-id');
323
+ await nexus.getFile('file-id');
324
+ await nexus.uploadFile(file, 'folder-id', onProgress);
325
+ await nexus.uploadFiles(files, 'folder-id', onProgress);
326
+ await nexus.downloadFile('file-id');
327
+ await nexus.getDownloadUrl('file-id');
328
+ await nexus.deleteFile('file-id');
329
+ await nexus.moveFile('file-id', 'target-folder-id');
330
+ await nexus.renameFile('file-id', 'new-name.pdf');
331
+ await nexus.starFile('file-id', true);
332
+
333
+ // Folder operations
334
+ await nexus.getFolders('parent-id');
335
+ await nexus.getFolderContents('folder-id');
336
+ await nexus.getFolderTree();
337
+ await nexus.createFolder('New Folder', 'parent-id');
338
+ await nexus.deleteFolder('folder-id');
339
+ await nexus.moveFolder('folder-id', 'new-parent-id');
340
+
341
+ // Navigation & selection
342
+ nexus.navigateTo('folder-id');
343
+ nexus.getCurrentFolder();
344
+ nexus.getSelection();
345
+ nexus.setSelection(['id1', 'id2']);
346
+ nexus.clearSelection();
347
+ nexus.selectAll();
348
+
349
+ // Search & stats
350
+ await nexus.search('query');
351
+ await nexus.getStats();
352
+ await nexus.getActivity(50);
353
+
354
+ // Labels
355
+ await nexus.getLabels();
356
+ await nexus.applyLabel(['file-id'], 'label-id');
357
+
358
+ // UI controls
359
+ nexus.setViewMode('grid');
360
+ nexus.toggleActivityFeed();
361
+ nexus.toggleSidebar();
362
+ nexus.setTheme('dark');
363
+ nexus.refresh();
364
+
365
+ // Debugging
366
+ nexus.getLogs();
367
+ nexus.clearLogs();
368
+
369
+ // Cleanup
370
+ nexus.destroy();
95
371
  ```
96
372
 
97
- ### Documents
373
+ ## Debugging with Logs
374
+
375
+ Enable logging to debug issues:
98
376
 
99
377
  ```typescript
100
- // Process a document
101
- const result = await sybil.documents.process(file, {
102
- fileName: 'document.pdf',
103
- metadata: { category: 'reports' }
378
+ const atlas = embedAtlas({
379
+ // ...
380
+ logging: {
381
+ enabled: true,
382
+ level: 'debug', // 'debug' | 'info' | 'warn' | 'error'
383
+ onLog: (entry) => {
384
+ // entry.timestamp
385
+ // entry.level
386
+ // entry.category: 'api' | 'render' | 'navigation' | 'editor' | 'sync'
387
+ // entry.message
388
+ // entry.data
389
+ // entry.duration
390
+ console.log(`[${entry.category}] ${entry.message}`, entry.data);
391
+ },
392
+ },
104
393
  });
105
394
 
106
- // Check processing status
107
- const status = await sybil.documents.status(result.documentId);
395
+ // Get all logs
396
+ const logs = atlas.getLogs();
108
397
 
109
- // Wait for processing to complete (polling)
110
- const document = await sybil.documents.waitForProcessing(result.documentId, {
111
- maxAttempts: 60,
112
- interval: 3000
113
- });
398
+ // Clear logs
399
+ atlas.clearLogs();
400
+ ```
401
+
402
+ ## Standalone Clients
114
403
 
115
- // List documents
116
- const { documents, pagination } = await sybil.documents.list({
117
- status: 'processed',
118
- fileType: 'application/pdf',
119
- search: 'quarterly report'
404
+ For server-side or non-embed use cases:
405
+
406
+ ```typescript
407
+ import { AtlasClient, NexusClient } from '@sybil-studio-devs/sdk';
408
+
409
+ // Atlas client
410
+ const atlas = new AtlasClient({
411
+ apiKey: 'sk_live_xxx',
412
+ workspaceId: 'workspace-id',
120
413
  });
121
414
 
122
- // Get document with content
123
- const { document } = await sybil.documents.get('doc-id', {
124
- includeContent: true,
125
- includeInsights: true
415
+ const sidebar = await atlas.getSidebar();
416
+ const page = await atlas.createPage({ title: 'New Page' });
417
+
418
+ // Nexus client
419
+ const nexus = new NexusClient({
420
+ apiKey: 'sk_live_xxx',
421
+ workspaceId: 'workspace-id',
126
422
  });
127
423
 
128
- // Get document insights
129
- const { insights, semanticAnalysis } = await sybil.documents.insights('doc-id');
424
+ const files = await nexus.listFiles('folder-id');
425
+ const folder = await nexus.createFolder('New Folder');
426
+ ```
427
+
428
+ ## Legacy APIs
429
+
430
+ ### Documents
431
+
432
+ ```typescript
433
+ import { SybilSDK } from '@sybil-studio-devs/sdk';
434
+
435
+ const sybil = new SybilSDK('sk_live_YOUR_API_KEY');
436
+
437
+ // Process a document
438
+ const result = await sybil.documents.process(file);
439
+
440
+ // Wait for processing
441
+ const document = await sybil.documents.waitForProcessing(result.documentId);
130
442
 
131
- // Delete document
132
- await sybil.documents.delete('doc-id');
443
+ // Get insights
444
+ const { insights } = await sybil.documents.insights('doc-id');
133
445
  ```
134
446
 
135
447
  ### YouTube
@@ -138,106 +450,81 @@ await sybil.documents.delete('doc-id');
138
450
  // Process YouTube video
139
451
  const result = await sybil.youtube.process('https://youtube.com/watch?v=...');
140
452
 
141
- // List processed videos
142
- const { videos } = await sybil.youtube.list({ limit: 20 });
143
-
144
- // Get video details with transcript
453
+ // Get video with transcript
145
454
  const { video } = await sybil.youtube.get('VIDEO_ID', {
146
455
  includeTranscript: true,
147
- includeChunks: true
148
456
  });
149
-
150
- // Delete video
151
- await sybil.youtube.delete('VIDEO_ID');
152
457
  ```
153
458
 
154
459
  ### Chat (RAG)
155
460
 
156
461
  ```typescript
157
- // Simple chat
462
+ // Chat with document
158
463
  const result = await sybil.chat.send('document-id', 'What are the key findings?');
159
464
 
160
- // Chat with options
161
- const result = await sybil.chat.send({
162
- documentId: 'document-id',
163
- query: 'Explain the methodology',
164
- conversationHistory: [
165
- { role: 'user', content: 'Previous question' },
166
- { role: 'assistant', content: 'Previous answer' }
167
- ],
168
- searchConfig: {
169
- semanticWeight: 0.4,
170
- maxResults: 15
171
- }
172
- });
173
-
174
465
  console.log(result.response);
175
- console.log(result.sources); // Relevant passages
176
- console.log(result.metadata.confidence);
177
-
178
- // Get chat history
179
- const { history } = await sybil.chat.history('document-id', 50);
180
- ```
181
-
182
- ### Analysis
183
-
184
- ```typescript
185
- // Run RAG analysis
186
- const result = await sybil.analyze.run('document-id');
187
-
188
- // Force refresh
189
- const result = await sybil.analyze.run('document-id', true);
190
-
191
- // Get existing analysis (no regeneration)
192
- const result = await sybil.analyze.get('document-id');
193
-
194
- console.log(result.analysis);
195
- console.log(result.cached); // true if from cache
466
+ console.log(result.sources);
196
467
  ```
197
468
 
198
469
  ## Error Handling
199
470
 
200
471
  ```typescript
201
- import { SybilSDK, SybilError } from '@sybil-studio/sdk';
472
+ import { SybilError } from '@sybil-studio-devs/sdk';
202
473
 
203
474
  try {
204
- const result = await sybil.youtube.process('invalid-url');
475
+ await atlas.createPage({ title: 'New' });
205
476
  } catch (error) {
206
477
  if (error instanceof SybilError) {
207
478
  console.error(`Error ${error.status}: ${error.message}`);
208
479
  console.error(`Code: ${error.code}`);
209
-
210
- if (error.status === 429) {
211
- // Rate limited - wait and retry
212
- }
213
480
  }
214
481
  }
482
+
483
+ // Or use callbacks
484
+ embedAtlas({
485
+ // ...
486
+ onError: (error) => {
487
+ console.error(`[${error.code}] ${error.message}`);
488
+ console.error('Request ID:', error.requestId);
489
+ console.error('Details:', error.details);
490
+ },
491
+ });
215
492
  ```
216
493
 
217
494
  ## TypeScript Types
218
495
 
219
- All types are exported for use in your application:
496
+ All types are exported:
220
497
 
221
498
  ```typescript
222
499
  import type {
500
+ // Atlas
501
+ AtlasPage,
502
+ AtlasSidebarData,
503
+ AtlasEmbedConfig,
504
+ AtlasInstance,
505
+ AtlasError,
506
+ AtlasLogEntry,
507
+
508
+ // Nexus
509
+ NexusFile,
510
+ NexusFolder,
511
+ NexusItem,
512
+ NexusEmbedConfig,
513
+ NexusInstance,
514
+ NexusError,
515
+ NexusLogEntry,
516
+
517
+ // Legacy
223
518
  Page,
224
519
  Document,
225
520
  YouTubeVideo,
226
521
  ChatResult,
227
- Insight,
228
- Block,
229
- DocumentStatus,
230
- // ... and more
231
- } from '@sybil-studio/sdk';
522
+ } from '@sybil-studio-devs/sdk';
232
523
  ```
233
524
 
234
525
  ## Browser & Node.js Support
235
526
 
236
- This SDK works in both browser and Node.js environments. It uses the native `fetch` API, which is available in:
237
- - Modern browsers
238
- - Node.js 18+
239
-
240
- For older Node.js versions, you may need a `fetch` polyfill.
527
+ Works in modern browsers and Node.js 18+.
241
528
 
242
529
  ## License
243
530