@agenttool/sdk 0.1.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 ADDED
@@ -0,0 +1,32 @@
1
+ # agenttool
2
+
3
+ TypeScript SDK for [agenttool.dev](https://agenttool.dev) — memory and tools for AI agents.
4
+
5
+ ```bash
6
+ npm install agenttool
7
+ ```
8
+
9
+ ```typescript
10
+ import { AgentTool } from "agenttool";
11
+
12
+ const at = new AgentTool(); // reads AT_API_KEY from env
13
+
14
+ // Memory
15
+ await at.memory.store("learned something new");
16
+ const results = await at.memory.search("what did I learn?");
17
+ const mem = await at.memory.get("mem-id");
18
+ const usage = await at.memory.usage();
19
+
20
+ // Tools
21
+ const hits = await at.tools.search("latest AI news");
22
+ const page = await at.tools.scrape("https://example.com");
23
+ const out = await at.tools.execute("print(1 + 1)");
24
+
25
+ // Verify
26
+ const v = await at.verify.check("The Earth is round");
27
+
28
+ // Economy
29
+ const wallet = await at.economy.createWallet({ name: "my-wallet" });
30
+ ```
31
+
32
+ Set your key: `export AT_API_KEY=your-key-here`
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Main AgentTool client — the single entry point.
3
+ */
4
+ import { EconomyClient } from "./economy.js";
5
+ import { MemoryClient } from "./memory.js";
6
+ import { ToolsClient } from "./tools.js";
7
+ import { VerifyClient } from "./verify.js";
8
+ /**
9
+ * Unified client for the agenttool.dev platform.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { AgentTool } from "agenttool";
14
+ *
15
+ * const at = new AgentTool(); // reads AT_API_KEY from env
16
+ * await at.memory.store("just a string"); // store a memory
17
+ * const results = await at.memory.search("q"); // semantic search
18
+ * const hits = await at.tools.search("AI news"); // web search
19
+ * const page = await at.tools.scrape("https://x.com"); // scrape
20
+ * const out = await at.tools.execute("print(42)"); // sandbox
21
+ * const v = await at.verify.check("claim"); // verify
22
+ * const w = await at.economy.createWallet({ name: "w" }); // wallet
23
+ * ```
24
+ */
25
+ export declare class AgentTool {
26
+ private readonly http;
27
+ private _memory;
28
+ private _tools;
29
+ private _verify;
30
+ private _economy;
31
+ /**
32
+ * Create a new AgentTool client.
33
+ *
34
+ * @param options - Optional api_key, base_url, timeout.
35
+ */
36
+ constructor(options?: {
37
+ apiKey?: string;
38
+ baseUrl?: string;
39
+ timeout?: number;
40
+ });
41
+ /** Access the Memory API. */
42
+ get memory(): MemoryClient;
43
+ /** Access the Tools API (search, scrape, execute). */
44
+ get tools(): ToolsClient;
45
+ /** Access the Verify API. */
46
+ get verify(): VerifyClient;
47
+ /** Access the Economy/Wallet API. */
48
+ get economy(): EconomyClient;
49
+ toString(): string;
50
+ }
package/dist/client.js ADDED
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Main AgentTool client — the single entry point.
3
+ */
4
+ import { AgentToolError } from "./errors.js";
5
+ import { EconomyClient } from "./economy.js";
6
+ import { MemoryClient } from "./memory.js";
7
+ import { ToolsClient } from "./tools.js";
8
+ import { VerifyClient } from "./verify.js";
9
+ /**
10
+ * Unified client for the agenttool.dev platform.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { AgentTool } from "agenttool";
15
+ *
16
+ * const at = new AgentTool(); // reads AT_API_KEY from env
17
+ * await at.memory.store("just a string"); // store a memory
18
+ * const results = await at.memory.search("q"); // semantic search
19
+ * const hits = await at.tools.search("AI news"); // web search
20
+ * const page = await at.tools.scrape("https://x.com"); // scrape
21
+ * const out = await at.tools.execute("print(42)"); // sandbox
22
+ * const v = await at.verify.check("claim"); // verify
23
+ * const w = await at.economy.createWallet({ name: "w" }); // wallet
24
+ * ```
25
+ */
26
+ export class AgentTool {
27
+ http;
28
+ _memory;
29
+ _tools;
30
+ _verify;
31
+ _economy;
32
+ /**
33
+ * Create a new AgentTool client.
34
+ *
35
+ * @param options - Optional api_key, base_url, timeout.
36
+ */
37
+ constructor(options) {
38
+ const resolvedKey = options?.apiKey ?? (typeof process !== "undefined" ? process.env.AT_API_KEY : undefined);
39
+ if (!resolvedKey) {
40
+ throw new AgentToolError("No API key provided.", {
41
+ hint: "Pass apiKey in options or set the AT_API_KEY environment variable.",
42
+ });
43
+ }
44
+ this.http = {
45
+ baseUrl: (options?.baseUrl ?? "https://api.agenttool.dev").replace(/\/+$/, ""),
46
+ headers: {
47
+ Authorization: `Bearer ${resolvedKey}`,
48
+ "Content-Type": "application/json",
49
+ },
50
+ timeout: (options?.timeout ?? 30) * 1000, // seconds → ms
51
+ };
52
+ }
53
+ /** Access the Memory API. */
54
+ get memory() {
55
+ this._memory ??= new MemoryClient(this.http);
56
+ return this._memory;
57
+ }
58
+ /** Access the Tools API (search, scrape, execute). */
59
+ get tools() {
60
+ this._tools ??= new ToolsClient(this.http);
61
+ return this._tools;
62
+ }
63
+ /** Access the Verify API. */
64
+ get verify() {
65
+ this._verify ??= new VerifyClient(this.http);
66
+ return this._verify;
67
+ }
68
+ /** Access the Economy/Wallet API. */
69
+ get economy() {
70
+ this._economy ??= new EconomyClient(this.http);
71
+ return this._economy;
72
+ }
73
+ toString() {
74
+ return `AgentTool(baseUrl=${JSON.stringify(this.http.baseUrl)})`;
75
+ }
76
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Economy client for the wallet/economy API.
3
+ */
4
+ import type { CreateWalletOptions, Wallet } from "./types.js";
5
+ import type { HttpConfig } from "./memory.js";
6
+ /**
7
+ * Client for the economy/wallet API.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const at = new AgentTool();
12
+ * const wallet = await at.economy.createWallet({ name: "my-wallet" });
13
+ * console.log(wallet.id, wallet.balance);
14
+ * ```
15
+ */
16
+ export declare class EconomyClient {
17
+ private readonly http;
18
+ /** @internal */
19
+ constructor(http: HttpConfig);
20
+ /**
21
+ * Create a new wallet.
22
+ *
23
+ * @param options - Wallet creation options (name required).
24
+ * @returns The created Wallet object.
25
+ */
26
+ createWallet(options: CreateWalletOptions): Promise<Wallet>;
27
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Economy client for the wallet/economy API.
3
+ */
4
+ import { AgentToolError } from "./errors.js";
5
+ /**
6
+ * Client for the economy/wallet API.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const at = new AgentTool();
11
+ * const wallet = await at.economy.createWallet({ name: "my-wallet" });
12
+ * console.log(wallet.id, wallet.balance);
13
+ * ```
14
+ */
15
+ export class EconomyClient {
16
+ http;
17
+ /** @internal */
18
+ constructor(http) {
19
+ this.http = http;
20
+ }
21
+ /**
22
+ * Create a new wallet.
23
+ *
24
+ * @param options - Wallet creation options (name required).
25
+ * @returns The created Wallet object.
26
+ */
27
+ async createWallet(options) {
28
+ const body = { name: options.name };
29
+ const url = `${this.http.baseUrl}/v1/wallets`;
30
+ const resp = await globalThis.fetch(url, {
31
+ method: "POST",
32
+ headers: this.http.headers,
33
+ body: JSON.stringify(body),
34
+ signal: AbortSignal.timeout(this.http.timeout),
35
+ });
36
+ if (resp.status >= 400) {
37
+ let detail;
38
+ try {
39
+ const json = (await resp.json());
40
+ detail = json.detail ?? resp.statusText;
41
+ }
42
+ catch {
43
+ detail = resp.statusText;
44
+ }
45
+ throw new AgentToolError(`Economy API error (${resp.status}): ${detail}`, {
46
+ hint: "Check your API key and request parameters.",
47
+ });
48
+ }
49
+ return (await resp.json());
50
+ }
51
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Exceptions for the AgentTool SDK.
3
+ */
4
+ /**
5
+ * Base error for all AgentTool SDK operations.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * throw new AgentToolError("something broke", { hint: "try again" });
10
+ * ```
11
+ */
12
+ export declare class AgentToolError extends Error {
13
+ /** Human-readable error description. */
14
+ readonly message: string;
15
+ /** Actionable suggestion for fixing the error. */
16
+ readonly hint: string | undefined;
17
+ constructor(message: string, options?: {
18
+ hint?: string;
19
+ });
20
+ toString(): string;
21
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Exceptions for the AgentTool SDK.
3
+ */
4
+ /**
5
+ * Base error for all AgentTool SDK operations.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * throw new AgentToolError("something broke", { hint: "try again" });
10
+ * ```
11
+ */
12
+ export class AgentToolError extends Error {
13
+ /** Human-readable error description. */
14
+ message;
15
+ /** Actionable suggestion for fixing the error. */
16
+ hint;
17
+ constructor(message, options) {
18
+ super(message);
19
+ this.name = "AgentToolError";
20
+ this.message = message;
21
+ this.hint = options?.hint;
22
+ }
23
+ toString() {
24
+ if (this.hint) {
25
+ return `${this.message} (hint: ${this.hint})`;
26
+ }
27
+ return this.message;
28
+ }
29
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * AgentTool SDK — memory and tools for AI agents.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { AgentTool } from "agenttool";
7
+ *
8
+ * const at = new AgentTool();
9
+ * await at.memory.store("just a string");
10
+ * ```
11
+ */
12
+ export { AgentTool } from "./client.js";
13
+ export { AgentToolError } from "./errors.js";
14
+ export type { CreateWalletOptions, ExecuteResult, Memory, ScrapeResult, SearchMemoryOptions, SearchResponse, SearchResult, StoreOptions, UsageStats, VerifyResult, Wallet, } from "./types.js";
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * AgentTool SDK — memory and tools for AI agents.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { AgentTool } from "agenttool";
7
+ *
8
+ * const at = new AgentTool();
9
+ * await at.memory.store("just a string");
10
+ * ```
11
+ */
12
+ export { AgentTool } from "./client.js";
13
+ export { AgentToolError } from "./errors.js";
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Memory client for the agent-memory API.
3
+ */
4
+ import type { Memory, SearchMemoryOptions, StoreOptions, UsageStats } from "./types.js";
5
+ /** @internal Shared HTTP config passed from the main client. */
6
+ export interface HttpConfig {
7
+ baseUrl: string;
8
+ headers: Record<string, string>;
9
+ timeout: number;
10
+ }
11
+ /**
12
+ * Client for the agent-memory API.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const at = new AgentTool();
17
+ * at.memory.store("just a string");
18
+ * const results = at.memory.search("what did I learn?");
19
+ * ```
20
+ */
21
+ export declare class MemoryClient {
22
+ private readonly http;
23
+ /** @internal */
24
+ constructor(http: HttpConfig);
25
+ /**
26
+ * Store a memory. Only `content` is required.
27
+ *
28
+ * @param content - The memory content string.
29
+ * @param options - Optional type, agent_id, key, metadata, importance.
30
+ * @returns The created Memory object.
31
+ */
32
+ store(content: string, options?: StoreOptions): Promise<Memory>;
33
+ /**
34
+ * Semantic search over stored memories.
35
+ *
36
+ * @param query - Natural-language search query.
37
+ * @param options - Optional limit, type, agent_id.
38
+ * @returns List of matching Memory objects.
39
+ */
40
+ search(query: string, options?: SearchMemoryOptions): Promise<Memory[]>;
41
+ /**
42
+ * Retrieve a single memory by ID.
43
+ *
44
+ * @param memoryId - The memory's unique identifier.
45
+ * @returns The Memory object.
46
+ */
47
+ get(memoryId: string): Promise<Memory>;
48
+ /**
49
+ * Get usage statistics.
50
+ *
51
+ * @returns UsageStats with current counters.
52
+ */
53
+ usage(): Promise<UsageStats>;
54
+ private post;
55
+ private fetch;
56
+ }
package/dist/memory.js ADDED
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Memory client for the agent-memory API.
3
+ */
4
+ import { AgentToolError } from "./errors.js";
5
+ /**
6
+ * Client for the agent-memory API.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const at = new AgentTool();
11
+ * at.memory.store("just a string");
12
+ * const results = at.memory.search("what did I learn?");
13
+ * ```
14
+ */
15
+ export class MemoryClient {
16
+ http;
17
+ /** @internal */
18
+ constructor(http) {
19
+ this.http = http;
20
+ }
21
+ /**
22
+ * Store a memory. Only `content` is required.
23
+ *
24
+ * @param content - The memory content string.
25
+ * @param options - Optional type, agent_id, key, metadata, importance.
26
+ * @returns The created Memory object.
27
+ */
28
+ async store(content, options) {
29
+ const body = {
30
+ content,
31
+ type: options?.type ?? "semantic",
32
+ importance: options?.importance ?? 0.5,
33
+ };
34
+ if (options?.agent_id !== undefined)
35
+ body.agent_id = options.agent_id;
36
+ if (options?.key !== undefined)
37
+ body.key = options.key;
38
+ if (options?.metadata !== undefined)
39
+ body.metadata = options.metadata;
40
+ const resp = await this.post("/v1/memories", body);
41
+ return resp;
42
+ }
43
+ /**
44
+ * Semantic search over stored memories.
45
+ *
46
+ * @param query - Natural-language search query.
47
+ * @param options - Optional limit, type, agent_id.
48
+ * @returns List of matching Memory objects.
49
+ */
50
+ async search(query, options) {
51
+ const body = {
52
+ query,
53
+ limit: options?.limit ?? 10,
54
+ };
55
+ if (options?.type !== undefined)
56
+ body.type = options.type;
57
+ if (options?.agent_id !== undefined)
58
+ body.agent_id = options.agent_id;
59
+ const data = await this.post("/v1/memories/search", body);
60
+ const results = Array.isArray(data) ? data : data.results ?? [];
61
+ return results;
62
+ }
63
+ /**
64
+ * Retrieve a single memory by ID.
65
+ *
66
+ * @param memoryId - The memory's unique identifier.
67
+ * @returns The Memory object.
68
+ */
69
+ async get(memoryId) {
70
+ const resp = await this.fetch("GET", `/v1/memories/${memoryId}`);
71
+ return resp;
72
+ }
73
+ /**
74
+ * Get usage statistics.
75
+ *
76
+ * @returns UsageStats with current counters.
77
+ */
78
+ async usage() {
79
+ const resp = await this.fetch("GET", "/v1/usage");
80
+ return resp;
81
+ }
82
+ // --- internal ---
83
+ async post(path, body) {
84
+ return this.fetch("POST", path, body);
85
+ }
86
+ async fetch(method, path, body) {
87
+ const url = `${this.http.baseUrl}${path}`;
88
+ const init = {
89
+ method,
90
+ headers: this.http.headers,
91
+ signal: AbortSignal.timeout(this.http.timeout),
92
+ };
93
+ if (body !== undefined) {
94
+ init.body = JSON.stringify(body);
95
+ }
96
+ const resp = await globalThis.fetch(url, init);
97
+ if (resp.status >= 400) {
98
+ let detail;
99
+ try {
100
+ const json = (await resp.json());
101
+ detail = json.detail ?? resp.statusText;
102
+ }
103
+ catch {
104
+ detail = resp.statusText;
105
+ }
106
+ throw new AgentToolError(`Memory API error (${resp.status}): ${detail}`, {
107
+ hint: "Check your API key and request parameters.",
108
+ });
109
+ }
110
+ return resp.json();
111
+ }
112
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Tools client for the agent-tools API.
3
+ */
4
+ import type { ExecuteResult, ScrapeResult, SearchResponse } from "./types.js";
5
+ import type { HttpConfig } from "./memory.js";
6
+ /**
7
+ * Client for the agent-tools API (search, scrape, execute).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const at = new AgentTool();
12
+ * const results = at.tools.search("latest AI news");
13
+ * const page = at.tools.scrape("https://example.com");
14
+ * const out = at.tools.execute("print(42)");
15
+ * ```
16
+ */
17
+ export declare class ToolsClient {
18
+ private readonly http;
19
+ /** @internal */
20
+ constructor(http: HttpConfig);
21
+ /**
22
+ * Web search.
23
+ *
24
+ * @param query - Search query string.
25
+ * @param options - Optional num_results.
26
+ * @returns SearchResponse with results, cached flag, and duration.
27
+ */
28
+ search(query: string, options?: {
29
+ num_results?: number;
30
+ }): Promise<SearchResponse>;
31
+ /**
32
+ * Scrape a URL and return its content.
33
+ *
34
+ * @param url - The URL to scrape.
35
+ * @returns ScrapeResult with the page content.
36
+ */
37
+ scrape(url: string): Promise<ScrapeResult>;
38
+ /**
39
+ * Execute code in a sandbox.
40
+ *
41
+ * @param code - Source code to execute.
42
+ * @param options - Optional language (default: "python").
43
+ * @returns ExecuteResult with stdout, stderr, exit_code, duration_ms.
44
+ */
45
+ execute(code: string, options?: {
46
+ language?: string;
47
+ }): Promise<ExecuteResult>;
48
+ private post;
49
+ }
package/dist/tools.js ADDED
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Tools client for the agent-tools API.
3
+ */
4
+ import { AgentToolError } from "./errors.js";
5
+ /**
6
+ * Client for the agent-tools API (search, scrape, execute).
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const at = new AgentTool();
11
+ * const results = at.tools.search("latest AI news");
12
+ * const page = at.tools.scrape("https://example.com");
13
+ * const out = at.tools.execute("print(42)");
14
+ * ```
15
+ */
16
+ export class ToolsClient {
17
+ http;
18
+ /** @internal */
19
+ constructor(http) {
20
+ this.http = http;
21
+ }
22
+ /**
23
+ * Web search.
24
+ *
25
+ * @param query - Search query string.
26
+ * @param options - Optional num_results.
27
+ * @returns SearchResponse with results, cached flag, and duration.
28
+ */
29
+ async search(query, options) {
30
+ const body = {
31
+ query,
32
+ num_results: options?.num_results ?? 5,
33
+ };
34
+ const data = (await this.post("/v1/search", body));
35
+ // Normalize: API may return results at top level or nested
36
+ const results = Array.isArray(data)
37
+ ? data
38
+ : (data.results ?? []);
39
+ return {
40
+ results: results,
41
+ cached: data.cached ?? false,
42
+ duration_ms: data.duration_ms ?? 0,
43
+ };
44
+ }
45
+ /**
46
+ * Scrape a URL and return its content.
47
+ *
48
+ * @param url - The URL to scrape.
49
+ * @returns ScrapeResult with the page content.
50
+ */
51
+ async scrape(url) {
52
+ const data = await this.post("/v1/scrape", { url });
53
+ return data;
54
+ }
55
+ /**
56
+ * Execute code in a sandbox.
57
+ *
58
+ * @param code - Source code to execute.
59
+ * @param options - Optional language (default: "python").
60
+ * @returns ExecuteResult with stdout, stderr, exit_code, duration_ms.
61
+ */
62
+ async execute(code, options) {
63
+ const body = {
64
+ code,
65
+ language: options?.language ?? "python",
66
+ };
67
+ const data = await this.post("/v1/execute", body);
68
+ return data;
69
+ }
70
+ // --- internal ---
71
+ async post(path, body) {
72
+ const url = `${this.http.baseUrl}${path}`;
73
+ const resp = await globalThis.fetch(url, {
74
+ method: "POST",
75
+ headers: this.http.headers,
76
+ body: JSON.stringify(body),
77
+ signal: AbortSignal.timeout(this.http.timeout),
78
+ });
79
+ if (resp.status >= 400) {
80
+ let detail;
81
+ try {
82
+ const json = (await resp.json());
83
+ detail = json.detail ?? resp.statusText;
84
+ }
85
+ catch {
86
+ detail = resp.statusText;
87
+ }
88
+ throw new AgentToolError(`Tools API error (${resp.status}): ${detail}`, {
89
+ hint: "Check your API key and request parameters.",
90
+ });
91
+ }
92
+ return resp.json();
93
+ }
94
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Data types for the AgentTool SDK.
3
+ */
4
+ /** A stored memory. */
5
+ export interface Memory {
6
+ id: string;
7
+ content: string;
8
+ type: string;
9
+ agent_id?: string;
10
+ key?: string;
11
+ metadata: Record<string, unknown>;
12
+ importance: number;
13
+ score?: number;
14
+ created_at?: string;
15
+ updated_at?: string;
16
+ }
17
+ /** Options for storing a memory. */
18
+ export interface StoreOptions {
19
+ type?: string;
20
+ agent_id?: string;
21
+ key?: string;
22
+ metadata?: Record<string, unknown>;
23
+ importance?: number;
24
+ }
25
+ /** Options for searching memories. */
26
+ export interface SearchMemoryOptions {
27
+ limit?: number;
28
+ type?: string;
29
+ agent_id?: string;
30
+ }
31
+ /** API usage statistics. */
32
+ export interface UsageStats {
33
+ writes: number;
34
+ reads: number;
35
+ searches: number;
36
+ total_memories: number;
37
+ plan: string;
38
+ }
39
+ /** A web search result. */
40
+ export interface SearchResult {
41
+ title: string;
42
+ url: string;
43
+ snippet: string;
44
+ date?: string;
45
+ }
46
+ /** Response from the search endpoint. */
47
+ export interface SearchResponse {
48
+ results: SearchResult[];
49
+ cached: boolean;
50
+ duration_ms: number;
51
+ }
52
+ /** Result of scraping a URL. */
53
+ export interface ScrapeResult {
54
+ url: string;
55
+ content: string;
56
+ status_code: number;
57
+ [key: string]: unknown;
58
+ }
59
+ /** Result of sandboxed code execution. */
60
+ export interface ExecuteResult {
61
+ stdout: string;
62
+ stderr: string;
63
+ exit_code: number;
64
+ duration_ms: number;
65
+ }
66
+ /** Result of a verification request. */
67
+ export interface VerifyResult {
68
+ verdict: string;
69
+ confidence: number;
70
+ sources: string[];
71
+ evidence: string;
72
+ caveats: string[];
73
+ }
74
+ /** A wallet object. */
75
+ export interface Wallet {
76
+ id: string;
77
+ name: string;
78
+ balance: number;
79
+ api_key: string;
80
+ }
81
+ /** Options for creating a wallet. */
82
+ export interface CreateWalletOptions {
83
+ name: string;
84
+ }
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Data types for the AgentTool SDK.
3
+ */
4
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Verify client for the verification API.
3
+ */
4
+ import type { VerifyResult } from "./types.js";
5
+ import type { HttpConfig } from "./memory.js";
6
+ /**
7
+ * Client for the verify API.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const at = new AgentTool();
12
+ * const result = await at.verify.check("The Earth is round");
13
+ * console.log(result.verdict, result.confidence);
14
+ * ```
15
+ */
16
+ export declare class VerifyClient {
17
+ private readonly http;
18
+ /** @internal */
19
+ constructor(http: HttpConfig);
20
+ /**
21
+ * Verify a claim.
22
+ *
23
+ * @param claim - The statement to verify.
24
+ * @param options - Optional sources array.
25
+ * @returns VerifyResult with verdict, confidence, sources, evidence, caveats.
26
+ */
27
+ check(claim: string, options?: {
28
+ sources?: string[];
29
+ }): Promise<VerifyResult>;
30
+ }
package/dist/verify.js ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Verify client for the verification API.
3
+ */
4
+ import { AgentToolError } from "./errors.js";
5
+ /**
6
+ * Client for the verify API.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const at = new AgentTool();
11
+ * const result = await at.verify.check("The Earth is round");
12
+ * console.log(result.verdict, result.confidence);
13
+ * ```
14
+ */
15
+ export class VerifyClient {
16
+ http;
17
+ /** @internal */
18
+ constructor(http) {
19
+ this.http = http;
20
+ }
21
+ /**
22
+ * Verify a claim.
23
+ *
24
+ * @param claim - The statement to verify.
25
+ * @param options - Optional sources array.
26
+ * @returns VerifyResult with verdict, confidence, sources, evidence, caveats.
27
+ */
28
+ async check(claim, options) {
29
+ const body = { claim };
30
+ if (options?.sources !== undefined)
31
+ body.sources = options.sources;
32
+ const url = `${this.http.baseUrl}/v1/verify`;
33
+ const resp = await globalThis.fetch(url, {
34
+ method: "POST",
35
+ headers: this.http.headers,
36
+ body: JSON.stringify(body),
37
+ signal: AbortSignal.timeout(this.http.timeout),
38
+ });
39
+ if (resp.status >= 400) {
40
+ let detail;
41
+ try {
42
+ const json = (await resp.json());
43
+ detail = json.detail ?? resp.statusText;
44
+ }
45
+ catch {
46
+ detail = resp.statusText;
47
+ }
48
+ throw new AgentToolError(`Verify API error (${resp.status}): ${detail}`, {
49
+ hint: "Check your API key and request parameters.",
50
+ });
51
+ }
52
+ return (await resp.json());
53
+ }
54
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@agenttool/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for agenttool.dev — memory and tools for AI agents",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "test": "bun test"
20
+ },
21
+ "license": "MIT",
22
+ "devDependencies": {
23
+ "@types/bun": "^1.2.0",
24
+ "typescript": "^5.7.0"
25
+ }
26
+ }