@babav/knowledge-core-client 0.43.0 → 0.44.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
@@ -39,15 +39,15 @@ const kc = new KnowledgeCoreClient({
39
39
  });
40
40
 
41
41
  // One-shot grounded query
42
- const r = await kc.query(agentId, { corpus_ids: [corpusId], query: "..." });
42
+ const r = await kc.query(profileId, { corpus_ids: [corpusId], query: "..." });
43
43
  console.log(r.answer, r.retrieval_contents, r.citations, r.groundedness);
44
44
 
45
45
  // Conversational (persisted, history-aware)
46
46
  const convo = await kc.conversations.create({ title: "Contract review", custom_metadata: { account_id } });
47
- const turn = await kc.query(agentId, { corpus_ids: [corpusId], query: "...", conversation_id: convo.id });
47
+ const turn = await kc.query(profileId, { corpus_ids: [corpusId], query: "...", conversation_id: convo.id });
48
48
 
49
49
  // Streaming (SSE)
50
- await kc.queryStream(agentId, { corpus_ids: [corpusId], query: "..." }, {
50
+ await kc.queryStream(profileId, { corpus_ids: [corpusId], query: "..." }, {
51
51
  onSources: (s) => render(s.retrieval_contents),
52
52
  onToken: (t) => append(t),
53
53
  onFinal: (f) => done(f),
@@ -57,7 +57,7 @@ await kc.queryStream(agentId, { corpus_ids: [corpusId], query: "..." }, {
57
57
  // Attachment-backed review
58
58
  const att = await kc.attachments.upload(convo.id, { filename: "c.pdf", content_type: "application/pdf", data: bytes });
59
59
  await kc.attachments.waitReady(convo.id, att.id);
60
- const review = await kc.query(agentId, { corpus_ids: [corpusId], conversation_id: convo.id, query: "Review the attached contract." });
60
+ const review = await kc.query(profileId, { corpus_ids: [corpusId], conversation_id: convo.id, query: "Review the attached contract." });
61
61
 
62
62
  // View/download a stored doc (signed URL)
63
63
  const { content_url, content_type } = await kc.documents.contentUrl(documentId, "inline");
@@ -65,7 +65,7 @@ const { content_url, content_type } = await kc.documents.contentUrl(documentId,
65
65
 
66
66
  ### Error handling (structured guards)
67
67
  ```ts
68
- try { await kc.query(agentId, body); }
68
+ try { await kc.query(profileId, body); }
69
69
  catch (e) {
70
70
  if (e instanceof KnowledgeCoreError) {
71
71
  if (e.code === "attachments_pending") { /* a document is still parsing */ }
@@ -75,7 +75,7 @@ catch (e) {
75
75
  }
76
76
  ```
77
77
 
78
- ## Admin client (tenant + key + agent management — ADMIN key)
78
+ ## Admin client (tenant + key + profile management — ADMIN key)
79
79
  ```ts
80
80
  import { AdminClient } from "@babav/knowledge-core-client";
81
81
  const admin = new AdminClient({ baseUrl, apiKey: ADMIN_KEY });
@@ -90,5 +90,5 @@ const created = await admin.tenants.createApiKey(tenantId, "label"); // created.
90
90
  - `conversations` (CRUD, search, listMessages)
91
91
  - `attachments` (upload, list, get, contentUrl, delete, waitReady)
92
92
  - `messages` (get, createFeedback, listFeedback), `feedback` (get, delete)
93
- - `parseJobs` (list, get), `agents` (list, get)
94
- - `AdminClient`: `tenants` (CRUD + api-keys), `agents` (create/update/delete)
93
+ - `parseJobs` (list, get), `profiles` (list, get)
94
+ - `AdminClient`: `tenants` (CRUD + api-keys), `profiles` (create/update/delete)
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Auth: every call carries an X-API-Key. Use KnowledgeCoreClient with a TENANT
12
12
  * key for all data ops; use AdminClient with the ADMIN key for tenant / API-key /
13
- * agent management. The key is server-side only — never ship it to a browser.
13
+ * profile management. The key is server-side only — never ship it to a browser.
14
14
  *
15
15
  * Configuration — the CALLER supplies credentials at construction; the SDK never reads
16
16
  * the environment or defaults/derives a key itself:
@@ -77,7 +77,7 @@ export interface VisualOverrides {
77
77
  claims_check_model?: string;
78
78
  vision_judge_model?: string;
79
79
  }
80
- /** Per-request visual control. Absent => mode resolves from the agent default. All visual
80
+ /** Per-request visual control. Absent => mode resolves from the profile default. All visual
81
81
  * PROCESSING is server-side; the client only displays the result. */
82
82
  export interface VisualRequest {
83
83
  mode?: "off" | "on";
@@ -539,13 +539,13 @@ export interface QueryProfile {
539
539
  visual_combine_generation_and_concept: boolean | null;
540
540
  concept_model_mode: string | null;
541
541
  }
542
- /** Fields settable when creating/updating an agent. All optional except `name` on create
542
+ /** Fields settable when creating/updating a query profile. All optional except `name` on create
543
543
  * (null/omit => server default); model fields must be one of
544
- * `agents.modelOptions().fields[field].supported`. The owning tenant is the caller's key —
544
+ * `profiles.modelOptions().fields[field].supported`. The owning tenant is the caller's key —
545
545
  * it is never part of the body. */
546
546
  export type QueryProfileWrite = Partial<Omit<QueryProfile, "id" | "tenant_id">>;
547
547
  /** Model catalog for the query-profile-config UI (GET /v1/query-profiles/model-options). `models` maps id → its
548
- * capabilities; `fields` gives each agent model-field its supported ids + default (+ usage metadata);
548
+ * capabilities; `fields` gives each profile model-field its supported ids + default (+ usage metadata);
549
549
  * `modes` says which model field governs each mode (reasoning is valid only if that model's
550
550
  * supports_reasoning is true). KC provides the data; the UI decides presentation. */
551
551
  export interface ModelOptions {
@@ -778,6 +778,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
778
778
  visibility?: Visibility;
779
779
  folder_id?: UUID;
780
780
  custom_metadata?: Record<string, unknown>;
781
+ profile_id?: UUID;
781
782
  }) => Promise<Document>;
782
783
  /** Mint a signed PUT URL to upload a large file straight to GCS (bypasses the
783
784
  * ~32 MB request limit). PUT the bytes to upload_url, then ingestFromUpload. */
@@ -794,6 +795,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
794
795
  visibility?: Visibility;
795
796
  folder_id?: UUID;
796
797
  custom_metadata?: Record<string, unknown>;
798
+ profile_id?: UUID;
797
799
  }) => Promise<Document>;
798
800
  /** Convenience for LARGE files: uploadUrl → PUT the bytes to GCS → ingestFromUpload.
799
801
  * Use this instead of ingestDocument when the file may exceed ~32 MB. */
@@ -804,6 +806,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
804
806
  visibility?: Visibility;
805
807
  folder_id?: UUID;
806
808
  custom_metadata?: Record<string, unknown>;
809
+ profile_id?: UUID;
807
810
  }) => Promise<Document>;
808
811
  /** Ingest MANY files in ONE go — any size, no 429, no client backoff. Mints all signed URLs in
809
812
  * one request, PUTs the bytes straight to GCS (bounded concurrency; never touches the KC), then
@@ -819,6 +822,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
819
822
  visibility?: Visibility;
820
823
  custom_metadata?: Record<string, unknown>;
821
824
  concurrency?: number;
825
+ profile_id?: UUID;
822
826
  }) => Promise<Document[]>;
823
827
  /** (server-side) Mint one RESUMABLE GCS upload session per file. Return only the sessions to the
824
828
  * browser; the browser PUTs bytes to each `upload_url` and needs NO KC/tenant credential (the
@@ -845,6 +849,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
845
849
  folder_id?: UUID;
846
850
  visibility?: Visibility;
847
851
  custom_metadata?: Record<string, unknown>;
852
+ profile_id?: UUID;
848
853
  }) => Promise<{
849
854
  results: FinalizeResult[];
850
855
  }>;
@@ -1003,7 +1008,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
1003
1008
  modelOptions: () => Promise<ModelOptions>;
1004
1009
  };
1005
1010
  /** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
1006
- * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike an agent
1011
+ * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike a query profile
1007
1012
  * (chosen per query), a profile binds at the TENANT/COLLECTION level — the tenant's one
1008
1013
  * `is_default` profile governs how ALL its documents are ingested; swapping it re-indexes.
1009
1014
  * A corpus's content is a RESULT of ingestion, so a corpus never selects a profile. */
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Auth: every call carries an X-API-Key. Use KnowledgeCoreClient with a TENANT
12
12
  * key for all data ops; use AdminClient with the ADMIN key for tenant / API-key /
13
- * agent management. The key is server-side only — never ship it to a browser.
13
+ * profile management. The key is server-side only — never ship it to a browser.
14
14
  *
15
15
  * Configuration — the CALLER supplies credentials at construction; the SDK never reads
16
16
  * the environment or defaults/derives a key itself:
@@ -303,6 +303,7 @@ export class KnowledgeCoreClient extends HttpBase {
303
303
  return this.corpora.ingestFromUpload(id, {
304
304
  document_id: u.document_id, filename: a.filename, content_type: a.content_type,
305
305
  visibility: a.visibility, folder_id: a.folder_id, custom_metadata: a.custom_metadata,
306
+ profile_id: a.profile_id,
306
307
  });
307
308
  },
308
309
  /** Ingest MANY files in ONE go — any size, no 429, no client backoff. Mints all signed URLs in
@@ -328,6 +329,7 @@ export class KnowledgeCoreClient extends HttpBase {
328
329
  });
329
330
  const res = await this.request("POST", `/v1/corpora/${id}/documents/batch`, { json: {
330
331
  folder_id: opts?.folder_id, visibility: opts?.visibility, custom_metadata: opts?.custom_metadata,
332
+ profile_id: opts?.profile_id,
331
333
  items: items.map((it) => ({ document_id: it.document_id, filename: it.filename })),
332
334
  } });
333
335
  return res.documents;
@@ -353,7 +355,7 @@ export class KnowledgeCoreClient extends HttpBase {
353
355
  * items. `document_id` is stable from createUploadSessions, so documents.events (SSE) tracks it. */
354
356
  finalizeUploads: (id, items, opts) => this.request("POST", `/v1/corpora/${id}/documents/finalize`, { json: {
355
357
  items, folder_id: opts?.folder_id, visibility: opts?.visibility,
356
- custom_metadata: opts?.custom_metadata,
358
+ custom_metadata: opts?.custom_metadata, profile_id: opts?.profile_id,
357
359
  } }),
358
360
  /** (server-side) Cancel upload sessions the browser gave up on (idempotent cleanup). Pass the
359
361
  * `upload_url` from createUploadSessions so the resumable session is dropped; any pending row is
@@ -468,7 +470,7 @@ export class KnowledgeCoreClient extends HttpBase {
468
470
  modelOptions: () => this.request("GET", "/v1/query-profiles/model-options"),
469
471
  };
470
472
  /** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
471
- * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike an agent
473
+ * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike a query profile
472
474
  * (chosen per query), a profile binds at the TENANT/COLLECTION level — the tenant's one
473
475
  * `is_default` profile governs how ALL its documents are ingested; swapping it re-indexes.
474
476
  * A corpus's content is a RESULT of ingestion, so a corpus never selects a profile. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babav/knowledge-core-client",
3
- "version": "0.43.0",
3
+ "version": "0.44.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
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Auth: every call carries an X-API-Key. Use KnowledgeCoreClient with a TENANT
12
12
  * key for all data ops; use AdminClient with the ADMIN key for tenant / API-key /
13
- * agent management. The key is server-side only — never ship it to a browser.
13
+ * profile management. The key is server-side only — never ship it to a browser.
14
14
  *
15
15
  * Configuration — the CALLER supplies credentials at construction; the SDK never reads
16
16
  * the environment or defaults/derives a key itself:
@@ -100,7 +100,7 @@ export interface VisualOverrides {
100
100
  vision_judge_model?: string;
101
101
  }
102
102
 
103
- /** Per-request visual control. Absent => mode resolves from the agent default. All visual
103
+ /** Per-request visual control. Absent => mode resolves from the profile default. All visual
104
104
  * PROCESSING is server-side; the client only displays the result. */
105
105
  export interface VisualRequest {
106
106
  mode?: "off" | "on";
@@ -474,12 +474,12 @@ export interface Feedback {
474
474
  }
475
475
  export interface QueryProfile {
476
476
  id: UUID;
477
- tenant_id: UUID; // the owning tenant (every agent belongs to exactly one; no globals)
477
+ tenant_id: UUID; // the owning tenant (every profile belongs to exactly one; no globals)
478
478
  name: string;
479
479
  identity_prompt: string | null; // answer-system: who/purpose (null => server default)
480
480
  response_prompt: string | null; // answer-system: output guidelines (null => server default)
481
481
  generation_model: string | null;
482
- generation_model_mode: string | null; // "reasoning" (adaptive thinking) | "standard"; per-agent
482
+ generation_model_mode: string | null; // "reasoning" (adaptive thinking) | "standard"; per-profile
483
483
  max_response_tokens: number | null;
484
484
  top_k_retrieved_chunks: number | null;
485
485
  top_k_reranked_chunks: number | null;
@@ -507,14 +507,14 @@ export interface QueryProfile {
507
507
  concept_model_mode: string | null; // "reasoning" | "standard"; overrules gen mode when combining
508
508
  }
509
509
 
510
- /** Fields settable when creating/updating an agent. All optional except `name` on create
510
+ /** Fields settable when creating/updating a query profile. All optional except `name` on create
511
511
  * (null/omit => server default); model fields must be one of
512
- * `agents.modelOptions().fields[field].supported`. The owning tenant is the caller's key —
512
+ * `profiles.modelOptions().fields[field].supported`. The owning tenant is the caller's key —
513
513
  * it is never part of the body. */
514
514
  export type QueryProfileWrite = Partial<Omit<QueryProfile, "id" | "tenant_id">>;
515
515
 
516
516
  /** Model catalog for the query-profile-config UI (GET /v1/query-profiles/model-options). `models` maps id → its
517
- * capabilities; `fields` gives each agent model-field its supported ids + default (+ usage metadata);
517
+ * capabilities; `fields` gives each profile model-field its supported ids + default (+ usage metadata);
518
518
  * `modes` says which model field governs each mode (reasoning is valid only if that model's
519
519
  * supports_reasoning is true). KC provides the data; the UI decides presentation. */
520
520
  export interface ModelOptions {
@@ -893,7 +893,7 @@ export class KnowledgeCoreClient extends HttpBase {
893
893
  * `pending` (HTTP 202); track via documents.events()/get() or the tenant webhook.
894
894
  * ALWAYS uploads the bytes straight to GCS via a signed URL (uploadUrl → PUT → ingestFromUpload),
895
895
  * regardless of size — so there is NO request-size cap, ever. One method, any size. */
896
- ingestDocument: (id: UUID, a: { file: FileData; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown> }) =>
896
+ ingestDocument: (id: UUID, a: { file: FileData; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown>; profile_id?: UUID }) =>
897
897
  this.corpora.uploadDocument(id, a),
898
898
  /** Mint a signed PUT URL to upload a large file straight to GCS (bypasses the
899
899
  * ~32 MB request limit). PUT the bytes to upload_url, then ingestFromUpload. */
@@ -901,11 +901,11 @@ export class KnowledgeCoreClient extends HttpBase {
901
901
  this.request<UploadUrl>("POST", `/v1/corpora/${id}/documents/upload-url`, { json: a }),
902
902
  /** Ingest a file already PUT to GCS via uploadUrl. Resolves with the `pending`
903
903
  * document (202); track via documents.get() / webhook. */
904
- ingestFromUpload: (id: UUID, a: { document_id: UUID; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown> }) =>
904
+ ingestFromUpload: (id: UUID, a: { document_id: UUID; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown>; profile_id?: UUID }) =>
905
905
  this.request<Document>("POST", `/v1/corpora/${id}/documents/from-upload`, { json: a }),
906
906
  /** Convenience for LARGE files: uploadUrl → PUT the bytes to GCS → ingestFromUpload.
907
907
  * Use this instead of ingestDocument when the file may exceed ~32 MB. */
908
- uploadDocument: async (id: UUID, a: { file: FileData; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown> }): Promise<Document> => {
908
+ uploadDocument: async (id: UUID, a: { file: FileData; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown>; profile_id?: UUID }): Promise<Document> => {
909
909
  const u = await this.corpora.uploadUrl(id, { filename: a.filename, content_type: a.content_type });
910
910
  const put = await this._fetch(u.upload_url, {
911
911
  method: "PUT",
@@ -918,6 +918,7 @@ export class KnowledgeCoreClient extends HttpBase {
918
918
  return this.corpora.ingestFromUpload(id, {
919
919
  document_id: u.document_id, filename: a.filename, content_type: a.content_type,
920
920
  visibility: a.visibility, folder_id: a.folder_id, custom_metadata: a.custom_metadata,
921
+ profile_id: a.profile_id,
921
922
  });
922
923
  },
923
924
  /** Ingest MANY files in ONE go — any size, no 429, no client backoff. Mints all signed URLs in
@@ -928,7 +929,7 @@ export class KnowledgeCoreClient extends HttpBase {
928
929
  uploadMany: async (
929
930
  id: UUID,
930
931
  files: Array<{ file: FileData; filename: string; content_type?: string }>,
931
- opts?: { folder_id?: UUID; visibility?: Visibility; custom_metadata?: Record<string, unknown>; concurrency?: number },
932
+ opts?: { folder_id?: UUID; visibility?: Visibility; custom_metadata?: Record<string, unknown>; concurrency?: number; profile_id?: UUID },
932
933
  ): Promise<Document[]> => {
933
934
  if (files.length === 0) return [];
934
935
  const urls = await this.request<BatchUploadUrls>(
@@ -950,6 +951,7 @@ export class KnowledgeCoreClient extends HttpBase {
950
951
  "POST", `/v1/corpora/${id}/documents/batch`,
951
952
  { json: {
952
953
  folder_id: opts?.folder_id, visibility: opts?.visibility, custom_metadata: opts?.custom_metadata,
954
+ profile_id: opts?.profile_id,
953
955
  items: items.map((it) => ({ document_id: it.document_id, filename: it.filename })),
954
956
  } },
955
957
  );
@@ -988,13 +990,13 @@ export class KnowledgeCoreClient extends HttpBase {
988
990
  finalizeUploads: (
989
991
  id: UUID,
990
992
  items: Array<{ document_id: UUID; filename: string; content_type?: string }>,
991
- opts?: { folder_id?: UUID; visibility?: Visibility; custom_metadata?: Record<string, unknown> },
993
+ opts?: { folder_id?: UUID; visibility?: Visibility; custom_metadata?: Record<string, unknown>; profile_id?: UUID },
992
994
  ): Promise<{ results: FinalizeResult[] }> =>
993
995
  this.request<{ results: FinalizeResult[] }>(
994
996
  "POST", `/v1/corpora/${id}/documents/finalize`,
995
997
  { json: {
996
998
  items, folder_id: opts?.folder_id, visibility: opts?.visibility,
997
- custom_metadata: opts?.custom_metadata,
999
+ custom_metadata: opts?.custom_metadata, profile_id: opts?.profile_id,
998
1000
  } },
999
1001
  ),
1000
1002
 
@@ -1142,7 +1144,7 @@ export class KnowledgeCoreClient extends HttpBase {
1142
1144
  };
1143
1145
 
1144
1146
  /** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
1145
- * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike an agent
1147
+ * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike a query profile
1146
1148
  * (chosen per query), a profile binds at the TENANT/COLLECTION level — the tenant's one
1147
1149
  * `is_default` profile governs how ALL its documents are ingested; swapping it re-indexes.
1148
1150
  * A corpus's content is a RESULT of ingestion, so a corpus never selects a profile. */