wauldo 0.3.0 → 0.4.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
@@ -11,7 +11,9 @@ Official TypeScript SDK for the [Wauldo API](https://wauldo.com) — the AI infe
11
11
 
12
12
  ## Why Wauldo?
13
13
 
14
- - **Fact-Check API** verify any claim against source context, get verdict (verified/weak/rejected), action (allow/review/block), and structured reason
14
+ - **Native PDF & DOCX Upload** upload files directly, server-side text extraction with document quality scoring
15
+ - **Citation Verify API** — detect uncited sentences, phantom citations, and measure coverage ratio. No LLM needed
16
+ - **Fact-Check API** — verify any claim against source with 3 modes (lexical, hybrid, semantic). Get verdict, action, and structured reason
15
17
  - **Zero hallucinations** — every answer is verified against source documents
16
18
  - **Smart model routing** — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
17
19
  - **One API, 7+ providers** — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
package/dist/index.d.mts CHANGED
@@ -277,6 +277,22 @@ interface RagUploadResponse {
277
277
  document_id: string;
278
278
  chunks_count: number;
279
279
  }
280
+ interface DocumentQuality {
281
+ score: number;
282
+ label: string;
283
+ word_count: number;
284
+ line_density: number;
285
+ avg_line_length: number;
286
+ paragraph_count: number;
287
+ }
288
+ interface UploadFileResponse {
289
+ document_id: string;
290
+ chunks_count: number;
291
+ indexed_at: string;
292
+ content_type: string;
293
+ trace_id: string;
294
+ quality?: DocumentQuality;
295
+ }
280
296
  interface RagSource {
281
297
  document_id: string;
282
298
  content: string;
@@ -487,6 +503,19 @@ declare class HttpClient {
487
503
  * @returns Upload confirmation with document_id and chunks_count
488
504
  */
489
505
  ragUpload(content: string, filename?: string, options?: RequestOptions): Promise<RagUploadResponse>;
506
+ /**
507
+ * POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
508
+ *
509
+ * @param file - File content as Buffer/Uint8Array
510
+ * @param filename - The filename (determines content type detection)
511
+ * @param options - Optional title, tags, timeoutMs
512
+ * @returns Upload confirmation with quality scoring
513
+ */
514
+ uploadFile(file: Uint8Array | Buffer, filename: string, options?: {
515
+ title?: string;
516
+ tags?: string;
517
+ timeoutMs?: number;
518
+ }): Promise<UploadFileResponse>;
490
519
  /** POST /v1/query — Query RAG knowledge base */
491
520
  ragQuery(query: string, topK?: number, options?: {
492
521
  debug?: boolean;
@@ -671,4 +700,4 @@ declare class ToolNotFoundError extends WauldoError {
671
700
  constructor(toolName: string);
672
701
  }
673
702
 
674
- export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type CitationDetail, type ClaimResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type FactCheckRequest, type FactCheckResponse, type GraphNode, HttpClient, type HttpClientConfig, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceChunk, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, type VerifyCitationRequest, type VerifyCitationResponse, WauldoError, chatContent };
703
+ export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type CitationDetail, type ClaimResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type DocumentQuality, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type FactCheckRequest, type FactCheckResponse, type GraphNode, HttpClient, type HttpClientConfig, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceChunk, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UploadFileResponse, ValidationError, type VerifyCitationRequest, type VerifyCitationResponse, WauldoError, chatContent };
package/dist/index.d.ts CHANGED
@@ -277,6 +277,22 @@ interface RagUploadResponse {
277
277
  document_id: string;
278
278
  chunks_count: number;
279
279
  }
280
+ interface DocumentQuality {
281
+ score: number;
282
+ label: string;
283
+ word_count: number;
284
+ line_density: number;
285
+ avg_line_length: number;
286
+ paragraph_count: number;
287
+ }
288
+ interface UploadFileResponse {
289
+ document_id: string;
290
+ chunks_count: number;
291
+ indexed_at: string;
292
+ content_type: string;
293
+ trace_id: string;
294
+ quality?: DocumentQuality;
295
+ }
280
296
  interface RagSource {
281
297
  document_id: string;
282
298
  content: string;
@@ -487,6 +503,19 @@ declare class HttpClient {
487
503
  * @returns Upload confirmation with document_id and chunks_count
488
504
  */
489
505
  ragUpload(content: string, filename?: string, options?: RequestOptions): Promise<RagUploadResponse>;
506
+ /**
507
+ * POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
508
+ *
509
+ * @param file - File content as Buffer/Uint8Array
510
+ * @param filename - The filename (determines content type detection)
511
+ * @param options - Optional title, tags, timeoutMs
512
+ * @returns Upload confirmation with quality scoring
513
+ */
514
+ uploadFile(file: Uint8Array | Buffer, filename: string, options?: {
515
+ title?: string;
516
+ tags?: string;
517
+ timeoutMs?: number;
518
+ }): Promise<UploadFileResponse>;
490
519
  /** POST /v1/query — Query RAG knowledge base */
491
520
  ragQuery(query: string, topK?: number, options?: {
492
521
  debug?: boolean;
@@ -671,4 +700,4 @@ declare class ToolNotFoundError extends WauldoError {
671
700
  constructor(toolName: string);
672
701
  }
673
702
 
674
- export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type CitationDetail, type ClaimResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type FactCheckRequest, type FactCheckResponse, type GraphNode, HttpClient, type HttpClientConfig, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceChunk, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, type VerifyCitationRequest, type VerifyCitationResponse, WauldoError, chatContent };
703
+ export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type CitationDetail, type ClaimResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type DocumentQuality, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type FactCheckRequest, type FactCheckResponse, type GraphNode, HttpClient, type HttpClientConfig, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceChunk, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, type UploadFileResponse, ValidationError, type VerifyCitationRequest, type VerifyCitationResponse, WauldoError, chatContent };
package/dist/index.js CHANGED
@@ -900,6 +900,16 @@ async function* parseSSEStream(body) {
900
900
  }
901
901
 
902
902
  // src/http_client.ts
903
+ function concatUint8Arrays(arrays) {
904
+ const total = arrays.reduce((n, a) => n + a.length, 0);
905
+ const result = new Uint8Array(total);
906
+ let offset = 0;
907
+ for (const a of arrays) {
908
+ result.set(a, offset);
909
+ offset += a.length;
910
+ }
911
+ return result;
912
+ }
903
913
  function validateResponse(data, typeName) {
904
914
  if (data === null || data === void 0) {
905
915
  throw new ServerError(`Invalid ${typeName}: response is null`, 0);
@@ -1034,6 +1044,51 @@ var HttpClient = class {
1034
1044
  );
1035
1045
  return validateResponse(data, "RagUploadResponse");
1036
1046
  }
1047
+ /**
1048
+ * POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
1049
+ *
1050
+ * @param file - File content as Buffer/Uint8Array
1051
+ * @param filename - The filename (determines content type detection)
1052
+ * @param options - Optional title, tags, timeoutMs
1053
+ * @returns Upload confirmation with quality scoring
1054
+ */
1055
+ async uploadFile(file, filename, options) {
1056
+ const boundary = "----WauldoSDKBoundary";
1057
+ const parts = [];
1058
+ const enc = new TextEncoder();
1059
+ parts.push(enc.encode(`--${boundary}\r
1060
+ Content-Disposition: form-data; name="file"; filename="${filename}"\r
1061
+ Content-Type: application/octet-stream\r
1062
+ \r
1063
+ `));
1064
+ parts.push(file instanceof Uint8Array ? file : new Uint8Array(file));
1065
+ parts.push(enc.encode("\r\n"));
1066
+ if (options?.title) {
1067
+ parts.push(enc.encode(`--${boundary}\r
1068
+ Content-Disposition: form-data; name="title"\r
1069
+ \r
1070
+ ${options.title}\r
1071
+ `));
1072
+ }
1073
+ if (options?.tags) {
1074
+ parts.push(enc.encode(`--${boundary}\r
1075
+ Content-Disposition: form-data; name="tags"\r
1076
+ \r
1077
+ ${options.tags}\r
1078
+ `));
1079
+ }
1080
+ parts.push(enc.encode(`--${boundary}--\r
1081
+ `));
1082
+ const body = concatUint8Arrays(parts);
1083
+ const data = await fetchWithRetry(
1084
+ { ...this.retryConfig, headers: { ...this.retryConfig.headers, "Content-Type": `multipart/form-data; boundary=${boundary}` } },
1085
+ "POST",
1086
+ "/v1/upload-file",
1087
+ body,
1088
+ options?.timeoutMs
1089
+ );
1090
+ return validateResponse(data, "UploadFileResponse");
1091
+ }
1037
1092
  /** POST /v1/query — Query RAG knowledge base */
1038
1093
  async ragQuery(query, topK = 5, options) {
1039
1094
  const body = { query, top_k: topK };
package/dist/index.mjs CHANGED
@@ -864,6 +864,16 @@ async function* parseSSEStream(body) {
864
864
  }
865
865
 
866
866
  // src/http_client.ts
867
+ function concatUint8Arrays(arrays) {
868
+ const total = arrays.reduce((n, a) => n + a.length, 0);
869
+ const result = new Uint8Array(total);
870
+ let offset = 0;
871
+ for (const a of arrays) {
872
+ result.set(a, offset);
873
+ offset += a.length;
874
+ }
875
+ return result;
876
+ }
867
877
  function validateResponse(data, typeName) {
868
878
  if (data === null || data === void 0) {
869
879
  throw new ServerError(`Invalid ${typeName}: response is null`, 0);
@@ -998,6 +1008,51 @@ var HttpClient = class {
998
1008
  );
999
1009
  return validateResponse(data, "RagUploadResponse");
1000
1010
  }
1011
+ /**
1012
+ * POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
1013
+ *
1014
+ * @param file - File content as Buffer/Uint8Array
1015
+ * @param filename - The filename (determines content type detection)
1016
+ * @param options - Optional title, tags, timeoutMs
1017
+ * @returns Upload confirmation with quality scoring
1018
+ */
1019
+ async uploadFile(file, filename, options) {
1020
+ const boundary = "----WauldoSDKBoundary";
1021
+ const parts = [];
1022
+ const enc = new TextEncoder();
1023
+ parts.push(enc.encode(`--${boundary}\r
1024
+ Content-Disposition: form-data; name="file"; filename="${filename}"\r
1025
+ Content-Type: application/octet-stream\r
1026
+ \r
1027
+ `));
1028
+ parts.push(file instanceof Uint8Array ? file : new Uint8Array(file));
1029
+ parts.push(enc.encode("\r\n"));
1030
+ if (options?.title) {
1031
+ parts.push(enc.encode(`--${boundary}\r
1032
+ Content-Disposition: form-data; name="title"\r
1033
+ \r
1034
+ ${options.title}\r
1035
+ `));
1036
+ }
1037
+ if (options?.tags) {
1038
+ parts.push(enc.encode(`--${boundary}\r
1039
+ Content-Disposition: form-data; name="tags"\r
1040
+ \r
1041
+ ${options.tags}\r
1042
+ `));
1043
+ }
1044
+ parts.push(enc.encode(`--${boundary}--\r
1045
+ `));
1046
+ const body = concatUint8Arrays(parts);
1047
+ const data = await fetchWithRetry(
1048
+ { ...this.retryConfig, headers: { ...this.retryConfig.headers, "Content-Type": `multipart/form-data; boundary=${boundary}` } },
1049
+ "POST",
1050
+ "/v1/upload-file",
1051
+ body,
1052
+ options?.timeoutMs
1053
+ );
1054
+ return validateResponse(data, "UploadFileResponse");
1055
+ }
1001
1056
  /** POST /v1/query — Query RAG knowledge base */
1002
1057
  async ragQuery(query, topK = 5, options) {
1003
1058
  const body = { query, top_k: topK };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wauldo",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Official TypeScript SDK for Wauldo — Verified AI answers from your documents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",