@nebula-ai/sdk 0.0.19
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/LICENSE +26 -0
- package/README.md +448 -0
- package/dist/index.d.mts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +664 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +651 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Nebula Cloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
# @nebula-ai/sdk
|
|
2
|
+
|
|
3
|
+
Official JavaScript/TypeScript SDK for Nebula Cloud - Memory, Search, and AI-powered conversations.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/%40nebula-ai%2Fsdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 🚀 **Full API Parity** - Mirrors the exact Nebula Python SDK client.py implementation
|
|
12
|
+
- 🔐 **Flexible Authentication** - Supports both API keys and Bearer tokens
|
|
13
|
+
- 🌐 **Browser & Node.js Ready** - Works in browsers and Node.js environments
|
|
14
|
+
- 📱 **TypeScript First** - Full type safety with comprehensive interfaces
|
|
15
|
+
- 🎯 **Unified Memory Model** - Store text, conversations, and structured data
|
|
16
|
+
- 🔍 **Advanced Search** - Vector search with graph results (entities, relationships, communities)
|
|
17
|
+
- 💬 **Conversation Support** - Built-in conversation tracking and management
|
|
18
|
+
- ⚡ **Performance Optimized** - Configurable timeouts and error handling
|
|
19
|
+
- 🧠 **Graph Intelligence** - Leverage knowledge graphs for enhanced search
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @nebula-ai/sdk
|
|
25
|
+
# or
|
|
26
|
+
yarn add @nebula-ai/sdk
|
|
27
|
+
# or
|
|
28
|
+
pnpm add @nebula-ai/sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { NebulaSDK, RetrievalType } from '@nebula-ai/sdk';
|
|
35
|
+
|
|
36
|
+
// Initialize the SDK
|
|
37
|
+
const client = new NebulaSDK({
|
|
38
|
+
apiKey: 'your-nebula-api-key',
|
|
39
|
+
baseUrl: 'https://api.nebulacloud.app', // optional, defaults to this
|
|
40
|
+
timeout: 30000 // optional, defaults to 30 seconds
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Create a cluster
|
|
44
|
+
const cluster = await client.createCluster(
|
|
45
|
+
'My Project',
|
|
46
|
+
'A collection of project memories'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Store a memory using the unified Memory model
|
|
50
|
+
const memoryId = await client.storeMemory({
|
|
51
|
+
cluster_id: cluster.id,
|
|
52
|
+
content: 'This is an important piece of information about my project.',
|
|
53
|
+
metadata: { category: 'project', priority: 'high' }
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Search for memories with advanced options
|
|
57
|
+
const results = await client.search(
|
|
58
|
+
'project information',
|
|
59
|
+
[cluster.id],
|
|
60
|
+
5,
|
|
61
|
+
RetrievalType.ADVANCED,
|
|
62
|
+
{ 'metadata.category': 'project' }
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
console.log('Found memories:', results);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API Reference
|
|
69
|
+
|
|
70
|
+
### Constructor
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
new NebulaSDK(config: NebulaSDKConfig)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Config Options:**
|
|
77
|
+
- `apiKey` (required): Your Nebula API key
|
|
78
|
+
- `baseUrl` (optional): Custom API base URL, defaults to `https://api.nebulacloud.app`
|
|
79
|
+
- `timeout` (optional): Request timeout in milliseconds, defaults to 30000
|
|
80
|
+
|
|
81
|
+
### Core Methods
|
|
82
|
+
|
|
83
|
+
#### Clusters
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// Create a new cluster
|
|
87
|
+
await client.createCluster(name: string, description?: string, metadata?: Record<string, any>)
|
|
88
|
+
|
|
89
|
+
// Get a cluster by ID
|
|
90
|
+
await client.getCluster(clusterId: string)
|
|
91
|
+
|
|
92
|
+
// Get a cluster by name
|
|
93
|
+
await client.getClusterByName(name: string)
|
|
94
|
+
|
|
95
|
+
// List all clusters
|
|
96
|
+
await client.listClusters(limit?: number, offset?: number)
|
|
97
|
+
|
|
98
|
+
// Update a cluster
|
|
99
|
+
await client.updateCluster(clusterId: string, name?: string, description?: string, metadata?: Record<string, any>)
|
|
100
|
+
|
|
101
|
+
// Delete a cluster
|
|
102
|
+
await client.deleteCluster(clusterId: string)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Memories
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// Store a single memory
|
|
109
|
+
await client.storeMemory(memory: Memory | Record<string, any>)
|
|
110
|
+
|
|
111
|
+
// Store multiple memories
|
|
112
|
+
await client.storeMemories(memories: Memory[])
|
|
113
|
+
|
|
114
|
+
// Get a specific memory
|
|
115
|
+
await client.getMemory(memoryId: string)
|
|
116
|
+
|
|
117
|
+
// List memories from clusters
|
|
118
|
+
await client.listMemories(clusterIds: string[], limit?: number, offset?: number)
|
|
119
|
+
|
|
120
|
+
// Delete a memory
|
|
121
|
+
await client.delete(memoryId: string)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### Search
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// Search within clusters
|
|
128
|
+
await client.search(
|
|
129
|
+
query: string,
|
|
130
|
+
clusterIds: string[],
|
|
131
|
+
limit?: number,
|
|
132
|
+
retrievalType?: RetrievalType | string,
|
|
133
|
+
filters?: Record<string, any>,
|
|
134
|
+
searchSettings?: Record<string, any>
|
|
135
|
+
)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Health Check
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Check API health
|
|
142
|
+
await client.healthCheck()
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Data Models
|
|
146
|
+
|
|
147
|
+
#### Memory (for writing)
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
interface Memory {
|
|
151
|
+
cluster_id: string; // Required: cluster to store in
|
|
152
|
+
content: string; // Required: text content
|
|
153
|
+
role?: string; // Optional: 'user', 'assistant', or custom (for conversations)
|
|
154
|
+
parent_id?: string; // Optional: conversation ID (for conversations)
|
|
155
|
+
metadata?: Record<string, any>; // Optional: additional metadata
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### MemoryResponse (for reading)
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
interface MemoryResponse {
|
|
163
|
+
id: string;
|
|
164
|
+
content?: string;
|
|
165
|
+
chunks?: string[];
|
|
166
|
+
metadata: Record<string, any>;
|
|
167
|
+
cluster_ids: string[];
|
|
168
|
+
created_at?: string;
|
|
169
|
+
updated_at?: string;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### SearchResult
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
interface SearchResult {
|
|
177
|
+
id: string;
|
|
178
|
+
score: number;
|
|
179
|
+
metadata: Record<string, any>;
|
|
180
|
+
source?: string;
|
|
181
|
+
|
|
182
|
+
// Chunk fields
|
|
183
|
+
content?: string;
|
|
184
|
+
|
|
185
|
+
// Graph fields
|
|
186
|
+
graph_result_type?: GraphSearchResultType;
|
|
187
|
+
graph_entity?: GraphEntityResult;
|
|
188
|
+
graph_relationship?: GraphRelationshipResult;
|
|
189
|
+
graph_community?: GraphCommunityResult;
|
|
190
|
+
chunk_ids?: string[];
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### RetrievalType
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
enum RetrievalType {
|
|
198
|
+
BASIC = "basic",
|
|
199
|
+
ADVANCED = "advanced",
|
|
200
|
+
CUSTOM = "custom"
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Search Options
|
|
205
|
+
|
|
206
|
+
The search method supports advanced configuration:
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
const results = await client.search(
|
|
210
|
+
'query',
|
|
211
|
+
[clusterId],
|
|
212
|
+
10,
|
|
213
|
+
RetrievalType.ADVANCED,
|
|
214
|
+
{ 'metadata.category': 'science' },
|
|
215
|
+
{
|
|
216
|
+
graph_settings: {
|
|
217
|
+
enabled: true,
|
|
218
|
+
bfs_enabled: true,
|
|
219
|
+
bfs_max_depth: 2
|
|
220
|
+
},
|
|
221
|
+
search_strategy: 'rag_fusion',
|
|
222
|
+
num_sub_queries: 3
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Error Handling
|
|
228
|
+
|
|
229
|
+
The SDK provides custom error classes matching the Python SDK:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import {
|
|
233
|
+
NebulaException,
|
|
234
|
+
NebulaClientException,
|
|
235
|
+
NebulaAuthenticationException,
|
|
236
|
+
NebulaRateLimitException,
|
|
237
|
+
NebulaValidationException,
|
|
238
|
+
NebulaClusterNotFoundException
|
|
239
|
+
} from '@nebula-ai/sdk';
|
|
240
|
+
|
|
241
|
+
try {
|
|
242
|
+
await client.search('query', [clusterId]);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if (error instanceof NebulaAuthenticationException) {
|
|
245
|
+
console.log('Invalid API key');
|
|
246
|
+
} else if (error instanceof NebulaRateLimitException) {
|
|
247
|
+
console.log('Rate limit exceeded');
|
|
248
|
+
} else if (error instanceof NebulaValidationException) {
|
|
249
|
+
console.log('Validation error:', error.details);
|
|
250
|
+
} else if (error instanceof NebulaException) {
|
|
251
|
+
console.log('API error:', error.statusCode, error.details);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Examples
|
|
257
|
+
|
|
258
|
+
### Basic Memory Management
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
import { NebulaSDK } from '@nebula-ai/sdk';
|
|
262
|
+
|
|
263
|
+
const client = new NebulaSDK({ apiKey: 'your-key' });
|
|
264
|
+
|
|
265
|
+
async function manageMemories() {
|
|
266
|
+
// Create a cluster
|
|
267
|
+
const cluster = await client.createCluster(
|
|
268
|
+
'Knowledge Base',
|
|
269
|
+
'My personal knowledge repository'
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
// Store memories using the unified model
|
|
273
|
+
const memories = [
|
|
274
|
+
{
|
|
275
|
+
cluster_id: cluster.id,
|
|
276
|
+
content: 'JavaScript is a programming language',
|
|
277
|
+
metadata: { category: 'programming', difficulty: 'beginner' }
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
cluster_id: cluster.id,
|
|
281
|
+
content: 'TypeScript adds static typing to JavaScript',
|
|
282
|
+
metadata: { category: 'programming', difficulty: 'beginner' }
|
|
283
|
+
}
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
// Store all memories at once
|
|
287
|
+
const memoryIds = await client.storeMemories(memories);
|
|
288
|
+
console.log('Stored memories:', memoryIds);
|
|
289
|
+
|
|
290
|
+
// Search for memories
|
|
291
|
+
const results = await client.search('JavaScript', [cluster.id]);
|
|
292
|
+
console.log('Search results:', results);
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Conversation Tracking
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { NebulaSDK } from '@nebula-ai/sdk';
|
|
300
|
+
|
|
301
|
+
const client = new NebulaSDK({ apiKey: 'your-key' });
|
|
302
|
+
|
|
303
|
+
async function trackConversation() {
|
|
304
|
+
const cluster = await client.createCluster('Conversations', 'AI chat history');
|
|
305
|
+
|
|
306
|
+
// Store conversation turns
|
|
307
|
+
const conversationMemories = [
|
|
308
|
+
{
|
|
309
|
+
cluster_id: cluster.id,
|
|
310
|
+
content: 'What is machine learning?',
|
|
311
|
+
role: 'user',
|
|
312
|
+
metadata: { topic: 'AI' }
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
cluster_id: cluster.id,
|
|
316
|
+
content: 'Machine learning is a subset of AI...',
|
|
317
|
+
role: 'assistant',
|
|
318
|
+
metadata: { topic: 'AI' }
|
|
319
|
+
}
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
// Store conversation (returns conversation IDs)
|
|
323
|
+
const conversationIds = await client.storeMemories(conversationMemories);
|
|
324
|
+
console.log('Conversation IDs:', conversationIds);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Advanced Search with Graph Results
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
import { NebulaSDK, RetrievalType } from '@nebula-ai/sdk';
|
|
332
|
+
|
|
333
|
+
const client = new NebulaSDK({ apiKey: 'your-key' });
|
|
334
|
+
|
|
335
|
+
async function advancedSearch() {
|
|
336
|
+
const cluster = await client.createCluster('Knowledge Graph', 'Entity relationships');
|
|
337
|
+
|
|
338
|
+
// Store knowledge graph data
|
|
339
|
+
await client.storeMemory({
|
|
340
|
+
cluster_id: cluster.id,
|
|
341
|
+
content: 'Einstein developed the theory of relativity',
|
|
342
|
+
metadata: { entity: 'Einstein', concept: 'relativity', field: 'physics' }
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// Search with graph settings
|
|
346
|
+
const results = await client.search(
|
|
347
|
+
'Einstein relativity',
|
|
348
|
+
[cluster.id],
|
|
349
|
+
10,
|
|
350
|
+
RetrievalType.ADVANCED,
|
|
351
|
+
undefined,
|
|
352
|
+
{
|
|
353
|
+
graph_settings: {
|
|
354
|
+
enabled: true,
|
|
355
|
+
bfs_enabled: true,
|
|
356
|
+
bfs_max_depth: 2
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
// Handle both chunk and graph results
|
|
362
|
+
results.forEach(result => {
|
|
363
|
+
if (result.content) {
|
|
364
|
+
console.log('Chunk result:', result.content);
|
|
365
|
+
}
|
|
366
|
+
if (result.graph_entity) {
|
|
367
|
+
console.log('Entity:', result.graph_entity.name);
|
|
368
|
+
}
|
|
369
|
+
if (result.graph_relationship) {
|
|
370
|
+
console.log('Relationship:', result.graph_relationship.subject,
|
|
371
|
+
result.graph_relationship.predicate,
|
|
372
|
+
result.graph_relationship.object);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Browser vs Node.js
|
|
379
|
+
|
|
380
|
+
### Browser Usage
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
import { NebulaSDK } from '@nebula-ai/sdk';
|
|
384
|
+
|
|
385
|
+
const client = new NebulaSDK({
|
|
386
|
+
apiKey: 'your-api-key'
|
|
387
|
+
// Note: CORS handling is now built into the SDK
|
|
388
|
+
});
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Node.js Usage
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
import { NebulaSDK } from '@nebula-ai/sdk';
|
|
395
|
+
|
|
396
|
+
const client = new NebulaSDK({
|
|
397
|
+
apiKey: 'your-api-key'
|
|
398
|
+
// No additional configuration needed
|
|
399
|
+
});
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Development
|
|
403
|
+
|
|
404
|
+
### Building
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
npm run build
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Testing
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
npm test
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Type Checking
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
npm run type-check
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
## Contributing
|
|
423
|
+
|
|
424
|
+
1. Fork the repository
|
|
425
|
+
2. Create a feature branch
|
|
426
|
+
3. Make your changes
|
|
427
|
+
4. Add tests
|
|
428
|
+
5. Submit a pull request
|
|
429
|
+
|
|
430
|
+
## License
|
|
431
|
+
|
|
432
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
433
|
+
|
|
434
|
+
## Support
|
|
435
|
+
|
|
436
|
+
- 📧 Email: support@trynebula.ai
|
|
437
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/nebula-cloud/nebula-sdk-js/issues)
|
|
438
|
+
- 📚 Documentation: [Nebula Cloud Docs](https://docs.trynebula.ai)
|
|
439
|
+
|
|
440
|
+
## Changelog
|
|
441
|
+
|
|
442
|
+
### v0.0.19
|
|
443
|
+
- Complete rewrite to match Python SDK client.py exactly
|
|
444
|
+
- Unified Memory model for text and conversations
|
|
445
|
+
- Advanced search with graph results support
|
|
446
|
+
- Proper error handling matching Python SDK
|
|
447
|
+
- Full TypeScript support with comprehensive interfaces
|
|
448
|
+
- Browser and Node.js compatibility
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
declare enum RetrievalType {
|
|
2
|
+
BASIC = "basic",
|
|
3
|
+
ADVANCED = "advanced",
|
|
4
|
+
CUSTOM = "custom"
|
|
5
|
+
}
|
|
6
|
+
declare enum GraphSearchResultType {
|
|
7
|
+
ENTITY = "entity",
|
|
8
|
+
RELATIONSHIP = "relationship",
|
|
9
|
+
COMMUNITY = "community"
|
|
10
|
+
}
|
|
11
|
+
interface MemoryResponse {
|
|
12
|
+
id: string;
|
|
13
|
+
content?: string;
|
|
14
|
+
chunks?: string[];
|
|
15
|
+
metadata: Record<string, any>;
|
|
16
|
+
cluster_ids: string[];
|
|
17
|
+
created_at?: string;
|
|
18
|
+
updated_at?: string;
|
|
19
|
+
}
|
|
20
|
+
interface Memory {
|
|
21
|
+
cluster_id: string;
|
|
22
|
+
content: string;
|
|
23
|
+
role?: string;
|
|
24
|
+
parent_id?: string;
|
|
25
|
+
metadata: Record<string, any>;
|
|
26
|
+
}
|
|
27
|
+
interface Cluster {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
metadata: Record<string, any>;
|
|
32
|
+
created_at?: string;
|
|
33
|
+
updated_at?: string;
|
|
34
|
+
memory_count: number;
|
|
35
|
+
owner_id?: string;
|
|
36
|
+
}
|
|
37
|
+
interface SearchResult {
|
|
38
|
+
id: string;
|
|
39
|
+
score: number;
|
|
40
|
+
metadata: Record<string, any>;
|
|
41
|
+
source?: string;
|
|
42
|
+
content?: string;
|
|
43
|
+
graph_result_type?: GraphSearchResultType;
|
|
44
|
+
graph_entity?: GraphEntityResult;
|
|
45
|
+
graph_relationship?: GraphRelationshipResult;
|
|
46
|
+
graph_community?: GraphCommunityResult;
|
|
47
|
+
chunk_ids?: string[];
|
|
48
|
+
}
|
|
49
|
+
interface GraphEntityResult {
|
|
50
|
+
id?: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
metadata: Record<string, any>;
|
|
54
|
+
}
|
|
55
|
+
interface GraphRelationshipResult {
|
|
56
|
+
id?: string;
|
|
57
|
+
subject: string;
|
|
58
|
+
predicate: string;
|
|
59
|
+
object: string;
|
|
60
|
+
subject_id?: string;
|
|
61
|
+
object_id?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
metadata: Record<string, any>;
|
|
64
|
+
}
|
|
65
|
+
interface GraphCommunityResult {
|
|
66
|
+
id?: string;
|
|
67
|
+
name: string;
|
|
68
|
+
summary: string;
|
|
69
|
+
metadata: Record<string, any>;
|
|
70
|
+
}
|
|
71
|
+
interface AgentResponse {
|
|
72
|
+
content: string;
|
|
73
|
+
agent_id: string;
|
|
74
|
+
conversation_id?: string;
|
|
75
|
+
metadata: Record<string, any>;
|
|
76
|
+
citations: Record<string, any>[];
|
|
77
|
+
}
|
|
78
|
+
interface SearchOptions {
|
|
79
|
+
limit: number;
|
|
80
|
+
filters?: Record<string, any>;
|
|
81
|
+
retrieval_type: RetrievalType;
|
|
82
|
+
}
|
|
83
|
+
interface NebulaSDKConfig {
|
|
84
|
+
apiKey: string;
|
|
85
|
+
baseUrl?: string;
|
|
86
|
+
timeout?: number;
|
|
87
|
+
}
|
|
88
|
+
declare class NebulaException extends Error {
|
|
89
|
+
statusCode?: number | undefined;
|
|
90
|
+
details?: any;
|
|
91
|
+
constructor(message: string, statusCode?: number | undefined, details?: any);
|
|
92
|
+
}
|
|
93
|
+
declare class NebulaClientException extends NebulaException {
|
|
94
|
+
cause?: Error | undefined;
|
|
95
|
+
constructor(message: string, cause?: Error | undefined);
|
|
96
|
+
}
|
|
97
|
+
declare class NebulaAuthenticationException extends NebulaException {
|
|
98
|
+
constructor(message?: string);
|
|
99
|
+
}
|
|
100
|
+
declare class NebulaRateLimitException extends NebulaException {
|
|
101
|
+
constructor(message?: string);
|
|
102
|
+
}
|
|
103
|
+
declare class NebulaValidationException extends NebulaException {
|
|
104
|
+
details?: any;
|
|
105
|
+
constructor(message?: string, details?: any);
|
|
106
|
+
}
|
|
107
|
+
declare class NebulaClusterNotFoundException extends NebulaException {
|
|
108
|
+
constructor(message?: string);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Official Nebula Cloud JavaScript/TypeScript SDK
|
|
113
|
+
* Mirrors the exact Nebula Python SDK client.py implementation
|
|
114
|
+
*/
|
|
115
|
+
declare class NebulaSDK {
|
|
116
|
+
private apiKey;
|
|
117
|
+
private baseUrl;
|
|
118
|
+
private timeout;
|
|
119
|
+
constructor(config: NebulaSDKConfig);
|
|
120
|
+
/**
|
|
121
|
+
* Check if API key is set
|
|
122
|
+
*/
|
|
123
|
+
isApiKeySet(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Detect if a token looks like a Nebula API key (public.raw)
|
|
126
|
+
*/
|
|
127
|
+
private _isNebulaApiKey;
|
|
128
|
+
/**
|
|
129
|
+
* Build authentication headers
|
|
130
|
+
*/
|
|
131
|
+
private _buildAuthHeaders;
|
|
132
|
+
/**
|
|
133
|
+
* Make an HTTP request to the Nebula API
|
|
134
|
+
*/
|
|
135
|
+
private _makeRequest;
|
|
136
|
+
/**
|
|
137
|
+
* Create a new cluster
|
|
138
|
+
*/
|
|
139
|
+
createCluster(name: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
|
|
140
|
+
/**
|
|
141
|
+
* Get a specific cluster by ID
|
|
142
|
+
*/
|
|
143
|
+
getCluster(clusterId: string): Promise<Cluster>;
|
|
144
|
+
/**
|
|
145
|
+
* Get a specific cluster by name
|
|
146
|
+
*/
|
|
147
|
+
getClusterByName(name: string): Promise<Cluster>;
|
|
148
|
+
/**
|
|
149
|
+
* Get all clusters
|
|
150
|
+
*/
|
|
151
|
+
listClusters(limit?: number, offset?: number): Promise<Cluster[]>;
|
|
152
|
+
/**
|
|
153
|
+
* List conversations for the authenticated user
|
|
154
|
+
*/
|
|
155
|
+
listConversations(limit?: number, offset?: number): Promise<any[]>;
|
|
156
|
+
/**
|
|
157
|
+
* Update a cluster
|
|
158
|
+
*/
|
|
159
|
+
updateCluster(clusterId: string, name?: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
|
|
160
|
+
/**
|
|
161
|
+
* Delete a cluster
|
|
162
|
+
*/
|
|
163
|
+
deleteCluster(clusterId: string): Promise<boolean>;
|
|
164
|
+
/**
|
|
165
|
+
* Store a single memory
|
|
166
|
+
*/
|
|
167
|
+
storeMemory(memory: Memory | Record<string, any>): Promise<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Store multiple memories
|
|
170
|
+
*/
|
|
171
|
+
storeMemories(memories: Memory[]): Promise<string[]>;
|
|
172
|
+
/**
|
|
173
|
+
* Delete a specific memory
|
|
174
|
+
*/
|
|
175
|
+
delete(memoryId: string): Promise<boolean>;
|
|
176
|
+
/**
|
|
177
|
+
* Get all memories from specific clusters
|
|
178
|
+
*/
|
|
179
|
+
listMemories(clusterIds: string[], limit?: number, offset?: number): Promise<MemoryResponse[]>;
|
|
180
|
+
/**
|
|
181
|
+
* Get a specific memory by ID
|
|
182
|
+
*/
|
|
183
|
+
getMemory(memoryId: string): Promise<MemoryResponse>;
|
|
184
|
+
/**
|
|
185
|
+
* Search within specific clusters
|
|
186
|
+
*/
|
|
187
|
+
search(query: string, clusterIds: string[], limit?: number, retrievalType?: RetrievalType | string, filters?: Record<string, any>, searchSettings?: Record<string, any>): Promise<SearchResult[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Check the health of the Nebula API
|
|
190
|
+
*/
|
|
191
|
+
healthCheck(): Promise<Record<string, any>>;
|
|
192
|
+
/**
|
|
193
|
+
* Convert cluster dict to Cluster object
|
|
194
|
+
*/
|
|
195
|
+
private _clusterFromDict;
|
|
196
|
+
/**
|
|
197
|
+
* Convert memory dict to MemoryResponse object
|
|
198
|
+
*/
|
|
199
|
+
private _memoryResponseFromDict;
|
|
200
|
+
/**
|
|
201
|
+
* Convert search result dict to SearchResult object
|
|
202
|
+
*/
|
|
203
|
+
private _searchResultFromDict;
|
|
204
|
+
/**
|
|
205
|
+
* Convert graph search result dict to SearchResult object
|
|
206
|
+
*/
|
|
207
|
+
private _searchResultFromGraphDict;
|
|
208
|
+
/**
|
|
209
|
+
* SHA-256 hash function
|
|
210
|
+
*/
|
|
211
|
+
private _sha256;
|
|
212
|
+
/**
|
|
213
|
+
* Convert object to FormData
|
|
214
|
+
*/
|
|
215
|
+
private _formDataFromObject;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException, NebulaSDK, type NebulaSDKConfig, NebulaValidationException, RetrievalType, type SearchOptions, type SearchResult, NebulaSDK as default };
|