conare 0.10.0 → 0.12.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/README.md CHANGED
@@ -19,7 +19,7 @@ const docs = conare.namespace("docs");
19
19
  await docs.add({ id: "refunds", text: "Refunds are available for 30 days.", metadata: { team: "support" } });
20
20
 
21
21
  const results = await docs.query("how do refunds work?", { topK: 5 });
22
- // [{ id: "refunds", text: "Refunds are available for 30 days.", score: 0.91, metadata: { team: "support" } }]
22
+ // [{ id: "refunds", text: "Refunds are available for 30 days.", score: 0.91, reranked: true, metadata: { team: "support" } }]
23
23
  ```
24
24
 
25
25
  A namespace is created by its first write. Writing the same id again replaces the document.
@@ -45,6 +45,8 @@ await docs.add([...]); // or many; sent 100 at a time. R
45
45
  await docs.get("refunds"); // { id, text, metadata, updatedAt } or null
46
46
  for await (const doc of docs.list()) {} // every document, page by page ({ limit } per page: 1-100, default 50)
47
47
  await docs.delete("refunds"); // 404 document_not_found if it does not exist
48
+ await docs.deleteMany(["a", "b"]); // up to 1000 ids in one call; missing ids are skipped. Returns the count
49
+ await docs.deleteWhere({ team: "support" }); // every document matching the filter, whole documents. Returns the count
48
50
  await docs.drop(); // delete the namespace and its documents (also succeeds if it is empty)
49
51
 
50
52
  await conare.namespaces(); // [{ name, documents }]
@@ -64,23 +66,32 @@ await docs.query("how do refunds work?", {
64
66
  ```
65
67
 
66
68
  Hybrid search (vector and keyword), reranked. One result per document: its best passage.
69
+ `score` is the reranker's when `reranked` is true, else the fused rank score of a result past the
70
+ rerank window (or of a query not reranked); the two scales do not compare.
67
71
 
68
- Filters match metadata values exactly: `{ key: value }` means equals (or, for an array value,
69
- contains). Operators: `$eq` and `$in`. Combine with `$and` and `$or`:
72
+ Filters match metadata values: `{ key: value }` means equals (or, for an array value,
73
+ contains). Operators: `$eq`, `$in` and the ranges below. Combine with `$and` and `$or`:
70
74
 
71
75
  ```ts
72
76
  { $or: [{ team: "support" }, { year: { $in: [2024, 2025] } }] }
73
77
  { $and: [{ lang: { $in: ["en", "de"] } }, { draft: false }] }
74
78
  ```
75
79
 
76
- There is no `$ne`, `$nin` or range operator (`$gt $gte $lt $lte`): the API answers 400
77
- `invalid_filter`. Store a value you want to filter on as its own metadata key instead.
80
+ Ranges `$gt $gte $lt $lte` compare a number or string value (not an array item): number bounds
81
+ compare numbers, string bounds compare strings by their UTF-8 bytes, so ISO dates sort as dates.
82
+
83
+ ```ts
84
+ { year: { $gte: 2020, $lt: 2025 } }
85
+ { published_at: { $gte: "2025-06-01" } }
86
+ ```
87
+
88
+ There is no `$ne` or `$nin`: the API answers 400 `invalid_filter`.
78
89
 
79
90
  ### Embed and rerank
80
91
 
81
92
  ```ts
82
93
  await conare.embed(["some text"], { type: "query" }); // number[][]; type defaults to "document"
83
- await conare.rerank("refund window", ["a", "b"], { topK: 1 }); // [{ index, score, document }]
94
+ await conare.rerank("refund window", ["a", "b"], { topK: 1 }); // [{ index, score, document }], plus .unscored
84
95
  ```
85
96
 
86
97
  ### Sources
@@ -147,7 +158,8 @@ Keep the API key on your server. It can read and write every namespace in your o
147
158
  ## MCP
148
159
 
149
160
  Conare is also an MCP server at `https://api.conare.ai/mcp`, with tools to search, fetch, save
150
- and delete documents and list namespaces.
161
+ and delete documents and list namespaces. Clients that sign in over OAuth (claude.ai connectors,
162
+ ChatGPT) need only the URL; the rest take a key:
151
163
 
152
164
  Claude Code:
153
165
 
