@rcrsr/rill-ext-qdrant 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andre Bremer
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.
package/README.md ADDED
@@ -0,0 +1,255 @@
1
+ # @rcrsr/rill-ext-qdrant
2
+
3
+ [rill](https://rill.run) extension for [Qdrant](https://qdrant.tech) vector database integration. Provides 11 host functions for vector CRUD, batch operations, and collection management.
4
+
5
+ > **Experimental.** Breaking changes will occur before stabilization.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @rcrsr/rill-ext-qdrant
11
+ ```
12
+
13
+ **Peer dependencies:** `@rcrsr/rill`
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { parse, execute, createRuntimeContext, prefixFunctions } from '@rcrsr/rill';
19
+ import { createQdrantExtension } from '@rcrsr/rill-ext-qdrant';
20
+
21
+ const ext = createQdrantExtension({
22
+ url: 'http://localhost:6333',
23
+ collection: 'my_vectors',
24
+ dimensions: 384,
25
+ });
26
+ const prefixed = prefixFunctions('qdrant', ext);
27
+ const { dispose, ...functions } = prefixed;
28
+
29
+ const ctx = createRuntimeContext({
30
+ functions,
31
+ callbacks: { onLog: (v) => console.log(v) },
32
+ });
33
+
34
+ const script = `
35
+ qdrant::upsert("doc-1", $embedding, [title: "Example"])
36
+ qdrant::search($embedding, [k: 5]) -> log
37
+ `;
38
+ const result = await execute(parse(script), ctx);
39
+
40
+ dispose?.();
41
+ ```
42
+
43
+ ## Host Functions
44
+
45
+ All vector database extensions share identical function signatures. Swap `qdrant::` for `pinecone::` or `chroma::` with no script changes.
46
+
47
+ ### qdrant::upsert(id, vector, metadata?)
48
+
49
+ Insert or update a single vector with metadata.
50
+
51
+ ```rill
52
+ qdrant::upsert("doc-1", $embedding, [title: "Example", page: 1]) => $result
53
+ $result.id -> log # "doc-1"
54
+ $result.success -> log # true
55
+ ```
56
+
57
+ **Idempotent.** Duplicate ID overwrites existing vector.
58
+
59
+ ### qdrant::upsert_batch(items)
60
+
61
+ Batch insert or update vectors. Processes sequentially; halts on first failure.
62
+
63
+ ```rill
64
+ qdrant::upsert_batch([
65
+ [id: "doc-1", vector: $v1, metadata: [title: "First"]],
66
+ [id: "doc-2", vector: $v2, metadata: [title: "Second"]]
67
+ ]) => $result
68
+ $result.succeeded -> log # 2
69
+ ```
70
+
71
+ Returns `{ succeeded }` on success. Returns `{ succeeded, failed, error }` on failure.
72
+
73
+ ### qdrant::search(vector, options?)
74
+
75
+ Search for k nearest neighbors.
76
+
77
+ ```rill
78
+ qdrant::search($embedding, [k: 5, score_threshold: 0.8]) => $results
79
+ $results -> each { "{.id}: {.score}" -> log }
80
+ ```
81
+
82
+ | Option | Type | Default | Description |
83
+ |--------|------|---------|-------------|
84
+ | `k` | number | `10` | Max results to return |
85
+ | `filter` | dict | `{}` | Metadata filter conditions |
86
+ | `score_threshold` | number | (none) | Exclude results below threshold |
87
+
88
+ Returns `[{ id, score, metadata }]`. Empty results return `[]`.
89
+
90
+ ### qdrant::get(id)
91
+
92
+ Fetch a vector by ID.
93
+
94
+ ```rill
95
+ qdrant::get("doc-1") => $point
96
+ $point.id -> log # "doc-1"
97
+ $point.metadata -> log # [title: "Example", page: 1]
98
+ ```
99
+
100
+ Returns `{ id, vector, metadata }`. Halts with error if ID not found.
101
+
102
+ ### qdrant::delete(id)
103
+
104
+ Delete a vector by ID.
105
+
106
+ ```rill
107
+ qdrant::delete("doc-1") => $result
108
+ $result.deleted -> log # true
109
+ ```
110
+
111
+ Returns `{ id, deleted }`. Halts with error if ID not found.
112
+
113
+ ### qdrant::delete_batch(ids)
114
+
115
+ Batch delete vectors. Processes sequentially; halts on first failure.
116
+
117
+ ```rill
118
+ qdrant::delete_batch(["doc-1", "doc-2", "doc-3"]) => $result
119
+ $result.succeeded -> log # 3
120
+ ```
121
+
122
+ Returns `{ succeeded }` on success. Returns `{ succeeded, failed, error }` on failure.
123
+
124
+ ### qdrant::count()
125
+
126
+ Count vectors in the collection.
127
+
128
+ ```rill
129
+ qdrant::count() -> log # 42
130
+ ```
131
+
132
+ Returns a number.
133
+
134
+ ### qdrant::create_collection(name, options?)
135
+
136
+ Create a new collection.
137
+
138
+ ```rill
139
+ qdrant::create_collection("my_vectors", [dimensions: 384, distance: "cosine"]) => $result
140
+ $result.created -> log # true
141
+ ```
142
+
143
+ | Option | Type | Default | Description |
144
+ |--------|------|---------|-------------|
145
+ | `dimensions` | number | (none) | Vector dimension size |
146
+ | `distance` | string | `"cosine"` | `"cosine"`, `"euclidean"`, or `"dot"` |
147
+
148
+ Returns `{ name, created }`. **Not idempotent** — halts if collection exists.
149
+
150
+ ### qdrant::delete_collection(id)
151
+
152
+ Delete a collection.
153
+
154
+ ```rill
155
+ qdrant::delete_collection("old_vectors") => $result
156
+ $result.deleted -> log # true
157
+ ```
158
+
159
+ Returns `{ name, deleted }`. **Not idempotent** — halts if collection not found.
160
+
161
+ ### qdrant::list_collections()
162
+
163
+ List all collection names.
164
+
165
+ ```rill
166
+ qdrant::list_collections() -> log # ["my_vectors", "archive"]
167
+ ```
168
+
169
+ Returns a list of strings.
170
+
171
+ ### qdrant::describe()
172
+
173
+ Describe the configured collection.
174
+
175
+ ```rill
176
+ qdrant::describe() => $info
177
+ $info.name -> log # "my_vectors"
178
+ $info.count -> log # 42
179
+ $info.dimensions -> log # 384
180
+ $info.distance -> log # "cosine"
181
+ ```
182
+
183
+ Returns `{ name, count, dimensions, distance }`.
184
+
185
+ ## Configuration
186
+
187
+ ```typescript
188
+ const ext = createQdrantExtension({
189
+ url: 'http://localhost:6333',
190
+ collection: 'my_vectors',
191
+ dimensions: 384,
192
+ distance: 'cosine',
193
+ apiKey: process.env.QDRANT_API_KEY,
194
+ timeout: 30000,
195
+ });
196
+ ```
197
+
198
+ | Option | Type | Default | Description |
199
+ |--------|------|---------|-------------|
200
+ | `url` | string | required | Qdrant API endpoint URL |
201
+ | `collection` | string | required | Default collection name |
202
+ | `dimensions` | number | undefined | Vector dimension size |
203
+ | `distance` | string | `"cosine"` | `"cosine"`, `"euclidean"`, or `"dot"` |
204
+ | `apiKey` | string | undefined | API key for Qdrant Cloud |
205
+ | `timeout` | number | SDK default | Request timeout in ms |
206
+
207
+ ## Error Handling
208
+
209
+ All errors use `RuntimeError('RILL-R004', 'qdrant: <message>')` and halt script execution.
210
+
211
+ | Condition | Message |
212
+ |-----------|---------|
213
+ | HTTP 401 | `qdrant: authentication failed (401)` |
214
+ | Collection not found | `qdrant: collection not found` |
215
+ | Rate limit (429) | `qdrant: rate limit exceeded` |
216
+ | Timeout | `qdrant: request timeout` |
217
+ | Dimension mismatch | `qdrant: dimension mismatch (expected N, got M)` |
218
+ | Collection exists | `qdrant: collection already exists` |
219
+ | ID not found | `qdrant: id not found` |
220
+ | After dispose | `qdrant: operation cancelled` |
221
+ | Other | `qdrant: <error message>` |
222
+
223
+ ## Local Setup
224
+
225
+ Run Qdrant locally with Docker:
226
+
227
+ ```bash
228
+ docker run -p 6333:6333 -p 6334:6334 \
229
+ -v $(pwd)/qdrant_storage:/qdrant/storage:z \
230
+ qdrant/qdrant
231
+ ```
232
+
233
+ Verify: `curl http://localhost:6333`
234
+
235
+ ## Lifecycle
236
+
237
+ ```typescript
238
+ const ext = createQdrantExtension({ ... });
239
+ // ... use extension ...
240
+ await ext.dispose?.();
241
+ ```
242
+
243
+ `dispose()` aborts pending requests and closes the SDK client. Idempotent — second call resolves without error.
244
+
245
+ ## Documentation
246
+
247
+ | Document | Description |
248
+ |----------|-------------|
249
+ | [Extensions Guide](https://github.com/rcrsr/rill/blob/main/docs/integration-extensions.md) | Extension contract and patterns |
250
+ | [Host API Reference](https://github.com/rcrsr/rill/blob/main/docs/ref-host-api.md) | Runtime context and host functions |
251
+ | [Qdrant Documentation](https://qdrant.tech/documentation/) | Official Qdrant docs |
252
+
253
+ ## License
254
+
255
+ MIT
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Extension factory for Qdrant vector database integration.
3
+ * Creates extension instance with config validation and SDK lifecycle management.
4
+ */
5
+ import { type ExtensionResult } from '@rcrsr/rill';
6
+ import type { QdrantConfig } from './types.js';
7
+ /**
8
+ * Create Qdrant extension instance.
9
+ * Validates configuration and returns host functions with cleanup.
10
+ *
11
+ * @param config - Extension configuration
12
+ * @returns ExtensionResult with 11 vector database functions and dispose
13
+ * @throws Error for invalid configuration (AC-10)
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const ext = createQdrantExtension({
18
+ * url: 'http://127.0.0.1:6333',
19
+ * collection: 'my_vectors',
20
+ * });
21
+ * // Use with rill runtime...
22
+ * await ext.dispose();
23
+ * ```
24
+ */
25
+ export declare function createQdrantExtension(config: QdrantConfig): ExtensionResult;
26
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGL,KAAK,eAAe,EAIrB,MAAM,aAAa,CAAC;AASrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAgjB3E"}
@@ -0,0 +1,434 @@
1
+ /**
2
+ * Extension factory for Qdrant vector database integration.
3
+ * Creates extension instance with config validation and SDK lifecycle management.
4
+ */
5
+ import { QdrantClient } from '@qdrant/js-client-rest';
6
+ import { RuntimeError, createVector, } from '@rcrsr/rill';
7
+ import { mapVectorError, withEventEmission, createDisposalState, checkDisposed, dispose, assertRequired, } from '@rcrsr/rill-ext-vector-shared';
8
+ // ============================================================
9
+ // FACTORY
10
+ // ============================================================
11
+ /**
12
+ * Create Qdrant extension instance.
13
+ * Validates configuration and returns host functions with cleanup.
14
+ *
15
+ * @param config - Extension configuration
16
+ * @returns ExtensionResult with 11 vector database functions and dispose
17
+ * @throws Error for invalid configuration (AC-10)
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const ext = createQdrantExtension({
22
+ * url: 'http://127.0.0.1:6333',
23
+ * collection: 'my_vectors',
24
+ * });
25
+ * // Use with rill runtime...
26
+ * await ext.dispose();
27
+ * ```
28
+ */
29
+ export function createQdrantExtension(config) {
30
+ // Validate required fields (AC-10)
31
+ assertRequired(config.url, 'url');
32
+ assertRequired(config.collection, 'collection');
33
+ // Instantiate SDK client at factory time
34
+ const clientConfig = { url: config.url };
35
+ if (config.apiKey !== undefined) {
36
+ clientConfig.apiKey = config.apiKey;
37
+ }
38
+ if (config.timeout !== undefined) {
39
+ clientConfig.timeout = config.timeout;
40
+ }
41
+ const client = new QdrantClient(clientConfig);
42
+ // Store config values for use in functions
43
+ const factoryCollection = config.collection;
44
+ // Create disposal state for tracking lifecycle
45
+ const disposalState = createDisposalState('qdrant');
46
+ // Dispose function for cleanup (AC-31, AC-32)
47
+ const disposeExtension = async () => {
48
+ await dispose(disposalState, async () => {
49
+ // Cleanup SDK HTTP connections
50
+ // Note: Qdrant SDK doesn't expose a close() method, but we include
51
+ // this structure for consistency with extension pattern
52
+ });
53
+ };
54
+ // Return extension result with implementations
55
+ const result = {
56
+ // IR-1: qdrant::upsert
57
+ upsert: {
58
+ params: [
59
+ { name: 'id', type: 'string' },
60
+ { name: 'vector', type: 'vector' },
61
+ { name: 'metadata', type: 'dict', defaultValue: {} },
62
+ ],
63
+ fn: async (args, ctx) => {
64
+ checkDisposed(disposalState, 'qdrant');
65
+ // Extract arguments
66
+ const id = args[0];
67
+ const vector = args[1];
68
+ const metadata = (args[2] ?? {});
69
+ return withEventEmission(ctx, 'qdrant', 'upsert', { id }, async () => {
70
+ // Call Qdrant API
71
+ await client.upsert(factoryCollection, {
72
+ wait: true,
73
+ points: [
74
+ {
75
+ id,
76
+ vector: Array.from(vector.data),
77
+ payload: metadata,
78
+ },
79
+ ],
80
+ });
81
+ // Build result
82
+ return {
83
+ id,
84
+ success: true,
85
+ };
86
+ });
87
+ },
88
+ description: 'Insert or update single vector with metadata',
89
+ returnType: 'dict',
90
+ },
91
+ // IR-2: qdrant::upsert_batch
92
+ upsert_batch: {
93
+ params: [{ name: 'items', type: 'list' }],
94
+ fn: async (args, ctx) => {
95
+ checkDisposed(disposalState, 'qdrant');
96
+ // Extract arguments
97
+ const items = args[0];
98
+ return withEventEmission(ctx, 'qdrant', 'upsert_batch', { count: items.length, succeeded: 0 }, async () => {
99
+ let succeeded = 0;
100
+ // Process sequentially; halt on first failure
101
+ for (let i = 0; i < items.length; i++) {
102
+ const item = items[i];
103
+ // Validate item structure
104
+ if (!item || typeof item !== 'object') {
105
+ return {
106
+ succeeded,
107
+ failed: `index ${i}`,
108
+ error: 'invalid item structure',
109
+ };
110
+ }
111
+ const id = item['id'];
112
+ const vector = item['vector'];
113
+ const metadata = (item['metadata'] ?? {});
114
+ try {
115
+ // Call Qdrant API
116
+ await client.upsert(factoryCollection, {
117
+ wait: true,
118
+ points: [
119
+ {
120
+ id,
121
+ vector: Array.from(vector.data),
122
+ payload: metadata,
123
+ },
124
+ ],
125
+ });
126
+ succeeded++;
127
+ }
128
+ catch (error) {
129
+ // Halt on first failure
130
+ const rillError = mapVectorError('qdrant', error);
131
+ return {
132
+ succeeded,
133
+ failed: id,
134
+ error: rillError.message,
135
+ };
136
+ }
137
+ }
138
+ // All succeeded
139
+ return { succeeded };
140
+ });
141
+ },
142
+ description: 'Batch insert/update vectors',
143
+ returnType: 'dict',
144
+ },
145
+ // IR-3: qdrant::search
146
+ search: {
147
+ params: [
148
+ { name: 'vector', type: 'vector' },
149
+ { name: 'options', type: 'dict', defaultValue: {} },
150
+ ],
151
+ fn: async (args, ctx) => {
152
+ checkDisposed(disposalState, 'qdrant');
153
+ // Extract arguments
154
+ const vector = args[0];
155
+ const options = (args[1] ?? {});
156
+ // Extract options with defaults
157
+ const k = typeof options['k'] === 'number' ? options['k'] : 10;
158
+ const filter = (options['filter'] ?? {});
159
+ const scoreThreshold = typeof options['score_threshold'] === 'number'
160
+ ? options['score_threshold']
161
+ : undefined;
162
+ // Metadata object for event emission (will be updated with result_count)
163
+ const eventMetadata = { k, result_count: 0 };
164
+ return withEventEmission(ctx, 'qdrant', 'search', eventMetadata, async () => {
165
+ // Build search request
166
+ const searchRequest = {
167
+ vector: Array.from(vector.data),
168
+ limit: k,
169
+ with_payload: true,
170
+ };
171
+ if (Object.keys(filter).length > 0) {
172
+ searchRequest.filter = filter;
173
+ }
174
+ if (scoreThreshold !== undefined) {
175
+ searchRequest.score_threshold = scoreThreshold;
176
+ }
177
+ // Call Qdrant API
178
+ const response = await client.search(factoryCollection, searchRequest);
179
+ // Build result list
180
+ const results = response.map((hit) => ({
181
+ id: String(hit.id),
182
+ score: hit.score,
183
+ metadata: hit.payload ?? {},
184
+ }));
185
+ // Update metadata with actual result count before event emission
186
+ eventMetadata.result_count = results.length;
187
+ return results;
188
+ });
189
+ },
190
+ description: 'Search k nearest neighbors',
191
+ returnType: 'list',
192
+ },
193
+ // IR-4: qdrant::get
194
+ get: {
195
+ params: [{ name: 'id', type: 'string' }],
196
+ fn: async (args, ctx) => {
197
+ checkDisposed(disposalState, 'qdrant');
198
+ // Extract arguments
199
+ const id = args[0];
200
+ return withEventEmission(ctx, 'qdrant', 'get', { id }, async () => {
201
+ // Call Qdrant API
202
+ const response = await client.retrieve(factoryCollection, {
203
+ ids: [id],
204
+ with_payload: true,
205
+ with_vector: true,
206
+ });
207
+ // EC-7: ID not found
208
+ if (response.length === 0) {
209
+ throw new RuntimeError('RILL-R004', 'qdrant: id not found');
210
+ }
211
+ const point = response[0];
212
+ const vectorData = point.vector;
213
+ // Convert vector to Float32Array
214
+ // vectorData can be number[] or number[][] (for named vectors) or Record (named vectors)
215
+ let vectorArray;
216
+ if (Array.isArray(vectorData) &&
217
+ vectorData.length > 0 &&
218
+ typeof vectorData[0] === 'number') {
219
+ // Simple vector case: number[]
220
+ vectorArray = vectorData;
221
+ }
222
+ else {
223
+ throw new RuntimeError('RILL-R004', 'qdrant: invalid vector format');
224
+ }
225
+ const float32Data = new Float32Array(vectorArray);
226
+ const vector = createVector(float32Data, factoryCollection);
227
+ // Build result
228
+ return {
229
+ id: String(point.id),
230
+ vector,
231
+ metadata: point.payload ?? {},
232
+ };
233
+ });
234
+ },
235
+ description: 'Fetch vector by ID',
236
+ returnType: 'dict',
237
+ },
238
+ // IR-5: qdrant::delete
239
+ delete: {
240
+ params: [{ name: 'id', type: 'string' }],
241
+ fn: async (args, ctx) => {
242
+ checkDisposed(disposalState, 'qdrant');
243
+ // Extract arguments
244
+ const id = args[0];
245
+ return withEventEmission(ctx, 'qdrant', 'delete', { id }, async () => {
246
+ // Call Qdrant API (Qdrant accepts string or number IDs)
247
+ await client.delete(factoryCollection, {
248
+ wait: true,
249
+ points: [id],
250
+ });
251
+ // Build result
252
+ return {
253
+ id,
254
+ deleted: true,
255
+ };
256
+ });
257
+ },
258
+ description: 'Delete vector by ID',
259
+ returnType: 'dict',
260
+ },
261
+ // IR-6: qdrant::delete_batch
262
+ delete_batch: {
263
+ params: [{ name: 'ids', type: 'list' }],
264
+ fn: async (args, ctx) => {
265
+ checkDisposed(disposalState, 'qdrant');
266
+ // Extract arguments
267
+ const ids = args[0];
268
+ return withEventEmission(ctx, 'qdrant', 'delete_batch', { count: ids.length, succeeded: 0 }, async () => {
269
+ let succeeded = 0;
270
+ // Process sequentially; halt on first failure
271
+ for (let i = 0; i < ids.length; i++) {
272
+ const id = ids[i];
273
+ try {
274
+ // Call Qdrant API (Qdrant accepts string or number IDs)
275
+ await client.delete(factoryCollection, {
276
+ wait: true,
277
+ points: [id],
278
+ });
279
+ succeeded++;
280
+ }
281
+ catch (error) {
282
+ // Halt on first failure
283
+ const rillError = mapVectorError('qdrant', error);
284
+ return {
285
+ succeeded,
286
+ failed: id,
287
+ error: rillError.message,
288
+ };
289
+ }
290
+ }
291
+ // All succeeded
292
+ return { succeeded };
293
+ });
294
+ },
295
+ description: 'Batch delete vectors',
296
+ returnType: 'dict',
297
+ },
298
+ // IR-7: qdrant::count
299
+ count: {
300
+ params: [],
301
+ fn: async (_args, ctx) => {
302
+ checkDisposed(disposalState, 'qdrant');
303
+ return withEventEmission(ctx, 'qdrant', 'count', {}, async () => {
304
+ // Call Qdrant API
305
+ const response = await client.getCollection(factoryCollection);
306
+ // Extract count
307
+ const count = response.points_count ?? 0;
308
+ return count;
309
+ });
310
+ },
311
+ description: 'Return total vector count in collection',
312
+ returnType: 'number',
313
+ },
314
+ // IR-8: qdrant::create_collection
315
+ create_collection: {
316
+ params: [
317
+ { name: 'name', type: 'string' },
318
+ { name: 'options', type: 'dict', defaultValue: {} },
319
+ ],
320
+ fn: async (args, ctx) => {
321
+ checkDisposed(disposalState, 'qdrant');
322
+ // Extract arguments
323
+ const name = args[0];
324
+ const options = (args[1] ?? {});
325
+ // Extract options
326
+ const dimensions = options['dimensions'];
327
+ const distance = options['distance'] ?? 'cosine';
328
+ return withEventEmission(ctx, 'qdrant', 'create_collection', { name }, async () => {
329
+ // Map distance metric to Qdrant format
330
+ let qdrantDistance;
331
+ if (distance === 'cosine') {
332
+ qdrantDistance = 'Cosine';
333
+ }
334
+ else if (distance === 'euclidean') {
335
+ qdrantDistance = 'Euclid';
336
+ }
337
+ else {
338
+ qdrantDistance = 'Dot';
339
+ }
340
+ // Call Qdrant API
341
+ await client.createCollection(name, {
342
+ vectors: {
343
+ size: dimensions,
344
+ distance: qdrantDistance,
345
+ },
346
+ });
347
+ // Build result
348
+ return {
349
+ name,
350
+ created: true,
351
+ };
352
+ });
353
+ },
354
+ description: 'Create new vector collection',
355
+ returnType: 'dict',
356
+ },
357
+ // IR-9: qdrant::delete_collection
358
+ delete_collection: {
359
+ params: [{ name: 'name', type: 'string' }],
360
+ fn: async (args, ctx) => {
361
+ checkDisposed(disposalState, 'qdrant');
362
+ // Extract arguments
363
+ const name = args[0];
364
+ return withEventEmission(ctx, 'qdrant', 'delete_collection', { name }, async () => {
365
+ // Call Qdrant API
366
+ await client.deleteCollection(name);
367
+ // Build result
368
+ return {
369
+ name,
370
+ deleted: true,
371
+ };
372
+ });
373
+ },
374
+ description: 'Delete vector collection',
375
+ returnType: 'dict',
376
+ },
377
+ // IR-10: qdrant::list_collections
378
+ list_collections: {
379
+ params: [],
380
+ fn: async (_args, ctx) => {
381
+ checkDisposed(disposalState, 'qdrant');
382
+ return withEventEmission(ctx, 'qdrant', 'list_collections', {}, async () => {
383
+ // Call Qdrant API
384
+ const response = await client.getCollections();
385
+ // Extract collection names
386
+ const names = response.collections.map((col) => col.name);
387
+ return names;
388
+ });
389
+ },
390
+ description: 'List all collection names',
391
+ returnType: 'list',
392
+ },
393
+ // IR-11: qdrant::describe
394
+ describe: {
395
+ params: [],
396
+ fn: async (_args, ctx) => {
397
+ checkDisposed(disposalState, 'qdrant');
398
+ return withEventEmission(ctx, 'qdrant', 'describe', { name: factoryCollection }, async () => {
399
+ // Call Qdrant API
400
+ const response = await client.getCollection(factoryCollection);
401
+ // Extract collection info
402
+ const vectorConfig = response.config?.params?.vectors;
403
+ let dimensions = 0;
404
+ let distance = 'cosine';
405
+ if (vectorConfig &&
406
+ typeof vectorConfig === 'object' &&
407
+ 'size' in vectorConfig) {
408
+ dimensions = vectorConfig.size;
409
+ const dist = vectorConfig.distance;
410
+ if (dist === 'Cosine')
411
+ distance = 'cosine';
412
+ else if (dist === 'Euclid')
413
+ distance = 'euclidean';
414
+ else if (dist === 'Dot')
415
+ distance = 'dot';
416
+ }
417
+ // Build result
418
+ return {
419
+ name: factoryCollection,
420
+ count: response.points_count ?? 0,
421
+ dimensions,
422
+ distance,
423
+ };
424
+ });
425
+ },
426
+ description: 'Describe configured collection',
427
+ returnType: 'dict',
428
+ },
429
+ };
430
+ // Attach dispose lifecycle method
431
+ result.dispose = disposeExtension;
432
+ return result;
433
+ }
434
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,YAAY,GAKb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,cAAc,GACf,MAAM,+BAA+B,CAAC;AAGvC,+DAA+D;AAC/D,UAAU;AACV,+DAA+D;AAE/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,mCAAmC;IACnC,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAEhD,yCAAyC;IACzC,MAAM,YAAY,GAId,EAAE,GAAG,EAAE,MAAM,CAAC,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gB,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const VERSION = "0.0.1";
2
+ export type { QdrantConfig, QdrantExtensionConfig } from './types.js';
3
+ export { createQdrantExtension } from './factory.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,UAAU,CAAC;AAK/B,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAKtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ // ============================================================
2
+ // VERSION
3
+ // ============================================================
4
+ export const VERSION = '0.0.1';
5
+ // ============================================================
6
+ // FACTORY
7
+ // ============================================================
8
+ export { createQdrantExtension } from './factory.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,UAAU;AACV,+DAA+D;AAE/D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAO/B,+DAA+D;AAC/D,UAAU;AACV,+DAA+D;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Type definitions for Qdrant extension.
3
+ * Defines configuration for connecting to Qdrant vector database.
4
+ */
5
+ /**
6
+ * Configuration options for Qdrant extension.
7
+ *
8
+ * Defines connection parameters for Qdrant REST client including
9
+ * endpoint URL, authentication, collection name, and vector settings.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Local deployment
14
+ * const localConfig: QdrantConfig = {
15
+ * url: 'http://127.0.0.1:6333',
16
+ * collection: 'my_collection',
17
+ * };
18
+ *
19
+ * // Cloud deployment with API key
20
+ * const cloudConfig: QdrantConfig = {
21
+ * url: 'https://xxxxxxxx.aws.cloud.qdrant.io',
22
+ * apiKey: 'your-api-key',
23
+ * collection: 'my_collection',
24
+ * dimensions: 384,
25
+ * distance: 'cosine',
26
+ * timeout: 30000,
27
+ * };
28
+ * ```
29
+ */
30
+ export interface QdrantConfig {
31
+ /**
32
+ * API endpoint URL for Qdrant server.
33
+ *
34
+ * Local: 'http://127.0.0.1:6333'
35
+ * Cloud: 'https://xxx.cloud.qdrant.io'
36
+ */
37
+ readonly url: string;
38
+ /**
39
+ * API key for authentication.
40
+ *
41
+ * Optional for local deployments, required for Qdrant Cloud.
42
+ */
43
+ readonly apiKey?: string | undefined;
44
+ /**
45
+ * Collection name for vector operations.
46
+ *
47
+ * Must match an existing collection in the Qdrant instance.
48
+ */
49
+ readonly collection: string;
50
+ /**
51
+ * Vector dimensions (embedding size).
52
+ *
53
+ * Optional - database infers from first vector if not specified.
54
+ * Common values: 384 (small models), 768 (BERT), 1536 (OpenAI).
55
+ */
56
+ readonly dimensions?: number | undefined;
57
+ /**
58
+ * Distance metric for similarity calculations.
59
+ *
60
+ * - 'cosine': Normalized dot product (default, most common)
61
+ * - 'euclidean': L2 distance
62
+ * - 'dot': Dot product without normalization
63
+ *
64
+ * Default: 'cosine'
65
+ */
66
+ readonly distance?: 'cosine' | 'euclidean' | 'dot' | undefined;
67
+ /**
68
+ * Request timeout in milliseconds.
69
+ *
70
+ * Must be a positive integer.
71
+ * Default: SDK default (30000ms)
72
+ */
73
+ readonly timeout?: number | undefined;
74
+ }
75
+ /**
76
+ * Legacy type alias for QdrantConfig.
77
+ *
78
+ * @deprecated Use QdrantConfig instead.
79
+ */
80
+ export type QdrantExtensionConfig = QdrantConfig;
81
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAErC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzC;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,KAAK,GAAG,SAAS,CAAC;IAE/D;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAMD;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,YAAY,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Type definitions for Qdrant extension.
3
+ * Defines configuration for connecting to Qdrant vector database.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@rcrsr/rill-ext-qdrant",
3
+ "version": "0.0.1",
4
+ "description": "rill extension for Qdrant vector database integration",
5
+ "license": "MIT",
6
+ "author": "Andre Bremer",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "keywords": [
11
+ "rill",
12
+ "qdrant",
13
+ "vector-database",
14
+ "vector-search",
15
+ "extension",
16
+ "ai",
17
+ "scripting"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc --build",
21
+ "test": "vitest run",
22
+ "typecheck": "tsc --noEmit",
23
+ "lint": "eslint --config ../../../eslint.config.js src/",
24
+ "check": "pnpm run build && pnpm run test && pnpm run lint"
25
+ },
26
+ "peerDependencies": {
27
+ "@rcrsr/rill": "workspace:^"
28
+ },
29
+ "devDependencies": {
30
+ "@rcrsr/rill": "workspace:^"
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/rcrsr/rill.git",
38
+ "directory": "packages/ext/qdrant"
39
+ },
40
+ "homepage": "https://github.com/rcrsr/rill/tree/main/packages/ext/qdrant#readme",
41
+ "bugs": {
42
+ "url": "https://github.com/rcrsr/rill/issues"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "dependencies": {
48
+ "@rcrsr/rill-ext-vector-shared": "workspace:^",
49
+ "@qdrant/js-client-rest": "^1.12.1"
50
+ }
51
+ }