@rcrsr/rill-ext-chroma 0.9.0 → 0.16.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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
- import { ExtensionConfigSchema, ExtensionResult } from '@rcrsr/rill';
3
+ import { ExtensionConfigSchema, ExtensionManifest, ExtensionResult } from '@rcrsr/rill';
4
4
 
5
5
  /**
6
6
  * Type definitions for ChromaDB extension.
@@ -88,7 +88,8 @@ export type ChromaExtensionConfig = ChromaConfig;
88
88
  * ```
89
89
  */
90
90
  export declare function createChromaExtension(config: ChromaConfig): ExtensionResult;
91
+ export declare const VERSION: string;
91
92
  export declare const configSchema: ExtensionConfigSchema;
92
- export declare const CHROMA_EXTENSION_VERSION = "0.0.1";
93
+ export declare const extensionManifest: ExtensionManifest;
93
94
 
94
95
  export {};
package/dist/index.js CHANGED
@@ -1,9 +1,13 @@
1
+ // src/index.ts
2
+ import { createRequire } from "module";
3
+
1
4
  // src/factory.ts
2
5
  import { ChromaClient } from "chromadb";
3
6
  import {
4
- RuntimeError as RuntimeError4,
7
+ RuntimeError as RuntimeError6,
5
8
  emitExtensionEvent as emitExtensionEvent3,
6
- createVector
9
+ createVector,
10
+ rillTypeToTypeValue
7
11
  } from "@rcrsr/rill";
8
12
 
9
13
  // ../../shared/ext-vector/dist/errors.js
