wauldo 0.1.0 → 0.2.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
@@ -7,10 +7,11 @@
7
7
 
8
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.
9
9
 
10
- Official TypeScript SDK for the [Wauldo API](https://wauldo.com) — the AI inference layer with smart model routing and zero hallucinations.
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
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
15
  - **Zero hallucinations** — every answer is verified against source documents
15
16
  - **Smart model routing** — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
16
17
  - **One API, 7+ providers** — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
@@ -93,6 +94,19 @@ const reply = await conv.say('What are generics?');
93
94
  const followUp = await conv.say('Give me an example');
94
95
  ```
95
96
 
97
+ ### Fact-Check — Verify Claims
98
+
99
+ ```typescript
100
+ const result = await client.factCheck({
101
+ text: 'Returns are accepted within 60 days.',
102
+ source_context: 'Our policy allows returns within 14 days.',
103
+ mode: 'lexical',
104
+ });
105
+ console.log(result.verdict); // "rejected"
106
+ console.log(result.action); // "block"
107
+ result.claims.forEach(c => console.log(`${c.text} → ${c.verdict} (${c.reason})`));
108
+ ```
109
+
96
110
  ## Error Handling
97
111
 
98
112
  ```typescript
package/dist/index.d.mts CHANGED
@@ -248,6 +248,8 @@ interface ChatResponse {
248
248
  choices: ChatChoice[];
249
249
  usage: ChatUsage;
250
250
  }
251
+ /** Get the text content of the first choice, or empty string */
252
+ declare function chatContent(response: ChatResponse): string;
251
253
  interface ModelInfo {
252
254
  id: string;
253
255
  object: string;
@@ -310,6 +312,34 @@ interface RagQueryResponse {
310
312
  interface OrchestratorResponse {
311
313
  final_output: string;
312
314
  }
315
+ interface FactCheckRequest {
316
+ text: string;
317
+ source_context: string;
318
+ mode?: 'lexical' | 'hybrid' | 'semantic';
319
+ }
320
+ interface ClaimResult {
321
+ text: string;
322
+ claim_type: string;
323
+ supported: boolean;
324
+ confidence: number;
325
+ confidence_label: string;
326
+ verdict: string;
327
+ action: string;
328
+ reason?: string | null;
329
+ evidence?: string | null;
330
+ }
331
+ interface FactCheckResponse {
332
+ verdict: string;
333
+ action: string;
334
+ hallucination_rate: number;
335
+ mode: string;
336
+ total_claims: number;
337
+ supported_claims: number;
338
+ confidence: number;
339
+ claims: ClaimResult[];
340
+ mode_warning?: string | null;
341
+ processing_time_ms: number;
342
+ }
313
343
  /** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
314
344
  interface ChatClientLike {
315
345
  chat(request: ChatRequest, options?: RequestOptions): Promise<ChatResponse>;
@@ -467,6 +497,23 @@ declare class HttpClient {
467
497
  orchestrate(prompt: string): Promise<OrchestratorResponse>;
468
498
  /** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
469
499
  orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
500
+ /**
501
+ * POST /v1/fact-check — Verify claims against source context.
502
+ *
503
+ * @param request - Text and source context to verify
504
+ * @returns FactCheckResponse with verdict, action, and per-claim results
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * const result = await client.factCheck({
509
+ * text: 'Returns accepted within 60 days.',
510
+ * source_context: 'Our policy allows returns within 14 days.',
511
+ * mode: 'lexical',
512
+ * });
513
+ * console.log(result.verdict); // "rejected"
514
+ * ```
515
+ */
516
+ factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
470
517
  }
471
518
 
472
519
  /**
@@ -587,4 +634,4 @@ declare class ToolNotFoundError extends WauldoError {
587
634
  constructor(toolName: string);
588
635
  }
589
636
 
590
- 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 };
637
+ export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, 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 SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, WauldoError, chatContent };
package/dist/index.d.ts CHANGED
@@ -248,6 +248,8 @@ interface ChatResponse {
248
248
  choices: ChatChoice[];
249
249
  usage: ChatUsage;
250
250
  }
251
+ /** Get the text content of the first choice, or empty string */
252
+ declare function chatContent(response: ChatResponse): string;
251
253
  interface ModelInfo {
252
254
  id: string;
253
255
  object: string;
@@ -310,6 +312,34 @@ interface RagQueryResponse {
310
312
  interface OrchestratorResponse {
311
313
  final_output: string;
312
314
  }
315
+ interface FactCheckRequest {
316
+ text: string;
317
+ source_context: string;
318
+ mode?: 'lexical' | 'hybrid' | 'semantic';
319
+ }
320
+ interface ClaimResult {
321
+ text: string;
322
+ claim_type: string;
323
+ supported: boolean;
324
+ confidence: number;
325
+ confidence_label: string;
326
+ verdict: string;
327
+ action: string;
328
+ reason?: string | null;
329
+ evidence?: string | null;
330
+ }
331
+ interface FactCheckResponse {
332
+ verdict: string;
333
+ action: string;
334
+ hallucination_rate: number;
335
+ mode: string;
336
+ total_claims: number;
337
+ supported_claims: number;
338
+ confidence: number;
339
+ claims: ClaimResult[];
340
+ mode_warning?: string | null;
341
+ processing_time_ms: number;
342
+ }
313
343
  /** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
314
344
  interface ChatClientLike {
315
345
  chat(request: ChatRequest, options?: RequestOptions): Promise<ChatResponse>;
@@ -467,6 +497,23 @@ declare class HttpClient {
467
497
  orchestrate(prompt: string): Promise<OrchestratorResponse>;
468
498
  /** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
469
499
  orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
500
+ /**
501
+ * POST /v1/fact-check — Verify claims against source context.
502
+ *
503
+ * @param request - Text and source context to verify
504
+ * @returns FactCheckResponse with verdict, action, and per-claim results
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * const result = await client.factCheck({
509
+ * text: 'Returns accepted within 60 days.',
510
+ * source_context: 'Our policy allows returns within 14 days.',
511
+ * mode: 'lexical',
512
+ * });
513
+ * console.log(result.verdict); // "rejected"
514
+ * ```
515
+ */
516
+ factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
470
517
  }
471
518
 
472
519
  /**
@@ -587,4 +634,4 @@ declare class ToolNotFoundError extends WauldoError {
587
634
  constructor(toolName: string);
588
635
  }
589
636
 
590
- 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 };
637
+ export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, 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 SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, WauldoError, chatContent };
package/dist/index.js CHANGED
@@ -29,7 +29,8 @@ __export(index_exports, {
29
29
  TimeoutError: () => TimeoutError,
30
30
  ToolNotFoundError: () => ToolNotFoundError,
31
31
  ValidationError: () => ValidationError,
32
- WauldoError: () => WauldoError
32
+ WauldoError: () => WauldoError,
33
+ chatContent: () => chatContent
33
34
  });
34
35
  module.exports = __toCommonJS(index_exports);
35
36
 
@@ -819,8 +820,14 @@ async function fetchWithRetry(config, method, path, body, overrideTimeoutMs) {
819
820
  continue;
820
821
  }
821
822
  const text = await resp.text();
822
- config.onLog?.("error", `${method} ${path} -> ${resp.status}: ${text}`);
823
- const err = new Error(`HTTP ${resp.status}: ${text}`);
823
+ let message = text;
824
+ try {
825
+ const j = JSON.parse(text);
826
+ if (j?.error?.message) message = j.error.message;
827
+ } catch {
828
+ }
829
+ config.onLog?.("error", `${method} ${path} -> ${resp.status}: ${message}`);
830
+ const err = new Error(`HTTP ${resp.status}: ${message}`);
824
831
  config.onError?.(err);
825
832
  throw err;
826
833
  } catch (err) {
@@ -982,7 +989,13 @@ var HttpClient = class {
982
989
  }
983
990
  if (!resp.ok) {
984
991
  const body = await resp.text();
985
- const err = new ServerError(`HTTP ${resp.status}: ${body}`, resp.status);
992
+ let message = body;
993
+ try {
994
+ const j = JSON.parse(body);
995
+ if (j?.error?.message) message = j.error.message;
996
+ } catch {
997
+ }
998
+ const err = new ServerError(`HTTP ${resp.status}: ${message}`, resp.status);
986
999
  cfg.onError?.(err);
987
1000
  throw err;
988
1001
  }
@@ -1084,6 +1097,32 @@ var HttpClient = class {
1084
1097
  );
1085
1098
  return validateResponse(data, "OrchestratorResponse");
1086
1099
  }
1100
+ // ── Fact-Check endpoints ──────────────────────────────────────────────
1101
+ /**
1102
+ * POST /v1/fact-check — Verify claims against source context.
1103
+ *
1104
+ * @param request - Text and source context to verify
1105
+ * @returns FactCheckResponse with verdict, action, and per-claim results
1106
+ *
1107
+ * @example
1108
+ * ```typescript
1109
+ * const result = await client.factCheck({
1110
+ * text: 'Returns accepted within 60 days.',
1111
+ * source_context: 'Our policy allows returns within 14 days.',
1112
+ * mode: 'lexical',
1113
+ * });
1114
+ * console.log(result.verdict); // "rejected"
1115
+ * ```
1116
+ */
1117
+ async factCheck(request) {
1118
+ const data = await fetchWithRetry(
1119
+ this.retryConfig,
1120
+ "POST",
1121
+ "/v1/fact-check",
1122
+ request
1123
+ );
1124
+ return validateResponse(data, "FactCheckResponse");
1125
+ }
1087
1126
  };
1088
1127
 
1089
1128
  // src/mock_client.ts
@@ -1197,6 +1236,11 @@ var MockHttpClient = class {
1197
1236
  this.calls.push({ method, args });
1198
1237
  }
1199
1238
  };
1239
+
1240
+ // src/http_types.ts
1241
+ function chatContent(response) {
1242
+ return response.choices[0]?.message?.content ?? "";
1243
+ }
1200
1244
  // Annotate the CommonJS export names for ESM import in node:
1201
1245
  0 && (module.exports = {
1202
1246
  AgentClient,
@@ -1208,5 +1252,6 @@ var MockHttpClient = class {
1208
1252
  TimeoutError,
1209
1253
  ToolNotFoundError,
1210
1254
  ValidationError,
1211
- WauldoError
1255
+ WauldoError,
1256
+ chatContent
1212
1257
  });
package/dist/index.mjs CHANGED
@@ -784,8 +784,14 @@ async function fetchWithRetry(config, method, path, body, overrideTimeoutMs) {
784
784
  continue;
785
785
  }
786
786
  const text = await resp.text();
787
- config.onLog?.("error", `${method} ${path} -> ${resp.status}: ${text}`);
788
- const err = new Error(`HTTP ${resp.status}: ${text}`);
787
+ let message = text;
788
+ try {
789
+ const j = JSON.parse(text);
790
+ if (j?.error?.message) message = j.error.message;
791
+ } catch {
792
+ }
793
+ config.onLog?.("error", `${method} ${path} -> ${resp.status}: ${message}`);
794
+ const err = new Error(`HTTP ${resp.status}: ${message}`);
789
795
  config.onError?.(err);
790
796
  throw err;
791
797
  } catch (err) {
@@ -947,7 +953,13 @@ var HttpClient = class {
947
953
  }
948
954
  if (!resp.ok) {
949
955
  const body = await resp.text();
950
- const err = new ServerError(`HTTP ${resp.status}: ${body}`, resp.status);
956
+ let message = body;
957
+ try {
958
+ const j = JSON.parse(body);
959
+ if (j?.error?.message) message = j.error.message;
960
+ } catch {
961
+ }
962
+ const err = new ServerError(`HTTP ${resp.status}: ${message}`, resp.status);
951
963
  cfg.onError?.(err);
952
964
  throw err;
953
965
  }
@@ -1049,6 +1061,32 @@ var HttpClient = class {
1049
1061
  );
1050
1062
  return validateResponse(data, "OrchestratorResponse");
1051
1063
  }
1064
+ // ── Fact-Check endpoints ──────────────────────────────────────────────
1065
+ /**
1066
+ * POST /v1/fact-check — Verify claims against source context.
1067
+ *
1068
+ * @param request - Text and source context to verify
1069
+ * @returns FactCheckResponse with verdict, action, and per-claim results
1070
+ *
1071
+ * @example
1072
+ * ```typescript
1073
+ * const result = await client.factCheck({
1074
+ * text: 'Returns accepted within 60 days.',
1075
+ * source_context: 'Our policy allows returns within 14 days.',
1076
+ * mode: 'lexical',
1077
+ * });
1078
+ * console.log(result.verdict); // "rejected"
1079
+ * ```
1080
+ */
1081
+ async factCheck(request) {
1082
+ const data = await fetchWithRetry(
1083
+ this.retryConfig,
1084
+ "POST",
1085
+ "/v1/fact-check",
1086
+ request
1087
+ );
1088
+ return validateResponse(data, "FactCheckResponse");
1089
+ }
1052
1090
  };
1053
1091
 
1054
1092
  // src/mock_client.ts
@@ -1162,6 +1200,11 @@ var MockHttpClient = class {
1162
1200
  this.calls.push({ method, args });
1163
1201
  }
1164
1202
  };
1203
+
1204
+ // src/http_types.ts
1205
+ function chatContent(response) {
1206
+ return response.choices[0]?.message?.content ?? "";
1207
+ }
1165
1208
  export {
1166
1209
  AgentClient,
1167
1210
  ConnectionError,
@@ -1172,5 +1215,6 @@ export {
1172
1215
  TimeoutError,
1173
1216
  ToolNotFoundError,
1174
1217
  ValidationError,
1175
- WauldoError
1218
+ WauldoError,
1219
+ chatContent
1176
1220
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wauldo",
3
- "version": "0.1.0",
3
+ "version": "0.2.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",