@@ -179,7 +191,3 @@ CONARE_API_KEY=sk-conare-... bun test # also runs test/live.test.ts ag
179
191
  ```
180
192
 
181
193
  Releases: push a tag `sdk-v<version>` matching `package.json`; CI tests and publishes to npm.
182
-
183
- ## Versions
184
-
185
- 0.8.0 is the first release of this client. Versions of `conare` before it (0.7.x and older) are the retired memory CLI.
package/dist/index.d.ts CHANGED
@@ -1,26 +1,28 @@
1
- export declare const VERSION = "0.10.0";
1
+ export declare const VERSION = "0.12.0";
2
2
  /** A metadata value: string, number, boolean or an array of strings. */
3
3
  export type MetadataValue = string | number | boolean | string[];
4
4
  export type Metadata = Record<string, MetadataValue>;
5
5
  type Scalar = string | number | boolean;
6
6
  /**
7
- * Operators for one metadata key: `$eq` and `$in`. Filters match values exactly; the API
8
- * answers 400 invalid_filter for the operators typed `never` here, so they do not compile.
7
+ * Operators for one metadata key: `$eq`, `$in` and the ranges `$gt` `$gte` `$lt` `$lte`. A range
8
+ * compares a number or string value (not an array item): number bounds compare numbers, string
9
+ * bounds compare strings by their UTF-8 bytes (ISO dates sort as dates). The API answers 400
10
+ * invalid_filter for the operators typed `never` here, so they do not compile.
9
11
  */
10
12
  export interface FilterOperators {
11
13
  $eq?: Scalar;
12
14
  $in?: Scalar[];
15
+ $gt?: number | string;
16
+ $gte?: number | string;
17
+ $lt?: number | string;
18
+ $lte?: number | string;
13
19
  $ne?: never;
14
20
  $nin?: never;
15
- $gt?: never;
16
- $gte?: never;
17
- $lt?: never;
18
- $lte?: never;
19
21
  }
20
22
  /**
21
23
  * A metadata filter. `{ team: "support" }` means equals (or, for an array value, contains);
22
- * use `$eq` / `$in` per key and `$and` / `$or` to combine:
23
- * `{ $or: [{ team: "support" }, { year: { $in: [2024, 2025] } }] }`.
24
+ * use `$eq` / `$in` / ranges per key and `$and` / `$or` to combine:
25
+ * `{ $or: [{ team: "support" }, { year: { $gte: 2024 } }] }`.
24
26
  */
25
27
  export interface Filter {
26
28
  $and?: Filter[];
@@ -48,7 +50,10 @@ export interface QueryResult {
48
50
  id: string;
49
51
  /** The best matching passage of the document. */
50
52
  text: string;
53
+ /** Higher is better: the reranker's score when `reranked`, else the fused rank score. The two do not compare. */
51
54
  score: number;
55
+ /** The reranking model scored this result (false past its window, with `rerank: false`, or when it failed). */
56
+ reranked: boolean;
52
57
  metadata: Metadata;
53
58
  }
54
59
  export interface NamespaceInfo {
@@ -60,6 +65,10 @@ export interface RerankResult {
60
65
  score: number;
61
66
  document: string;
62
67
  }
68
+ /** Rerank results, best first, and the indexes of the documents no window read before the budget ended. */
69
+ export type RerankResults = RerankResult[] & {
70
+ unscored: number[];
71
+ };
63
72
  export type SourceStatus = "connecting" | "syncing" | "ready" | "error";
64
73
  export interface Source {
65
74
  id: string;
@@ -126,7 +135,7 @@ export declare class Conare {
126
135
  /** Rerank documents against a query, best first. */
127
136
  rerank(query: string, documents: string[], options?: RequestOptions & {
128
137
  topK?: number;
129
- }): Promise<RerankResult[]>;
138
+ }): Promise<RerankResults>;
130
139
  private send;
131
140
  }
132
141
  /** One namespace: a named set of documents, e.g. "docs" or "user-42". */
@@ -154,6 +163,10 @@ export declare class Namespace {
154
163
  }): AsyncGenerator<DocumentSummary>;
155
164
  /** Delete one document. Throws a ConareError with status 404 (`document_not_found`) if it does not exist. */
156
165
  delete(id: string, options?: RequestOptions): Promise<void>;
166
+ /** Delete up to 1000 documents by id in one call. Ids that do not exist are skipped. Returns how many were deleted. */
167
+ deleteMany(ids: string[], options?: RequestOptions): Promise<number>;
168
+ /** Delete every document matching filter (at least one condition), calling until none match. Returns how many were deleted. */
169
+ deleteWhere(filter: Filter, options?: RequestOptions): Promise<number>;
157
170
  /** Delete the namespace and every document in it. Succeeds as well when it holds no documents (already deleted or never written). */
158
171
  drop(options?: RequestOptions): Promise<void>;
159
172
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // conare: TypeScript client for the Conare API. Zero dependencies; uses global fetch.
2
- export const VERSION = "0.10.0";
2
+ export const VERSION = "0.12.0";
3
3
  const DEFAULT_BASE_URL = "https://api.conare.ai";
4
4
  const BATCH_SIZE = 100;
5
5
  // ---- Errors ----------------------------------------------------------------
@@ -64,7 +64,8 @@ export class Conare {
64
64
  /** Rerank documents against a query, best first. */
65
65
  async rerank(query, documents, options = {}) {
66
66
  const body = await this.request("POST", "/rerank", { query, documents, top_k: options.topK }, options, true);
67
- return body.results.map((r) => ({ index: r.index, score: r.score, document: documents[r.index] ?? "" }));
67
+ const results = body.results.map((r) => ({ index: r.index, score: r.score, document: documents[r.index] ?? "" }));
68
+ return Object.assign(results, { unscored: body.unscored ?? [] });
68
69
  }
69
70
  /**
70
71
  * @internal Sends one API request. An idempotent request (every GET and DELETE, and the POSTs
@@ -201,6 +202,21 @@ export class Namespace {
201
202
  async delete(id, options) {
202
203
  await this.client.request("DELETE", this.path(`/documents/${encodeURIComponent(id)}`), undefined, options);
203
204
  }
205
+ /** Delete up to 1000 documents by id in one call. Ids that do not exist are skipped. Returns how many were deleted. */
206
+ async deleteMany(ids, options) {
207
+ const out = await this.client.request("POST", this.path("/documents/delete"), { ids }, options);
208
+ return out.deleted;
209
+ }
210
+ /** Delete every document matching filter (at least one condition), calling until none match. Returns how many were deleted. */
211
+ async deleteWhere(filter, options) {
212
+ let deleted = 0;
213
+ for (;;) {
214
+ const out = await this.client.request("POST", this.path("/documents/delete"), { filter }, options);
215
+ deleted += out.deleted;
216
+ if (!out.more)
217
+ return deleted;
218
+ }
219
+ }
204
220
  /** Delete the namespace and every document in it. Succeeds as well when it holds no documents (already deleted or never written). */
205
221
  async drop(options) {
206
222
  await this.client.request("DELETE", this.path(), undefined, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conare",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "TypeScript client for Conare: add documents, query them, connect apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",