@veroq/sdk 2.0.0 → 2.1.1
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 +49 -2
- package/dist/cjs/agent.js +1 -1
- package/dist/cjs/agent.js.map +1 -1
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/client.d.ts +53 -0
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +116 -1
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +9 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/middleware.d.ts +46 -0
- package/dist/cjs/middleware.d.ts.map +1 -0
- package/dist/cjs/middleware.js +133 -0
- package/dist/cjs/middleware.js.map +1 -0
- package/dist/cjs/shield.d.ts +169 -0
- package/dist/cjs/shield.d.ts.map +1 -0
- package/dist/cjs/shield.js +245 -0
- package/dist/cjs/shield.js.map +1 -0
- package/dist/esm/agent.js +1 -1
- package/dist/esm/agent.js.map +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/client.d.ts +53 -0
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +116 -1
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/middleware.d.ts +46 -0
- package/dist/esm/middleware.d.ts.map +1 -0
- package/dist/esm/middleware.js +128 -0
- package/dist/esm/middleware.js.map +1 -0
- package/dist/esm/shield.d.ts +169 -0
- package/dist/esm/shield.d.ts.map +1 -0
- package/dist/esm/shield.js +239 -0
- package/dist/esm/shield.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeroQ Middleware — Auto-shield LLM responses in any framework.
|
|
3
|
+
*
|
|
4
|
+
* @example OpenAI wrapper
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { shieldOpenAI } from "@veroq/sdk";
|
|
7
|
+
* import OpenAI from "openai";
|
|
8
|
+
*
|
|
9
|
+
* const client = shieldOpenAI(new OpenAI());
|
|
10
|
+
* const response = await client.chat.completions.create({
|
|
11
|
+
* model: "gpt-4o",
|
|
12
|
+
* messages: [{ role: "user", content: "What's NVIDIA's revenue?" }],
|
|
13
|
+
* });
|
|
14
|
+
* console.log(response.choices[0].message.content);
|
|
15
|
+
* console.log(response.veroqShield.trustScore); // 0.85
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example Express middleware
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { shieldMiddleware } from "@veroq/sdk";
|
|
21
|
+
* app.use("/api/ai", shieldMiddleware({ threshold: 0.7 }));
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
import { shield, ShieldResult } from "./shield.js";
|
|
25
|
+
export function shieldOpenAI(client, options = {}) {
|
|
26
|
+
const source = options.source || "openai";
|
|
27
|
+
const originalCreate = client.chat.completions.create.bind(client.chat.completions);
|
|
28
|
+
client.chat.completions.create = async function (...args) {
|
|
29
|
+
const response = await originalCreate(...args);
|
|
30
|
+
try {
|
|
31
|
+
const text = response.choices?.[0]?.message?.content || "";
|
|
32
|
+
const model = response.model || source;
|
|
33
|
+
if (text.trim().length >= 20) {
|
|
34
|
+
response.veroqShield = await shield(text, {
|
|
35
|
+
source: model,
|
|
36
|
+
agentId: options.agentId,
|
|
37
|
+
maxClaims: options.maxClaims,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
response.veroqShield = new ShieldResult({
|
|
42
|
+
text, claims: [], overall_confidence: 1.0, overall_verdict: "no_claims",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
response.veroqShield = new ShieldResult({
|
|
48
|
+
text: "", claims: [], overall_confidence: 0, overall_verdict: "error",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return response;
|
|
52
|
+
};
|
|
53
|
+
return client;
|
|
54
|
+
}
|
|
55
|
+
// ── Anthropic Wrapper ──
|
|
56
|
+
export function shieldAnthropic(client, options = {}) {
|
|
57
|
+
const source = options.source || "anthropic";
|
|
58
|
+
const originalCreate = client.messages.create.bind(client.messages);
|
|
59
|
+
client.messages.create = async function (...args) {
|
|
60
|
+
const response = await originalCreate(...args);
|
|
61
|
+
try {
|
|
62
|
+
const text = response.content?.[0]?.text || "";
|
|
63
|
+
const model = response.model || source;
|
|
64
|
+
if (text.trim().length >= 20) {
|
|
65
|
+
response.veroqShield = await shield(text, {
|
|
66
|
+
source: model,
|
|
67
|
+
agentId: options.agentId,
|
|
68
|
+
maxClaims: options.maxClaims,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
response.veroqShield = new ShieldResult({
|
|
73
|
+
text, claims: [], overall_confidence: 1.0, overall_verdict: "no_claims",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
response.veroqShield = new ShieldResult({
|
|
79
|
+
text: "", claims: [], overall_confidence: 0, overall_verdict: "error",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return response;
|
|
83
|
+
};
|
|
84
|
+
return client;
|
|
85
|
+
}
|
|
86
|
+
// ── Express Middleware ──
|
|
87
|
+
export function shieldMiddleware(options = {}) {
|
|
88
|
+
const threshold = options.threshold ?? 0;
|
|
89
|
+
return (req, res, next) => {
|
|
90
|
+
const originalJson = res.json.bind(res);
|
|
91
|
+
res.json = async function (body) {
|
|
92
|
+
// Only shield responses that have text content
|
|
93
|
+
const text = typeof body === "string" ? body
|
|
94
|
+
: body?.text || body?.content || body?.message || body?.summary || body?.answer;
|
|
95
|
+
if (text && typeof text === "string" && text.length >= 20) {
|
|
96
|
+
try {
|
|
97
|
+
const result = await shield(text, {
|
|
98
|
+
source: options.source,
|
|
99
|
+
agentId: options.agentId,
|
|
100
|
+
maxClaims: options.maxClaims,
|
|
101
|
+
});
|
|
102
|
+
body._veroqShield = {
|
|
103
|
+
trustScore: result.trustScore,
|
|
104
|
+
isTrusted: result.isTrusted,
|
|
105
|
+
claimsChecked: result.claimsExtracted,
|
|
106
|
+
corrections: result.corrections,
|
|
107
|
+
receiptIds: result.receiptIds,
|
|
108
|
+
};
|
|
109
|
+
if (options.blockIfUntrusted && !result.isTrusted) {
|
|
110
|
+
return originalJson.call(this, {
|
|
111
|
+
error: "Response blocked by VeroQ Shield — claims contradicted",
|
|
112
|
+
shield: body._veroqShield,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (threshold > 0 && result.trustScore < threshold) {
|
|
116
|
+
body._veroqShield.belowThreshold = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Shield failure is non-blocking
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return originalJson.call(this, body);
|
|
124
|
+
};
|
|
125
|
+
next();
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASnD,MAAM,UAAU,YAAY,CAAC,MAAW,EAAE,UAItC,EAAE;IACJ,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC;IAE1C,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IA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AC,UAAU,GAAG,SAAS,EAAE,CAAC;wBACnD,IAAI,CAAC,YAAY,CAAC,cAAc,GAAG,IAAI,CAAC;oBAC1C,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,iCAAiC;gBACnC,CAAC;YACH,CAAC;YAED,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeroQ Prompt Shield — One-line verification for any LLM output.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { shield } from "@veroq/sdk";
|
|
7
|
+
*
|
|
8
|
+
* const result = await shield("NVIDIA reported $22B in Q4 revenue");
|
|
9
|
+
* console.log(result.trustScore); // 0.73
|
|
10
|
+
* console.log(result.isTrusted); // false
|
|
11
|
+
* console.log(result.corrections); // [{claim, correction, confidence}]
|
|
12
|
+
* console.log(result.verifiedText); // text with corrections inline
|
|
13
|
+
*
|
|
14
|
+
* // Wrap any LLM call
|
|
15
|
+
* const response = await openai.chat.completions.create({...});
|
|
16
|
+
* const verified = await shield(response.choices[0].message.content);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface ShieldOptions {
|
|
20
|
+
/** Source identifier (e.g., "gpt-4o", "claude-3") */
|
|
21
|
+
source?: string;
|
|
22
|
+
/** Agent ID for memory integration */
|
|
23
|
+
agentId?: string;
|
|
24
|
+
/** Max claims to extract (1-10, default 5) */
|
|
25
|
+
maxClaims?: number;
|
|
26
|
+
/** API key override */
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
/** API base URL override */
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
/** If true, throws VeroqError when claims are contradicted */
|
|
31
|
+
blockIfUntrusted?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ShieldClaim {
|
|
34
|
+
text: string;
|
|
35
|
+
category: string;
|
|
36
|
+
verdict: string;
|
|
37
|
+
confidence: number;
|
|
38
|
+
correction: string | null;
|
|
39
|
+
receiptId: string | null;
|
|
40
|
+
evidenceChain: Array<{
|
|
41
|
+
source: string;
|
|
42
|
+
position: string;
|
|
43
|
+
snippet: string;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export declare class ShieldResult {
|
|
47
|
+
/** Original text (truncated) */
|
|
48
|
+
readonly text: string;
|
|
49
|
+
/** Source identifier */
|
|
50
|
+
readonly source: string;
|
|
51
|
+
/** All extracted claims with verdicts */
|
|
52
|
+
readonly claims: ShieldClaim[];
|
|
53
|
+
/** Number of claims extracted */
|
|
54
|
+
readonly claimsExtracted: number;
|
|
55
|
+
/** Number of claims verified */
|
|
56
|
+
readonly claimsVerified: number;
|
|
57
|
+
/** Number of claims supported */
|
|
58
|
+
readonly claimsSupported: number;
|
|
59
|
+
/** Number of claims contradicted */
|
|
60
|
+
readonly claimsContradicted: number;
|
|
61
|
+
/** Overall trust score (0-1) */
|
|
62
|
+
readonly trustScore: number;
|
|
63
|
+
/** Overall verdict */
|
|
64
|
+
readonly overallVerdict: string;
|
|
65
|
+
/** Summary */
|
|
66
|
+
readonly summary: string;
|
|
67
|
+
/** Credits used */
|
|
68
|
+
readonly creditsUsed: number;
|
|
69
|
+
/** Processing time in ms */
|
|
70
|
+
readonly processingTimeMs: number;
|
|
71
|
+
/** Full original text (before server truncation) */
|
|
72
|
+
private readonly _fullText;
|
|
73
|
+
constructor(raw: Record<string, any>, fullText?: string);
|
|
74
|
+
/** True if no claims were contradicted */
|
|
75
|
+
get isTrusted(): boolean;
|
|
76
|
+
/** Corrections for contradicted claims */
|
|
77
|
+
get corrections(): Array<{
|
|
78
|
+
claim: string;
|
|
79
|
+
correction: string;
|
|
80
|
+
confidence: number;
|
|
81
|
+
}>;
|
|
82
|
+
/** Text with contradicted claims annotated */
|
|
83
|
+
get verifiedText(): string;
|
|
84
|
+
/** Verification receipt IDs */
|
|
85
|
+
get receiptIds(): string[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Shield any LLM output with VeroQ verification.
|
|
89
|
+
*
|
|
90
|
+
* Extracts claims, verifies each against evidence, returns trust score
|
|
91
|
+
* with corrections for any contradicted claims.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* import { shield } from "@veroq/sdk";
|
|
96
|
+
*
|
|
97
|
+
* // Basic
|
|
98
|
+
* const result = await shield("NVIDIA's Q4 revenue exceeded $22B");
|
|
99
|
+
* console.log(result.trustScore, result.corrections);
|
|
100
|
+
*
|
|
101
|
+
* // With options
|
|
102
|
+
* const result = await shield(llmOutput, {
|
|
103
|
+
* source: "gpt-4o",
|
|
104
|
+
* agentId: "my-bot",
|
|
105
|
+
* blockIfUntrusted: true,
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function shield(text: string, options?: ShieldOptions): Promise<ShieldResult>;
|
|
110
|
+
export interface CachedShieldOptions {
|
|
111
|
+
/** Maximum entries in the LRU cache (default 500) */
|
|
112
|
+
maxCache?: number;
|
|
113
|
+
/** Time-to-live for cached results in milliseconds (default 3_600_000 = 1 hour) */
|
|
114
|
+
ttlMs?: number;
|
|
115
|
+
/** API key override */
|
|
116
|
+
apiKey?: string;
|
|
117
|
+
/** API base URL override */
|
|
118
|
+
baseUrl?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface CachedShieldStats {
|
|
121
|
+
hits: number;
|
|
122
|
+
misses: number;
|
|
123
|
+
hitRate: number;
|
|
124
|
+
size: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Lightweight shield with local caching for repeated verifications.
|
|
128
|
+
*
|
|
129
|
+
* Caches results by SHA-256 hash of text. Reduces API calls for repeated or
|
|
130
|
+
* similar content. Useful for high-volume pipelines or edge/offline scenarios.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* import { CachedShield } from "@veroq/sdk";
|
|
135
|
+
*
|
|
136
|
+
* const cached = new CachedShield({ maxCache: 1000, ttlMs: 30 * 60_000 });
|
|
137
|
+
* const r1 = await cached.shield("NVIDIA reported $22B in Q4 revenue"); // API call
|
|
138
|
+
* const r2 = await cached.shield("NVIDIA reported $22B in Q4 revenue"); // instant cache hit
|
|
139
|
+
* console.log(cached.stats()); // { hits: 1, misses: 1, hitRate: 0.5, size: 1 }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export declare class CachedShield {
|
|
143
|
+
private readonly _maxCache;
|
|
144
|
+
private readonly _ttlMs;
|
|
145
|
+
private readonly _apiKey?;
|
|
146
|
+
private readonly _baseUrl?;
|
|
147
|
+
private readonly _cache;
|
|
148
|
+
private readonly _inFlight;
|
|
149
|
+
private _hits;
|
|
150
|
+
private _misses;
|
|
151
|
+
private _lastEvict;
|
|
152
|
+
constructor(options?: CachedShieldOptions);
|
|
153
|
+
private static _hashText;
|
|
154
|
+
private _evictExpired;
|
|
155
|
+
private _evictLru;
|
|
156
|
+
/**
|
|
157
|
+
* Verify text using cached shield.
|
|
158
|
+
*
|
|
159
|
+
* Checks local cache first (by SHA-256 of text). On miss, calls the
|
|
160
|
+
* regular shield() function and stores the result. Deduplicates
|
|
161
|
+
* concurrent calls for the same text.
|
|
162
|
+
*/
|
|
163
|
+
shield(text: string, options?: ShieldOptions): Promise<ShieldResult>;
|
|
164
|
+
/** Return cache hit/miss statistics. */
|
|
165
|
+
stats(): CachedShieldStats;
|
|
166
|
+
/** Clear the cache and reset stats. */
|
|
167
|
+
clear(): void;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=shield.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shield.d.ts","sourceRoot":"","sources":["../../src/shield.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA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GAeG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAC7D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiD;IAC3E,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,UAAU,CAAK;gBAEX,OAAO,GAAE,mBAAwB;IAO7C,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,SAAS;IAQjB;;;;;;OAMG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAwC9E,wCAAwC;IACxC,KAAK,IAAI,iBAAiB;IAU1B,uCAAuC;IACvC,KAAK,IAAI,IAAI;CAMd"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeroQ Prompt Shield — One-line verification for any LLM output.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { shield } from "@veroq/sdk";
|
|
7
|
+
*
|
|
8
|
+
* const result = await shield("NVIDIA reported $22B in Q4 revenue");
|
|
9
|
+
* console.log(result.trustScore); // 0.73
|
|
10
|
+
* console.log(result.isTrusted); // false
|
|
11
|
+
* console.log(result.corrections); // [{claim, correction, confidence}]
|
|
12
|
+
* console.log(result.verifiedText); // text with corrections inline
|
|
13
|
+
*
|
|
14
|
+
* // Wrap any LLM call
|
|
15
|
+
* const response = await openai.chat.completions.create({...});
|
|
16
|
+
* const verified = await shield(response.choices[0].message.content);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { createHash } from "node:crypto";
|
|
20
|
+
import { VeroqClient } from "./client.js";
|
|
21
|
+
import { VeroqError } from "./errors.js";
|
|
22
|
+
export class ShieldResult {
|
|
23
|
+
constructor(raw, fullText) {
|
|
24
|
+
this._fullText = fullText || raw.text || "";
|
|
25
|
+
this.text = raw.text || "";
|
|
26
|
+
this.source = raw.source || "unknown";
|
|
27
|
+
this.claims = (raw.claims || []).map((c) => ({
|
|
28
|
+
text: c.text,
|
|
29
|
+
category: c.category,
|
|
30
|
+
verdict: c.verdict,
|
|
31
|
+
confidence: c.confidence || 0,
|
|
32
|
+
correction: c.correction || null,
|
|
33
|
+
receiptId: c.receipt_id || null,
|
|
34
|
+
evidenceChain: c.evidence_chain || [],
|
|
35
|
+
}));
|
|
36
|
+
this.claimsExtracted = raw.claims_extracted || 0;
|
|
37
|
+
this.claimsVerified = raw.claims_verified || 0;
|
|
38
|
+
this.claimsSupported = raw.claims_supported || 0;
|
|
39
|
+
this.claimsContradicted = raw.claims_contradicted || 0;
|
|
40
|
+
this.trustScore = raw.overall_confidence || 0;
|
|
41
|
+
this.overallVerdict = raw.overall_verdict || "unknown";
|
|
42
|
+
this.summary = raw.summary || "";
|
|
43
|
+
this.creditsUsed = raw.credits_used || 0;
|
|
44
|
+
this.processingTimeMs = raw.processing_time_ms || 0;
|
|
45
|
+
}
|
|
46
|
+
/** True if no claims were contradicted */
|
|
47
|
+
get isTrusted() {
|
|
48
|
+
return this.claimsContradicted === 0;
|
|
49
|
+
}
|
|
50
|
+
/** Corrections for contradicted claims */
|
|
51
|
+
get corrections() {
|
|
52
|
+
return this.claims
|
|
53
|
+
.filter(c => c.verdict === "contradicted" && c.correction)
|
|
54
|
+
.map(c => ({ claim: c.text, correction: c.correction, confidence: c.confidence }));
|
|
55
|
+
}
|
|
56
|
+
/** Text with contradicted claims annotated */
|
|
57
|
+
get verifiedText() {
|
|
58
|
+
let result = this._fullText;
|
|
59
|
+
for (const c of this.claims) {
|
|
60
|
+
if (c.verdict === "contradicted" && c.correction && result.includes(c.text)) {
|
|
61
|
+
result = result.replace(c.text, `[CORRECTED: ${c.correction.slice(0, 200)}]`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
/** Verification receipt IDs */
|
|
67
|
+
get receiptIds() {
|
|
68
|
+
return this.claims.map(c => c.receiptId).filter((id) => !!id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Module-level client
|
|
72
|
+
let _client = null;
|
|
73
|
+
function getClient(apiKey, baseUrl) {
|
|
74
|
+
if (!_client || apiKey) {
|
|
75
|
+
_client = new VeroqClient({ apiKey, baseUrl });
|
|
76
|
+
}
|
|
77
|
+
return _client;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Shield any LLM output with VeroQ verification.
|
|
81
|
+
*
|
|
82
|
+
* Extracts claims, verifies each against evidence, returns trust score
|
|
83
|
+
* with corrections for any contradicted claims.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* import { shield } from "@veroq/sdk";
|
|
88
|
+
*
|
|
89
|
+
* // Basic
|
|
90
|
+
* const result = await shield("NVIDIA's Q4 revenue exceeded $22B");
|
|
91
|
+
* console.log(result.trustScore, result.corrections);
|
|
92
|
+
*
|
|
93
|
+
* // With options
|
|
94
|
+
* const result = await shield(llmOutput, {
|
|
95
|
+
* source: "gpt-4o",
|
|
96
|
+
* agentId: "my-bot",
|
|
97
|
+
* blockIfUntrusted: true,
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export async function shield(text, options = {}) {
|
|
102
|
+
if (!text || text.trim().length < 20) {
|
|
103
|
+
return new ShieldResult({
|
|
104
|
+
text: text || "",
|
|
105
|
+
claims: [],
|
|
106
|
+
claims_extracted: 0,
|
|
107
|
+
overall_confidence: 1.0,
|
|
108
|
+
overall_verdict: "no_claims",
|
|
109
|
+
summary: "Text too short to extract verifiable claims.",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const client = getClient(options.apiKey, options.baseUrl);
|
|
113
|
+
const raw = await client.verifyOutput(text, {
|
|
114
|
+
source: options.source,
|
|
115
|
+
maxClaims: options.maxClaims,
|
|
116
|
+
});
|
|
117
|
+
// Store to memory if agentId provided
|
|
118
|
+
if (options.agentId && raw.claims?.length) {
|
|
119
|
+
client.memoryStore(options.agentId, `shield:${text.slice(0, 50).replace(/\s+/g, "_")}`, {
|
|
120
|
+
trust_score: raw.overall_confidence,
|
|
121
|
+
verdict: raw.overall_verdict,
|
|
122
|
+
claims_extracted: raw.claims_extracted,
|
|
123
|
+
claims_contradicted: raw.claims_contradicted,
|
|
124
|
+
}, { category: "verification", queryText: text.slice(0, 200) }).catch(() => { });
|
|
125
|
+
}
|
|
126
|
+
const result = new ShieldResult(raw, text);
|
|
127
|
+
if (options.blockIfUntrusted && !result.isTrusted) {
|
|
128
|
+
throw new VeroqError(`Shield blocked: ${result.claimsContradicted} of ${result.claimsExtracted} claims contradicted. ` +
|
|
129
|
+
`Corrections: ${result.corrections.map(c => c.claim.slice(0, 80)).join("; ")}`);
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Lightweight shield with local caching for repeated verifications.
|
|
135
|
+
*
|
|
136
|
+
* Caches results by SHA-256 hash of text. Reduces API calls for repeated or
|
|
137
|
+
* similar content. Useful for high-volume pipelines or edge/offline scenarios.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* import { CachedShield } from "@veroq/sdk";
|
|
142
|
+
*
|
|
143
|
+
* const cached = new CachedShield({ maxCache: 1000, ttlMs: 30 * 60_000 });
|
|
144
|
+
* const r1 = await cached.shield("NVIDIA reported $22B in Q4 revenue"); // API call
|
|
145
|
+
* const r2 = await cached.shield("NVIDIA reported $22B in Q4 revenue"); // instant cache hit
|
|
146
|
+
* console.log(cached.stats()); // { hits: 1, misses: 1, hitRate: 0.5, size: 1 }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export class CachedShield {
|
|
150
|
+
constructor(options = {}) {
|
|
151
|
+
this._cache = new Map();
|
|
152
|
+
this._inFlight = new Map();
|
|
153
|
+
this._hits = 0;
|
|
154
|
+
this._misses = 0;
|
|
155
|
+
this._lastEvict = 0;
|
|
156
|
+
this._maxCache = Math.max(1, options.maxCache ?? 500);
|
|
157
|
+
this._ttlMs = Math.max(1, options.ttlMs ?? 3600000);
|
|
158
|
+
this._apiKey = options.apiKey;
|
|
159
|
+
this._baseUrl = options.baseUrl;
|
|
160
|
+
}
|
|
161
|
+
static _hashText(text) {
|
|
162
|
+
return createHash("sha256").update(text, "utf8").digest("hex");
|
|
163
|
+
}
|
|
164
|
+
_evictExpired() {
|
|
165
|
+
const now = Date.now();
|
|
166
|
+
for (const [key, entry] of this._cache) {
|
|
167
|
+
if (now - entry.timestamp > this._ttlMs) {
|
|
168
|
+
this._cache.delete(key);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
_evictLru() {
|
|
173
|
+
// Map iteration order is insertion order; oldest entries are first.
|
|
174
|
+
while (this._cache.size > this._maxCache) {
|
|
175
|
+
const firstKey = this._cache.keys().next().value;
|
|
176
|
+
this._cache.delete(firstKey);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Verify text using cached shield.
|
|
181
|
+
*
|
|
182
|
+
* Checks local cache first (by SHA-256 of text). On miss, calls the
|
|
183
|
+
* regular shield() function and stores the result. Deduplicates
|
|
184
|
+
* concurrent calls for the same text.
|
|
185
|
+
*/
|
|
186
|
+
async shield(text, options = {}) {
|
|
187
|
+
const key = CachedShield._hashText(text);
|
|
188
|
+
// Amortize TTL eviction — run at most once per second
|
|
189
|
+
const now = Date.now();
|
|
190
|
+
if (now - this._lastEvict > 1000) {
|
|
191
|
+
this._evictExpired();
|
|
192
|
+
this._lastEvict = now;
|
|
193
|
+
}
|
|
194
|
+
const cached = this._cache.get(key);
|
|
195
|
+
if (cached) {
|
|
196
|
+
// Move to end (most recently used) by re-inserting
|
|
197
|
+
this._cache.delete(key);
|
|
198
|
+
this._cache.set(key, cached);
|
|
199
|
+
this._hits++;
|
|
200
|
+
return cached.result;
|
|
201
|
+
}
|
|
202
|
+
// Deduplicate concurrent calls for the same text (counts as a miss, not a hit)
|
|
203
|
+
const inflight = this._inFlight.get(key);
|
|
204
|
+
if (inflight) {
|
|
205
|
+
return inflight;
|
|
206
|
+
}
|
|
207
|
+
// Cache miss — call API and share the Promise with any concurrent callers
|
|
208
|
+
this._misses++;
|
|
209
|
+
const promise = shield(text, { ...options, apiKey: this._apiKey ?? options.apiKey, baseUrl: this._baseUrl ?? options.baseUrl });
|
|
210
|
+
this._inFlight.set(key, promise);
|
|
211
|
+
try {
|
|
212
|
+
const result = await promise;
|
|
213
|
+
this._cache.set(key, { result, timestamp: Date.now() });
|
|
214
|
+
this._evictLru();
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
this._inFlight.delete(key);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/** Return cache hit/miss statistics. */
|
|
222
|
+
stats() {
|
|
223
|
+
const total = this._hits + this._misses;
|
|
224
|
+
return {
|
|
225
|
+
hits: this._hits,
|
|
226
|
+
misses: this._misses,
|
|
227
|
+
hitRate: total > 0 ? this._hits / total : 0,
|
|
228
|
+
size: this._cache.size,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/** Clear the cache and reset stats. */
|
|
232
|
+
clear() {
|
|
233
|
+
this._cache.clear();
|
|
234
|
+
this._inFlight.clear();
|
|
235
|
+
this._hits = 0;
|
|
236
|
+
this._misses = 0;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=shield.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACxD,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,OAAO,MAAM,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,KAAK;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;QACxC,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SACvB,CAAC;IACJ,CAAC;IAED,uCAAuC;IACvC,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACnB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veroq/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "VeroQ TypeScript SDK — the verified intelligence layer for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"homepage": "https://veroq.ai",
|
|
57
57
|
"repository": {
|
|
58
58
|
"type": "git",
|
|
59
|
-
"url": "https://github.com/
|
|
59
|
+
"url": "https://github.com/veroq-ai/veroq-sdk",
|
|
60
60
|
"directory": "veroq-sdk"
|
|
61
61
|
},
|
|
62
62
|
"bugs": {
|
|
63
|
-
"url": "https://github.com/
|
|
63
|
+
"url": "https://github.com/veroq-ai/veroq-sdk/issues"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=18"
|