@nebula-ai/sdk 1.2.2 → 1.4.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/LICENSE +5 -10
- package/README.md +41 -166
- package/dist/index.cjs +1268 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2824 -0
- package/dist/index.d.ts +2811 -586
- package/dist/index.js +1232 -1333
- package/dist/index.js.map +1 -1
- package/package.json +35 -50
- package/dist/index.d.mts +0 -599
- package/dist/index.mjs +0 -1330
- package/dist/index.mjs.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Nebula
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -9,18 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
copies or substantial portions of the Software.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
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
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,192 +1,67 @@
|
|
|
1
1
|
# @nebula-ai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official Nebula API SDK for TypeScript. Provides typed access to the public
|
|
4
|
+
Nebula REST API: collections, memories, connectors, snapshots, and system
|
|
5
|
+
health.
|
|
4
6
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- Node.js 18.0.0 or higher
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
7
|
+
## Install
|
|
10
8
|
|
|
11
9
|
```bash
|
|
12
10
|
npm install @nebula-ai/sdk
|
|
11
|
+
# or
|
|
12
|
+
bun add @nebula-ai/sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## Quick
|
|
15
|
+
## Quick start
|
|
16
16
|
|
|
17
|
-
```
|
|
18
|
-
import Nebula from
|
|
17
|
+
```ts
|
|
18
|
+
import { Nebula } from "@nebula-ai/sdk";
|
|
19
19
|
|
|
20
|
-
// Initialize client
|
|
21
20
|
const client = new Nebula({
|
|
22
|
-
apiKey:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Create a collection
|
|
26
|
-
const collection = await client.createCluster({
|
|
27
|
-
name: 'my_notes'
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Store a memory
|
|
31
|
-
const memoryId = await client.storeMemory({
|
|
32
|
-
collection_id: collection.id,
|
|
33
|
-
content: 'Machine learning is transforming healthcare',
|
|
34
|
-
metadata: { topic: 'AI', importance: 'high' }
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Search memories
|
|
38
|
-
const results = await client.search({
|
|
39
|
-
query: 'machine learning healthcare',
|
|
40
|
-
collection_ids: [collection.id],
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
results.forEach(result => {
|
|
44
|
-
console.log(`Score: ${result.score?.toFixed(2)}`);
|
|
45
|
-
console.log(`Content: ${result.content}`);
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Core Operations
|
|
50
|
-
|
|
51
|
-
### Collections
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
// Create
|
|
55
|
-
const collection = await client.createCluster({
|
|
56
|
-
name: 'my_collection',
|
|
57
|
-
description: 'Optional description'
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// List
|
|
61
|
-
const collections = await client.listClusters();
|
|
62
|
-
|
|
63
|
-
// Get by ID or name
|
|
64
|
-
const collection = await client.getCluster(collectionId);
|
|
65
|
-
const collection = await client.getClusterByName('my_collection');
|
|
66
|
-
|
|
67
|
-
// Update
|
|
68
|
-
await client.updateCluster({
|
|
69
|
-
collectionId,
|
|
70
|
-
name: 'new_name'
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Delete
|
|
74
|
-
await client.deleteCluster(collectionId);
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Store Memories
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
// Single memory
|
|
81
|
-
const memoryId = await client.storeMemory({
|
|
82
|
-
collection_id: collection.id,
|
|
83
|
-
content: 'Your content here',
|
|
84
|
-
metadata: { category: 'example' }
|
|
21
|
+
apiKey: process.env.NEBULA_API_KEY,
|
|
22
|
+
// or: bearerToken: process.env.NEBULA_BEARER_TOKEN,
|
|
85
23
|
});
|
|
86
24
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{ collection_id: collection.id, content: 'Second memory' }
|
|
91
|
-
]);
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Retrieve Memories
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
// List memories
|
|
98
|
-
const memories = await client.listMemories({
|
|
99
|
-
collection_ids: [collection.id],
|
|
100
|
-
limit: 10
|
|
25
|
+
const id = await client.storeMemory({
|
|
26
|
+
collection_id: "01234567-...",
|
|
27
|
+
raw_text: "hello, world",
|
|
101
28
|
});
|
|
102
29
|
|
|
103
|
-
|
|
104
|
-
const memories = await client.listMemories({
|
|
105
|
-
collection_ids: [collection.id],
|
|
106
|
-
metadata_filters: {
|
|
107
|
-
'metadata.category': { $eq: 'example' }
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Get specific memory
|
|
112
|
-
const memory = await client.getMemory('memory-id');
|
|
30
|
+
const results = await client.search({ query: "hello" });
|
|
113
31
|
```
|
|
114
32
|
|
|
115
|
-
|
|
33
|
+
The high-level methods (`storeMemory`, `search`, `deleteMemory`, ...) come
|
|
34
|
+
from the handwritten DX layer at `src/lib/dx.ts`. The low-level resource
|
|
35
|
+
clients (`client.memories.*`, `client.collections.*`, ...) are generated
|
|
36
|
+
directly from the OpenAPI spec and remain available as
|
|
37
|
+
`client.memories.create(...)`, `client.memories.search(...)`, etc.
|
|
116
38
|
|
|
117
|
-
|
|
118
|
-
// Semantic search
|
|
119
|
-
const results = await client.search({
|
|
120
|
-
query: 'your search query',
|
|
121
|
-
collection_ids: [collection.id],
|
|
122
|
-
});
|
|
123
|
-
```
|
|
39
|
+
## Auth
|
|
124
40
|
|
|
125
|
-
|
|
41
|
+
The constructor accepts both `apiKey` / `bearerToken` (camelCase) and the
|
|
42
|
+
snake_case aliases `api_key` / `access_token`. If you pass an API key that
|
|
43
|
+
doesn't look like a Nebula key (not prefixed with `key_` or `neb_`), the
|
|
44
|
+
DX layer automatically routes it through the bearer-token header instead.
|
|
126
45
|
|
|
127
|
-
|
|
128
|
-
// Single deletion
|
|
129
|
-
const deleted = await client.delete('memory-id'); // Returns boolean
|
|
46
|
+
## Errors
|
|
130
47
|
|
|
131
|
-
|
|
132
|
-
const result = await client.delete(['id1', 'id2', 'id3']); // Returns detailed results
|
|
133
|
-
```
|
|
48
|
+
All HTTP errors map to a typed exception hierarchy:
|
|
134
49
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
await client.storeMemory({
|
|
147
|
-
collection_id: collection.id,
|
|
148
|
-
content: 'Machine learning is a subset of AI...',
|
|
149
|
-
role: 'assistant',
|
|
150
|
-
parent_id: conversationId,
|
|
151
|
-
metadata: { content_type: 'conversation' }
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// List conversation memories
|
|
155
|
-
const conversations = await client.listMemories({
|
|
156
|
-
collection_ids: [collection.id],
|
|
157
|
-
metadata_filters: { 'metadata.content_type': { $eq: 'conversation' } }
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// Get messages from a conversation memory
|
|
161
|
-
const conversation = await client.getMemory(conversationId);
|
|
162
|
-
const messages = conversation.chunks ?? [];
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Error Handling
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
import Nebula, {
|
|
169
|
-
NebulaAuthenticationException,
|
|
170
|
-
NebulaRateLimitException,
|
|
171
|
-
NebulaValidationException
|
|
172
|
-
} from '@nebula-ai/sdk';
|
|
173
|
-
|
|
174
|
-
try {
|
|
175
|
-
await client.search({ query: 'query', collection_ids: [collectionId] });
|
|
176
|
-
} catch (error) {
|
|
177
|
-
if (error instanceof NebulaAuthenticationException) {
|
|
178
|
-
console.log('Invalid API key');
|
|
179
|
-
} else if (error instanceof NebulaRateLimitException) {
|
|
180
|
-
console.log('Rate limit exceeded');
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
```
|
|
50
|
+
- `NebulaBadRequestError` (400)
|
|
51
|
+
- `NebulaUnauthorizedError` (401)
|
|
52
|
+
- `NebulaForbiddenError` (403)
|
|
53
|
+
- `NebulaNotFoundError` (404)
|
|
54
|
+
- `NebulaConflictError` (409)
|
|
55
|
+
- `NebulaValidationError` (422)
|
|
56
|
+
- `NebulaRateLimitError` (429) — carries `retryAfter` when the server returns `Retry-After`
|
|
57
|
+
- `NebulaServerError` (5xx)
|
|
58
|
+
- `NebulaConnectionError` / `NebulaTimeoutError` — transport-level
|
|
184
59
|
|
|
185
|
-
##
|
|
60
|
+
## Docs
|
|
186
61
|
|
|
187
|
-
-
|
|
188
|
-
-
|
|
62
|
+
- API reference: https://docs.zeroset.com
|
|
63
|
+
- Migration notes: see `MIGRATION.md` in the source repo
|
|
189
64
|
|
|
190
|
-
##
|
|
65
|
+
## License
|
|
191
66
|
|
|
192
|
-
|
|
67
|
+
MIT
|