@babav/knowledge-core-client 0.27.0 → 0.29.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
@@ -181,6 +181,7 @@ export interface Corpus {
181
181
  id: UUID;
182
182
  name: string;
183
183
  description: string | null;
184
+ custom_metadata: Record<string, unknown>;
184
185
  }
185
186
  export interface Folder {
186
187
  id: UUID;
@@ -468,8 +469,12 @@ declare class HttpBase {
468
469
  protected pageAll<T>(path: string, query?: RequestOpts["query"]): Promise<T[]>;
469
470
  }
470
471
  export interface StreamHandlers {
472
+ /** Retrieval milestone. `retrieval_contents` is the reranked top_k (unchanged).
473
+ * `retrieved_count` is the total distinct candidate chunks fetched across ALL corpora
474
+ * (and sub-queries) BEFORE reranking/truncation — i.e. the recall-net size. */
471
475
  onSources?: (d: {
472
476
  retrieval_contents: RetrievalContent[];
477
+ retrieved_count: number;
473
478
  }) => void;
474
479
  onToken?: (text: string) => void;
475
480
  /** A citation, emitted inline as the answer streams (Claude/native path). Also
@@ -545,16 +550,25 @@ export declare class KnowledgeCoreClient extends HttpBase {
545
550
  create: (b: {
546
551
  name: string;
547
552
  description?: string;
553
+ custom_metadata?: Record<string, unknown>;
548
554
  }) => Promise<Corpus>;
549
555
  list: (q?: {
550
556
  limit?: number;
551
557
  cursor?: string;
552
558
  }) => Promise<Page<Corpus>>;
553
559
  listAll: () => Promise<Corpus[]>;
560
+ /** Filter corpora by custom_metadata using the same metadata filter as documents. */
561
+ search: (b: {
562
+ filter?: MetadataFilter;
563
+ limit?: number;
564
+ cursor?: string;
565
+ }) => Promise<Page<Corpus>>;
554
566
  get: (id: UUID) => Promise<Corpus>;
567
+ /** `custom_metadata` merges (provided keys upsert, a null value deletes a key). */
555
568
  update: (id: UUID, b: {
556
569
  name?: string;
557
570
  description?: string;
571
+ custom_metadata?: Record<string, unknown>;
558
572
  }) => Promise<Corpus>;
559
573
  delete: (id: UUID, confirmName: string) => Promise<void>;
560
574
  listFolders: (id: UUID) => Promise<Folder[]>;
package/dist/index.js CHANGED
@@ -219,7 +219,10 @@ export class KnowledgeCoreClient extends HttpBase {
219
219
  create: (b) => this.request("POST", "/v1/corpora", { json: b }),
220
220
  list: (q) => this.request("GET", "/v1/corpora", { query: q }),
221
221
  listAll: () => this.pageAll("/v1/corpora"),
222
+ /** Filter corpora by custom_metadata using the same metadata filter as documents. */
223
+ search: (b) => this.request("POST", "/v1/corpora/search", { json: b }),
222
224
  get: (id) => this.request("GET", `/v1/corpora/${id}`),
225
+ /** `custom_metadata` merges (provided keys upsert, a null value deletes a key). */
223
226
  update: (id, b) => this.request("PATCH", `/v1/corpora/${id}`, { json: b }),
224
227
  delete: (id, confirmName) => this.request("DELETE", `/v1/corpora/${id}`, { query: { confirm: confirmName } }),
225
228
  listFolders: (id) => this.pageAll(`/v1/corpora/${id}/folders`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babav/knowledge-core-client",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "TypeScript client for the Babav Knowledge Core API (Deno + Node 18+, zero deps). Includes the babav.visual grammar TYPES at the ./visual subpath (types only; all visual rendering is server-side).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -211,6 +211,7 @@ export interface Corpus {
211
211
  id: UUID;
212
212
  name: string;
213
213
  description: string | null;
214
+ custom_metadata: Record<string, unknown>;
214
215
  }
215
216
  export interface Folder {
216
217
  id: UUID;
@@ -551,7 +552,10 @@ const MULTIPART_MAX_BYTES = 30 * 1024 * 1024;
551
552
  // SSE handlers
552
553
  // ---------------------------------------------------------------------------
553
554
  export interface StreamHandlers {
554
- onSources?: (d: { retrieval_contents: RetrievalContent[] }) => void;
555
+ /** Retrieval milestone. `retrieval_contents` is the reranked top_k (unchanged).
556
+ * `retrieved_count` is the total distinct candidate chunks fetched across ALL corpora
557
+ * (and sub-queries) BEFORE reranking/truncation — i.e. the recall-net size. */
558
+ onSources?: (d: { retrieval_contents: RetrievalContent[]; retrieved_count: number }) => void;
555
559
  onToken?: (text: string) => void;
556
560
  /** A citation, emitted inline as the answer streams (Claude/native path). Also
557
561
  * present aggregated in the `final` event. */
@@ -676,12 +680,16 @@ export class KnowledgeCoreClient extends HttpBase {
676
680
 
677
681
  // --- corpora ---
678
682
  corpora = {
679
- create: (b: { name: string; description?: string }) =>
683
+ create: (b: { name: string; description?: string; custom_metadata?: Record<string, unknown> }) =>
680
684
  this.request<Corpus>("POST", "/v1/corpora", { json: b }),
681
685
  list: (q?: { limit?: number; cursor?: string }) => this.request<Page<Corpus>>("GET", "/v1/corpora", { query: q }),
682
686
  listAll: () => this.pageAll<Corpus>("/v1/corpora"),
687
+ /** Filter corpora by custom_metadata using the same metadata filter as documents. */
688
+ search: (b: { filter?: MetadataFilter; limit?: number; cursor?: string }) =>
689
+ this.request<Page<Corpus>>("POST", "/v1/corpora/search", { json: b }),
683
690
  get: (id: UUID) => this.request<Corpus>("GET", `/v1/corpora/${id}`),
684
- update: (id: UUID, b: { name?: string; description?: string }) =>
691
+ /** `custom_metadata` merges (provided keys upsert, a null value deletes a key). */
692
+ update: (id: UUID, b: { name?: string; description?: string; custom_metadata?: Record<string, unknown> }) =>
685
693
  this.request<Corpus>("PATCH", `/v1/corpora/${id}`, { json: b }),
686
694
  delete: (id: UUID, confirmName: string) => this.request<void>("DELETE", `/v1/corpora/${id}`, { query: { confirm: confirmName } }),
687
695
  listFolders: (id: UUID) => this.pageAll<Folder>(`/v1/corpora/${id}/folders`),