@robota-sdk/agent-tools 3.0.0-beta.2 → 3.0.0-beta.21

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,90 +1,72 @@
1
1
  # @robota-sdk/agent-tools
2
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.
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 custom tool with `createZodFunctionTool`:
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: 'GetWeather',
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
- execute: async ({ city, unit }) => {
29
- // Your implementation here
30
- return { temperature: 22, unit, city };
31
- },
27
+ handler: async ({ city }) => ({
28
+ data: JSON.stringify({ city, temperature: 22, condition: 'sunny' }),
29
+ }),
32
30
  });
33
31
  ```
34
32
 
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 |
33
+ ### Use Built-in Tools
47
34
 
48
35
  ```typescript
49
- import {
50
- bashTool,
51
- readTool,
52
- writeTool,
53
- editTool,
54
- globTool,
55
- grepTool,
56
- } from '@robota-sdk/agent-tools';
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
- Each tool implements `getName()`, `getDescription()`, `getSchema()`, and `execute()`.
47
+ ## Built-in Tools (8)
60
48
 
61
- ## Tool Infrastructure
49
+ | Export | Tool Name | Description |
50
+ | --------------- | --------- | ------------------------------------ |
51
+ | `bashTool` | Bash | Execute shell commands |
52
+ | `readTool` | Read | Read file contents with line numbers |
53
+ | `writeTool` | Write | Write content to a file |
54
+ | `editTool` | Edit | Replace a specific string in a file |
55
+ | `globTool` | Glob | Find files matching a glob pattern |
56
+ | `grepTool` | Grep | Search file contents with regex |
57
+ | `webFetchTool` | WebFetch | Fetch URL content (HTML-to-text) |
58
+ | `webSearchTool` | WebSearch | Web search via Brave Search API |
62
59
 
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
60
+ ## Tool Infrastructure
86
61
 
87
- See [docs/SPEC.md](./docs/SPEC.md) for the full specification, architecture details, and type ownership.
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
+ | `zodToJsonSchema` | Converts Zod schemas to JSON Schema format |
88
70
 
89
71
  ## License
90
72
 
@@ -276,6 +276,12 @@ function convertZodTypeToProperty(typeObj) {
276
276
  return { ...innerProperty, ...base };
277
277
  }
278
278
  throw new Error("ZodDefault is missing innerType; cannot convert to JSON schema.");
279
+ case "ZodRecord":
280
+ if (typeDef.valueType) {
281
+ const valueProperty = convertZodTypeToProperty(typeDef.valueType);
282
+ return { type: "object", additionalProperties: valueProperty, ...base };
283
+ }
284
+ return { type: "object", additionalProperties: { type: "string" }, ...base };
279
285
  default:
280
286
  throw new Error(`Unsupported Zod type: ${String(typeDef.typeName)}`);
281
287
  }
@@ -1012,7 +1018,7 @@ async function writeFileTool(args) {
1012
1018
  await (0, import_promises2.writeFile)(filePath, content, "utf8");
1013
1019
  const result = {
1014
1020
  success: true,
1015
- output: `Written ${content.length} bytes to ${filePath}`
1021
+ output: `Written ${Buffer.byteLength(content, "utf8")} bytes to ${filePath}`
1016
1022
  };
1017
1023
  return JSON.stringify(result);
1018
1024
  } catch (err) {
@@ -86,6 +86,7 @@ interface IZodParseResult {
86
86
  interface IZodSchemaDef {
87
87
  typeName?: string;
88
88
  innerType?: IZodSchema;
89
+ valueType?: IZodSchema;
89
90
  checks?: Array<{
90
91
  kind: string;
91
92
  value?: TUniversalValue;
@@ -86,6 +86,7 @@ interface IZodParseResult {
86
86
  interface IZodSchemaDef {
87
87
  typeName?: string;
88
88
  innerType?: IZodSchema;
89
+ valueType?: IZodSchema;
89
90
  checks?: Array<{
90
91
  kind: string;
91
92
  value?: TUniversalValue;
@@ -226,6 +226,12 @@ function convertZodTypeToProperty(typeObj) {
226
226
  return { ...innerProperty, ...base };
227
227
  }
228
228
  throw new Error("ZodDefault is missing innerType; cannot convert to JSON schema.");
229
+ case "ZodRecord":
230
+ if (typeDef.valueType) {
231
+ const valueProperty = convertZodTypeToProperty(typeDef.valueType);
232
+ return { type: "object", additionalProperties: valueProperty, ...base };
233
+ }
234
+ return { type: "object", additionalProperties: { type: "string" }, ...base };
229
235
  default:
230
236
  throw new Error(`Unsupported Zod type: ${String(typeDef.typeName)}`);
231
237
  }
@@ -962,7 +968,7 @@ async function writeFileTool(args) {
962
968
  await writeFile(filePath, content, "utf8");
963
969
  const result = {
964
970
  success: true,
965
- output: `Written ${content.length} bytes to ${filePath}`
971
+ output: `Written ${Buffer.byteLength(content, "utf8")} bytes to ${filePath}`
966
972
  };
967
973
  return JSON.stringify(result);
968
974
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robota-sdk/agent-tools",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.21",
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.2"
29
+ "@robota-sdk/agent-core": "3.0.0-beta.21"
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.2"
37
+ "@robota-sdk/agent-core": "3.0.0-beta.21"
38
38
  },
39
39
  "license": "MIT",
40
40
  "publishConfig": {