wauldo 0.4.0 → 0.5.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
@@ -1,82 +1,129 @@
1
- # Wauldo TypeScript SDK
1
+ <h1 align="center">Wauldo TypeScript SDK</h1>
2
2
 
3
- [![npm](https://img.shields.io/npm/v/wauldo.svg)](https://npmjs.com/package/wauldo)
4
- [![Downloads](https://img.shields.io/npm/dm/wauldo.svg)](https://npmjs.com/package/wauldo)
5
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)
3
+ <p align="center">
4
+ <strong>Verified AI answers from your documents — or no answer at all.</strong>
5
+ </p>
7
6
 
8
- > **Verified AI answers from your documents.** Every response includes source citations, confidence scores, and an audit trail — or we don't answer at all.
7
+ <p align="center">
8
+ Most RAG APIs guess. Wauldo verifies.
9
+ </p>
9
10
 
10
- Official TypeScript SDK for the [Wauldo API](https://wauldo.com) — the AI inference layer with smart model routing, zero hallucinations, and standalone fact-checking.
11
+ <p align="center">
12
+ <b>0% hallucination</b> &nbsp;|&nbsp; 83% accuracy &nbsp;|&nbsp; 61 eval tasks &nbsp;|&nbsp; 14 LLMs tested
13
+ </p>
11
14
 
12
- ## Why Wauldo?
15
+ <p align="center">
16
+ <a href="https://npmjs.com/package/wauldo"><img src="https://img.shields.io/npm/v/wauldo.svg" alt="npm" /></a>&nbsp;
17
+ <a href="https://npmjs.com/package/wauldo"><img src="https://img.shields.io/npm/dm/wauldo.svg" alt="Downloads" /></a>&nbsp;
18
+ <img src="https://img.shields.io/badge/TypeScript-5.0+-blue.svg" alt="TypeScript" />&nbsp;
19
+ <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="MIT" />
20
+ </p>
13
21
 
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
17
- - **Zero hallucinations** — every answer is verified against source documents
18
- - **Smart model routing** — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
19
- - **One API, 7+ providers** — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
20
- - **OpenAI-compatible** — swap your `baseUrl`, keep your existing code
21
- - **Full audit trail** — confidence score, grounded status, model used, latency on every response
22
- - **Zero dependencies** — uses Node 18+ built-in APIs (fetch, ReadableStream)
22
+ <p align="center">
23
+ <a href="https://wauldo.com/demo">Demo</a> &bull;
24
+ <a href="https://wauldo.com/docs">Docs</a> &bull;
25
+ <a href="https://rapidapi.com/binnewzzin/api/smart-rag-api">Free API Key</a> &bull;
26
+ <a href="https://dev.to/wauldo/how-we-achieved-0-hallucination-rate-in-our-rag-api-with-benchmarks-4g54">Benchmarks</a>
27
+ </p>
28
+
29
+ ---
30
+
31
+ ## Quickstart (30 seconds)
23
32
 
24
- ## Quick Start
33
+ ```bash
34
+ npm install wauldo
35
+ ```
25
36
 
26
37
  ```typescript
27
38
  import { HttpClient } from 'wauldo';
28
39
 
29
40
  const client = new HttpClient({ baseUrl: 'https://api.wauldo.com', apiKey: 'YOUR_API_KEY' });
30
41
 
31
- const reply = await client.chatSimple('auto', 'What is TypeScript?');
32
- console.log(reply);
42
+ // Upload a document
43
+ await client.ragUpload('Our refund policy allows returns within 60 days...', 'policy.txt');
44
+
45
+ // Ask a question — answer is verified against the source
46
+ const result = await client.ragQuery('What is the refund policy?');
47
+ console.log(result.answer);
48
+ console.log(result.sources);
33
49
  ```
34
50
 
35
- ## Installation
51
+ ```
52
+ Output:
53
+ Answer: Returns are accepted within 60 days of purchase.
54
+ Sources: policy.txt — "Our refund policy allows returns within 60 days"
55
+ Grounded: true | Confidence: 0.92
56
+ ```
36
57
 
37
- ```bash
38
- npm install wauldo
58
+ [Try the demo](https://wauldo.com/demo) | [Get a free API key](https://rapidapi.com/binnewzzin/api/smart-rag-api)
59
+
60
+ ---
61
+
62
+ ## Why Wauldo (and not standard RAG)
63
+
64
+ **Typical RAG pipeline**
65
+
66
+ ```
67
+ retrieve → generate → hope it's correct
39
68
  ```
40
69
 
41
- **Requirements:** Node.js 18+, TypeScript 5.0+
70
+ **Wauldo pipeline**
42
71
 
43
- ## Features
72
+ ```
73
+ retrieve → extract facts → generate → verify → return or refuse
74
+ ```
44
75
 
45
- ### Chat Completions
76
+ If the answer can't be verified, it returns **"insufficient evidence"** instead of guessing.
46
77
 
47
- ```typescript
48
- import { HttpClient } from 'wauldo';
78
+ ### See the difference
49
79
 
50
- const client = new HttpClient({ baseUrl: 'https://api.wauldo.com', apiKey: 'YOUR_API_KEY' });
80
+ ```
81
+ Document: "Refunds are processed within 60 days"
51
82
 
52
- const response = await client.chat({
53
- model: 'auto',
54
- messages: [
55
- { role: 'system', content: 'You are a helpful assistant.' },
56
- { role: 'user', content: 'Explain async/await in TypeScript' },
57
- ],
58
- });
59
- console.log(response.choices[0]?.message?.content);
83
+ Typical RAG: "Refunds are processed within 30 days" ← wrong
84
+ Wauldo: "Refunds are processed within 60 days" ← verified
85
+ or "insufficient evidence" if unclear ← safe
60
86
  ```
61
87
 
62
- ### RAG — Upload & Query
88
+ ---
89
+
90
+ ## Examples
91
+
92
+ ### Upload a PDF and ask questions
63
93
 
64
94
  ```typescript
65
- // Upload a document
66
- const upload = await client.ragUpload('Contract text here...', 'contract.txt');
67
- console.log(`Indexed ${upload.chunks_count} chunks`);
95
+ // Upload text extraction + quality scoring happens server-side
96
+ const upload = await client.uploadFile(filePath, { title: 'Q3 Contract' });
97
+ console.log(`Extracted ${upload.chunks_count} chunks, quality: ${upload.quality_label}`);
68
98
 
69
- // Query with verified answer
99
+ // Query
70
100
  const result = await client.ragQuery('What are the payment terms?');
71
101
  console.log(`Answer: ${result.answer}`);
72
102
  console.log(`Confidence: ${Math.round(result.audit.confidence * 100)}%`);
73
103
  console.log(`Grounded: ${result.audit.grounded}`);
74
- for (const source of result.sources) {
75
- console.log(` Source (${Math.round(source.score * 100)}%): ${source.content}`);
76
- }
77
104
  ```
78
105
 
79
- ### Streaming (SSE)
106
+ ### Fact-check any LLM output
107
+
108
+ ```typescript
109
+ const result = await client.factCheck({
110
+ text: 'Returns are accepted within 60 days.',
111
+ sourceContext: 'Our policy allows returns within 14 days.',
112
+ mode: 'lexical',
113
+ });
114
+ console.log(result.verdict); // "rejected"
115
+ console.log(result.action); // "block"
116
+ console.log(result.claims[0].reason); // "numerical_mismatch"
117
+ ```
118
+
119
+ ### Chat (OpenAI-compatible)
120
+
121
+ ```typescript
122
+ const reply = await client.chatSimple('auto', 'Explain async/await in TypeScript');
123
+ console.log(reply);
124
+ ```
125
+
126
+ ### Streaming
80
127
 
81
128
  ```typescript
82
129
  const stream = client.chatStream({
@@ -88,7 +135,7 @@ for await (const chunk of stream) {
88
135
  }
89
136
  ```
90
137
 
91
- ### Conversation Helper
138
+ ### Conversation
92
139
 
93
140
  ```typescript
94
141
  const conv = client.conversation({ system: 'You are an expert on TypeScript.', model: 'auto' });
@@ -96,18 +143,20 @@ const reply = await conv.say('What are generics?');
96
143
  const followUp = await conv.say('Give me an example');
97
144
  ```
98
145
 
99
- ### Fact-Check — Verify Claims
146
+ ---
100
147
 
101
- ```typescript
102
- const result = await client.factCheck({
103
- text: 'Returns are accepted within 60 days.',
104
- source_context: 'Our policy allows returns within 14 days.',
105
- mode: 'lexical',
106
- });
107
- console.log(result.verdict); // "rejected"
108
- console.log(result.action); // "block"
109
- result.claims.forEach(c => console.log(`${c.text} ${c.verdict} (${c.reason})`));
110
- ```
148
+ ## Features
149
+
150
+ - **Pre-generation fact extraction** numbers, dates, limits injected as constraints
151
+ - **Post-generation grounding check** every answer verified against sources
152
+ - **Citation validation** — detects phantom references
153
+ - **Fact-check API** — verify any claim against any source (3 modes)
154
+ - **Native PDF/DOCX upload** — server-side extraction with quality scoring
155
+ - **Smart model routing** — auto-selects cheapest model that meets quality
156
+ - **OpenAI-compatible** swap your `baseUrl`, keep your existing code
157
+ - **Zero dependencies** — uses Node 18+ built-in APIs (fetch, ReadableStream)
158
+
159
+ ---
111
160
 
112
161
  ## Error Handling
113
162
 
@@ -115,19 +164,16 @@ result.claims.forEach(c => console.log(`${c.text} → ${c.verdict} (${c.reason})
115
164
  import { HttpClient, ServerError } from 'wauldo';
116
165
 
117
166
  try {
118
- const response = await client.chat({
119
- model: 'auto',
120
- messages: [{ role: 'user', content: 'Hello' }],
121
- });
167
+ const response = await client.chat({ model: 'auto', messages: [{ role: 'user', content: 'Hello' }] });
122
168
  } catch (error) {
123
169
  if (error instanceof ServerError) {
124
170
  console.error(`Server error [${error.code}]: ${error.message}`);
125
- } else {
126
- console.error('Unknown error:', error);
127
171
  }
128
172
  }
129
173
  ```
130
174
 
175
+ ---
176
+
131
177
  ## RapidAPI
132
178
 
133
179
  ```typescript
@@ -140,19 +186,15 @@ const client = new HttpClient({
140
186
  });
141
187
  ```
142
188
 
143
- Get your free API key (300 req/month): [RapidAPI](https://rapidapi.com/binnewzzin/api/smart-rag-api)
189
+ Free tier (300 req/month): [RapidAPI](https://rapidapi.com/binnewzzin/api/smart-rag-api)
144
190
 
145
- ## Links
191
+ ---
146
192
 
147
- - [Website](https://wauldo.com)
148
- - [Documentation](https://wauldo.com/docs)
149
- - [Live Demo](https://api.wauldo.com/demo)
150
- - [Cost Calculator](https://wauldo.com/calculator)
151
- - [Status](https://wauldo.com/status)
193
+ [Website](https://wauldo.com) | [Docs](https://wauldo.com/docs) | [Demo](https://wauldo.com/demo) | [Benchmarks](https://dev.to/wauldo/how-we-achieved-0-hallucination-rate-in-our-rag-api-with-benchmarks-4g54)
152
194
 
153
195
  ## Contributing
154
196
 
155
- Found a bug? Have a feature request? [Open an issue](https://github.com/wauldo/wauldo-sdk-js/issues).
197
+ PRs welcome. Check the [good first issues](https://github.com/wauldo/wauldo-sdk-js/labels/good%20first%20issue).
156
198
 
157
199
  ## License
158
200
 
package/dist/index.d.mts CHANGED
@@ -277,22 +277,6 @@ 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
- }
296
280
  interface RagSource {
297
281
  document_id: string;
298
282
  content: string;
@@ -328,58 +312,6 @@ interface RagQueryResponse {
328
312
  interface OrchestratorResponse {
329
313
  final_output: string;
330
314
  }
331
- interface FactCheckRequest {
332
- text: string;
333
- source_context: string;
334
- mode?: 'lexical' | 'hybrid' | 'semantic';
335
- }
336
- interface ClaimResult {
337
- text: string;
338
- claim_type: string;
339
- supported: boolean;
340
- confidence: number;
341
- confidence_label: string;
342
- verdict: string;
343
- action: string;
344
- reason?: string | null;
345
- evidence?: string | null;
346
- }
347
- interface FactCheckResponse {
348
- verdict: string;
349
- action: string;
350
- hallucination_rate: number;
351
- mode: string;
352
- total_claims: number;
353
- supported_claims: number;
354
- confidence: number;
355
- claims: ClaimResult[];
356
- mode_warning?: string | null;
357
- processing_time_ms: number;
358
- }
359
- interface SourceChunk {
360
- name: string;
361
- content: string;
362
- }
363
- interface CitationDetail {
364
- citation: string;
365
- source_name: string;
366
- is_valid: boolean;
367
- }
368
- interface VerifyCitationRequest {
369
- text: string;
370
- sources?: SourceChunk[];
371
- threshold?: number;
372
- }
373
- interface VerifyCitationResponse {
374
- citation_ratio: number;
375
- has_sufficient_citations: boolean;
376
- sentence_count: number;
377
- citation_count: number;
378
- uncited_sentences: string[];
379
- citations?: CitationDetail[];
380
- phantom_count?: number;
381
- processing_time_ms: number;
382
- }
383
315
  /** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
384
316
  interface ChatClientLike {
385
317
  chat(request: ChatRequest, options?: RequestOptions): Promise<ChatResponse>;
@@ -503,19 +435,6 @@ declare class HttpClient {
503
435
  * @returns Upload confirmation with document_id and chunks_count
504
436
  */
505
437
  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>;
519
438
  /** POST /v1/query — Query RAG knowledge base */
520
439
  ragQuery(query: string, topK?: number, options?: {
521
440
  debug?: boolean;
@@ -550,36 +469,6 @@ declare class HttpClient {
550
469
  orchestrate(prompt: string): Promise<OrchestratorResponse>;
551
470
  /** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
552
471
  orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
553
- /**
554
- * POST /v1/fact-check — Verify claims against source context.
555
- *
556
- * @param request - Text and source context to verify
557
- * @returns FactCheckResponse with verdict, action, and per-claim results
558
- *
559
- * @example
560
- * ```typescript
561
- * const result = await client.factCheck({
562
- * text: 'Returns accepted within 60 days.',
563
- * source_context: 'Our policy allows returns within 14 days.',
564
- * mode: 'lexical',
565
- * });
566
- * console.log(result.verdict); // "rejected"
567
- * ```
568
- */
569
- factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
570
- /**
571
- * POST /v1/verify — Verify citations in AI-generated text.
572
- *
573
- * @example
574
- * ```ts
575
- * const result = await client.verifyCitation({
576
- * text: 'Rust was released in 2010 [Source: rust_book].',
577
- * sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
578
- * });
579
- * console.log(result.phantom_count); // 0
580
- * ```
581
- */
582
- verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
583
472
  }
584
473
 
585
474
  /**
@@ -700,4 +589,4 @@ declare class ToolNotFoundError extends WauldoError {
700
589
  constructor(toolName: string);
701
590
  }
702
591
 
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 };
592
+ export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, 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 SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, WauldoError, chatContent };
package/dist/index.d.ts CHANGED
@@ -277,22 +277,6 @@ 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
- }
296
280
  interface RagSource {
297
281
  document_id: string;
298
282
  content: string;
@@ -328,58 +312,6 @@ interface RagQueryResponse {
328
312
  interface OrchestratorResponse {
329
313
  final_output: string;
330
314
  }
331
- interface FactCheckRequest {
332
- text: string;
333
- source_context: string;
334
- mode?: 'lexical' | 'hybrid' | 'semantic';
335
- }
336
- interface ClaimResult {
337
- text: string;
338
- claim_type: string;
339
- supported: boolean;
340
- confidence: number;
341
- confidence_label: string;
342
- verdict: string;
343
- action: string;
344
- reason?: string | null;
345
- evidence?: string | null;
346
- }
347
- interface FactCheckResponse {
348
- verdict: string;
349
- action: string;
350
- hallucination_rate: number;
351
- mode: string;
352
- total_claims: number;
353
- supported_claims: number;
354
- confidence: number;
355
- claims: ClaimResult[];
356
- mode_warning?: string | null;
357
- processing_time_ms: number;
358
- }
359
- interface SourceChunk {
360
- name: string;
361
- content: string;
362
- }
363
- interface CitationDetail {
364
- citation: string;
365
- source_name: string;
366
- is_valid: boolean;
367
- }
368
- interface VerifyCitationRequest {
369
- text: string;
370
- sources?: SourceChunk[];
371
- threshold?: number;
372
- }
373
- interface VerifyCitationResponse {
374
- citation_ratio: number;
375
- has_sufficient_citations: boolean;
376
- sentence_count: number;
377
- citation_count: number;
378
- uncited_sentences: string[];
379
- citations?: CitationDetail[];
380
- phantom_count?: number;
381
- processing_time_ms: number;
382
- }
383
315
  /** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
384
316
  interface ChatClientLike {
385
317
  chat(request: ChatRequest, options?: RequestOptions): Promise<ChatResponse>;
@@ -503,19 +435,6 @@ declare class HttpClient {
503
435
  * @returns Upload confirmation with document_id and chunks_count
504
436
  */
505
437
  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>;
519
438
  /** POST /v1/query — Query RAG knowledge base */
520
439
  ragQuery(query: string, topK?: number, options?: {
521
440
  debug?: boolean;
@@ -550,36 +469,6 @@ declare class HttpClient {
550
469
  orchestrate(prompt: string): Promise<OrchestratorResponse>;
551
470
  /** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
552
471
  orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
553
- /**
554
- * POST /v1/fact-check — Verify claims against source context.
555
- *
556
- * @param request - Text and source context to verify
557
- * @returns FactCheckResponse with verdict, action, and per-claim results
558
- *
559
- * @example
560
- * ```typescript
561
- * const result = await client.factCheck({
562
- * text: 'Returns accepted within 60 days.',
563
- * source_context: 'Our policy allows returns within 14 days.',
564
- * mode: 'lexical',
565
- * });
566
- * console.log(result.verdict); // "rejected"
567
- * ```
568
- */
569
- factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
570
- /**
571
- * POST /v1/verify — Verify citations in AI-generated text.
572
- *
573
- * @example
574
- * ```ts
575
- * const result = await client.verifyCitation({
576
- * text: 'Rust was released in 2010 [Source: rust_book].',
577
- * sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
578
- * });
579
- * console.log(result.phantom_count); // 0
580
- * ```
581
- */
582
- verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
583
472
  }
584
473
 
585
474
  /**
@@ -700,4 +589,4 @@ declare class ToolNotFoundError extends WauldoError {
700
589
  constructor(toolName: string);
701
590
  }
702
591
 
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 };
592
+ export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, 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 SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, WauldoError, chatContent };
package/dist/index.js CHANGED
@@ -900,16 +900,6 @@ 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
- }
913
903
  function validateResponse(data, typeName) {
914
904
  if (data === null || data === void 0) {
915
905
  throw new ServerError(`Invalid ${typeName}: response is null`, 0);
@@ -1044,51 +1034,6 @@ var HttpClient = class {
1044
1034
  );
1045
1035
  return validateResponse(data, "RagUploadResponse");
1046
1036
  }
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
- }
1092
1037
  /** POST /v1/query — Query RAG knowledge base */
1093
1038
  async ragQuery(query, topK = 5, options) {
1094
1039
  const body = { query, top_k: topK };
@@ -1152,53 +1097,6 @@ ${options.tags}\r
1152
1097
  );
1153
1098
  return validateResponse(data, "OrchestratorResponse");
1154
1099
  }
1155
- // ── Fact-Check endpoints ──────────────────────────────────────────────
1156
- /**
1157
- * POST /v1/fact-check — Verify claims against source context.
1158
- *
1159
- * @param request - Text and source context to verify
1160
- * @returns FactCheckResponse with verdict, action, and per-claim results
1161
- *
1162
- * @example
1163
- * ```typescript
1164
- * const result = await client.factCheck({
1165
- * text: 'Returns accepted within 60 days.',
1166
- * source_context: 'Our policy allows returns within 14 days.',
1167
- * mode: 'lexical',
1168
- * });
1169
- * console.log(result.verdict); // "rejected"
1170
- * ```
1171
- */
1172
- async factCheck(request) {
1173
- const data = await fetchWithRetry(
1174
- this.retryConfig,
1175
- "POST",
1176
- "/v1/fact-check",
1177
- request
1178
- );
1179
- return validateResponse(data, "FactCheckResponse");
1180
- }
1181
- /**
1182
- * POST /v1/verify — Verify citations in AI-generated text.
1183
- *
1184
- * @example
1185
- * ```ts
1186
- * const result = await client.verifyCitation({
1187
- * text: 'Rust was released in 2010 [Source: rust_book].',
1188
- * sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
1189
- * });
1190
- * console.log(result.phantom_count); // 0
1191
- * ```
1192
- */
1193
- async verifyCitation(request) {
1194
- const data = await fetchWithRetry(
1195
- this.retryConfig,
1196
- "POST",
1197
- "/v1/verify",
1198
- request
1199
- );
1200
- return validateResponse(data, "VerifyCitationResponse");
1201
- }
1202
1100
  };
1203
1101
 
1204
1102
  // src/mock_client.ts
package/dist/index.mjs CHANGED
@@ -864,16 +864,6 @@ 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
- }
877
867
  function validateResponse(data, typeName) {
878
868
  if (data === null || data === void 0) {
879
869
  throw new ServerError(`Invalid ${typeName}: response is null`, 0);
@@ -1008,51 +998,6 @@ var HttpClient = class {
1008
998
  );
1009
999
  return validateResponse(data, "RagUploadResponse");
1010
1000
  }
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
- }
1056
1001
  /** POST /v1/query — Query RAG knowledge base */
1057
1002
  async ragQuery(query, topK = 5, options) {
1058
1003
  const body = { query, top_k: topK };
@@ -1116,53 +1061,6 @@ ${options.tags}\r
1116
1061
  );
1117
1062
  return validateResponse(data, "OrchestratorResponse");
1118
1063
  }
1119
- // ── Fact-Check endpoints ──────────────────────────────────────────────
1120
- /**
1121
- * POST /v1/fact-check — Verify claims against source context.
1122
- *
1123
- * @param request - Text and source context to verify
1124
- * @returns FactCheckResponse with verdict, action, and per-claim results
1125
- *
1126
- * @example
1127
- * ```typescript
1128
- * const result = await client.factCheck({
1129
- * text: 'Returns accepted within 60 days.',
1130
- * source_context: 'Our policy allows returns within 14 days.',
1131
- * mode: 'lexical',
1132
- * });
1133
- * console.log(result.verdict); // "rejected"
1134
- * ```
1135
- */
1136
- async factCheck(request) {
1137
- const data = await fetchWithRetry(
1138
- this.retryConfig,
1139
- "POST",
1140
- "/v1/fact-check",
1141
- request
1142
- );
1143
- return validateResponse(data, "FactCheckResponse");
1144
- }
1145
- /**
1146
- * POST /v1/verify — Verify citations in AI-generated text.
1147
- *
1148
- * @example
1149
- * ```ts
1150
- * const result = await client.verifyCitation({
1151
- * text: 'Rust was released in 2010 [Source: rust_book].',
1152
- * sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
1153
- * });
1154
- * console.log(result.phantom_count); // 0
1155
- * ```
1156
- */
1157
- async verifyCitation(request) {
1158
- const data = await fetchWithRetry(
1159
- this.retryConfig,
1160
- "POST",
1161
- "/v1/verify",
1162
- request
1163
- );
1164
- return validateResponse(data, "VerifyCitationResponse");
1165
- }
1166
1064
  };
1167
1065
 
1168
1066
  // src/mock_client.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wauldo",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",