@agenttool/sdk 0.2.2 → 0.2.4

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
@@ -1,10 +1,11 @@
1
1
  # @agenttool/sdk · TypeScript
2
2
 
3
- > Persistent memory, verified actions, and tool access for AI agents — one API key.
3
+ > Persistent memory, reasoning traces, fact verification, tool access, and agent-to-agent payments — one API key.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@agenttool/sdk)](https://www.npmjs.com/package/@agenttool/sdk)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org/)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
+ [![API Status](https://img.shields.io/badge/API-live-brightgreen)](https://api.agenttool.dev/health)
8
9
 
9
10
  ```bash
10
11
  npm install @agenttool/sdk
@@ -19,11 +20,12 @@ AgentTool gives AI agents the infrastructure they need to operate reliably:
19
20
  | Service | What it does |
20
21
  |---------|-------------|
21
22
  | **agent-memory** | Persistent semantic memory — store facts, retrieve by similarity |
22
- | **agent-tools** | Web search, page scraping, code execution |
23
- | **agent-verify** | SHA-256 proof-of-work attestations with timestamps |
24
- | **agent-economy** | Wallets, credits, agent-to-agent billing |
23
+ | **agent-tools** | Web search, page scraping, sandboxed code execution |
24
+ | **agent-verify** | Fact-check claims with AI-powered evidence gathering |
25
+ | **agent-economy** | Wallets, spending policies, escrow, agent-to-agent payments |
26
+ | **agent-trace** | Reasoning provenance — log and search decision traces |
25
27
 
26
- All four services, one API key, one SDK.
28
+ All five services, one API key, one SDK.
27
29
 
28
30
  ## Quick start (60 seconds)
29
31
 
@@ -53,8 +55,8 @@ const results = await at.memory.search({
53
55
  limit: 5,
54
56
  });
55
57
 
56
- for (const result of results) {
57
- console.log(`${result.score.toFixed(2)} ${result.content}`);
58
+ for (const r of results) {
59
+ console.log(`${r.score.toFixed(2)} ${r.content}`);
58
60
  }
59
61
  ```
60
62
 
@@ -63,78 +65,117 @@ for (const result of results) {
63
65
  ### Memory
64
66
 
65
67
  ```typescript
66
- import { AgentTool } from "@agenttool/sdk";
67
-
68
68
  const at = new AgentTool({ apiKey: "at_..." }); // or use AT_API_KEY env var
69
69
 
70
70
  // Store
71
- const mem = await at.memory.store({
72
- content: "User is based in London, timezone Europe/London",
73
- });
71
+ const mem = await at.memory.store({ content: "User is in London, timezone Europe/London" });
74
72
 
75
- // Search (semantic)
76
- const results = await at.memory.search({ query: "where is the user?" });
73
+ // Semantic search
74
+ const results = await at.memory.search({ query: "where is the user?", limit: 5 });
77
75
 
78
76
  // Retrieve by ID
79
- const mem2 = await at.memory.get("mem_...");
77
+ const mem = await at.memory.get("mem_abc123");
80
78
 
81
- // Delete
82
- await at.memory.delete("mem_...");
79
+ // Usage stats
80
+ const stats = await at.memory.usage();
81
+ console.log(stats.memoriesStored, stats.searchesPerformed);
83
82
  ```
84
83
 
85
84
  ### Tools
86
85
 
87
86
  ```typescript
88
87
  // Web search
89
- const results = await at.tools.search({ query: "latest papers on RAG", numResults: 5 });
90
- for (const r of results) {
91
- console.log(r.title, r.url);
92
- }
88
+ const results = await at.tools.search("latest papers on RAG", { numResults: 5 });
89
+ for (const r of results) console.log(r.title, r.url);
93
90
 
94
91
  // Scrape a page
95
- const page = await at.tools.scrape({ url: "https://example.com" });
96
- console.log(page.text);
97
-
98
- // Execute code
99
- const output = await at.tools.execute({ code: "console.log(Math.PI)" });
100
- console.log(output.stdout);
92
+ const page = await at.tools.scrape("https://example.com");
93
+ console.log(page.content); // page text/HTML
94
+ console.log(page.statusCode);
95
+
96
+ // Execute code (sandboxed Python, JavaScript, Bash)
97
+ const result = await at.tools.execute("print(42)", { language: "python" });
98
+ console.log(result.output); // stdout
99
+ console.log(result.error); // stderr
100
+ console.log(result.exitCode); // 0 = success
101
101
  ```
102
102
 
103
103
  ### Verify
104
104
 
105
105
  ```typescript
106
- // Create an attestation
107
- const proof = await at.verify.create({
108
- action: "task_completed",
109
- agentId: "my-agent",
110
- payload: { task: "data_analysis", rowsProcessed: 1500 },
106
+ // Fact-check a claim with AI-powered evidence gathering
107
+ const result = await at.verify.check("The Eiffel Tower is 330 metres tall.");
108
+ console.log(result.verdict); // "verified" | "false" | "disputed" | "unverifiable"
109
+ console.log(result.confidence); // 0.0 – 1.0
110
+ console.log(result.caveats); // string[] of nuances
111
+
112
+ // With domain hint for better evidence
113
+ const r = await at.verify.check("Bitcoin was created in 2009.", {
114
+ domain: "finance", // "finance" | "science" | "medical" | "legal" | "general"
115
+ context: "On the whitepaper publication date",
111
116
  });
112
- console.log(proof.attestationId, proof.hash);
113
-
114
- // Verify an attestation
115
- const result = await at.verify.check("att_...");
116
- console.log(result.valid); // true
117
117
  ```
118
118
 
119
- ### Economy
119
+ ### Economy (wallets & escrows)
120
120
 
121
121
  ```typescript
122
122
  // Create a wallet
123
- const wallet = await at.economy.createWallet({ name: "agent-wallet" });
123
+ const wallet = await at.economy.createWallet({ name: "agent-wallet", agentId: "agent-42" });
124
124
 
125
- // Check balance
126
- const { balance } = await at.economy.getBalance(wallet.id);
125
+ // Fund it
126
+ await at.economy.fundWallet(wallet.id, { amount: 500, description: "Weekly budget" });
127
127
 
128
- // Transfer credits
129
- await at.economy.transfer({
130
- fromWallet: wallet.id,
131
- toWallet: "wlt_...",
128
+ // Spend credits
129
+ await at.economy.spend(wallet.id, {
132
130
  amount: 10,
133
- memo: "payment for search service",
131
+ counterparty: "wal_target_id",
132
+ description: "Payment for research task",
133
+ });
134
+
135
+ // Set a spending policy
136
+ await at.economy.setPolicy(wallet.id, {
137
+ maxPerTransaction: 50,
138
+ maxPerHour: 200,
139
+ maxPerDay: 1000,
140
+ });
141
+
142
+ // Escrow: lock credits until work is done
143
+ const escrow = await at.economy.createEscrow({
144
+ creatorWalletId: wallet.id,
145
+ amount: 100,
146
+ description: "Summarise 50 research papers",
147
+ deadline: "2026-03-14T12:00:00Z",
148
+ });
149
+ // Worker accepts:
150
+ await at.economy.acceptEscrow(escrow.id, "wal_worker");
151
+ // Release on completion:
152
+ await at.economy.releaseEscrow(escrow.id);
153
+ ```
154
+
155
+ ### Traces (reasoning provenance)
156
+
157
+ ```typescript
158
+ // Store a reasoning trace
159
+ const trace = await at.traces.store({
160
+ step: "web_search",
161
+ input: { query: "climate change solutions" },
162
+ output: { results: ["..."] },
163
+ });
164
+
165
+ // Semantic search across traces
166
+ const results = await at.traces.search({
167
+ query: "decisions about climate data",
168
+ limit: 5,
134
169
  });
170
+
171
+ // Get a chain of reasoning steps
172
+ const chain = await at.traces.chain("parent_trace_id");
173
+
174
+ // Delete
175
+ await at.traces.delete(trace.id);
135
176
  ```
136
177
 
137
- ## Integration example — Vercel AI SDK
178
+ ## Integration example — LangChain / Vercel AI SDK
138
179
 
139
180
  ```typescript
140
181
  import { AgentTool } from "@agenttool/sdk";
@@ -143,48 +184,34 @@ import { z } from "zod";
143
184
 
144
185
  const at = new AgentTool();
145
186
 
146
- export const memoryTools = {
187
+ const tools = {
147
188
  remember: tool({
148
189
  description: "Store a memory for later retrieval",
149
190
  parameters: z.object({ content: z.string() }),
150
191
  execute: async ({ content }) => {
151
- const mem = await at.memory.store({ content, agentId: "vercel-ai-agent" });
152
- return { id: mem.id, stored: true };
192
+ const mem = await at.memory.store({ content, agentId: "my-agent" });
193
+ return `Stored memory ${mem.id}`;
153
194
  },
154
195
  }),
155
196
  recall: tool({
156
197
  description: "Search past memories by semantic similarity",
157
198
  parameters: z.object({ query: z.string() }),
158
199
  execute: async ({ query }) => {
159
- const results = await at.memory.search({ query, limit: 5 });
160
- return results.map((r) => ({ content: r.content, score: r.score }));
200
+ const results = await at.memory.search({ query, limit: 3 });
201
+ return results.map((r) => r.content).join("\n");
202
+ },
203
+ }),
204
+ factCheck: tool({
205
+ description: "Verify whether a factual claim is true",
206
+ parameters: z.object({ claim: z.string() }),
207
+ execute: async ({ claim }) => {
208
+ const result = await at.verify.check(claim);
209
+ return `${result.verdict} (${(result.confidence * 100).toFixed(0)}% confidence)`;
161
210
  },
162
211
  }),
163
212
  };
164
213
  ```
165
214
 
166
- ## Integration example — any agent loop
167
-
168
- ```typescript
169
- import { AgentTool } from "@agenttool/sdk";
170
-
171
- const at = new AgentTool();
172
-
173
- async function agentLoop(userMessage: string): Promise<string> {
174
- // Recall relevant memories
175
- const memories = await at.memory.search({ query: userMessage, limit: 5 });
176
- const context = memories.map((m) => m.content).join("\n");
177
-
178
- // Call your LLM with context
179
- const response = await yourLLM(`Context:\n${context}\n\nUser: ${userMessage}`);
180
-
181
- // Store the exchange
182
- await at.memory.store({ content: `User: ${userMessage}\nAgent: ${response}` });
183
-
184
- return response;
185
- }
186
- ```
187
-
188
215
  ## Free tier
189
216
 
190
217
  | Resource | Free | Seed ($29/mo) | Grow ($99/mo) |
@@ -192,6 +219,7 @@ async function agentLoop(userMessage: string): Promise<string> {
192
219
  | Memory ops/day | 100 | 10,000 | 100,000 |
193
220
  | Tool calls/day | 10 | 500 | 5,000 |
194
221
  | Verifications/day | 5 | 100 | 1,000 |
222
+ | Traces/day | 100 | 10,000 | 100,000 |
195
223
 
196
224
  [Upgrade at app.agenttool.dev/billing](https://app.agenttool.dev/billing)
197
225
 
@@ -201,9 +229,9 @@ async function agentLoop(userMessage: string): Promise<string> {
201
229
  import { AgentTool } from "@agenttool/sdk";
202
230
 
203
231
  const at = new AgentTool({
204
- apiKey: "at_...", // default: AT_API_KEY env var
205
- baseUrl: "https://api.agenttool.dev", // default
206
- timeout: 30_000, // ms, default 30s
232
+ apiKey: "at_...", // default: AT_API_KEY env var
233
+ baseUrl: "https://api.agenttool.dev", // default
234
+ timeout: 30_000, // ms
207
235
  });
208
236
  ```
209
237
 
@@ -213,7 +241,7 @@ const at = new AgentTool({
213
241
  - 📖 [docs.agenttool.dev](https://docs.agenttool.dev)
214
242
  - 🎛️ [app.agenttool.dev](https://app.agenttool.dev) — dashboard + API key
215
243
  - 📦 [npm](https://www.npmjs.com/package/@agenttool/sdk)
216
- - 🐍 [Python SDK](https://github.com/cambridgetcg/agenttool-sdk-py)
244
+ - 🐍 [Python SDK](https://github.com/mynameisyou-cmyk/agenttool-sdk-py)
217
245
 
218
246
  ## License
219
247
 
package/dist/economy.d.ts CHANGED
@@ -1,27 +1,108 @@
1
1
  /**
2
- * Economy client for the wallet/economy API.
2
+ * Economy client for the wallet/escrow API.
3
3
  */
4
- import type { CreateWalletOptions, Wallet } from "./types.js";
4
+ import type { CreateEscrowOptions, CreateWalletOptions, Escrow, Wallet, WalletPolicy } from "./types.js";
5
5
  import type { HttpConfig } from "./memory.js";
6
6
  /**
7
- * Client for the economy/wallet API.
7
+ * Client for the agent-economy API — wallets and escrows.
8
8
  *
9
9
  * @example
10
10
  * ```ts
11
11
  * const at = new AgentTool();
12
- * const wallet = await at.economy.createWallet({ name: "my-wallet" });
13
- * console.log(wallet.id, wallet.balance);
12
+ *
13
+ * // Create and fund a wallet
14
+ * const wallet = await at.economy.createWallet({ name: "agent-wallet", agentId: "agent-1" });
15
+ * await at.economy.fundWallet(wallet.id, { amount: 500, description: "Weekly budget" });
16
+ *
17
+ * // Create an escrow for agent-to-agent payment
18
+ * const escrow = await at.economy.createEscrow({
19
+ * creatorWalletId: wallet.id,
20
+ * amount: 100,
21
+ * description: "Summarise 50 research papers",
22
+ * });
23
+ * await at.economy.releaseEscrow(escrow.id);
14
24
  * ```
15
25
  */
16
26
  export declare class EconomyClient {
17
27
  private readonly http;
18
28
  /** @internal */
19
29
  constructor(http: HttpConfig);
30
+ private url;
31
+ private req;
20
32
  /**
21
33
  * Create a new wallet.
22
- *
23
- * @param options - Wallet creation options (name required).
24
- * @returns The created Wallet object.
25
34
  */
26
35
  createWallet(options: CreateWalletOptions): Promise<Wallet>;
36
+ /**
37
+ * List all wallets for this project.
38
+ */
39
+ listWallets(): Promise<Wallet[]>;
40
+ /**
41
+ * Get a wallet by ID.
42
+ */
43
+ getWallet(walletId: string): Promise<Wallet>;
44
+ /**
45
+ * Fund a wallet with credits.
46
+ */
47
+ fundWallet(walletId: string, options: {
48
+ amount: number;
49
+ description?: string;
50
+ metadata?: Record<string, unknown>;
51
+ }): Promise<Record<string, unknown>>;
52
+ /**
53
+ * Spend credits from a wallet (subject to spending policy).
54
+ */
55
+ spend(walletId: string, options: {
56
+ amount: number;
57
+ counterparty: string;
58
+ description: string;
59
+ metadata?: Record<string, unknown>;
60
+ }): Promise<Record<string, unknown>>;
61
+ /**
62
+ * Set or update a wallet's spending policy.
63
+ */
64
+ setPolicy(walletId: string, policy: WalletPolicy): Promise<Record<string, unknown>>;
65
+ /**
66
+ * Freeze a wallet — halts all spending immediately.
67
+ */
68
+ freezeWallet(walletId: string): Promise<Wallet>;
69
+ /**
70
+ * Unfreeze a wallet to resume normal operation.
71
+ */
72
+ unfreezeWallet(walletId: string): Promise<Wallet>;
73
+ /**
74
+ * Get paginated transaction history for a wallet.
75
+ */
76
+ getTransactions(walletId: string, options?: {
77
+ limit?: number;
78
+ offset?: number;
79
+ }): Promise<Record<string, unknown>[]>;
80
+ /**
81
+ * Create an escrow — locks credits until work is released or refunded.
82
+ */
83
+ createEscrow(options: CreateEscrowOptions): Promise<Escrow>;
84
+ /**
85
+ * List escrows, optionally filtered by status.
86
+ */
87
+ listEscrows(status?: Escrow["status"]): Promise<Escrow[]>;
88
+ /**
89
+ * Get an escrow by ID.
90
+ */
91
+ getEscrow(escrowId: string): Promise<Escrow>;
92
+ /**
93
+ * Accept an escrow as the worker.
94
+ */
95
+ acceptEscrow(escrowId: string, workerWalletId: string): Promise<Escrow>;
96
+ /**
97
+ * Release escrow funds to the worker.
98
+ */
99
+ releaseEscrow(escrowId: string): Promise<Escrow>;
100
+ /**
101
+ * Refund escrow credits back to the creator.
102
+ */
103
+ refundEscrow(escrowId: string): Promise<Escrow>;
104
+ /**
105
+ * Flag an escrow as disputed — credits stay locked pending resolution.
106
+ */
107
+ disputeEscrow(escrowId: string): Promise<Escrow>;
27
108
  }
package/dist/economy.js CHANGED
@@ -1,15 +1,25 @@
1
1
  /**
2
- * Economy client for the wallet/economy API.
2
+ * Economy client for the wallet/escrow API.
3
3
  */
4
4
  import { AgentToolError } from "./errors.js";
5
5
  /**
6
- * Client for the economy/wallet API.
6
+ * Client for the agent-economy API — wallets and escrows.
7
7
  *
8
8
  * @example
9
9
  * ```ts
10
10
  * const at = new AgentTool();
11
- * const wallet = await at.economy.createWallet({ name: "my-wallet" });
12
- * console.log(wallet.id, wallet.balance);
11
+ *
12
+ * // Create and fund a wallet
13
+ * const wallet = await at.economy.createWallet({ name: "agent-wallet", agentId: "agent-1" });
14
+ * await at.economy.fundWallet(wallet.id, { amount: 500, description: "Weekly budget" });
15
+ *
16
+ * // Create an escrow for agent-to-agent payment
17
+ * const escrow = await at.economy.createEscrow({
18
+ * creatorWalletId: wallet.id,
19
+ * amount: 100,
20
+ * description: "Summarise 50 research papers",
21
+ * });
22
+ * await at.economy.releaseEscrow(escrow.id);
13
23
  * ```
14
24
  */
15
25
  export class EconomyClient {
@@ -18,34 +28,179 @@ export class EconomyClient {
18
28
  constructor(http) {
19
29
  this.http = http;
20
30
  }
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`;
31
+ // ── helpers ──────────────────────────────────────────────────────────────
32
+ url(path) {
33
+ return `${this.http.baseUrl}${path}`;
34
+ }
35
+ async req(method, path, body, params) {
36
+ let url = this.url(path);
37
+ if (params) {
38
+ const qs = new URLSearchParams(params).toString();
39
+ url = `${url}?${qs}`;
40
+ }
30
41
  const resp = await globalThis.fetch(url, {
31
- method: "POST",
42
+ method,
32
43
  headers: this.http.headers,
33
- body: JSON.stringify(body),
44
+ body: body !== undefined ? JSON.stringify(body) : undefined,
34
45
  signal: AbortSignal.timeout(this.http.timeout),
35
46
  });
36
47
  if (resp.status >= 400) {
37
48
  let detail;
38
49
  try {
39
50
  const json = (await resp.json());
40
- detail = json.detail ?? resp.statusText;
51
+ detail = json.detail ?? json.error ?? resp.statusText;
41
52
  }
42
53
  catch {
43
54
  detail = resp.statusText;
44
55
  }
45
56
  throw new AgentToolError(`Economy API error (${resp.status}): ${detail}`, {
46
- hint: "Check your API key and request parameters.",
57
+ hint: "Check wallet ID, balance, and spending policy.",
47
58
  });
48
59
  }
49
- return (await resp.json());
60
+ return resp.json();
61
+ }
62
+ // ── Wallets ───────────────────────────────────────────────────────────────
63
+ /**
64
+ * Create a new wallet.
65
+ */
66
+ async createWallet(options) {
67
+ const body = { name: options.name };
68
+ if (options.agentId)
69
+ body.agentId = options.agentId;
70
+ if (options.currency)
71
+ body.currency = options.currency;
72
+ const r = await this.req("POST", "/v1/wallets", body);
73
+ return r.data ?? r;
74
+ }
75
+ /**
76
+ * List all wallets for this project.
77
+ */
78
+ async listWallets() {
79
+ const r = await this.req("GET", "/v1/wallets");
80
+ return r.data ?? r;
81
+ }
82
+ /**
83
+ * Get a wallet by ID.
84
+ */
85
+ async getWallet(walletId) {
86
+ const r = await this.req("GET", `/v1/wallets/${walletId}`);
87
+ return r.data ?? r;
88
+ }
89
+ /**
90
+ * Fund a wallet with credits.
91
+ */
92
+ async fundWallet(walletId, options) {
93
+ const body = {
94
+ amount: options.amount,
95
+ description: options.description ?? "Manual fund",
96
+ };
97
+ if (options.metadata)
98
+ body.metadata = options.metadata;
99
+ return this.req("POST", `/v1/wallets/${walletId}/fund`, body);
100
+ }
101
+ /**
102
+ * Spend credits from a wallet (subject to spending policy).
103
+ */
104
+ async spend(walletId, options) {
105
+ const body = {
106
+ amount: options.amount,
107
+ counterparty: options.counterparty,
108
+ description: options.description,
109
+ };
110
+ if (options.metadata)
111
+ body.metadata = options.metadata;
112
+ return this.req("POST", `/v1/wallets/${walletId}/spend`, body);
113
+ }
114
+ /**
115
+ * Set or update a wallet's spending policy.
116
+ */
117
+ async setPolicy(walletId, policy) {
118
+ return this.req("PUT", `/v1/wallets/${walletId}/policy`, policy);
119
+ }
120
+ /**
121
+ * Freeze a wallet — halts all spending immediately.
122
+ */
123
+ async freezeWallet(walletId) {
124
+ const r = await this.req("POST", `/v1/wallets/${walletId}/freeze`);
125
+ return r.data ?? r;
126
+ }
127
+ /**
128
+ * Unfreeze a wallet to resume normal operation.
129
+ */
130
+ async unfreezeWallet(walletId) {
131
+ const r = await this.req("POST", `/v1/wallets/${walletId}/unfreeze`);
132
+ return r.data ?? r;
133
+ }
134
+ /**
135
+ * Get paginated transaction history for a wallet.
136
+ */
137
+ async getTransactions(walletId, options) {
138
+ const params = {};
139
+ if (options?.limit)
140
+ params.limit = String(options.limit);
141
+ if (options?.offset)
142
+ params.offset = String(options.offset);
143
+ const r = await this.req("GET", `/v1/wallets/${walletId}/transactions`, undefined, Object.keys(params).length ? params : undefined);
144
+ return r.data ?? r;
145
+ }
146
+ // ── Escrows ───────────────────────────────────────────────────────────────
147
+ /**
148
+ * Create an escrow — locks credits until work is released or refunded.
149
+ */
150
+ async createEscrow(options) {
151
+ const body = {
152
+ creatorWalletId: options.creatorWalletId,
153
+ amount: options.amount,
154
+ description: options.description,
155
+ };
156
+ if (options.workerWalletId)
157
+ body.workerWalletId = options.workerWalletId;
158
+ if (options.deadline)
159
+ body.deadline = options.deadline;
160
+ const r = await this.req("POST", "/v1/escrows", body);
161
+ return r.data ?? r;
162
+ }
163
+ /**
164
+ * List escrows, optionally filtered by status.
165
+ */
166
+ async listEscrows(status) {
167
+ const params = status ? { status } : undefined;
168
+ const r = await this.req("GET", "/v1/escrows", undefined, params);
169
+ return r.data ?? r;
170
+ }
171
+ /**
172
+ * Get an escrow by ID.
173
+ */
174
+ async getEscrow(escrowId) {
175
+ const r = await this.req("GET", `/v1/escrows/${escrowId}`);
176
+ return r.data ?? r;
177
+ }
178
+ /**
179
+ * Accept an escrow as the worker.
180
+ */
181
+ async acceptEscrow(escrowId, workerWalletId) {
182
+ const r = await this.req("POST", `/v1/escrows/${escrowId}/accept`, { workerWalletId });
183
+ return r.data ?? r;
184
+ }
185
+ /**
186
+ * Release escrow funds to the worker.
187
+ */
188
+ async releaseEscrow(escrowId) {
189
+ const r = await this.req("POST", `/v1/escrows/${escrowId}/release`);
190
+ return r.data ?? r;
191
+ }
192
+ /**
193
+ * Refund escrow credits back to the creator.
194
+ */
195
+ async refundEscrow(escrowId) {
196
+ const r = await this.req("POST", `/v1/escrows/${escrowId}/refund`);
197
+ return r.data ?? r;
198
+ }
199
+ /**
200
+ * Flag an escrow as disputed — credits stay locked pending resolution.
201
+ */
202
+ async disputeEscrow(escrowId) {
203
+ const r = await this.req("POST", `/v1/escrows/${escrowId}/dispute`);
204
+ return r.data ?? r;
50
205
  }
51
206
  }
package/dist/index.d.ts CHANGED
@@ -12,4 +12,4 @@
12
12
  export { AgentTool } from "./client.js";
13
13
  export { AgentToolError } from "./errors.js";
14
14
  export type { Trace, StoreTraceOptions, SearchTracesOptions, TraceSearchResult, TraceChain } from "./traces.js";
15
- export type { CreateWalletOptions, ExecuteResult, Memory, ScrapeResult, SearchMemoryOptions, SearchResponse, SearchResult, StoreOptions, UsageStats, VerifyResult, Wallet, } from "./types.js";
15
+ export type { CreateEscrowOptions, CreateWalletOptions, Escrow, ExecuteResult, Memory, ScrapeResult, SearchMemoryOptions, SearchResponse, SearchResult, StoreOptions, UsageStats, VerifyResult, Wallet, WalletPolicy, } from "./types.js";
package/dist/memory.d.ts CHANGED
@@ -51,6 +51,16 @@ export declare class MemoryClient {
51
51
  * @returns UsageStats with current counters.
52
52
  */
53
53
  usage(): Promise<UsageStats>;
54
+ /**
55
+ * Delete a memory by ID.
56
+ * @param memoryId - UUID of the memory to delete.
57
+ */
58
+ delete(memoryId: string): Promise<void>;
59
+ /**
60
+ * Delete all memories with a given key.
61
+ * @param key - The key shared by memories to delete.
62
+ */
63
+ deleteByKey(key: string): Promise<void>;
54
64
  private post;
55
65
  private fetch;
56
66
  }
package/dist/memory.js CHANGED
@@ -79,6 +79,38 @@ export class MemoryClient {
79
79
  const resp = await this.fetch("GET", "/v1/usage");
80
80
  return resp;
81
81
  }
82
+ /**
83
+ * Delete a memory by ID.
84
+ * @param memoryId - UUID of the memory to delete.
85
+ */
86
+ async delete(memoryId) {
87
+ await this.fetch("DELETE", `/v1/memories/${memoryId}`);
88
+ }
89
+ /**
90
+ * Delete all memories with a given key.
91
+ * @param key - The key shared by memories to delete.
92
+ */
93
+ async deleteByKey(key) {
94
+ const url = `${this.http.baseUrl}/v1/memories?key=${encodeURIComponent(key)}`;
95
+ const resp = await globalThis.fetch(url, {
96
+ method: "DELETE",
97
+ headers: this.http.headers,
98
+ signal: AbortSignal.timeout(this.http.timeout),
99
+ });
100
+ if (resp.status >= 400) {
101
+ let detail;
102
+ try {
103
+ const json = (await resp.json());
104
+ detail = json.detail ?? resp.statusText;
105
+ }
106
+ catch {
107
+ detail = resp.statusText;
108
+ }
109
+ throw new AgentToolError(`Memory API error (${resp.status}): ${detail}`, {
110
+ hint: "Check your API key and memory key.",
111
+ });
112
+ }
113
+ }
82
114
  // --- internal ---
83
115
  async post(path, body) {
84
116
  return this.fetch("POST", path, body);
package/dist/types.d.ts CHANGED
@@ -76,9 +76,41 @@ export interface Wallet {
76
76
  id: string;
77
77
  name: string;
78
78
  balance: number;
79
- api_key: string;
79
+ currency: string;
80
+ frozen: boolean;
81
+ agentId?: string;
82
+ createdAt?: string;
80
83
  }
81
84
  /** Options for creating a wallet. */
82
85
  export interface CreateWalletOptions {
83
86
  name: string;
87
+ agentId?: string;
88
+ currency?: string;
89
+ }
90
+ /** A wallet spending policy. */
91
+ export interface WalletPolicy {
92
+ maxPerTransaction?: number | null;
93
+ maxPerHour?: number | null;
94
+ maxPerDay?: number | null;
95
+ allowedRecipients?: string[] | null;
96
+ requiresApprovalAbove?: number | null;
97
+ }
98
+ /** An escrow object. */
99
+ export interface Escrow {
100
+ id: string;
101
+ status: "pending" | "active" | "released" | "refunded" | "disputed";
102
+ amount: number;
103
+ description: string;
104
+ creatorWalletId: string;
105
+ workerWalletId?: string | null;
106
+ deadline?: string | null;
107
+ createdAt?: string;
108
+ }
109
+ /** Options for creating an escrow. */
110
+ export interface CreateEscrowOptions {
111
+ creatorWalletId: string;
112
+ amount: number;
113
+ description: string;
114
+ workerWalletId?: string;
115
+ deadline?: string;
84
116
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenttool/sdk",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "TypeScript SDK for agenttool.dev — memory and tools for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",