@agenttool/sdk 0.2.7 → 0.2.8
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/dist/verify.d.ts +32 -5
- package/dist/verify.js +52 -6
- package/package.json +1 -1
package/dist/verify.d.ts
CHANGED
|
@@ -18,13 +18,40 @@ export declare class VerifyClient {
|
|
|
18
18
|
/** @internal */
|
|
19
19
|
constructor(http: HttpConfig);
|
|
20
20
|
/**
|
|
21
|
-
* Verify a claim.
|
|
21
|
+
* Verify a claim with AI-powered evidence gathering.
|
|
22
22
|
*
|
|
23
|
-
* @param claim - The statement to verify.
|
|
24
|
-
* @param options - Optional
|
|
25
|
-
* @returns VerifyResult with verdict, confidence,
|
|
23
|
+
* @param claim - The statement to verify (max 2000 chars).
|
|
24
|
+
* @param options - Optional context and domain hint.
|
|
25
|
+
* @returns VerifyResult with verdict, confidence, evidence, caveats.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const r = await at.verify.check("The Eiffel Tower is 330m tall.", { domain: "general" });
|
|
30
|
+
* console.log(r.verdict, r.confidence); // "disputed" 0.71
|
|
31
|
+
* ```
|
|
26
32
|
*/
|
|
27
33
|
check(claim: string, options?: {
|
|
28
|
-
|
|
34
|
+
context?: string;
|
|
35
|
+
domain?: "finance" | "legal" | "medical" | "science" | "general";
|
|
29
36
|
}): Promise<VerifyResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Batch-verify up to 10 claims in parallel.
|
|
39
|
+
*
|
|
40
|
+
* @param claims - Array of claim objects (max 10). Each must include `claim`;
|
|
41
|
+
* `context` and `domain` are optional per-claim.
|
|
42
|
+
* @returns Array of VerifyResult in the same order as input.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const results = await at.verify.batch([
|
|
47
|
+
* { claim: "The Earth orbits the Sun." },
|
|
48
|
+
* { claim: "Water boils at 100°C at sea level.", domain: "science" },
|
|
49
|
+
* ]);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
batch(claims: Array<{
|
|
53
|
+
claim: string;
|
|
54
|
+
context?: string;
|
|
55
|
+
domain?: "finance" | "legal" | "medical" | "science" | "general";
|
|
56
|
+
}>): Promise<VerifyResult[]>;
|
|
30
57
|
}
|
package/dist/verify.js
CHANGED
|
@@ -19,16 +19,24 @@ export class VerifyClient {
|
|
|
19
19
|
this.http = http;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Verify a claim.
|
|
22
|
+
* Verify a claim with AI-powered evidence gathering.
|
|
23
23
|
*
|
|
24
|
-
* @param claim - The statement to verify.
|
|
25
|
-
* @param options - Optional
|
|
26
|
-
* @returns VerifyResult with verdict, confidence,
|
|
24
|
+
* @param claim - The statement to verify (max 2000 chars).
|
|
25
|
+
* @param options - Optional context and domain hint.
|
|
26
|
+
* @returns VerifyResult with verdict, confidence, evidence, caveats.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const r = await at.verify.check("The Eiffel Tower is 330m tall.", { domain: "general" });
|
|
31
|
+
* console.log(r.verdict, r.confidence); // "disputed" 0.71
|
|
32
|
+
* ```
|
|
27
33
|
*/
|
|
28
34
|
async check(claim, options) {
|
|
29
35
|
const body = { claim };
|
|
30
|
-
if (options?.
|
|
31
|
-
body.
|
|
36
|
+
if (options?.context !== undefined)
|
|
37
|
+
body.context = options.context;
|
|
38
|
+
if (options?.domain !== undefined)
|
|
39
|
+
body.domain = options.domain;
|
|
32
40
|
const url = `${this.http.baseUrl}/v1/verify`;
|
|
33
41
|
const resp = await globalThis.fetch(url, {
|
|
34
42
|
method: "POST",
|
|
@@ -51,4 +59,42 @@ export class VerifyClient {
|
|
|
51
59
|
}
|
|
52
60
|
return (await resp.json());
|
|
53
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Batch-verify up to 10 claims in parallel.
|
|
64
|
+
*
|
|
65
|
+
* @param claims - Array of claim objects (max 10). Each must include `claim`;
|
|
66
|
+
* `context` and `domain` are optional per-claim.
|
|
67
|
+
* @returns Array of VerifyResult in the same order as input.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const results = await at.verify.batch([
|
|
72
|
+
* { claim: "The Earth orbits the Sun." },
|
|
73
|
+
* { claim: "Water boils at 100°C at sea level.", domain: "science" },
|
|
74
|
+
* ]);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
async batch(claims) {
|
|
78
|
+
const url = `${this.http.baseUrl}/v1/verify/batch`;
|
|
79
|
+
const resp = await globalThis.fetch(url, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: this.http.headers,
|
|
82
|
+
body: JSON.stringify({ claims }),
|
|
83
|
+
signal: AbortSignal.timeout(this.http.timeout),
|
|
84
|
+
});
|
|
85
|
+
if (resp.status >= 400) {
|
|
86
|
+
let detail;
|
|
87
|
+
try {
|
|
88
|
+
const json = (await resp.json());
|
|
89
|
+
detail = json.detail ?? resp.statusText;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
detail = resp.statusText;
|
|
93
|
+
}
|
|
94
|
+
throw new AgentToolError(`Verify API error (${resp.status}): ${detail}`, {
|
|
95
|
+
hint: "Check your API key and request parameters.",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return (await resp.json());
|
|
99
|
+
}
|
|
54
100
|
}
|