@nebula-ai/sdk 0.0.24 → 0.0.27
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 +73 -48
- package/dist/index.d.mts +151 -17
- package/dist/index.d.ts +151 -17
- package/dist/index.js +186 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,10 +29,10 @@ const client = new NebulaClient({
|
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
// Create a cluster
|
|
32
|
-
const cluster = await client.createCluster(
|
|
33
|
-
'My Project',
|
|
34
|
-
'A collection of project memories'
|
|
35
|
-
);
|
|
32
|
+
const cluster = await client.createCluster({
|
|
33
|
+
name: 'My Project',
|
|
34
|
+
description: 'A collection of project memories'
|
|
35
|
+
});
|
|
36
36
|
|
|
37
37
|
// Store a memory using the unified Memory model
|
|
38
38
|
const memoryId = await client.storeMemory({
|
|
@@ -42,13 +42,13 @@ const memoryId = await client.storeMemory({
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// Search for memories with advanced options
|
|
45
|
-
const results = await client.search(
|
|
46
|
-
'project information',
|
|
47
|
-
[cluster.id],
|
|
48
|
-
5,
|
|
49
|
-
RetrievalType.ADVANCED,
|
|
50
|
-
{ 'metadata.category': 'project' }
|
|
51
|
-
);
|
|
45
|
+
const results = await client.search({
|
|
46
|
+
query: 'project information',
|
|
47
|
+
cluster_ids: [cluster.id],
|
|
48
|
+
limit: 5,
|
|
49
|
+
retrieval_type: RetrievalType.ADVANCED,
|
|
50
|
+
filters: { 'metadata.category': 'project' }
|
|
51
|
+
});
|
|
52
52
|
|
|
53
53
|
console.log('Found memories:', results);
|
|
54
54
|
```
|
|
@@ -72,7 +72,7 @@ new NebulaClient(config: NebulaClientConfig)
|
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
74
|
// Create a new cluster
|
|
75
|
-
await client.createCluster(name: string, description?: string, metadata?: Record<string, any>)
|
|
75
|
+
await client.createCluster(options: { name: string, description?: string, metadata?: Record<string, any> })
|
|
76
76
|
|
|
77
77
|
// Get a cluster by ID
|
|
78
78
|
await client.getCluster(clusterId: string)
|
|
@@ -81,10 +81,10 @@ await client.getCluster(clusterId: string)
|
|
|
81
81
|
await client.getClusterByName(name: string)
|
|
82
82
|
|
|
83
83
|
// List all clusters
|
|
84
|
-
await client.listClusters(limit?: number, offset?: number)
|
|
84
|
+
await client.listClusters(options?: { limit?: number, offset?: number })
|
|
85
85
|
|
|
86
86
|
// Update a cluster
|
|
87
|
-
await client.updateCluster(clusterId: string, name?: string, description?: string, metadata?: Record<string, any>)
|
|
87
|
+
await client.updateCluster(options: { clusterId: string, name?: string, description?: string, metadata?: Record<string, any> })
|
|
88
88
|
|
|
89
89
|
// Delete a cluster
|
|
90
90
|
await client.deleteCluster(clusterId: string)
|
|
@@ -94,7 +94,7 @@ await client.deleteCluster(clusterId: string)
|
|
|
94
94
|
|
|
95
95
|
```typescript
|
|
96
96
|
// List conversations for the authenticated user
|
|
97
|
-
await client.listConversations(limit?: number, offset?: number, cluster_ids?: string[])
|
|
97
|
+
await client.listConversations(options?: { limit?: number, offset?: number, cluster_ids?: string[] })
|
|
98
98
|
|
|
99
99
|
// Get conversation messages
|
|
100
100
|
await client.getConversationMessages(conversationId: string): Promise<MemoryResponse[]>
|
|
@@ -117,24 +117,28 @@ await client.storeMemories(memories: Memory[])
|
|
|
117
117
|
await client.getMemory(memoryId: string)
|
|
118
118
|
|
|
119
119
|
// List memories from clusters
|
|
120
|
-
await client.listMemories(
|
|
120
|
+
await client.listMemories(options: { cluster_ids: string | string[], limit?: number, offset?: number })
|
|
121
|
+
|
|
122
|
+
// Delete one or more memories
|
|
123
|
+
// Single deletion:
|
|
124
|
+
await client.delete('memory-id') // Returns: boolean
|
|
121
125
|
|
|
122
|
-
//
|
|
123
|
-
await client.delete(
|
|
126
|
+
// Batch deletion:
|
|
127
|
+
await client.delete(['id1', 'id2', 'id3']) // Returns: detailed results object
|
|
124
128
|
```
|
|
125
129
|
|
|
126
130
|
#### Search
|
|
127
131
|
|
|
128
132
|
```typescript
|
|
129
133
|
// Search within clusters
|
|
130
|
-
await client.search(
|
|
134
|
+
await client.search(options: {
|
|
131
135
|
query: string,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
cluster_ids: string | string[],
|
|
137
|
+
limit?: number,
|
|
138
|
+
retrieval_type?: RetrievalType | string,
|
|
135
139
|
filters?: Record<string, any>,
|
|
136
140
|
searchSettings?: Record<string, any>
|
|
137
|
-
)
|
|
141
|
+
})
|
|
138
142
|
```
|
|
139
143
|
|
|
140
144
|
#### Health Check
|
|
@@ -220,13 +224,13 @@ enum RetrievalType {
|
|
|
220
224
|
The search method supports advanced configuration:
|
|
221
225
|
|
|
222
226
|
```typescript
|
|
223
|
-
const results = await client.search(
|
|
224
|
-
'query',
|
|
225
|
-
[clusterId],
|
|
226
|
-
10,
|
|
227
|
-
RetrievalType.ADVANCED,
|
|
228
|
-
{ 'metadata.category': 'science' },
|
|
229
|
-
{
|
|
227
|
+
const results = await client.search({
|
|
228
|
+
query: 'query',
|
|
229
|
+
cluster_ids: [clusterId],
|
|
230
|
+
limit: 10,
|
|
231
|
+
retrieval_type: RetrievalType.ADVANCED,
|
|
232
|
+
filters: { 'metadata.category': 'science' },
|
|
233
|
+
searchSettings: {
|
|
230
234
|
graph_settings: {
|
|
231
235
|
enabled: true,
|
|
232
236
|
bfs_enabled: true,
|
|
@@ -234,7 +238,7 @@ const results = await client.search(
|
|
|
234
238
|
},
|
|
235
239
|
num_sub_queries: 3
|
|
236
240
|
}
|
|
237
|
-
);
|
|
241
|
+
});
|
|
238
242
|
```
|
|
239
243
|
|
|
240
244
|
### Error Handling
|
|
@@ -252,7 +256,7 @@ import {
|
|
|
252
256
|
} from '@nebula-ai/sdk';
|
|
253
257
|
|
|
254
258
|
try {
|
|
255
|
-
await client.search('query', [clusterId]);
|
|
259
|
+
await client.search({ query: 'query', cluster_ids: [clusterId] });
|
|
256
260
|
} catch (error) {
|
|
257
261
|
if (error instanceof NebulaAuthenticationException) {
|
|
258
262
|
console.log('Invalid API key');
|
|
@@ -277,10 +281,10 @@ const client = new NebulaClient({ apiKey: 'your-key' });
|
|
|
277
281
|
|
|
278
282
|
async function manageMemories() {
|
|
279
283
|
// Create a cluster
|
|
280
|
-
const cluster = await client.createCluster(
|
|
281
|
-
'Knowledge Base',
|
|
282
|
-
'My personal knowledge repository'
|
|
283
|
-
);
|
|
284
|
+
const cluster = await client.createCluster({
|
|
285
|
+
name: 'Knowledge Base',
|
|
286
|
+
description: 'My personal knowledge repository'
|
|
287
|
+
});
|
|
284
288
|
|
|
285
289
|
// Store memories using the unified model
|
|
286
290
|
const memories = [
|
|
@@ -301,8 +305,24 @@ async function manageMemories() {
|
|
|
301
305
|
console.log('Stored memories:', memoryIds);
|
|
302
306
|
|
|
303
307
|
// Search for memories
|
|
304
|
-
const results = await client.search('JavaScript', [cluster.id]);
|
|
308
|
+
const results = await client.search({ query: 'JavaScript', cluster_ids: [cluster.id] });
|
|
305
309
|
console.log('Search results:', results);
|
|
310
|
+
|
|
311
|
+
// Delete a single memory
|
|
312
|
+
const deleted = await client.delete(memoryIds[0]);
|
|
313
|
+
console.log('Deleted single memory:', deleted); // true
|
|
314
|
+
|
|
315
|
+
// Delete multiple memories at once
|
|
316
|
+
const batchResult = await client.delete([memoryIds[1], memoryIds[2]]);
|
|
317
|
+
console.log('Batch deletion results:', batchResult);
|
|
318
|
+
// {
|
|
319
|
+
// message: "Deleted 2 of 2 documents",
|
|
320
|
+
// results: {
|
|
321
|
+
// successful: ["id1", "id2"],
|
|
322
|
+
// failed: [],
|
|
323
|
+
// summary: { total: 2, succeeded: 2, failed: 0 }
|
|
324
|
+
// }
|
|
325
|
+
// }
|
|
306
326
|
}
|
|
307
327
|
```
|
|
308
328
|
|
|
@@ -314,7 +334,10 @@ import { NebulaClient } from '@nebula-ai/sdk';
|
|
|
314
334
|
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
315
335
|
|
|
316
336
|
async function trackConversation() {
|
|
317
|
-
const cluster = await client.createCluster(
|
|
337
|
+
const cluster = await client.createCluster({
|
|
338
|
+
name: 'Conversations',
|
|
339
|
+
description: 'AI chat history'
|
|
340
|
+
});
|
|
318
341
|
|
|
319
342
|
// Store conversation turns
|
|
320
343
|
const conversationMemories = [
|
|
@@ -350,7 +373,7 @@ const client = new NebulaClient({ apiKey: 'your-key' });
|
|
|
350
373
|
|
|
351
374
|
async function manageConversations() {
|
|
352
375
|
// List all conversations
|
|
353
|
-
const conversations = await client.listConversations(10, 0);
|
|
376
|
+
const conversations = await client.listConversations({ limit: 10, offset: 0 });
|
|
354
377
|
console.log('All conversations:', conversations);
|
|
355
378
|
|
|
356
379
|
// Get messages from a specific conversation
|
|
@@ -375,7 +398,10 @@ import { NebulaClient, RetrievalType } from '@nebula-ai/sdk';
|
|
|
375
398
|
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
376
399
|
|
|
377
400
|
async function advancedSearch() {
|
|
378
|
-
const cluster = await client.createCluster(
|
|
401
|
+
const cluster = await client.createCluster({
|
|
402
|
+
name: 'Knowledge Graph',
|
|
403
|
+
description: 'Entity relationships'
|
|
404
|
+
});
|
|
379
405
|
|
|
380
406
|
// Store knowledge graph data
|
|
381
407
|
await client.storeMemory({
|
|
@@ -385,20 +411,19 @@ async function advancedSearch() {
|
|
|
385
411
|
});
|
|
386
412
|
|
|
387
413
|
// Search with graph settings
|
|
388
|
-
const results = await client.search(
|
|
389
|
-
'Einstein relativity',
|
|
390
|
-
[cluster.id],
|
|
391
|
-
10,
|
|
392
|
-
RetrievalType.ADVANCED,
|
|
393
|
-
|
|
394
|
-
{
|
|
414
|
+
const results = await client.search({
|
|
415
|
+
query: 'Einstein relativity',
|
|
416
|
+
cluster_ids: [cluster.id],
|
|
417
|
+
limit: 10,
|
|
418
|
+
retrieval_type: RetrievalType.ADVANCED,
|
|
419
|
+
searchSettings: {
|
|
395
420
|
graph_settings: {
|
|
396
421
|
enabled: true,
|
|
397
422
|
bfs_enabled: true,
|
|
398
423
|
bfs_max_depth: 2
|
|
399
424
|
}
|
|
400
425
|
}
|
|
401
|
-
);
|
|
426
|
+
});
|
|
402
427
|
|
|
403
428
|
// Handle both chunk and graph results
|
|
404
429
|
results.forEach(result => {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
declare enum RetrievalType {
|
|
2
|
-
BASIC = "basic",
|
|
3
|
-
ADVANCED = "advanced",
|
|
4
|
-
CUSTOM = "custom"
|
|
5
|
-
}
|
|
6
1
|
declare enum GraphSearchResultType {
|
|
7
2
|
ENTITY = "entity",
|
|
8
3
|
RELATIONSHIP = "relationship",
|
|
@@ -39,6 +34,11 @@ interface SearchResult {
|
|
|
39
34
|
score: number;
|
|
40
35
|
metadata: Record<string, any>;
|
|
41
36
|
source?: string;
|
|
37
|
+
timestamp?: string;
|
|
38
|
+
display_name?: string;
|
|
39
|
+
source_role?: string;
|
|
40
|
+
document_id?: string;
|
|
41
|
+
owner_id?: string;
|
|
42
42
|
content?: string;
|
|
43
43
|
graph_result_type?: GraphSearchResultType;
|
|
44
44
|
graph_entity?: GraphEntityResult;
|
|
@@ -78,7 +78,7 @@ interface AgentResponse {
|
|
|
78
78
|
interface SearchOptions {
|
|
79
79
|
limit: number;
|
|
80
80
|
filters?: Record<string, any>;
|
|
81
|
-
|
|
81
|
+
search_mode?: 'fast' | 'super';
|
|
82
82
|
}
|
|
83
83
|
interface NebulaClientConfig {
|
|
84
84
|
apiKey: string;
|
|
@@ -129,22 +129,38 @@ declare class NebulaClient {
|
|
|
129
129
|
/** Make an HTTP request to the Nebula API */
|
|
130
130
|
private _makeRequest;
|
|
131
131
|
/** Create a new cluster */
|
|
132
|
-
createCluster(
|
|
132
|
+
createCluster(options: {
|
|
133
|
+
name: string;
|
|
134
|
+
description?: string;
|
|
135
|
+
metadata?: Record<string, any>;
|
|
136
|
+
}): Promise<Cluster>;
|
|
133
137
|
/** Get a specific cluster by ID */
|
|
134
138
|
getCluster(clusterId: string): Promise<Cluster>;
|
|
135
139
|
/** Get a specific cluster by name */
|
|
136
140
|
getClusterByName(name: string): Promise<Cluster>;
|
|
137
141
|
/** Get all clusters */
|
|
138
|
-
listClusters(
|
|
142
|
+
listClusters(options?: {
|
|
143
|
+
limit?: number;
|
|
144
|
+
offset?: number;
|
|
145
|
+
}): Promise<Cluster[]>;
|
|
139
146
|
/** List conversations for the authenticated user */
|
|
140
|
-
listConversations(
|
|
147
|
+
listConversations(options?: {
|
|
148
|
+
limit?: number;
|
|
149
|
+
offset?: number;
|
|
150
|
+
cluster_ids?: string[];
|
|
151
|
+
}): Promise<any[]>;
|
|
141
152
|
/** Get conversation messages directly from the conversations API */
|
|
142
153
|
getConversationMessages(conversationId: string): Promise<MemoryResponse[]>;
|
|
143
154
|
getConversationMessages(conversationIds: string[]): Promise<Record<string, MemoryResponse[]>>;
|
|
144
155
|
/** Helper method to transform conversation messages to MemoryResponse format */
|
|
145
156
|
private _transformConversationMessages;
|
|
146
157
|
/** Update a cluster */
|
|
147
|
-
updateCluster(
|
|
158
|
+
updateCluster(options: {
|
|
159
|
+
clusterId: string;
|
|
160
|
+
name?: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
metadata?: Record<string, any>;
|
|
163
|
+
}): Promise<Cluster>;
|
|
148
164
|
/** Delete a cluster */
|
|
149
165
|
deleteCluster(clusterId: string): Promise<boolean>;
|
|
150
166
|
/**
|
|
@@ -155,18 +171,136 @@ declare class NebulaClient {
|
|
|
155
171
|
storeMemory(memory: Memory | Record<string, any>): Promise<string>;
|
|
156
172
|
/** Store multiple memories */
|
|
157
173
|
storeMemories(memories: Memory[]): Promise<string[]>;
|
|
158
|
-
/** Delete
|
|
159
|
-
delete(
|
|
174
|
+
/** Delete one or more memories */
|
|
175
|
+
delete(memoryIds: string | string[]): Promise<boolean | {
|
|
176
|
+
message: string;
|
|
177
|
+
results: {
|
|
178
|
+
successful: string[];
|
|
179
|
+
failed: Array<{
|
|
180
|
+
id: string;
|
|
181
|
+
error: string;
|
|
182
|
+
}>;
|
|
183
|
+
summary: {
|
|
184
|
+
total: number;
|
|
185
|
+
succeeded: number;
|
|
186
|
+
failed: number;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
}>;
|
|
160
190
|
/** Delete a conversation and all its messages */
|
|
161
191
|
deleteConversation(conversationId: string): Promise<boolean>;
|
|
162
192
|
/** Get all memories from specific clusters */
|
|
163
|
-
listMemories(
|
|
193
|
+
listMemories(options: {
|
|
194
|
+
cluster_ids: string | string[];
|
|
195
|
+
limit?: number;
|
|
196
|
+
offset?: number;
|
|
197
|
+
}): Promise<MemoryResponse[]>;
|
|
164
198
|
/** Get a specific memory by ID */
|
|
165
199
|
getMemory(memoryId: string): Promise<MemoryResponse>;
|
|
166
|
-
/**
|
|
167
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Search within specific clusters with optional metadata filtering.
|
|
202
|
+
*
|
|
203
|
+
* @param options - Search configuration
|
|
204
|
+
* @param options.query - Search query string
|
|
205
|
+
* @param options.cluster_ids - One or more cluster IDs to search within
|
|
206
|
+
* @param options.limit - Maximum number of results to return (default: 10)
|
|
207
|
+
* @param options.retrieval_type - Retrieval strategy (default: ADVANCED)
|
|
208
|
+
* @param options.filters - Optional filters to apply to the search. Supports comprehensive metadata filtering
|
|
209
|
+
* with MongoDB-like operators for both vector/chunk search and graph search.
|
|
210
|
+
* @param options.searchSettings - Optional search configuration
|
|
211
|
+
*
|
|
212
|
+
* @returns Promise resolving to array of SearchResult objects containing both vector/chunk and graph search results
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // Basic equality filter
|
|
216
|
+
* await client.search({
|
|
217
|
+
* query: "machine learning",
|
|
218
|
+
* cluster_ids: ["research-cluster"],
|
|
219
|
+
* filters: {
|
|
220
|
+
* "metadata.category": { $eq: "research" },
|
|
221
|
+
* "metadata.verified": true // Shorthand for $eq
|
|
222
|
+
* }
|
|
223
|
+
* });
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* // Numeric comparisons
|
|
227
|
+
* await client.search({
|
|
228
|
+
* query: "high priority",
|
|
229
|
+
* cluster_ids: ["tasks"],
|
|
230
|
+
* filters: {
|
|
231
|
+
* "metadata.priority": { $gte: 8 },
|
|
232
|
+
* "metadata.score": { $lt: 100 }
|
|
233
|
+
* }
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* // String matching
|
|
238
|
+
* await client.search({
|
|
239
|
+
* query: "employees",
|
|
240
|
+
* cluster_ids: ["team"],
|
|
241
|
+
* filters: {
|
|
242
|
+
* "metadata.email": { $ilike: "%@company.com" } // Case-insensitive
|
|
243
|
+
* }
|
|
244
|
+
* });
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* // Array operations
|
|
248
|
+
* await client.search({
|
|
249
|
+
* query: "developers",
|
|
250
|
+
* cluster_ids: ["team"],
|
|
251
|
+
* filters: {
|
|
252
|
+
* "metadata.skills": { $overlap: ["python", "typescript"] } // Has any
|
|
253
|
+
* }
|
|
254
|
+
* });
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* // Nested paths
|
|
258
|
+
* await client.search({
|
|
259
|
+
* query: "users",
|
|
260
|
+
* cluster_ids: ["profiles"],
|
|
261
|
+
* filters: {
|
|
262
|
+
* "metadata.user.preferences.theme": { $eq: "dark" }
|
|
263
|
+
* }
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* // Complex logical combinations
|
|
268
|
+
* await client.search({
|
|
269
|
+
* query: "candidates",
|
|
270
|
+
* cluster_ids: ["hiring"],
|
|
271
|
+
* filters: {
|
|
272
|
+
* $and: [
|
|
273
|
+
* { "metadata.verified": true },
|
|
274
|
+
* { "metadata.level": { $gte: 5 } },
|
|
275
|
+
* {
|
|
276
|
+
* $or: [
|
|
277
|
+
* { "metadata.skills": { $overlap: ["python", "go"] } },
|
|
278
|
+
* { "metadata.years_experience": { $gte: 8 } }
|
|
279
|
+
* ]
|
|
280
|
+
* }
|
|
281
|
+
* ]
|
|
282
|
+
* }
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
* Supported Operators:
|
|
287
|
+
* - Comparison: $eq, $ne, $lt, $lte, $gt, $gte
|
|
288
|
+
* - String: $like (case-sensitive), $ilike (case-insensitive)
|
|
289
|
+
* - Array: $in, $nin, $overlap, $contains
|
|
290
|
+
* - JSONB: $json_contains
|
|
291
|
+
* - Logical: $and, $or
|
|
292
|
+
*
|
|
293
|
+
* For comprehensive filtering documentation, see the Metadata Filtering Guide:
|
|
294
|
+
* https://docs.nebulacloud.app/guides/metadata-filtering
|
|
295
|
+
*/
|
|
296
|
+
search(options: {
|
|
297
|
+
query: string;
|
|
298
|
+
cluster_ids: string | string[];
|
|
168
299
|
limit?: number;
|
|
169
|
-
|
|
300
|
+
filters?: Record<string, any>;
|
|
301
|
+
search_mode?: 'fast' | 'super';
|
|
302
|
+
searchSettings?: Record<string, any>;
|
|
303
|
+
}): Promise<SearchResult[]>;
|
|
170
304
|
/**
|
|
171
305
|
* Legacy wrapper: store a two-message conversation turn as a document
|
|
172
306
|
*/
|
|
@@ -184,4 +318,4 @@ declare class NebulaClient {
|
|
|
184
318
|
private _formDataFromObject;
|
|
185
319
|
}
|
|
186
320
|
|
|
187
|
-
export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClient, type NebulaClientConfig, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException, NebulaValidationException,
|
|
321
|
+
export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClient, type NebulaClientConfig, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException, NebulaValidationException, type SearchOptions, type SearchResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
declare enum RetrievalType {
|
|
2
|
-
BASIC = "basic",
|
|
3
|
-
ADVANCED = "advanced",
|
|
4
|
-
CUSTOM = "custom"
|
|
5
|
-
}
|
|
6
1
|
declare enum GraphSearchResultType {
|
|
7
2
|
ENTITY = "entity",
|
|
8
3
|
RELATIONSHIP = "relationship",
|
|
@@ -39,6 +34,11 @@ interface SearchResult {
|
|
|
39
34
|
score: number;
|
|
40
35
|
metadata: Record<string, any>;
|
|
41
36
|
source?: string;
|
|
37
|
+
timestamp?: string;
|
|
38
|
+
display_name?: string;
|
|
39
|
+
source_role?: string;
|
|
40
|
+
document_id?: string;
|
|
41
|
+
owner_id?: string;
|
|
42
42
|
content?: string;
|
|
43
43
|
graph_result_type?: GraphSearchResultType;
|
|
44
44
|
graph_entity?: GraphEntityResult;
|
|
@@ -78,7 +78,7 @@ interface AgentResponse {
|
|
|
78
78
|
interface SearchOptions {
|
|
79
79
|
limit: number;
|
|
80
80
|
filters?: Record<string, any>;
|
|
81
|
-
|
|
81
|
+
search_mode?: 'fast' | 'super';
|
|
82
82
|
}
|
|
83
83
|
interface NebulaClientConfig {
|
|
84
84
|
apiKey: string;
|
|
@@ -129,22 +129,38 @@ declare class NebulaClient {
|
|
|
129
129
|
/** Make an HTTP request to the Nebula API */
|
|
130
130
|
private _makeRequest;
|
|
131
131
|
/** Create a new cluster */
|
|
132
|
-
createCluster(
|
|
132
|
+
createCluster(options: {
|
|
133
|
+
name: string;
|
|
134
|
+
description?: string;
|
|
135
|
+
metadata?: Record<string, any>;
|
|
136
|
+
}): Promise<Cluster>;
|
|
133
137
|
/** Get a specific cluster by ID */
|
|
134
138
|
getCluster(clusterId: string): Promise<Cluster>;
|
|
135
139
|
/** Get a specific cluster by name */
|
|
136
140
|
getClusterByName(name: string): Promise<Cluster>;
|
|
137
141
|
/** Get all clusters */
|
|
138
|
-
listClusters(
|
|
142
|
+
listClusters(options?: {
|
|
143
|
+
limit?: number;
|
|
144
|
+
offset?: number;
|
|
145
|
+
}): Promise<Cluster[]>;
|
|
139
146
|
/** List conversations for the authenticated user */
|
|
140
|
-
listConversations(
|
|
147
|
+
listConversations(options?: {
|
|
148
|
+
limit?: number;
|
|
149
|
+
offset?: number;
|
|
150
|
+
cluster_ids?: string[];
|
|
151
|
+
}): Promise<any[]>;
|
|
141
152
|
/** Get conversation messages directly from the conversations API */
|
|
142
153
|
getConversationMessages(conversationId: string): Promise<MemoryResponse[]>;
|
|
143
154
|
getConversationMessages(conversationIds: string[]): Promise<Record<string, MemoryResponse[]>>;
|
|
144
155
|
/** Helper method to transform conversation messages to MemoryResponse format */
|
|
145
156
|
private _transformConversationMessages;
|
|
146
157
|
/** Update a cluster */
|
|
147
|
-
updateCluster(
|
|
158
|
+
updateCluster(options: {
|
|
159
|
+
clusterId: string;
|
|
160
|
+
name?: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
metadata?: Record<string, any>;
|
|
163
|
+
}): Promise<Cluster>;
|
|
148
164
|
/** Delete a cluster */
|
|
149
165
|
deleteCluster(clusterId: string): Promise<boolean>;
|
|
150
166
|
/**
|
|
@@ -155,18 +171,136 @@ declare class NebulaClient {
|
|
|
155
171
|
storeMemory(memory: Memory | Record<string, any>): Promise<string>;
|
|
156
172
|
/** Store multiple memories */
|
|
157
173
|
storeMemories(memories: Memory[]): Promise<string[]>;
|
|
158
|
-
/** Delete
|
|
159
|
-
delete(
|
|
174
|
+
/** Delete one or more memories */
|
|
175
|
+
delete(memoryIds: string | string[]): Promise<boolean | {
|
|
176
|
+
message: string;
|
|
177
|
+
results: {
|
|
178
|
+
successful: string[];
|
|
179
|
+
failed: Array<{
|
|
180
|
+
id: string;
|
|
181
|
+
error: string;
|
|
182
|
+
}>;
|
|
183
|
+
summary: {
|
|
184
|
+
total: number;
|
|
185
|
+
succeeded: number;
|
|
186
|
+
failed: number;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
}>;
|
|
160
190
|
/** Delete a conversation and all its messages */
|
|
161
191
|
deleteConversation(conversationId: string): Promise<boolean>;
|
|
162
192
|
/** Get all memories from specific clusters */
|
|
163
|
-
listMemories(
|
|
193
|
+
listMemories(options: {
|
|
194
|
+
cluster_ids: string | string[];
|
|
195
|
+
limit?: number;
|
|
196
|
+
offset?: number;
|
|
197
|
+
}): Promise<MemoryResponse[]>;
|
|
164
198
|
/** Get a specific memory by ID */
|
|
165
199
|
getMemory(memoryId: string): Promise<MemoryResponse>;
|
|
166
|
-
/**
|
|
167
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Search within specific clusters with optional metadata filtering.
|
|
202
|
+
*
|
|
203
|
+
* @param options - Search configuration
|
|
204
|
+
* @param options.query - Search query string
|
|
205
|
+
* @param options.cluster_ids - One or more cluster IDs to search within
|
|
206
|
+
* @param options.limit - Maximum number of results to return (default: 10)
|
|
207
|
+
* @param options.retrieval_type - Retrieval strategy (default: ADVANCED)
|
|
208
|
+
* @param options.filters - Optional filters to apply to the search. Supports comprehensive metadata filtering
|
|
209
|
+
* with MongoDB-like operators for both vector/chunk search and graph search.
|
|
210
|
+
* @param options.searchSettings - Optional search configuration
|
|
211
|
+
*
|
|
212
|
+
* @returns Promise resolving to array of SearchResult objects containing both vector/chunk and graph search results
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // Basic equality filter
|
|
216
|
+
* await client.search({
|
|
217
|
+
* query: "machine learning",
|
|
218
|
+
* cluster_ids: ["research-cluster"],
|
|
219
|
+
* filters: {
|
|
220
|
+
* "metadata.category": { $eq: "research" },
|
|
221
|
+
* "metadata.verified": true // Shorthand for $eq
|
|
222
|
+
* }
|
|
223
|
+
* });
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* // Numeric comparisons
|
|
227
|
+
* await client.search({
|
|
228
|
+
* query: "high priority",
|
|
229
|
+
* cluster_ids: ["tasks"],
|
|
230
|
+
* filters: {
|
|
231
|
+
* "metadata.priority": { $gte: 8 },
|
|
232
|
+
* "metadata.score": { $lt: 100 }
|
|
233
|
+
* }
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* // String matching
|
|
238
|
+
* await client.search({
|
|
239
|
+
* query: "employees",
|
|
240
|
+
* cluster_ids: ["team"],
|
|
241
|
+
* filters: {
|
|
242
|
+
* "metadata.email": { $ilike: "%@company.com" } // Case-insensitive
|
|
243
|
+
* }
|
|
244
|
+
* });
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* // Array operations
|
|
248
|
+
* await client.search({
|
|
249
|
+
* query: "developers",
|
|
250
|
+
* cluster_ids: ["team"],
|
|
251
|
+
* filters: {
|
|
252
|
+
* "metadata.skills": { $overlap: ["python", "typescript"] } // Has any
|
|
253
|
+
* }
|
|
254
|
+
* });
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* // Nested paths
|
|
258
|
+
* await client.search({
|
|
259
|
+
* query: "users",
|
|
260
|
+
* cluster_ids: ["profiles"],
|
|
261
|
+
* filters: {
|
|
262
|
+
* "metadata.user.preferences.theme": { $eq: "dark" }
|
|
263
|
+
* }
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* // Complex logical combinations
|
|
268
|
+
* await client.search({
|
|
269
|
+
* query: "candidates",
|
|
270
|
+
* cluster_ids: ["hiring"],
|
|
271
|
+
* filters: {
|
|
272
|
+
* $and: [
|
|
273
|
+
* { "metadata.verified": true },
|
|
274
|
+
* { "metadata.level": { $gte: 5 } },
|
|
275
|
+
* {
|
|
276
|
+
* $or: [
|
|
277
|
+
* { "metadata.skills": { $overlap: ["python", "go"] } },
|
|
278
|
+
* { "metadata.years_experience": { $gte: 8 } }
|
|
279
|
+
* ]
|
|
280
|
+
* }
|
|
281
|
+
* ]
|
|
282
|
+
* }
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
* Supported Operators:
|
|
287
|
+
* - Comparison: $eq, $ne, $lt, $lte, $gt, $gte
|
|
288
|
+
* - String: $like (case-sensitive), $ilike (case-insensitive)
|
|
289
|
+
* - Array: $in, $nin, $overlap, $contains
|
|
290
|
+
* - JSONB: $json_contains
|
|
291
|
+
* - Logical: $and, $or
|
|
292
|
+
*
|
|
293
|
+
* For comprehensive filtering documentation, see the Metadata Filtering Guide:
|
|
294
|
+
* https://docs.nebulacloud.app/guides/metadata-filtering
|
|
295
|
+
*/
|
|
296
|
+
search(options: {
|
|
297
|
+
query: string;
|
|
298
|
+
cluster_ids: string | string[];
|
|
168
299
|
limit?: number;
|
|
169
|
-
|
|
300
|
+
filters?: Record<string, any>;
|
|
301
|
+
search_mode?: 'fast' | 'super';
|
|
302
|
+
searchSettings?: Record<string, any>;
|
|
303
|
+
}): Promise<SearchResult[]>;
|
|
170
304
|
/**
|
|
171
305
|
* Legacy wrapper: store a two-message conversation turn as a document
|
|
172
306
|
*/
|
|
@@ -184,4 +318,4 @@ declare class NebulaClient {
|
|
|
184
318
|
private _formDataFromObject;
|
|
185
319
|
}
|
|
186
320
|
|
|
187
|
-
export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClient, type NebulaClientConfig, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException, NebulaValidationException,
|
|
321
|
+
export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClient, type NebulaClientConfig, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException, NebulaValidationException, type SearchOptions, type SearchResult };
|