@robota-sdk/agent-tools 3.0.0-beta.4 → 3.0.0-beta.44
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 +51 -45
- package/dist/node/index.cjs +5 -2
- package/dist/node/index.d.cts +2 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +5 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,77 +1,76 @@
|
|
|
1
1
|
# @robota-sdk/agent-tools
|
|
2
2
|
|
|
3
|
-
Tool registry, tool creation infrastructure, and built-in CLI tools for the Robota SDK.
|
|
3
|
+
Tool registry, tool creation infrastructure, and 8 built-in CLI tools for the Robota SDK.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @robota-sdk/agent-tools
|
|
9
|
-
# or
|
|
10
|
-
pnpm add @robota-sdk/agent-tools
|
|
11
9
|
```
|
|
12
10
|
|
|
11
|
+
Peer dependency: `@robota-sdk/agent-core`
|
|
12
|
+
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
|
-
Create a
|
|
15
|
+
### Create a Tool with Zod
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { z } from 'zod';
|
|
19
18
|
import { createZodFunctionTool } from '@robota-sdk/agent-tools';
|
|
19
|
+
import { z } from 'zod';
|
|
20
20
|
|
|
21
21
|
const weatherTool = createZodFunctionTool({
|
|
22
|
-
name: '
|
|
22
|
+
name: 'get_weather',
|
|
23
23
|
description: 'Get current weather for a city',
|
|
24
24
|
schema: z.object({
|
|
25
25
|
city: z.string().describe('City name'),
|
|
26
|
-
unit: z.enum(['celsius', 'fahrenheit']).default('celsius'),
|
|
27
26
|
}),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
27
|
+
handler: async ({ city }) => ({
|
|
28
|
+
data: JSON.stringify({ city, temperature: 22, condition: 'sunny' }),
|
|
29
|
+
}),
|
|
32
30
|
});
|
|
33
31
|
```
|
|
34
32
|
|
|
35
|
-
|
|
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 |
|
|
33
|
+
### Use Built-in Tools
|
|
47
34
|
|
|
48
35
|
```typescript
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
import { bashTool, readTool, globTool, grepTool } from '@robota-sdk/agent-tools';
|
|
37
|
+
import { Robota } from '@robota-sdk/agent-core';
|
|
38
|
+
|
|
39
|
+
const agent = new Robota({
|
|
40
|
+
name: 'DevAgent',
|
|
41
|
+
aiProviders: [provider],
|
|
42
|
+
defaultModel: { provider: 'anthropic', model: 'claude-sonnet-4-6' },
|
|
43
|
+
tools: [bashTool, readTool, globTool, grepTool],
|
|
44
|
+
});
|
|
57
45
|
```
|
|
58
46
|
|
|
59
|
-
|
|
47
|
+
## Built-in Tools (8)
|
|
60
48
|
|
|
61
|
-
|
|
49
|
+
| Export | Tool Name | Description |
|
|
50
|
+
| --------------- | --------- | ------------------------------------------------ |
|
|
51
|
+
| `bashTool` | Bash | Execute shell commands via `child_process.spawn` |
|
|
52
|
+
| `readTool` | Read | Read file contents with line numbers (cat -n) |
|
|
53
|
+
| `writeTool` | Write | Write content to a file (creates parent dirs) |
|
|
54
|
+
| `editTool` | Edit | Replace a specific string in a file |
|
|
55
|
+
| `globTool` | Glob | Find files matching a glob pattern (fast-glob) |
|
|
56
|
+
| `grepTool` | Grep | Search file contents with regex patterns |
|
|
57
|
+
| `webFetchTool` | WebFetch | Fetch URL content (HTML-to-text conversion) |
|
|
58
|
+
| `webSearchTool` | WebSearch | Web search via Brave Search API |
|
|
62
59
|
|
|
63
|
-
|
|
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 |
|
|
60
|
+
## Tool Infrastructure
|
|
71
61
|
|
|
72
|
-
|
|
62
|
+
| Export | Description |
|
|
63
|
+
| ----------------------- | ------------------------------------------------------ |
|
|
64
|
+
| `ToolRegistry` | Central tool registration and schema lookup |
|
|
65
|
+
| `FunctionTool` | JS function tool with Zod schema validation |
|
|
66
|
+
| `createFunctionTool` | Factory for creating function tools |
|
|
67
|
+
| `createZodFunctionTool` | Factory with Zod validation and JSON Schema conversion |
|
|
68
|
+
| `OpenAPITool` | Tool generated from OpenAPI specification |
|
|
69
|
+
| `createOpenAPITool` | Factory for creating OpenAPI tools |
|
|
70
|
+
| `zodToJsonSchema` | Converts Zod schemas to JSON Schema format |
|
|
71
|
+
| `TToolResult` | Result type for built-in CLI tool invocations |
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
## TToolResult Shape
|
|
75
74
|
|
|
76
75
|
```typescript
|
|
77
76
|
interface TToolResult {
|
|
@@ -79,12 +78,19 @@ interface TToolResult {
|
|
|
79
78
|
output: string;
|
|
80
79
|
error?: string;
|
|
81
80
|
exitCode?: number;
|
|
81
|
+
startLine?: number; // Start line number of the edit in the original file (Edit tool only)
|
|
82
82
|
}
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
`TToolResult` is the inner result type used by built-in tools. It is serialized to JSON and placed inside the `IToolResult.data` field before being returned to the Robota execution loop.
|
|
86
|
+
|
|
87
|
+
## Dependencies
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
| Dependency | Kind | Purpose |
|
|
90
|
+
| ------------------------ | ---- | ------------------------------------------------------ |
|
|
91
|
+
| `@robota-sdk/agent-core` | Peer | Abstract tool base class, tool interfaces, event types |
|
|
92
|
+
| `fast-glob` | Prod | High-performance glob matching for the Glob tool |
|
|
93
|
+
| `zod` | Prod | Schema validation for function tool parameters |
|
|
88
94
|
|
|
89
95
|
## License
|
|
90
96
|
|
package/dist/node/index.cjs
CHANGED
|
@@ -1018,7 +1018,7 @@ async function writeFileTool(args) {
|
|
|
1018
1018
|
await (0, import_promises2.writeFile)(filePath, content, "utf8");
|
|
1019
1019
|
const result = {
|
|
1020
1020
|
success: true,
|
|
1021
|
-
output: `Written ${content
|
|
1021
|
+
output: `Written ${Buffer.byteLength(content, "utf8")} bytes to ${filePath}`
|
|
1022
1022
|
};
|
|
1023
1023
|
return JSON.stringify(result);
|
|
1024
1024
|
} catch (err) {
|
|
@@ -1096,9 +1096,12 @@ async function editFileTool(args) {
|
|
|
1096
1096
|
return JSON.stringify(result2);
|
|
1097
1097
|
}
|
|
1098
1098
|
const count = replaceAll ? content.split(oldString).length - 1 : 1;
|
|
1099
|
+
const matchIdx = content.indexOf(oldString);
|
|
1100
|
+
const startLine = matchIdx >= 0 ? content.substring(0, matchIdx).split("\n").length : 1;
|
|
1099
1101
|
const result = {
|
|
1100
1102
|
success: true,
|
|
1101
|
-
output: `Replaced ${count} occurrence(s) in ${filePath}
|
|
1103
|
+
output: `Replaced ${count} occurrence(s) in ${filePath}`,
|
|
1104
|
+
startLine
|
|
1102
1105
|
};
|
|
1103
1106
|
return JSON.stringify(result);
|
|
1104
1107
|
}
|
package/dist/node/index.d.cts
CHANGED
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.js
CHANGED
|
@@ -968,7 +968,7 @@ async function writeFileTool(args) {
|
|
|
968
968
|
await writeFile(filePath, content, "utf8");
|
|
969
969
|
const result = {
|
|
970
970
|
success: true,
|
|
971
|
-
output: `Written ${content
|
|
971
|
+
output: `Written ${Buffer.byteLength(content, "utf8")} bytes to ${filePath}`
|
|
972
972
|
};
|
|
973
973
|
return JSON.stringify(result);
|
|
974
974
|
} catch (err) {
|
|
@@ -1046,9 +1046,12 @@ async function editFileTool(args) {
|
|
|
1046
1046
|
return JSON.stringify(result2);
|
|
1047
1047
|
}
|
|
1048
1048
|
const count = replaceAll ? content.split(oldString).length - 1 : 1;
|
|
1049
|
+
const matchIdx = content.indexOf(oldString);
|
|
1050
|
+
const startLine = matchIdx >= 0 ? content.substring(0, matchIdx).split("\n").length : 1;
|
|
1049
1051
|
const result = {
|
|
1050
1052
|
success: true,
|
|
1051
|
-
output: `Replaced ${count} occurrence(s) in ${filePath}
|
|
1053
|
+
output: `Replaced ${count} occurrence(s) in ${filePath}`,
|
|
1054
|
+
startLine
|
|
1052
1055
|
};
|
|
1053
1056
|
return JSON.stringify(result);
|
|
1054
1057
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-tools",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.44",
|
|
4
4
|
"description": "Tool registry and implementations for Robota SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/node/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"zod": "^3.24.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@robota-sdk/agent-core": "3.0.0-beta.
|
|
29
|
+
"@robota-sdk/agent-core": "3.0.0-beta.44"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"openapi-types": "^12.1.3",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"tsup": "^8.0.1",
|
|
35
35
|
"typescript": "^5.3.3",
|
|
36
36
|
"vitest": "^1.6.1",
|
|
37
|
-
"@robota-sdk/agent-core": "3.0.0-beta.
|
|
37
|
+
"@robota-sdk/agent-core": "3.0.0-beta.44"
|
|
38
38
|
},
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"publishConfig": {
|