wauldo 0.7.0 → 0.7.2
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 +9 -37
- package/dist/index.d.mts +20 -198
- package/dist/index.d.ts +20 -198
- package/dist/index.js +50 -285
- package/dist/index.mjs +47 -284
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,35 +28,12 @@
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Quickstart (30 seconds)
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
34
|
npm install wauldo
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
```typescript
|
|
38
|
-
import { MockHttpClient } from 'wauldo';
|
|
39
|
-
|
|
40
|
-
const client = new MockHttpClient();
|
|
41
|
-
|
|
42
|
-
// Upload, query, fact-check — all offline
|
|
43
|
-
await client.ragUpload('Refund policy allows returns within 60 days.', 'policy.txt');
|
|
44
|
-
const result = await client.ragQuery('What is the refund policy?');
|
|
45
|
-
console.log(result.answer); // "Mock answer for: What is the refund policy?"
|
|
46
|
-
|
|
47
|
-
const check = await client.factCheck({
|
|
48
|
-
text: 'Returns accepted within 30 days.',
|
|
49
|
-
source_context: 'Refund policy allows returns within 60 days.',
|
|
50
|
-
});
|
|
51
|
-
console.log(check.verdict); // "rejected"
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Run the full quickstart: `npx tsx examples/quickstart.ts`
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Quickstart with real API
|
|
59
|
-
|
|
60
37
|
```typescript
|
|
61
38
|
import { HttpClient } from 'wauldo';
|
|
62
39
|
|
|
@@ -126,14 +103,14 @@ console.log(`Confidence: ${Math.round(result.audit.confidence * 100)}%`);
|
|
|
126
103
|
console.log(`Grounded: ${result.audit.grounded}`);
|
|
127
104
|
```
|
|
128
105
|
|
|
129
|
-
###
|
|
106
|
+
### Guard — fact-check any LLM output
|
|
130
107
|
|
|
131
108
|
```typescript
|
|
132
|
-
const result = await client.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
109
|
+
const result = await client.guard(
|
|
110
|
+
'Returns are accepted within 60 days.',
|
|
111
|
+
'Our policy allows returns within 14 days.',
|
|
112
|
+
'lexical',
|
|
113
|
+
);
|
|
137
114
|
console.log(result.verdict); // "rejected"
|
|
138
115
|
console.log(result.action); // "block"
|
|
139
116
|
console.log(result.claims[0].reason); // "numerical_mismatch"
|
|
@@ -172,10 +149,7 @@ const followUp = await conv.say('Give me an example');
|
|
|
172
149
|
|
|
173
150
|
- **Pre-generation fact extraction** — numbers, dates, limits injected as constraints
|
|
174
151
|
- **Post-generation grounding check** — every answer verified against sources
|
|
175
|
-
- **
|
|
176
|
-
- **Analytics & Insights** — track token savings, cache performance, cost per hour, and per-tenant traffic
|
|
177
|
-
- **Guard method** — one-call hallucination firewall (`client.guard(text, source)` → safe/unsafe)
|
|
178
|
-
- **Fact-check API** — verify any claim against any source (3 modes)
|
|
152
|
+
- **Guard API** — verify any claim against any source (3 modes: lexical, hybrid, semantic)
|
|
179
153
|
- **Native PDF/DOCX upload** — server-side extraction with quality scoring
|
|
180
154
|
- **Smart model routing** — auto-selects cheapest model that meets quality
|
|
181
155
|
- **OpenAI-compatible** — swap your `baseUrl`, keep your existing code
|
|
@@ -219,9 +193,7 @@ Free tier (300 req/month): [RapidAPI](https://rapidapi.com/binnewzzin/api/smart-
|
|
|
219
193
|
|
|
220
194
|
## Contributing
|
|
221
195
|
|
|
222
|
-
PRs welcome
|
|
223
|
-
|
|
224
|
-
Check the [good first issues](https://github.com/wauldo/wauldo-sdk-js/labels/good%20first%20issue) to get started.
|
|
196
|
+
PRs welcome. Check the [good first issues](https://github.com/wauldo/wauldo-sdk-js/labels/good%20first%20issue).
|
|
225
197
|
|
|
226
198
|
## License
|
|
227
199
|
|
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;
|
|
@@ -325,69 +309,7 @@ interface RagQueryResponse {
|
|
|
325
309
|
confidence?: number;
|
|
326
310
|
grounded?: boolean;
|
|
327
311
|
}
|
|
328
|
-
|
|
329
|
-
final_output: string;
|
|
330
|
-
}
|
|
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
|
-
/** @deprecated Use GuardResponse instead */
|
|
384
|
-
interface GuardResult {
|
|
385
|
-
safe: boolean;
|
|
386
|
-
verdict: string;
|
|
387
|
-
action: string;
|
|
388
|
-
reason: string | null;
|
|
389
|
-
confidence: number;
|
|
390
|
-
}
|
|
312
|
+
/** A single verified claim from the Guard response */
|
|
391
313
|
interface GuardClaim {
|
|
392
314
|
text: string;
|
|
393
315
|
claim_type?: string;
|
|
@@ -399,6 +321,7 @@ interface GuardClaim {
|
|
|
399
321
|
reason?: string | null;
|
|
400
322
|
evidence?: string | null;
|
|
401
323
|
}
|
|
324
|
+
/** Response from POST /v1/fact-check — the Guard verification API */
|
|
402
325
|
interface GuardResponse {
|
|
403
326
|
verdict: string;
|
|
404
327
|
action: string;
|
|
@@ -411,51 +334,14 @@ interface GuardResponse {
|
|
|
411
334
|
mode_warning?: string;
|
|
412
335
|
processing_time_ms?: number;
|
|
413
336
|
}
|
|
337
|
+
/** Check if a GuardResponse allows the content through */
|
|
338
|
+
declare function guardIsSafe(response: GuardResponse): boolean;
|
|
339
|
+
/** Check if a GuardResponse blocks the content */
|
|
340
|
+
declare function guardIsBlocked(response: GuardResponse): boolean;
|
|
341
|
+
/** Guard verification modes */
|
|
414
342
|
type GuardMode = 'lexical' | 'hybrid' | 'semantic';
|
|
415
|
-
interface
|
|
416
|
-
|
|
417
|
-
total_requests: number;
|
|
418
|
-
intelligence_requests: number;
|
|
419
|
-
fallback_requests: number;
|
|
420
|
-
tokens: {
|
|
421
|
-
baseline_total: number;
|
|
422
|
-
real_total: number;
|
|
423
|
-
saved_total: number;
|
|
424
|
-
saved_percent_avg: number;
|
|
425
|
-
};
|
|
426
|
-
cost: {
|
|
427
|
-
estimated_usd_saved: number;
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
interface AnalyticsResponse {
|
|
431
|
-
cache: {
|
|
432
|
-
total_requests: number;
|
|
433
|
-
cache_hit_rate: number;
|
|
434
|
-
avg_latency_ms: number;
|
|
435
|
-
p95_latency_ms: number;
|
|
436
|
-
};
|
|
437
|
-
tokens: {
|
|
438
|
-
total_baseline: number;
|
|
439
|
-
total_real: number;
|
|
440
|
-
total_saved: number;
|
|
441
|
-
avg_savings_percent: number;
|
|
442
|
-
};
|
|
443
|
-
uptime_secs: number;
|
|
444
|
-
}
|
|
445
|
-
interface TrafficSummary {
|
|
446
|
-
total_requests_today: number;
|
|
447
|
-
total_tokens_today: number;
|
|
448
|
-
top_tenants: Array<{
|
|
449
|
-
tenant_id: string;
|
|
450
|
-
requests_today: number;
|
|
451
|
-
tokens_used: number;
|
|
452
|
-
success_rate: number;
|
|
453
|
-
avg_latency_ms: number;
|
|
454
|
-
}>;
|
|
455
|
-
error_rate: number;
|
|
456
|
-
avg_latency_ms: number;
|
|
457
|
-
p95_latency_ms: number;
|
|
458
|
-
uptime_secs: number;
|
|
343
|
+
interface OrchestratorResponse {
|
|
344
|
+
final_output: string;
|
|
459
345
|
}
|
|
460
346
|
/** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
|
|
461
347
|
interface ChatClientLike {
|
|
@@ -580,19 +466,6 @@ declare class HttpClient {
|
|
|
580
466
|
* @returns Upload confirmation with document_id and chunks_count
|
|
581
467
|
*/
|
|
582
468
|
ragUpload(content: string, filename?: string, options?: RequestOptions): Promise<RagUploadResponse>;
|
|
583
|
-
/**
|
|
584
|
-
* POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
|
|
585
|
-
*
|
|
586
|
-
* @param file - File content as Buffer/Uint8Array
|
|
587
|
-
* @param filename - The filename (determines content type detection)
|
|
588
|
-
* @param options - Optional title, tags, timeoutMs
|
|
589
|
-
* @returns Upload confirmation with quality scoring
|
|
590
|
-
*/
|
|
591
|
-
uploadFile(file: Uint8Array | Buffer, filename: string, options?: {
|
|
592
|
-
title?: string;
|
|
593
|
-
tags?: string;
|
|
594
|
-
timeoutMs?: number;
|
|
595
|
-
}): Promise<UploadFileResponse>;
|
|
596
469
|
/** POST /v1/query — Query RAG knowledge base */
|
|
597
470
|
ragQuery(query: string, topK?: number, options?: {
|
|
598
471
|
debug?: boolean;
|
|
@@ -623,49 +496,16 @@ declare class HttpClient {
|
|
|
623
496
|
* @returns The answer string
|
|
624
497
|
*/
|
|
625
498
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
626
|
-
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
627
|
-
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
628
|
-
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
629
|
-
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
630
|
-
/**
|
|
631
|
-
* POST /v1/fact-check — Verify claims against source context.
|
|
632
|
-
*
|
|
633
|
-
* @param request - Text and source context to verify
|
|
634
|
-
* @returns FactCheckResponse with verdict, action, and per-claim results
|
|
635
|
-
*
|
|
636
|
-
* @example
|
|
637
|
-
* ```typescript
|
|
638
|
-
* const result = await client.factCheck({
|
|
639
|
-
* text: 'Returns accepted within 60 days.',
|
|
640
|
-
* source_context: 'Our policy allows returns within 14 days.',
|
|
641
|
-
* mode: 'lexical',
|
|
642
|
-
* });
|
|
643
|
-
* console.log(result.verdict); // "rejected"
|
|
644
|
-
* ```
|
|
645
|
-
*/
|
|
646
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
647
|
-
/**
|
|
648
|
-
* POST /v1/verify — Verify citations in AI-generated text.
|
|
649
|
-
*
|
|
650
|
-
* @example
|
|
651
|
-
* ```ts
|
|
652
|
-
* const result = await client.verifyCitation({
|
|
653
|
-
* text: 'Rust was released in 2010 [Source: rust_book].',
|
|
654
|
-
* sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
|
|
655
|
-
* });
|
|
656
|
-
* console.log(result.phantom_count); // 0
|
|
657
|
-
* ```
|
|
658
|
-
*/
|
|
659
|
-
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
660
499
|
/**
|
|
661
500
|
* POST /v1/fact-check — Verify text claims against source context.
|
|
662
501
|
*
|
|
663
|
-
* Guard is a hallucination firewall: checks whether LLM output is
|
|
664
|
-
*
|
|
502
|
+
* Guard is a hallucination firewall: checks whether LLM output is supported
|
|
503
|
+
* by source documents. Blocks wrong answers before they reach users.
|
|
665
504
|
*
|
|
666
505
|
* @param text - The LLM-generated text to verify
|
|
667
506
|
* @param sourceContext - The ground-truth source document(s)
|
|
668
507
|
* @param mode - "lexical" (<1ms), "hybrid" (~50ms), or "semantic" (~500ms)
|
|
508
|
+
* @param options - Optional per-request overrides
|
|
669
509
|
*
|
|
670
510
|
* @example
|
|
671
511
|
* ```typescript
|
|
@@ -673,24 +513,16 @@ declare class HttpClient {
|
|
|
673
513
|
* 'Returns accepted within 60 days',
|
|
674
514
|
* 'Our return policy: 14 days.',
|
|
675
515
|
* );
|
|
676
|
-
* if (
|
|
516
|
+
* if (result.action === 'block') {
|
|
677
517
|
* console.log('Hallucination caught:', result.claims[0]?.reason);
|
|
678
518
|
* }
|
|
679
519
|
* ```
|
|
680
520
|
*/
|
|
681
|
-
guard(text: string, sourceContext: string, mode?: GuardMode): Promise<GuardResponse>;
|
|
682
|
-
/**
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* GET /v1/analytics — Usage analytics and cache performance
|
|
688
|
-
*/
|
|
689
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
690
|
-
/**
|
|
691
|
-
* GET /v1/analytics/traffic — Per-tenant traffic monitoring
|
|
692
|
-
*/
|
|
693
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
521
|
+
guard(text: string, sourceContext: string, mode?: GuardMode, options?: RequestOptions): Promise<GuardResponse>;
|
|
522
|
+
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
523
|
+
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
524
|
+
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
525
|
+
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
694
526
|
}
|
|
695
527
|
|
|
696
528
|
/**
|
|
@@ -761,17 +593,7 @@ declare class MockHttpClient {
|
|
|
761
593
|
system?: string;
|
|
762
594
|
model?: string;
|
|
763
595
|
}): Conversation;
|
|
764
|
-
|
|
765
|
-
title?: string;
|
|
766
|
-
tags?: string;
|
|
767
|
-
timeoutMs?: number;
|
|
768
|
-
}): Promise<UploadFileResponse>;
|
|
769
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
770
|
-
guard(text: string, sourceContext: string, mode?: 'lexical' | 'hybrid' | 'semantic'): Promise<GuardResponse>;
|
|
771
|
-
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
772
|
-
getInsights(): Promise<InsightsResponse>;
|
|
773
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
774
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
596
|
+
guard(text: string, sourceContext: string, mode?: GuardMode, _options?: RequestOptions): Promise<GuardResponse>;
|
|
775
597
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
776
598
|
private record;
|
|
777
599
|
}
|
|
@@ -822,4 +644,4 @@ declare class ToolNotFoundError extends WauldoError {
|
|
|
822
644
|
constructor(toolName: string);
|
|
823
645
|
}
|
|
824
646
|
|
|
825
|
-
export { AgentClient, type
|
|
647
|
+
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, type GuardClaim, type GuardMode, type GuardResponse, 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, guardIsBlocked, guardIsSafe };
|
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;
|
|
@@ -325,69 +309,7 @@ interface RagQueryResponse {
|
|
|
325
309
|
confidence?: number;
|
|
326
310
|
grounded?: boolean;
|
|
327
311
|
}
|
|
328
|
-
|
|
329
|
-
final_output: string;
|
|
330
|
-
}
|
|
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
|
-
/** @deprecated Use GuardResponse instead */
|
|
384
|
-
interface GuardResult {
|
|
385
|
-
safe: boolean;
|
|
386
|
-
verdict: string;
|
|
387
|
-
action: string;
|
|
388
|
-
reason: string | null;
|
|
389
|
-
confidence: number;
|
|
390
|
-
}
|
|
312
|
+
/** A single verified claim from the Guard response */
|
|
391
313
|
interface GuardClaim {
|
|
392
314
|
text: string;
|
|
393
315
|
claim_type?: string;
|
|
@@ -399,6 +321,7 @@ interface GuardClaim {
|
|
|
399
321
|
reason?: string | null;
|
|
400
322
|
evidence?: string | null;
|
|
401
323
|
}
|
|
324
|
+
/** Response from POST /v1/fact-check — the Guard verification API */
|
|
402
325
|
interface GuardResponse {
|
|
403
326
|
verdict: string;
|
|
404
327
|
action: string;
|
|
@@ -411,51 +334,14 @@ interface GuardResponse {
|
|
|
411
334
|
mode_warning?: string;
|
|
412
335
|
processing_time_ms?: number;
|
|
413
336
|
}
|
|
337
|
+
/** Check if a GuardResponse allows the content through */
|
|
338
|
+
declare function guardIsSafe(response: GuardResponse): boolean;
|
|
339
|
+
/** Check if a GuardResponse blocks the content */
|
|
340
|
+
declare function guardIsBlocked(response: GuardResponse): boolean;
|
|
341
|
+
/** Guard verification modes */
|
|
414
342
|
type GuardMode = 'lexical' | 'hybrid' | 'semantic';
|
|
415
|
-
interface
|
|
416
|
-
|
|
417
|
-
total_requests: number;
|
|
418
|
-
intelligence_requests: number;
|
|
419
|
-
fallback_requests: number;
|
|
420
|
-
tokens: {
|
|
421
|
-
baseline_total: number;
|
|
422
|
-
real_total: number;
|
|
423
|
-
saved_total: number;
|
|
424
|
-
saved_percent_avg: number;
|
|
425
|
-
};
|
|
426
|
-
cost: {
|
|
427
|
-
estimated_usd_saved: number;
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
interface AnalyticsResponse {
|
|
431
|
-
cache: {
|
|
432
|
-
total_requests: number;
|
|
433
|
-
cache_hit_rate: number;
|
|
434
|
-
avg_latency_ms: number;
|
|
435
|
-
p95_latency_ms: number;
|
|
436
|
-
};
|
|
437
|
-
tokens: {
|
|
438
|
-
total_baseline: number;
|
|
439
|
-
total_real: number;
|
|
440
|
-
total_saved: number;
|
|
441
|
-
avg_savings_percent: number;
|
|
442
|
-
};
|
|
443
|
-
uptime_secs: number;
|
|
444
|
-
}
|
|
445
|
-
interface TrafficSummary {
|
|
446
|
-
total_requests_today: number;
|
|
447
|
-
total_tokens_today: number;
|
|
448
|
-
top_tenants: Array<{
|
|
449
|
-
tenant_id: string;
|
|
450
|
-
requests_today: number;
|
|
451
|
-
tokens_used: number;
|
|
452
|
-
success_rate: number;
|
|
453
|
-
avg_latency_ms: number;
|
|
454
|
-
}>;
|
|
455
|
-
error_rate: number;
|
|
456
|
-
avg_latency_ms: number;
|
|
457
|
-
p95_latency_ms: number;
|
|
458
|
-
uptime_secs: number;
|
|
343
|
+
interface OrchestratorResponse {
|
|
344
|
+
final_output: string;
|
|
459
345
|
}
|
|
460
346
|
/** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
|
|
461
347
|
interface ChatClientLike {
|
|
@@ -580,19 +466,6 @@ declare class HttpClient {
|
|
|
580
466
|
* @returns Upload confirmation with document_id and chunks_count
|
|
581
467
|
*/
|
|
582
468
|
ragUpload(content: string, filename?: string, options?: RequestOptions): Promise<RagUploadResponse>;
|
|
583
|
-
/**
|
|
584
|
-
* POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
|
|
585
|
-
*
|
|
586
|
-
* @param file - File content as Buffer/Uint8Array
|
|
587
|
-
* @param filename - The filename (determines content type detection)
|
|
588
|
-
* @param options - Optional title, tags, timeoutMs
|
|
589
|
-
* @returns Upload confirmation with quality scoring
|
|
590
|
-
*/
|
|
591
|
-
uploadFile(file: Uint8Array | Buffer, filename: string, options?: {
|
|
592
|
-
title?: string;
|
|
593
|
-
tags?: string;
|
|
594
|
-
timeoutMs?: number;
|
|
595
|
-
}): Promise<UploadFileResponse>;
|
|
596
469
|
/** POST /v1/query — Query RAG knowledge base */
|
|
597
470
|
ragQuery(query: string, topK?: number, options?: {
|
|
598
471
|
debug?: boolean;
|
|
@@ -623,49 +496,16 @@ declare class HttpClient {
|
|
|
623
496
|
* @returns The answer string
|
|
624
497
|
*/
|
|
625
498
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
626
|
-
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
627
|
-
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
628
|
-
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
629
|
-
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
630
|
-
/**
|
|
631
|
-
* POST /v1/fact-check — Verify claims against source context.
|
|
632
|
-
*
|
|
633
|
-
* @param request - Text and source context to verify
|
|
634
|
-
* @returns FactCheckResponse with verdict, action, and per-claim results
|
|
635
|
-
*
|
|
636
|
-
* @example
|
|
637
|
-
* ```typescript
|
|
638
|
-
* const result = await client.factCheck({
|
|
639
|
-
* text: 'Returns accepted within 60 days.',
|
|
640
|
-
* source_context: 'Our policy allows returns within 14 days.',
|
|
641
|
-
* mode: 'lexical',
|
|
642
|
-
* });
|
|
643
|
-
* console.log(result.verdict); // "rejected"
|
|
644
|
-
* ```
|
|
645
|
-
*/
|
|
646
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
647
|
-
/**
|
|
648
|
-
* POST /v1/verify — Verify citations in AI-generated text.
|
|
649
|
-
*
|
|
650
|
-
* @example
|
|
651
|
-
* ```ts
|
|
652
|
-
* const result = await client.verifyCitation({
|
|
653
|
-
* text: 'Rust was released in 2010 [Source: rust_book].',
|
|
654
|
-
* sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
|
|
655
|
-
* });
|
|
656
|
-
* console.log(result.phantom_count); // 0
|
|
657
|
-
* ```
|
|
658
|
-
*/
|
|
659
|
-
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
660
499
|
/**
|
|
661
500
|
* POST /v1/fact-check — Verify text claims against source context.
|
|
662
501
|
*
|
|
663
|
-
* Guard is a hallucination firewall: checks whether LLM output is
|
|
664
|
-
*
|
|
502
|
+
* Guard is a hallucination firewall: checks whether LLM output is supported
|
|
503
|
+
* by source documents. Blocks wrong answers before they reach users.
|
|
665
504
|
*
|
|
666
505
|
* @param text - The LLM-generated text to verify
|
|
667
506
|
* @param sourceContext - The ground-truth source document(s)
|
|
668
507
|
* @param mode - "lexical" (<1ms), "hybrid" (~50ms), or "semantic" (~500ms)
|
|
508
|
+
* @param options - Optional per-request overrides
|
|
669
509
|
*
|
|
670
510
|
* @example
|
|
671
511
|
* ```typescript
|
|
@@ -673,24 +513,16 @@ declare class HttpClient {
|
|
|
673
513
|
* 'Returns accepted within 60 days',
|
|
674
514
|
* 'Our return policy: 14 days.',
|
|
675
515
|
* );
|
|
676
|
-
* if (
|
|
516
|
+
* if (result.action === 'block') {
|
|
677
517
|
* console.log('Hallucination caught:', result.claims[0]?.reason);
|
|
678
518
|
* }
|
|
679
519
|
* ```
|
|
680
520
|
*/
|
|
681
|
-
guard(text: string, sourceContext: string, mode?: GuardMode): Promise<GuardResponse>;
|
|
682
|
-
/**
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* GET /v1/analytics — Usage analytics and cache performance
|
|
688
|
-
*/
|
|
689
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
690
|
-
/**
|
|
691
|
-
* GET /v1/analytics/traffic — Per-tenant traffic monitoring
|
|
692
|
-
*/
|
|
693
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
521
|
+
guard(text: string, sourceContext: string, mode?: GuardMode, options?: RequestOptions): Promise<GuardResponse>;
|
|
522
|
+
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
523
|
+
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
524
|
+
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
525
|
+
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
694
526
|
}
|
|
695
527
|
|
|
696
528
|
/**
|
|
@@ -761,17 +593,7 @@ declare class MockHttpClient {
|
|
|
761
593
|
system?: string;
|
|
762
594
|
model?: string;
|
|
763
595
|
}): Conversation;
|
|
764
|
-
|
|
765
|
-
title?: string;
|
|
766
|
-
tags?: string;
|
|
767
|
-
timeoutMs?: number;
|
|
768
|
-
}): Promise<UploadFileResponse>;
|
|
769
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
770
|
-
guard(text: string, sourceContext: string, mode?: 'lexical' | 'hybrid' | 'semantic'): Promise<GuardResponse>;
|
|
771
|
-
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
772
|
-
getInsights(): Promise<InsightsResponse>;
|
|
773
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
774
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
596
|
+
guard(text: string, sourceContext: string, mode?: GuardMode, _options?: RequestOptions): Promise<GuardResponse>;
|
|
775
597
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
776
598
|
private record;
|
|
777
599
|
}
|
|
@@ -822,4 +644,4 @@ declare class ToolNotFoundError extends WauldoError {
|
|
|
822
644
|
constructor(toolName: string);
|
|
823
645
|
}
|
|
824
646
|
|
|
825
|
-
export { AgentClient, type
|
|
647
|
+
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, type GuardClaim, type GuardMode, type GuardResponse, 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, guardIsBlocked, guardIsSafe };
|