@nebula-ai/sdk 0.0.20 → 0.0.24
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 +67 -29
- package/dist/index.d.mts +46 -81
- package/dist/index.d.ts +46 -81
- package/dist/index.js +2 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +65 -65
package/README.md
CHANGED
|
@@ -6,18 +6,6 @@ Official JavaScript/TypeScript SDK for Nebula - Memory, Search, and AI-powered c
|
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
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
9
|
## Installation
|
|
22
10
|
|
|
23
11
|
```bash
|
|
@@ -31,10 +19,10 @@ pnpm add @nebula-ai/sdk
|
|
|
31
19
|
## Quick Start
|
|
32
20
|
|
|
33
21
|
```typescript
|
|
34
|
-
import {
|
|
22
|
+
import { NebulaClient, RetrievalType } from '@nebula-ai/sdk';
|
|
35
23
|
|
|
36
24
|
// Initialize the SDK
|
|
37
|
-
const client = new
|
|
25
|
+
const client = new NebulaClient({
|
|
38
26
|
apiKey: 'your-nebula-api-key',
|
|
39
27
|
baseUrl: 'https://api.nebulacloud.app', // optional, defaults to this
|
|
40
28
|
timeout: 30000 // optional, defaults to 30 seconds
|
|
@@ -70,7 +58,7 @@ console.log('Found memories:', results);
|
|
|
70
58
|
### Constructor
|
|
71
59
|
|
|
72
60
|
```typescript
|
|
73
|
-
new
|
|
61
|
+
new NebulaClient(config: NebulaClientConfig)
|
|
74
62
|
```
|
|
75
63
|
|
|
76
64
|
**Config Options:**
|
|
@@ -102,6 +90,20 @@ await client.updateCluster(clusterId: string, name?: string, description?: strin
|
|
|
102
90
|
await client.deleteCluster(clusterId: string)
|
|
103
91
|
```
|
|
104
92
|
|
|
93
|
+
#### Conversations
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// List conversations for the authenticated user
|
|
97
|
+
await client.listConversations(limit?: number, offset?: number, cluster_ids?: string[])
|
|
98
|
+
|
|
99
|
+
// Get conversation messages
|
|
100
|
+
await client.getConversationMessages(conversationId: string): Promise<MemoryResponse[]>
|
|
101
|
+
await client.getConversationMessages(conversationIds: string[]): Promise<Record<string, MemoryResponse[]>>
|
|
102
|
+
|
|
103
|
+
// Delete a conversation and all its messages
|
|
104
|
+
await client.deleteConversation(conversationId: string)
|
|
105
|
+
```
|
|
106
|
+
|
|
105
107
|
#### Memories
|
|
106
108
|
|
|
107
109
|
```typescript
|
|
@@ -115,7 +117,7 @@ await client.storeMemories(memories: Memory[])
|
|
|
115
117
|
await client.getMemory(memoryId: string)
|
|
116
118
|
|
|
117
119
|
// List memories from clusters
|
|
118
|
-
await client.listMemories(clusterIds: string[], limit?: number, offset?: number)
|
|
120
|
+
await client.listMemories(clusterIds: string | string[], limit?: number, offset?: number)
|
|
119
121
|
|
|
120
122
|
// Delete a memory
|
|
121
123
|
await client.delete(memoryId: string)
|
|
@@ -127,8 +129,8 @@ await client.delete(memoryId: string)
|
|
|
127
129
|
// Search within clusters
|
|
128
130
|
await client.search(
|
|
129
131
|
query: string,
|
|
130
|
-
|
|
131
|
-
limit?: number,
|
|
132
|
+
clusters: string | string[],
|
|
133
|
+
limitOrOptions?: number | { limit?: number },
|
|
132
134
|
retrievalType?: RetrievalType | string,
|
|
133
135
|
filters?: Record<string, any>,
|
|
134
136
|
searchSettings?: Record<string, any>
|
|
@@ -191,6 +193,18 @@ interface SearchResult {
|
|
|
191
193
|
}
|
|
192
194
|
```
|
|
193
195
|
|
|
196
|
+
#### AgentResponse
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
interface AgentResponse {
|
|
200
|
+
content: string;
|
|
201
|
+
agent_id: string;
|
|
202
|
+
conversation_id?: string;
|
|
203
|
+
metadata: Record<string, any>;
|
|
204
|
+
citations: Record<string, any>[];
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
194
208
|
#### RetrievalType
|
|
195
209
|
|
|
196
210
|
```typescript
|
|
@@ -218,7 +232,6 @@ const results = await client.search(
|
|
|
218
232
|
bfs_enabled: true,
|
|
219
233
|
bfs_max_depth: 2
|
|
220
234
|
},
|
|
221
|
-
search_strategy: 'rag_fusion',
|
|
222
235
|
num_sub_queries: 3
|
|
223
236
|
}
|
|
224
237
|
);
|
|
@@ -258,9 +271,9 @@ try {
|
|
|
258
271
|
### Basic Memory Management
|
|
259
272
|
|
|
260
273
|
```typescript
|
|
261
|
-
import {
|
|
274
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
262
275
|
|
|
263
|
-
const client = new
|
|
276
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
264
277
|
|
|
265
278
|
async function manageMemories() {
|
|
266
279
|
// Create a cluster
|
|
@@ -296,9 +309,9 @@ async function manageMemories() {
|
|
|
296
309
|
### Conversation Tracking
|
|
297
310
|
|
|
298
311
|
```typescript
|
|
299
|
-
import {
|
|
312
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
300
313
|
|
|
301
|
-
const client = new
|
|
314
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
302
315
|
|
|
303
316
|
async function trackConversation() {
|
|
304
317
|
const cluster = await client.createCluster('Conversations', 'AI chat history');
|
|
@@ -327,14 +340,39 @@ async function trackConversation() {
|
|
|
327
340
|
const messages = await client.getConversationMessages(conversationIds[0]);
|
|
328
341
|
console.log('Conversation messages:', messages);
|
|
329
342
|
}
|
|
343
|
+
|
|
344
|
+
### Managing Conversations
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
348
|
+
|
|
349
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
350
|
+
|
|
351
|
+
async function manageConversations() {
|
|
352
|
+
// List all conversations
|
|
353
|
+
const conversations = await client.listConversations(10, 0);
|
|
354
|
+
console.log('All conversations:', conversations);
|
|
355
|
+
|
|
356
|
+
// Get messages from a specific conversation
|
|
357
|
+
const messages = await client.getConversationMessages('conversation-id');
|
|
358
|
+
console.log('Conversation messages:', messages);
|
|
359
|
+
|
|
360
|
+
// Get messages from multiple conversations at once
|
|
361
|
+
const multipleMessages = await client.getConversationMessages(['conv1', 'conv2']);
|
|
362
|
+
console.log('Multiple conversations:', multipleMessages);
|
|
363
|
+
|
|
364
|
+
// Delete a conversation
|
|
365
|
+
await client.deleteConversation('conversation-id');
|
|
366
|
+
console.log('Conversation deleted');
|
|
367
|
+
}
|
|
330
368
|
```
|
|
331
369
|
|
|
332
370
|
### Advanced Search with Graph Results
|
|
333
371
|
|
|
334
372
|
```typescript
|
|
335
|
-
import {
|
|
373
|
+
import { NebulaClient, RetrievalType } from '@nebula-ai/sdk';
|
|
336
374
|
|
|
337
|
-
const client = new
|
|
375
|
+
const client = new NebulaClient({ apiKey: 'your-key' });
|
|
338
376
|
|
|
339
377
|
async function advancedSearch() {
|
|
340
378
|
const cluster = await client.createCluster('Knowledge Graph', 'Entity relationships');
|
|
@@ -384,9 +422,9 @@ async function advancedSearch() {
|
|
|
384
422
|
### Browser Usage
|
|
385
423
|
|
|
386
424
|
```typescript
|
|
387
|
-
import {
|
|
425
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
388
426
|
|
|
389
|
-
const client = new
|
|
427
|
+
const client = new NebulaClient({
|
|
390
428
|
apiKey: 'your-api-key'
|
|
391
429
|
// Note: CORS handling is now built into the SDK
|
|
392
430
|
});
|
|
@@ -395,9 +433,9 @@ const client = new NebulaSDK({
|
|
|
395
433
|
### Node.js Usage
|
|
396
434
|
|
|
397
435
|
```typescript
|
|
398
|
-
import {
|
|
436
|
+
import { NebulaClient } from '@nebula-ai/sdk';
|
|
399
437
|
|
|
400
|
-
const client = new
|
|
438
|
+
const client = new NebulaClient({
|
|
401
439
|
apiKey: 'your-api-key'
|
|
402
440
|
// No additional configuration needed
|
|
403
441
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -80,15 +80,15 @@ interface SearchOptions {
|
|
|
80
80
|
filters?: Record<string, any>;
|
|
81
81
|
retrieval_type: RetrievalType;
|
|
82
82
|
}
|
|
83
|
-
interface
|
|
83
|
+
interface NebulaClientConfig {
|
|
84
84
|
apiKey: string;
|
|
85
85
|
baseUrl?: string;
|
|
86
86
|
timeout?: number;
|
|
87
87
|
}
|
|
88
88
|
declare class NebulaException extends Error {
|
|
89
89
|
statusCode?: number | undefined;
|
|
90
|
-
details?: any;
|
|
91
|
-
constructor(message: string, statusCode?: number | undefined, details?: any);
|
|
90
|
+
details?: any | undefined;
|
|
91
|
+
constructor(message: string, statusCode?: number | undefined, details?: any | undefined);
|
|
92
92
|
}
|
|
93
93
|
declare class NebulaClientException extends NebulaException {
|
|
94
94
|
cause?: Error | undefined;
|
|
@@ -101,122 +101,87 @@ declare class NebulaRateLimitException extends NebulaException {
|
|
|
101
101
|
constructor(message?: string);
|
|
102
102
|
}
|
|
103
103
|
declare class NebulaValidationException extends NebulaException {
|
|
104
|
-
details?: any;
|
|
105
|
-
constructor(message?: string, details?: any);
|
|
104
|
+
details?: any | undefined;
|
|
105
|
+
constructor(message?: string, details?: any | undefined);
|
|
106
106
|
}
|
|
107
107
|
declare class NebulaClusterNotFoundException extends NebulaException {
|
|
108
108
|
constructor(message?: string);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* Official Nebula
|
|
112
|
+
* Official Nebula JavaScript/TypeScript SDK
|
|
113
113
|
* Mirrors the exact Nebula Python SDK client.py implementation
|
|
114
114
|
*/
|
|
115
|
-
declare class
|
|
115
|
+
declare class NebulaClient {
|
|
116
116
|
private apiKey;
|
|
117
117
|
private baseUrl;
|
|
118
118
|
private timeout;
|
|
119
|
-
constructor(config:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
constructor(config: NebulaClientConfig);
|
|
120
|
+
setApiKey(next: string): void;
|
|
121
|
+
setBaseUrl(next: string): void;
|
|
122
|
+
setCorsProxy(_next: string): void;
|
|
123
|
+
/** Check if API key is set */
|
|
123
124
|
isApiKeySet(): boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Detect if a token looks like a Nebula API key (public.raw)
|
|
126
|
-
*/
|
|
125
|
+
/** Detect if a token looks like a Nebula API key (public.raw) */
|
|
127
126
|
private _isNebulaApiKey;
|
|
128
|
-
/**
|
|
129
|
-
* Build authentication headers
|
|
130
|
-
*/
|
|
127
|
+
/** Build authentication headers */
|
|
131
128
|
private _buildAuthHeaders;
|
|
132
|
-
/**
|
|
133
|
-
* Make an HTTP request to the Nebula API
|
|
134
|
-
*/
|
|
129
|
+
/** Make an HTTP request to the Nebula API */
|
|
135
130
|
private _makeRequest;
|
|
136
|
-
/**
|
|
137
|
-
* Create a new cluster
|
|
138
|
-
*/
|
|
131
|
+
/** Create a new cluster */
|
|
139
132
|
createCluster(name: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
|
|
140
|
-
/**
|
|
141
|
-
* Get a specific cluster by ID
|
|
142
|
-
*/
|
|
133
|
+
/** Get a specific cluster by ID */
|
|
143
134
|
getCluster(clusterId: string): Promise<Cluster>;
|
|
144
|
-
/**
|
|
145
|
-
* Get a specific cluster by name
|
|
146
|
-
*/
|
|
135
|
+
/** Get a specific cluster by name */
|
|
147
136
|
getClusterByName(name: string): Promise<Cluster>;
|
|
148
|
-
/**
|
|
149
|
-
* Get all clusters
|
|
150
|
-
*/
|
|
137
|
+
/** Get all clusters */
|
|
151
138
|
listClusters(limit?: number, offset?: number): Promise<Cluster[]>;
|
|
152
|
-
/**
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
139
|
+
/** List conversations for the authenticated user */
|
|
140
|
+
listConversations(limit?: number, offset?: number, cluster_ids?: string[]): Promise<any[]>;
|
|
141
|
+
/** Get conversation messages directly from the conversations API */
|
|
142
|
+
getConversationMessages(conversationId: string): Promise<MemoryResponse[]>;
|
|
143
|
+
getConversationMessages(conversationIds: string[]): Promise<Record<string, MemoryResponse[]>>;
|
|
144
|
+
/** Helper method to transform conversation messages to MemoryResponse format */
|
|
145
|
+
private _transformConversationMessages;
|
|
146
|
+
/** Update a cluster */
|
|
159
147
|
updateCluster(clusterId: string, name?: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
|
|
160
|
-
/**
|
|
161
|
-
* Delete a cluster
|
|
162
|
-
*/
|
|
148
|
+
/** Delete a cluster */
|
|
163
149
|
deleteCluster(clusterId: string): Promise<boolean>;
|
|
164
150
|
/**
|
|
165
|
-
*
|
|
151
|
+
* Legacy convenience: store raw text content into a cluster as a document
|
|
166
152
|
*/
|
|
153
|
+
store(content: string, clusterId: string, metadata?: Record<string, any>): Promise<MemoryResponse>;
|
|
154
|
+
/** Store a single memory */
|
|
167
155
|
storeMemory(memory: Memory | Record<string, any>): Promise<string>;
|
|
168
|
-
/**
|
|
169
|
-
* Store multiple memories
|
|
170
|
-
*/
|
|
156
|
+
/** Store multiple memories */
|
|
171
157
|
storeMemories(memories: Memory[]): Promise<string[]>;
|
|
172
|
-
/**
|
|
173
|
-
* Delete a specific memory
|
|
174
|
-
*/
|
|
158
|
+
/** Delete a specific memory */
|
|
175
159
|
delete(memoryId: string): Promise<boolean>;
|
|
176
|
-
/**
|
|
177
|
-
* Delete a conversation and all its messages
|
|
178
|
-
*/
|
|
160
|
+
/** Delete a conversation and all its messages */
|
|
179
161
|
deleteConversation(conversationId: string): Promise<boolean>;
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
listMemories(clusterIds: string[], limit?: number, offset?: number): Promise<MemoryResponse[]>;
|
|
184
|
-
/**
|
|
185
|
-
* Get a specific memory by ID
|
|
186
|
-
*/
|
|
162
|
+
/** Get all memories from specific clusters */
|
|
163
|
+
listMemories(clusterIds: string | string[], limit?: number, offset?: number): Promise<MemoryResponse[]>;
|
|
164
|
+
/** Get a specific memory by ID */
|
|
187
165
|
getMemory(memoryId: string): Promise<MemoryResponse>;
|
|
166
|
+
/** Search within specific clusters */
|
|
167
|
+
search(query: string, clusters: string | string[], limitOrOptions?: number | {
|
|
168
|
+
limit?: number;
|
|
169
|
+
}, retrievalType?: RetrievalType | string, filters?: Record<string, any>, searchSettings?: Record<string, any>): Promise<SearchResult[]>;
|
|
188
170
|
/**
|
|
189
|
-
*
|
|
171
|
+
* Legacy wrapper: store a two-message conversation turn as a document
|
|
190
172
|
*/
|
|
191
|
-
|
|
173
|
+
storeConversation(userMessage: string, assistantMessage: string, clusterId: string, sessionId: string): Promise<MemoryResponse>;
|
|
192
174
|
/**
|
|
193
|
-
*
|
|
175
|
+
* Legacy wrapper: search conversations optionally scoped by session
|
|
194
176
|
*/
|
|
177
|
+
searchConversations(query: string, clusterId: string, sessionId?: string, includeAllSessions?: boolean): Promise<SearchResult[]>;
|
|
195
178
|
healthCheck(): Promise<Record<string, any>>;
|
|
196
|
-
/**
|
|
197
|
-
* Convert cluster dict to Cluster object
|
|
198
|
-
*/
|
|
199
179
|
private _clusterFromDict;
|
|
200
|
-
/**
|
|
201
|
-
* Convert memory dict to MemoryResponse object
|
|
202
|
-
*/
|
|
203
180
|
private _memoryResponseFromDict;
|
|
204
|
-
/**
|
|
205
|
-
* Convert search result dict to SearchResult object
|
|
206
|
-
*/
|
|
207
181
|
private _searchResultFromDict;
|
|
208
|
-
/**
|
|
209
|
-
* Convert graph search result dict to SearchResult object
|
|
210
|
-
*/
|
|
211
182
|
private _searchResultFromGraphDict;
|
|
212
|
-
/**
|
|
213
|
-
* SHA-256 hash function
|
|
214
|
-
*/
|
|
215
183
|
private _sha256;
|
|
216
|
-
/**
|
|
217
|
-
* Convert object to FormData
|
|
218
|
-
*/
|
|
219
184
|
private _formDataFromObject;
|
|
220
185
|
}
|
|
221
186
|
|
|
222
|
-
export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException,
|
|
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, RetrievalType, type SearchOptions, type SearchResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,15 +80,15 @@ interface SearchOptions {
|
|
|
80
80
|
filters?: Record<string, any>;
|
|
81
81
|
retrieval_type: RetrievalType;
|
|
82
82
|
}
|
|
83
|
-
interface
|
|
83
|
+
interface NebulaClientConfig {
|
|
84
84
|
apiKey: string;
|
|
85
85
|
baseUrl?: string;
|
|
86
86
|
timeout?: number;
|
|
87
87
|
}
|
|
88
88
|
declare class NebulaException extends Error {
|
|
89
89
|
statusCode?: number | undefined;
|
|
90
|
-
details?: any;
|
|
91
|
-
constructor(message: string, statusCode?: number | undefined, details?: any);
|
|
90
|
+
details?: any | undefined;
|
|
91
|
+
constructor(message: string, statusCode?: number | undefined, details?: any | undefined);
|
|
92
92
|
}
|
|
93
93
|
declare class NebulaClientException extends NebulaException {
|
|
94
94
|
cause?: Error | undefined;
|
|
@@ -101,122 +101,87 @@ declare class NebulaRateLimitException extends NebulaException {
|
|
|
101
101
|
constructor(message?: string);
|
|
102
102
|
}
|
|
103
103
|
declare class NebulaValidationException extends NebulaException {
|
|
104
|
-
details?: any;
|
|
105
|
-
constructor(message?: string, details?: any);
|
|
104
|
+
details?: any | undefined;
|
|
105
|
+
constructor(message?: string, details?: any | undefined);
|
|
106
106
|
}
|
|
107
107
|
declare class NebulaClusterNotFoundException extends NebulaException {
|
|
108
108
|
constructor(message?: string);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* Official Nebula
|
|
112
|
+
* Official Nebula JavaScript/TypeScript SDK
|
|
113
113
|
* Mirrors the exact Nebula Python SDK client.py implementation
|
|
114
114
|
*/
|
|
115
|
-
declare class
|
|
115
|
+
declare class NebulaClient {
|
|
116
116
|
private apiKey;
|
|
117
117
|
private baseUrl;
|
|
118
118
|
private timeout;
|
|
119
|
-
constructor(config:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
constructor(config: NebulaClientConfig);
|
|
120
|
+
setApiKey(next: string): void;
|
|
121
|
+
setBaseUrl(next: string): void;
|
|
122
|
+
setCorsProxy(_next: string): void;
|
|
123
|
+
/** Check if API key is set */
|
|
123
124
|
isApiKeySet(): boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Detect if a token looks like a Nebula API key (public.raw)
|
|
126
|
-
*/
|
|
125
|
+
/** Detect if a token looks like a Nebula API key (public.raw) */
|
|
127
126
|
private _isNebulaApiKey;
|
|
128
|
-
/**
|
|
129
|
-
* Build authentication headers
|
|
130
|
-
*/
|
|
127
|
+
/** Build authentication headers */
|
|
131
128
|
private _buildAuthHeaders;
|
|
132
|
-
/**
|
|
133
|
-
* Make an HTTP request to the Nebula API
|
|
134
|
-
*/
|
|
129
|
+
/** Make an HTTP request to the Nebula API */
|
|
135
130
|
private _makeRequest;
|
|
136
|
-
/**
|
|
137
|
-
* Create a new cluster
|
|
138
|
-
*/
|
|
131
|
+
/** Create a new cluster */
|
|
139
132
|
createCluster(name: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
|
|
140
|
-
/**
|
|
141
|
-
* Get a specific cluster by ID
|
|
142
|
-
*/
|
|
133
|
+
/** Get a specific cluster by ID */
|
|
143
134
|
getCluster(clusterId: string): Promise<Cluster>;
|
|
144
|
-
/**
|
|
145
|
-
* Get a specific cluster by name
|
|
146
|
-
*/
|
|
135
|
+
/** Get a specific cluster by name */
|
|
147
136
|
getClusterByName(name: string): Promise<Cluster>;
|
|
148
|
-
/**
|
|
149
|
-
* Get all clusters
|
|
150
|
-
*/
|
|
137
|
+
/** Get all clusters */
|
|
151
138
|
listClusters(limit?: number, offset?: number): Promise<Cluster[]>;
|
|
152
|
-
/**
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
139
|
+
/** List conversations for the authenticated user */
|
|
140
|
+
listConversations(limit?: number, offset?: number, cluster_ids?: string[]): Promise<any[]>;
|
|
141
|
+
/** Get conversation messages directly from the conversations API */
|
|
142
|
+
getConversationMessages(conversationId: string): Promise<MemoryResponse[]>;
|
|
143
|
+
getConversationMessages(conversationIds: string[]): Promise<Record<string, MemoryResponse[]>>;
|
|
144
|
+
/** Helper method to transform conversation messages to MemoryResponse format */
|
|
145
|
+
private _transformConversationMessages;
|
|
146
|
+
/** Update a cluster */
|
|
159
147
|
updateCluster(clusterId: string, name?: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
|
|
160
|
-
/**
|
|
161
|
-
* Delete a cluster
|
|
162
|
-
*/
|
|
148
|
+
/** Delete a cluster */
|
|
163
149
|
deleteCluster(clusterId: string): Promise<boolean>;
|
|
164
150
|
/**
|
|
165
|
-
*
|
|
151
|
+
* Legacy convenience: store raw text content into a cluster as a document
|
|
166
152
|
*/
|
|
153
|
+
store(content: string, clusterId: string, metadata?: Record<string, any>): Promise<MemoryResponse>;
|
|
154
|
+
/** Store a single memory */
|
|
167
155
|
storeMemory(memory: Memory | Record<string, any>): Promise<string>;
|
|
168
|
-
/**
|
|
169
|
-
* Store multiple memories
|
|
170
|
-
*/
|
|
156
|
+
/** Store multiple memories */
|
|
171
157
|
storeMemories(memories: Memory[]): Promise<string[]>;
|
|
172
|
-
/**
|
|
173
|
-
* Delete a specific memory
|
|
174
|
-
*/
|
|
158
|
+
/** Delete a specific memory */
|
|
175
159
|
delete(memoryId: string): Promise<boolean>;
|
|
176
|
-
/**
|
|
177
|
-
* Delete a conversation and all its messages
|
|
178
|
-
*/
|
|
160
|
+
/** Delete a conversation and all its messages */
|
|
179
161
|
deleteConversation(conversationId: string): Promise<boolean>;
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
listMemories(clusterIds: string[], limit?: number, offset?: number): Promise<MemoryResponse[]>;
|
|
184
|
-
/**
|
|
185
|
-
* Get a specific memory by ID
|
|
186
|
-
*/
|
|
162
|
+
/** Get all memories from specific clusters */
|
|
163
|
+
listMemories(clusterIds: string | string[], limit?: number, offset?: number): Promise<MemoryResponse[]>;
|
|
164
|
+
/** Get a specific memory by ID */
|
|
187
165
|
getMemory(memoryId: string): Promise<MemoryResponse>;
|
|
166
|
+
/** Search within specific clusters */
|
|
167
|
+
search(query: string, clusters: string | string[], limitOrOptions?: number | {
|
|
168
|
+
limit?: number;
|
|
169
|
+
}, retrievalType?: RetrievalType | string, filters?: Record<string, any>, searchSettings?: Record<string, any>): Promise<SearchResult[]>;
|
|
188
170
|
/**
|
|
189
|
-
*
|
|
171
|
+
* Legacy wrapper: store a two-message conversation turn as a document
|
|
190
172
|
*/
|
|
191
|
-
|
|
173
|
+
storeConversation(userMessage: string, assistantMessage: string, clusterId: string, sessionId: string): Promise<MemoryResponse>;
|
|
192
174
|
/**
|
|
193
|
-
*
|
|
175
|
+
* Legacy wrapper: search conversations optionally scoped by session
|
|
194
176
|
*/
|
|
177
|
+
searchConversations(query: string, clusterId: string, sessionId?: string, includeAllSessions?: boolean): Promise<SearchResult[]>;
|
|
195
178
|
healthCheck(): Promise<Record<string, any>>;
|
|
196
|
-
/**
|
|
197
|
-
* Convert cluster dict to Cluster object
|
|
198
|
-
*/
|
|
199
179
|
private _clusterFromDict;
|
|
200
|
-
/**
|
|
201
|
-
* Convert memory dict to MemoryResponse object
|
|
202
|
-
*/
|
|
203
180
|
private _memoryResponseFromDict;
|
|
204
|
-
/**
|
|
205
|
-
* Convert search result dict to SearchResult object
|
|
206
|
-
*/
|
|
207
181
|
private _searchResultFromDict;
|
|
208
|
-
/**
|
|
209
|
-
* Convert graph search result dict to SearchResult object
|
|
210
|
-
*/
|
|
211
182
|
private _searchResultFromGraphDict;
|
|
212
|
-
/**
|
|
213
|
-
* SHA-256 hash function
|
|
214
|
-
*/
|
|
215
183
|
private _sha256;
|
|
216
|
-
/**
|
|
217
|
-
* Convert object to FormData
|
|
218
|
-
*/
|
|
219
184
|
private _formDataFromObject;
|
|
220
185
|
}
|
|
221
186
|
|
|
222
|
-
export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException,
|
|
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, RetrievalType, type SearchOptions, type SearchResult };
|
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var NebulaClusterNotFoundException = class extends NebulaException {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
// src/client.ts
|
|
58
|
-
var
|
|
58
|
+
var NebulaClient = class {
|
|
59
59
|
constructor(config) {
|
|
60
60
|
this.apiKey = config.apiKey;
|
|
61
61
|
if (!this.apiKey) {
|
|
@@ -530,23 +530,6 @@ var NebulaSDK = class {
|
|
|
530
530
|
}
|
|
531
531
|
const effectiveSettings = { ...searchSettings };
|
|
532
532
|
effectiveSettings.limit = limit;
|
|
533
|
-
effectiveSettings.use_semantic_search = false;
|
|
534
|
-
effectiveSettings.use_fulltext_search = false;
|
|
535
|
-
effectiveSettings.use_hybrid_search = false;
|
|
536
|
-
effectiveSettings.chunk_settings = {
|
|
537
|
-
...effectiveSettings.chunk_settings || {},
|
|
538
|
-
enabled: false
|
|
539
|
-
};
|
|
540
|
-
effectiveSettings.search_strategy = "rag_fusion";
|
|
541
|
-
effectiveSettings.num_sub_queries = 3;
|
|
542
|
-
const gs = { ...effectiveSettings.graph_settings };
|
|
543
|
-
gs.enabled = true;
|
|
544
|
-
gs.bfs_enabled = true;
|
|
545
|
-
gs.bfs_max_depth = 2;
|
|
546
|
-
effectiveSettings.graph_settings = gs;
|
|
547
|
-
if (retrievalType !== "advanced" /* ADVANCED */) {
|
|
548
|
-
effectiveSettings.retrieval_type = retrievalType;
|
|
549
|
-
}
|
|
550
533
|
const userFilters = { ...effectiveSettings.filters };
|
|
551
534
|
if (filters) {
|
|
552
535
|
Object.assign(userFilters, filters);
|
|
@@ -745,11 +728,11 @@ Assistant: ${String(assistantMessage || "")}`;
|
|
|
745
728
|
|
|
746
729
|
exports.GraphSearchResultType = GraphSearchResultType;
|
|
747
730
|
exports.NebulaAuthenticationException = NebulaAuthenticationException;
|
|
731
|
+
exports.NebulaClient = NebulaClient;
|
|
748
732
|
exports.NebulaClientException = NebulaClientException;
|
|
749
733
|
exports.NebulaClusterNotFoundException = NebulaClusterNotFoundException;
|
|
750
734
|
exports.NebulaException = NebulaException;
|
|
751
735
|
exports.NebulaRateLimitException = NebulaRateLimitException;
|
|
752
|
-
exports.NebulaSDK = NebulaSDK;
|
|
753
736
|
exports.NebulaValidationException = NebulaValidationException;
|
|
754
737
|
exports.RetrievalType = RetrievalType;
|
|
755
738
|
//# sourceMappingURL=index.js.map
|