@agenttool/sdk 0.2.4 → 0.2.6
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/index.d.ts +1 -1
- package/dist/tools.d.ts +15 -1
- package/dist/tools.js +22 -0
- package/dist/types.d.ts +15 -0
- package/package.json +1 -1
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 { CreateEscrowOptions, CreateWalletOptions, Escrow, ExecuteResult, Memory, ScrapeResult, SearchMemoryOptions, SearchResponse, SearchResult, StoreOptions, UsageStats, VerifyResult, Wallet, WalletPolicy, } from "./types.js";
|
|
15
|
+
export type { CreateEscrowOptions, CreateWalletOptions, DocumentResult, Escrow, ExecuteResult, ParseDocumentOptions, Memory, ScrapeResult, SearchMemoryOptions, SearchResponse, SearchResult, StoreOptions, UsageStats, VerifyResult, Wallet, WalletPolicy, } from "./types.js";
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tools client for the agent-tools API.
|
|
3
3
|
*/
|
|
4
|
-
import type { ExecuteResult, ScrapeResult, SearchResponse } from "./types.js";
|
|
4
|
+
import type { DocumentResult, ExecuteResult, ParseDocumentOptions, ScrapeResult, SearchResponse } from "./types.js";
|
|
5
5
|
import type { HttpConfig } from "./memory.js";
|
|
6
6
|
/**
|
|
7
7
|
* Client for the agent-tools API (search, scrape, execute).
|
|
@@ -45,5 +45,19 @@ export declare class ToolsClient {
|
|
|
45
45
|
execute(code: string, options?: {
|
|
46
46
|
language?: string;
|
|
47
47
|
}): Promise<ExecuteResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Parse a document and extract readable text.
|
|
50
|
+
* Supports HTML (via Readability) and plain text.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Either `url` (fetched server-side) or `base64` encoded content.
|
|
53
|
+
* @returns DocumentResult with title, content, word_count, metadata.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const doc = await at.tools.parseDocument({ url: "https://example.com/paper.html" });
|
|
58
|
+
* console.log(doc.title, doc.word_count);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
parseDocument(options: ParseDocumentOptions): Promise<DocumentResult>;
|
|
48
62
|
private post;
|
|
49
63
|
}
|
package/dist/tools.js
CHANGED
|
@@ -67,6 +67,28 @@ export class ToolsClient {
|
|
|
67
67
|
const data = await this.post("/v1/execute", body);
|
|
68
68
|
return data;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Parse a document and extract readable text.
|
|
72
|
+
* Supports HTML (via Readability) and plain text.
|
|
73
|
+
*
|
|
74
|
+
* @param options - Either `url` (fetched server-side) or `base64` encoded content.
|
|
75
|
+
* @returns DocumentResult with title, content, word_count, metadata.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const doc = await at.tools.parseDocument({ url: "https://example.com/paper.html" });
|
|
80
|
+
* console.log(doc.title, doc.word_count);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
async parseDocument(options) {
|
|
84
|
+
if (!options.url && !options.base64) {
|
|
85
|
+
throw new AgentToolError("parseDocument requires either url or base64.", {
|
|
86
|
+
hint: "Pass { url: '...' } or { base64: '...', content_type: 'text/html' }",
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const data = await this.post("/v1/document/document", options);
|
|
90
|
+
return data;
|
|
91
|
+
}
|
|
70
92
|
// --- internal ---
|
|
71
93
|
async post(path, body) {
|
|
72
94
|
const url = `${this.http.baseUrl}${path}`;
|
package/dist/types.d.ts
CHANGED
|
@@ -56,6 +56,21 @@ export interface ScrapeResult {
|
|
|
56
56
|
status_code: number;
|
|
57
57
|
[key: string]: unknown;
|
|
58
58
|
}
|
|
59
|
+
/** Result of document parsing. */
|
|
60
|
+
export interface DocumentResult {
|
|
61
|
+
title: string;
|
|
62
|
+
content: string;
|
|
63
|
+
word_count: number;
|
|
64
|
+
content_type: string;
|
|
65
|
+
metadata: Record<string, unknown>;
|
|
66
|
+
duration_ms: number;
|
|
67
|
+
}
|
|
68
|
+
/** Options for document parsing. */
|
|
69
|
+
export interface ParseDocumentOptions {
|
|
70
|
+
url?: string;
|
|
71
|
+
base64?: string;
|
|
72
|
+
content_type?: string;
|
|
73
|
+
}
|
|
59
74
|
/** Result of sandboxed code execution. */
|
|
60
75
|
export interface ExecuteResult {
|
|
61
76
|
stdout: string;
|