@agenttool/sdk 0.2.6 → 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/README.md CHANGED
@@ -43,17 +43,13 @@ import { AgentTool } from "@agenttool/sdk";
43
43
  const at = new AgentTool(); // reads AT_API_KEY from env
44
44
 
45
45
  // Store a memory
46
- const memory = await at.memory.store({
47
- content: "The user prefers dark mode and concise responses",
48
- agentId: "my-assistant",
49
- tags: ["preference", "ui"],
50
- });
46
+ const memory = await at.memory.store(
47
+ "The user prefers dark mode and concise responses",
48
+ { agent_id: "my-assistant", key: "preferences" }
49
+ );
51
50
 
52
51
  // Retrieve it later (semantic search)
53
- const results = await at.memory.search({
54
- query: "what does the user prefer?",
55
- limit: 5,
56
- });
52
+ const results = await at.memory.search("what does the user prefer?", { limit: 5 });
57
53
 
58
54
  for (const r of results) {
59
55
  console.log(`${r.score.toFixed(2)} ${r.content}`);
@@ -68,10 +64,10 @@ for (const r of results) {
68
64
  const at = new AgentTool({ apiKey: "at_..." }); // or use AT_API_KEY env var
69
65
 
70
66
  // Store
71
- const mem = await at.memory.store({ content: "User is in London, timezone Europe/London" });
67
+ const mem = await at.memory.store("User is in London, timezone Europe/London");
72
68
 
73
69
  // Semantic search
74
- const results = await at.memory.search({ query: "where is the user?", limit: 5 });
70
+ const results = await at.memory.search("where is the user?", { limit: 5 });
75
71
 
76
72
  // Retrieve by ID
77
73
  const mem = await at.memory.get("mem_abc123");
@@ -189,7 +185,7 @@ const tools = {
189
185
  description: "Store a memory for later retrieval",
190
186
  parameters: z.object({ content: z.string() }),
191
187
  execute: async ({ content }) => {
192
- const mem = await at.memory.store({ content, agentId: "my-agent" });
188
+ const mem = await at.memory.store(content, { agent_id: "my-agent" });
193
189
  return `Stored memory ${mem.id}`;
194
190
  },
195
191
  }),
@@ -197,7 +193,7 @@ const tools = {
197
193
  description: "Search past memories by semantic similarity",
198
194
  parameters: z.object({ query: z.string() }),
199
195
  execute: async ({ query }) => {
200
- const results = await at.memory.search({ query, limit: 3 });
196
+ const results = await at.memory.search(query, { limit: 3 });
201
197
  return results.map((r) => r.content).join("\n");
202
198
  },
203
199
  }),
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 sources array.
25
- * @returns VerifyResult with verdict, confidence, sources, evidence, caveats.
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
- sources?: string[];
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 sources array.
26
- * @returns VerifyResult with verdict, confidence, sources, evidence, caveats.
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?.sources !== undefined)
31
- body.sources = options.sources;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenttool/sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "TypeScript SDK for agenttool.dev — memory and tools for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",