@@ -87,6 +91,146 @@ function assertRequired(value, fieldName) {
87
91
  // ../../shared/ext-vector/dist/wrapper.js
88
92
  import { emitExtensionEvent as emitExtensionEvent2 } from "@rcrsr/rill";
89
93
 
94
+ // ../../shared/ext-vector/dist/param.js
95
+ import { RuntimeError as RuntimeError4 } from "@rcrsr/rill";
96
+ function validateParamName(name) {
97
+ if (name === "")
98
+ throw new RuntimeError4("RILL-R001", "param name must not be empty");
99
+ if (/\s/.test(name))
100
+ throw new RuntimeError4("RILL-R001", "param name must be a valid identifier");
101
+ }
102
+ function vectorParam(name) {
103
+ validateParamName(name);
104
+ return {
105
+ name,
106
+ type: { type: "vector" },
107
+ defaultValue: void 0,
108
+ annotations: {}
109
+ };
110
+ }
111
+
112
+ // ../../shared/ext-param/dist/param.js
113
+ import { RuntimeError as RuntimeError5 } from "@rcrsr/rill";
114
+ function validateParamName2(name) {
115
+ if (name === "") {
116
+ throw new RuntimeError5("RILL-R001", "param name must not be empty");
117
+ }
118
+ if (/\s/.test(name)) {
119
+ throw new RuntimeError5("RILL-R001", "param name must be a valid identifier");
120
+ }
121
+ }
122
+ function buildAnnotations(desc) {
123
+ if (desc !== void 0) {
124
+ return { description: desc };
125
+ }
126
+ return {};
127
+ }
128
+ var p = {
129
+ /**
130
+ * IR-1: Creates a string parameter descriptor.
131
+ *
132
+ * @param name - Parameter name (must be a valid identifier)
133
+ * @param desc - Optional description
134
+ * @returns RillParam with type 'string'
135
+ */
136
+ str(name, desc) {
137
+ validateParamName2(name);
138
+ return {
139
+ name,
140
+ type: { type: "string" },
141
+ defaultValue: void 0,
142
+ annotations: buildAnnotations(desc)
143
+ };
144
+ },
145
+ /**
146
+ * IR-2: Creates a number parameter descriptor.
147
+ *
148
+ * @param name - Parameter name (must be a valid identifier)
149
+ * @param desc - Optional description
150
+ * @param def - Optional default value
151
+ * @returns RillParam with type 'number'
152
+ */
153
+ num(name, desc, def) {
154
+ validateParamName2(name);
155
+ return {
156
+ name,
157
+ type: { type: "number" },
158
+ defaultValue: def,
159
+ annotations: buildAnnotations(desc)
160
+ };
161
+ },
162
+ /**
163
+ * IR-3: Creates a boolean parameter descriptor.
164
+ *
165
+ * @param name - Parameter name (must be a valid identifier)
166
+ * @param desc - Optional description
167
+ * @param def - Optional default value
168
+ * @returns RillParam with type 'bool'
169
+ */
170
+ bool(name, desc, def) {
171
+ validateParamName2(name);
172
+ return {
173
+ name,
174
+ type: { type: "bool" },
175
+ defaultValue: def,
176
+ annotations: buildAnnotations(desc)
177
+ };
178
+ },
179
+ /**
180
+ * IR-4: Creates a dict parameter descriptor.
181
+ *
182
+ * @param name - Parameter name (must be a valid identifier)
183
+ * @param desc - Optional description
184
+ * @param def - Optional default value
185
+ * @param fields - Optional structural field definitions (RillFieldDef with type and optional defaultValue)
186
+ * @returns RillParam with type 'dict' (with fields if provided)
187
+ */
188
+ dict(name, desc, def, fields) {
189
+ validateParamName2(name);
190
+ const type = fields !== void 0 ? { type: "dict", fields } : { type: "dict" };
191
+ return {
192
+ name,
193
+ type,
194
+ defaultValue: def,
195
+ annotations: buildAnnotations(desc)
196
+ };
197
+ },
198
+ /**
199
+ * IR-5: Creates a list parameter descriptor.
200
+ *
201
+ * @param name - Parameter name (must be a valid identifier)
202
+ * @param itemType - Optional element type; omitted when not provided
203
+ * @param desc - Optional description
204
+ * @returns RillParam with type 'list' (with element if itemType provided)
205
+ */
206
+ list(name, itemType, desc) {
207
+ validateParamName2(name);
208
+ const type = itemType !== void 0 ? { type: "list", element: itemType } : { type: "list" };
209
+ return {
210
+ name,
211
+ type,
212
+ defaultValue: void 0,
213
+ annotations: buildAnnotations(desc)
214
+ };
215
+ },
216
+ /**
217
+ * IR-6: Creates a callable parameter descriptor.
218
+ *
219
+ * @param name - Parameter name (must be a valid identifier)
220
+ * @param desc - Optional description
221
+ * @returns RillParam with type 'closure'
222
+ */
223
+ callable(name, desc) {
224
+ validateParamName2(name);
225
+ return {
226
+ name,
227
+ type: { type: "closure" },
228
+ defaultValue: void 0,
229
+ annotations: buildAnnotations(desc)
230
+ };
231
+ }
232
+ };
233
+
90
234
  // src/factory.ts
91
235
  function createChromaExtension(config) {
92
236
  assertRequired(config.collection, "collection");
@@ -101,17 +245,17 @@ function createChromaExtension(config) {
101
245
  // IR-1: chroma::upsert
102
246
  upsert: {
103
247
  params: [
104
- { name: "id", type: "string" },
105
- { name: "vector", type: "vector" },
106
- { name: "metadata", type: "dict", defaultValue: {} }
248
+ p.str("id"),
249
+ vectorParam("vector"),
250
+ p.dict("metadata", void 0, {})
107
251
  ],
108
252
  fn: async (args, ctx) => {
109
253
  const startTime = Date.now();
110
254
  try {
111
255
  checkDisposed(disposalState, "chroma");
112
- const id = args[0];
113
- const vector = args[1];
114
- const metadata = args[2] ?? {};
256
+ const id = args["id"];
257
+ const vector = args["vector"];
258
+ const metadata = args["metadata"] ?? {};
115
259
  const collection = await client.getOrCreateCollection({
116
260
  name: factoryCollection
117
261
  });
@@ -144,17 +288,17 @@ function createChromaExtension(config) {
144
288
  throw rillError;
145
289
  }
146
290
  },
147
- description: "Insert or update single vector with metadata",
148
- returnType: "dict"
291
+ annotations: { description: "Insert or update single vector with metadata" },
292
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { id: { type: { type: "string" } }, success: { type: { type: "bool" } } } })
149
293
  },
150
294
  // IR-2: chroma::upsert_batch
151
295
  upsert_batch: {
152
- params: [{ name: "items", type: "list" }],
296
+ params: [p.list("items")],
153
297
  fn: async (args, ctx) => {
154
298
  const startTime = Date.now();
155
299
  try {
156
300
  checkDisposed(disposalState, "chroma");
157
- const items = args[0];
301
+ const items = args["items"];
158
302
  let succeeded = 0;
159
303
  const collection = await client.getOrCreateCollection({
160
304
  name: factoryCollection
@@ -229,21 +373,24 @@ function createChromaExtension(config) {
229
373
  throw rillError;
230
374
  }
231
375
  },
232
- description: "Batch insert/update vectors",
233
- returnType: "dict"
376
+ annotations: { description: "Batch insert/update vectors" },
377
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { succeeded: { type: { type: "number" } }, failed: { type: { type: "string" } }, error: { type: { type: "string" } } } })
234
378
  },
235
379
  // IR-3: chroma::search
236
380
  search: {
237
381
  params: [
238
- { name: "vector", type: "vector" },
239
- { name: "options", type: "dict", defaultValue: {} }
382
+ vectorParam("vector"),
383
+ p.dict("options", void 0, {}, {
384
+ k: { type: { type: "number" }, defaultValue: 10 },
385
+ filter: { type: { type: "dict" }, defaultValue: {} }
386
+ })
240
387
  ],
241
388
  fn: async (args, ctx) => {
242
389
  const startTime = Date.now();
243
390
  try {
244
391
  checkDisposed(disposalState, "chroma");
245
- const vector = args[0];
246
- const options = args[1] ?? {};
392
+ const vector = args["vector"];
393
+ const options = args["options"] ?? {};
247
394
  const k = typeof options["k"] === "number" ? options["k"] : 10;
248
395
  const filter = options["filter"] ?? {};
249
396
  const collection = await client.getOrCreateCollection({
@@ -283,17 +430,17 @@ function createChromaExtension(config) {
283
430
  throw rillError;
284
431
  }
285
432
  },
286
- description: "Search k nearest neighbors",
287
- returnType: "list"
433
+ annotations: { description: "Search k nearest neighbors" },
434
+ returnType: rillTypeToTypeValue({ type: "list", element: { type: "dict", fields: { id: { type: { type: "string" } }, score: { type: { type: "number" } }, metadata: { type: { type: "dict" } } } } })
288
435
  },
289
436
  // IR-4: chroma::get
290
437
  get: {
291
- params: [{ name: "id", type: "string" }],
438
+ params: [p.str("id")],
292
439
  fn: async (args, ctx) => {
293
440
  const startTime = Date.now();
294
441
  try {
295
442
  checkDisposed(disposalState, "chroma");
296
- const id = args[0];
443
+ const id = args["id"];
297
444
  const collection = await client.getOrCreateCollection({
298
445
  name: factoryCollection
299
446
  });
@@ -301,12 +448,12 @@ function createChromaExtension(config) {
301
448
  ids: [id]
302
449
  });
303
450
  if (response.ids.length === 0) {
304
- throw new RuntimeError4("RILL-R004", "chroma: id not found");
451
+ throw new RuntimeError6("RILL-R004", "chroma: id not found");
305
452
  }
306
453
  const embedding = response.embeddings?.[0];
307
454
  const metadata = response.metadatas?.[0];
308
455
  if (!embedding || !Array.isArray(embedding)) {
309
- throw new RuntimeError4(
456
+ throw new RuntimeError6(
310
457
  "RILL-R004",
311
458
  "chroma: invalid vector format"
312
459
  );
@@ -338,17 +485,17 @@ function createChromaExtension(config) {
338
485
  throw rillError;
339
486
  }
340
487
  },
341
- description: "Fetch vector by ID",
342
- returnType: "dict"
488
+ annotations: { description: "Fetch vector by ID" },
489
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { id: { type: { type: "string" } }, vector: { type: { type: "vector" } }, metadata: { type: { type: "dict" } } } })
343
490
  },
344
491
  // IR-5: chroma::delete
345
492
  delete: {
346
- params: [{ name: "id", type: "string" }],
493
+ params: [p.str("id")],
347
494
  fn: async (args, ctx) => {
348
495
  const startTime = Date.now();
349
496
  try {
350
497
  checkDisposed(disposalState, "chroma");
351
- const id = args[0];
498
+ const id = args["id"];
352
499
  const collection = await client.getOrCreateCollection({
353
500
  name: factoryCollection
354
501
  });
@@ -379,17 +526,17 @@ function createChromaExtension(config) {
379
526
  throw rillError;
380
527
  }
381
528
  },
382
- description: "Delete vector by ID",
383
- returnType: "dict"
529
+ annotations: { description: "Delete vector by ID" },
530
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { id: { type: { type: "string" } }, deleted: { type: { type: "bool" } } } })
384
531
  },
385
532
  // IR-6: chroma::delete_batch
386
533
  delete_batch: {
387
- params: [{ name: "ids", type: "list" }],
534
+ params: [p.list("ids")],
388
535
  fn: async (args, ctx) => {
389
536
  const startTime = Date.now();
390
537
  try {
391
538
  checkDisposed(disposalState, "chroma");
392
- const ids = args[0];
539
+ const ids = args["ids"];
393
540
  let succeeded = 0;
394
541
  const collection = await client.getOrCreateCollection({
395
542
  name: factoryCollection
@@ -441,8 +588,8 @@ function createChromaExtension(config) {
441
588
  throw rillError;
442
589
  }
443
590
  },
444
- description: "Batch delete vectors",
445
- returnType: "dict"
591
+ annotations: { description: "Batch delete vectors" },
592
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { succeeded: { type: { type: "number" } }, failed: { type: { type: "string" } }, error: { type: { type: "string" } } } })
446
593
  },
447
594
  // IR-7: chroma::count
448
595
  count: {
@@ -475,21 +622,23 @@ function createChromaExtension(config) {
475
622
  throw rillError;
476
623
  }
477
624
  },
478
- description: "Return total vector count in collection",
479
- returnType: "number"
625
+ annotations: { description: "Return total vector count in collection" },
626
+ returnType: rillTypeToTypeValue({ type: "number" })
480
627
  },
481
628
  // IR-8: chroma::create_collection
482
629
  create_collection: {
483
630
  params: [
484
- { name: "name", type: "string" },
485
- { name: "options", type: "dict", defaultValue: {} }
631
+ p.str("name"),
632
+ p.dict("options", void 0, {}, {
633
+ metadata: { type: { type: "dict" }, defaultValue: {} }
634
+ })
486
635
  ],
487
636
  fn: async (args, ctx) => {
488
637
  const startTime = Date.now();
489
638
  try {
490
639
  checkDisposed(disposalState, "chroma");
491
- const name = args[0];
492
- const options = args[1] ?? {};
640
+ const name = args["name"];
641
+ const options = args["options"] ?? {};
493
642
  const metadata = options["metadata"] ?? {};
494
643
  await client.createCollection({
495
644
  name,
@@ -519,17 +668,17 @@ function createChromaExtension(config) {
519
668
  throw rillError;
520
669
  }
521
670
  },
522
- description: "Create new vector collection",
523
- returnType: "dict"
671
+ annotations: { description: "Create new vector collection" },
672
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { name: { type: { type: "string" } }, created: { type: { type: "bool" } } } })
524
673
  },
525
674
  // IR-9: chroma::delete_collection
526
675
  delete_collection: {
527
- params: [{ name: "name", type: "string" }],
676
+ params: [p.str("name")],
528
677
  fn: async (args, ctx) => {
529
678
  const startTime = Date.now();
530
679
  try {
531
680
  checkDisposed(disposalState, "chroma");
532
- const name = args[0];
681
+ const name = args["name"];
533
682
  await client.deleteCollection({ name });
534
683
  const result2 = {
535
684
  name,
@@ -555,8 +704,8 @@ function createChromaExtension(config) {
555
704
  throw rillError;
556
705
  }
557
706
  },
558
- description: "Delete vector collection",
559
- returnType: "dict"
707
+ annotations: { description: "Delete vector collection" },
708
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { name: { type: { type: "string" } }, deleted: { type: { type: "bool" } } } })
560
709
  },
561
710
  // IR-10: chroma::list_collections
562
711
  list_collections: {
@@ -586,8 +735,8 @@ function createChromaExtension(config) {
586
735
  throw rillError;
587
736
  }
588
737
  },
589
- description: "List all collection names",
590
- returnType: "list"
738
+ annotations: { description: "List all collection names" },
739
+ returnType: rillTypeToTypeValue({ type: "list", element: { type: "string" } })
591
740
  },
592
741
  // IR-11: chroma::describe
593
742
  describe: {
@@ -624,8 +773,8 @@ function createChromaExtension(config) {
624
773
  throw rillError;
625
774
  }
626
775
  },
627
- description: "Describe configured collection",
628
- returnType: "dict"
776
+ annotations: { description: "Describe configured collection" },
777
+ returnType: rillTypeToTypeValue({ type: "dict", fields: { name: { type: { type: "string" } }, count: { type: { type: "number" } } } })
629
778
  }
630
779
  };
631
780
  result.dispose = async () => {
@@ -636,15 +785,23 @@ function createChromaExtension(config) {
636
785
  }
637
786
 
638
787
  // src/index.ts
788
+ var _require = createRequire(import.meta.url);
789
+ var _pkg = _require("../package.json");
790
+ var VERSION = _pkg.version;
639
791
  var configSchema = {
640
792
  url: { type: "string" },
641
793
  collection: { type: "string", required: true },
642
794
  embeddingFunction: { type: "string" },
643
795
  timeout: { type: "number" }
644
796
  };
645
- var CHROMA_EXTENSION_VERSION = "0.0.1";
797
+ var extensionManifest = {
798
+ factory: createChromaExtension,
799
+ configSchema,
800
+ version: VERSION
801
+ };
646
802
  export {
647
- CHROMA_EXTENSION_VERSION,
803
+ VERSION,
648
804
  configSchema,
649
- createChromaExtension
805
+ createChromaExtension,
806
+ extensionManifest
650
807
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcrsr/rill-ext-chroma",
3
- "version": "0.9.0",
3
+ "version": "0.16.0",
4
4
  "description": "rill extension for ChromaDB vector database integration",
5
5
  "license": "MIT",
6
6
  "author": "Andre Bremer",
@@ -18,10 +18,10 @@
18
18
  "scripting"
19
19
  ],
20
20
  "peerDependencies": {
21
- "@rcrsr/rill": "^0.9.0"
21
+ "@rcrsr/rill": "~0.16.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@rcrsr/rill": "^0.9.0",
24
+ "@rcrsr/rill": "~0.16.0",
25
25
  "@types/node": "^25.3.0",
26
26
  "dts-bundle-generator": "^9.5.1",
27
27
  "tsup": "^8.5.1",
@@ -44,7 +44,8 @@
44
44
  "access": "public"
45
45
  },
46
46
  "dependencies": {
47
- "chromadb": "^3.3.1"
47
+ "chromadb": "^3.3.1",
48
+ "@rcrsr/rill-ext-param-shared": "^0.0.1"
48
49
  },
49
50
  "scripts": {
50
51
  "build": "tsup && dts-bundle-generator --config dts-bundle-generator.config.cjs",