@agentier/tools 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/dist/fetch.d.ts +68 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +5475 -0
- package/dist/read-file.d.ts +49 -0
- package/dist/shell.d.ts +61 -0
- package/dist/utils/security.d.ts +77 -0
- package/dist/write-file.d.ts +49 -0
- package/package.json +32 -0
package/dist/fetch.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for the {@link fetchTool} factory.
|
|
3
|
+
*/
|
|
4
|
+
export interface FetchToolOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Regex patterns specifying which URLs the tool is allowed to request.
|
|
7
|
+
* When provided, only matching URLs are accessible.
|
|
8
|
+
*/
|
|
9
|
+
allowedUrls?: RegExp[];
|
|
10
|
+
/**
|
|
11
|
+
* Regex patterns specifying which URLs the tool must not request.
|
|
12
|
+
* Deny rules are evaluated before allow rules.
|
|
13
|
+
*/
|
|
14
|
+
deniedUrls?: RegExp[];
|
|
15
|
+
/**
|
|
16
|
+
* Maximum time in milliseconds to wait for a response before aborting.
|
|
17
|
+
* @defaultValue `30_000` (30 seconds)
|
|
18
|
+
*/
|
|
19
|
+
timeout?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Maximum response body size in bytes. Responses exceeding this limit are
|
|
22
|
+
* truncated and flagged with `truncated: true`.
|
|
23
|
+
* @defaultValue `5_242_880` (5 MB)
|
|
24
|
+
*/
|
|
25
|
+
maxResponseSize?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a tool definition that performs HTTP requests using the global
|
|
29
|
+
* `fetch` API.
|
|
30
|
+
*
|
|
31
|
+
* The tool validates URLs against optional allow/deny regex lists, enforces
|
|
32
|
+
* a request timeout, and truncates oversized response bodies. The parent
|
|
33
|
+
* context's abort signal is forwarded so cancellation propagates correctly.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Optional configuration for URL security, timeouts, and
|
|
36
|
+
* response size limits.
|
|
37
|
+
* @returns A tool definition compatible with the agentier core runtime.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { fetchTool } from '@agentier/tools'
|
|
42
|
+
*
|
|
43
|
+
* const tool = fetchTool({
|
|
44
|
+
* allowedUrls: [/^https:\/\/api\.example\.com/],
|
|
45
|
+
* timeout: 10_000,
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function fetchTool(options?: FetchToolOptions): import("@agentier/core").Tool<{
|
|
50
|
+
url: string;
|
|
51
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | undefined;
|
|
52
|
+
headers?: Record<string, string> | undefined;
|
|
53
|
+
body?: string | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
status: number;
|
|
56
|
+
headers: {
|
|
57
|
+
[k: string]: string;
|
|
58
|
+
};
|
|
59
|
+
body: string;
|
|
60
|
+
truncated: boolean;
|
|
61
|
+
} | {
|
|
62
|
+
status: number;
|
|
63
|
+
headers: {
|
|
64
|
+
[k: string]: string;
|
|
65
|
+
};
|
|
66
|
+
body: string;
|
|
67
|
+
truncated?: undefined;
|
|
68
|
+
}>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @agentier/tools
|
|
3
|
+
*
|
|
4
|
+
* A collection of pre-built tool definitions for the agentier runtime.
|
|
5
|
+
* Each factory function returns a tool that can be registered with an agent:
|
|
6
|
+
*
|
|
7
|
+
* - {@link readFileTool} -- Read files from the filesystem.
|
|
8
|
+
* - {@link writeFileTool} -- Write or create files on the filesystem.
|
|
9
|
+
* - {@link fetchTool} -- Make HTTP requests.
|
|
10
|
+
* - {@link shellTool} -- Execute shell commands.
|
|
11
|
+
*
|
|
12
|
+
* All tools enforce configurable security boundaries (path globs, URL
|
|
13
|
+
* regexes, command regexes) to limit what the agent is allowed to do.
|
|
14
|
+
*/
|
|
15
|
+
export { readFileTool } from './read-file';
|
|
16
|
+
export type { ReadFileToolOptions } from './read-file';
|
|
17
|
+
export { writeFileTool } from './write-file';
|
|
18
|
+
export type { WriteFileToolOptions } from './write-file';
|
|
19
|
+
export { fetchTool } from './fetch';
|
|
20
|
+
export type { FetchToolOptions } from './fetch';
|
|
21
|
+
export { shellTool } from './shell';
|
|
22
|
+
export type { ShellToolOptions } from './shell';
|