@robota-sdk/agent-tools 3.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/node/index.cjs +1352 -0
- package/dist/node/index.d.cts +353 -0
- package/dist/node/index.d.ts +353 -0
- package/dist/node/index.js +1303 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Robota Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @robota-sdk/agent-tools
|
|
2
|
+
|
|
3
|
+
Tool registry, tool creation infrastructure, and built-in CLI tools for the Robota SDK. Provides everything needed to define custom tools with Zod schema validation and includes six ready-to-use file system tools.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @robota-sdk/agent-tools
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @robota-sdk/agent-tools
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Create a custom tool with `createZodFunctionTool`:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import { createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
20
|
+
|
|
21
|
+
const weatherTool = createZodFunctionTool({
|
|
22
|
+
name: 'GetWeather',
|
|
23
|
+
description: 'Get current weather for a city',
|
|
24
|
+
schema: z.object({
|
|
25
|
+
city: z.string().describe('City name'),
|
|
26
|
+
unit: z.enum(['celsius', 'fahrenheit']).default('celsius'),
|
|
27
|
+
}),
|
|
28
|
+
execute: async ({ city, unit }) => {
|
|
29
|
+
// Your implementation here
|
|
30
|
+
return { temperature: 22, unit, city };
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Built-in Tools
|
|
36
|
+
|
|
37
|
+
Six CLI tools are included for file system operations:
|
|
38
|
+
|
|
39
|
+
| Export | Tool Name | Description |
|
|
40
|
+
| ----------- | --------- | ---------------------------------------- |
|
|
41
|
+
| `bashTool` | `Bash` | Execute shell commands via child_process |
|
|
42
|
+
| `readTool` | `Read` | Read file contents with line numbers |
|
|
43
|
+
| `writeTool` | `Write` | Write content to a file |
|
|
44
|
+
| `editTool` | `Edit` | Replace a specific string in a file |
|
|
45
|
+
| `globTool` | `Glob` | Find files matching a glob pattern |
|
|
46
|
+
| `grepTool` | `Grep` | Search file contents with regex |
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import {
|
|
50
|
+
bashTool,
|
|
51
|
+
readTool,
|
|
52
|
+
writeTool,
|
|
53
|
+
editTool,
|
|
54
|
+
globTool,
|
|
55
|
+
grepTool,
|
|
56
|
+
} from '@robota-sdk/agent-tools';
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Each tool implements `getName()`, `getDescription()`, `getSchema()`, and `execute()`.
|
|
60
|
+
|
|
61
|
+
## Tool Infrastructure
|
|
62
|
+
|
|
63
|
+
| Export | Description |
|
|
64
|
+
| ----------------------- | ------------------------------------------- |
|
|
65
|
+
| `ToolRegistry` | Central tool registration and schema lookup |
|
|
66
|
+
| `FunctionTool` | JS function tool with Zod schema validation |
|
|
67
|
+
| `createFunctionTool` | Factory for creating function tools |
|
|
68
|
+
| `createZodFunctionTool` | Factory with Zod validation and conversion |
|
|
69
|
+
| `OpenAPITool` | Tool generated from OpenAPI specification |
|
|
70
|
+
| `zodToJsonSchema` | Converts Zod schemas to JSON Schema format |
|
|
71
|
+
|
|
72
|
+
## TToolResult
|
|
73
|
+
|
|
74
|
+
Built-in tools return results using the `TToolResult` type:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
interface TToolResult {
|
|
78
|
+
success: boolean;
|
|
79
|
+
output: string;
|
|
80
|
+
error?: string;
|
|
81
|
+
exitCode?: number;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Documentation
|
|
86
|
+
|
|
87
|
+
See [docs/SPEC.md](./docs/SPEC.md) for the full specification, architecture details, and type ownership.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|