@push.rocks/smartagent 1.3.0 → 1.4.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.
@@ -176,6 +176,59 @@ export class BrowserTool extends BaseToolWrapper {
176
176
  }
177
177
  }
178
178
 
179
+ public getToolExplanation(): string {
180
+ return `## Tool: browser
181
+ Interact with web pages - take screenshots, generate PDFs, and execute JavaScript on pages.
182
+
183
+ ### Actions:
184
+
185
+ **screenshot** - Take a screenshot of a webpage
186
+ Parameters:
187
+ - url (required): URL of the page to screenshot
188
+
189
+ Example:
190
+ <tool_call>
191
+ <tool>browser</tool>
192
+ <action>screenshot</action>
193
+ <params>{"url": "https://example.com"}</params>
194
+ </tool_call>
195
+
196
+ **pdf** - Generate a PDF from a webpage
197
+ Parameters:
198
+ - url (required): URL of the page to convert to PDF
199
+
200
+ Example:
201
+ <tool_call>
202
+ <tool>browser</tool>
203
+ <action>pdf</action>
204
+ <params>{"url": "https://example.com/report"}</params>
205
+ </tool_call>
206
+
207
+ **evaluate** - Execute JavaScript code on a webpage and return the result
208
+ Parameters:
209
+ - url (required): URL of the page to run the script on
210
+ - script (required): JavaScript code to execute (must return a value)
211
+
212
+ Example:
213
+ <tool_call>
214
+ <tool>browser</tool>
215
+ <action>evaluate</action>
216
+ <params>{"url": "https://example.com", "script": "document.querySelectorAll('a').length"}</params>
217
+ </tool_call>
218
+
219
+ **getPageContent** - Get the text content and title of a webpage
220
+ Parameters:
221
+ - url (required): URL of the page to get content from
222
+
223
+ Example:
224
+ <tool_call>
225
+ <tool>browser</tool>
226
+ <action>getPageContent</action>
227
+ <params>{"url": "https://example.com"}</params>
228
+ </tool_call>
229
+ `;
230
+ }
231
+
179
232
  public getCallSummary(action: string, params: Record<string, unknown>): string {
180
233
  switch (action) {
181
234
  case 'screenshot':
@@ -164,6 +164,45 @@ export class DenoTool extends BaseToolWrapper {
164
164
  }
165
165
  }
166
166
 
167
+ public getToolExplanation(): string {
168
+ return `## Tool: deno
169
+ Execute TypeScript/JavaScript code in a sandboxed Deno environment with fine-grained permission control.
170
+
171
+ ### Actions:
172
+
173
+ **execute** - Execute TypeScript/JavaScript code and return stdout/stderr
174
+ Parameters:
175
+ - code (required): TypeScript/JavaScript code to execute
176
+ - permissions (optional): Array of Deno permissions to grant. Options: "all", "env", "net", "read", "write", "run", "sys", "ffi", "hrtime". Default: none (fully sandboxed)
177
+
178
+ Example - Simple execution:
179
+ <tool_call>
180
+ <tool>deno</tool>
181
+ <action>execute</action>
182
+ <params>{"code": "console.log('Hello from Deno!');"}</params>
183
+ </tool_call>
184
+
185
+ Example - With network permission:
186
+ <tool_call>
187
+ <tool>deno</tool>
188
+ <action>execute</action>
189
+ <params>{"code": "const resp = await fetch('https://api.example.com/data');\\nconsole.log(await resp.text());", "permissions": ["net"]}</params>
190
+ </tool_call>
191
+
192
+ **executeWithResult** - Execute code that outputs JSON on the last line of stdout
193
+ Parameters:
194
+ - code (required): Code that console.logs a JSON value on the final line
195
+ - permissions (optional): Array of Deno permissions to grant
196
+
197
+ Example:
198
+ <tool_call>
199
+ <tool>deno</tool>
200
+ <action>executeWithResult</action>
201
+ <params>{"code": "const result = { sum: 1 + 2, product: 2 * 3 };\\nconsole.log(JSON.stringify(result));"}</params>
202
+ </tool_call>
203
+ `;
204
+ }
205
+
167
206
  public getCallSummary(action: string, params: Record<string, unknown>): string {
168
207
  const code = params.code as string;
169
208
  const permissions = (params.permissions as string[]) || [];
@@ -666,6 +666,170 @@ export class FilesystemTool extends BaseToolWrapper {
666
666
  }
667
667
  }
668
668
 
669
+ public getToolExplanation(): string {
670
+ return `## Tool: filesystem
671
+ Read, write, list, and delete files and directories.
672
+
673
+ ### Actions:
674
+
675
+ **read** - Read file contents (full or specific line range)
676
+ Parameters:
677
+ - path (required): Path to the file
678
+ - encoding (optional): File encoding - "utf8" (default), "binary", or "base64"
679
+ - startLine (optional): First line to read (1-indexed, inclusive)
680
+ - endLine (optional): Last line to read (1-indexed, inclusive)
681
+
682
+ Example:
683
+ <tool_call>
684
+ <tool>filesystem</tool>
685
+ <action>read</action>
686
+ <params>{"path": "/path/to/file.txt"}</params>
687
+ </tool_call>
688
+
689
+ Example with line range:
690
+ <tool_call>
691
+ <tool>filesystem</tool>
692
+ <action>read</action>
693
+ <params>{"path": "/path/to/file.txt", "startLine": 10, "endLine": 20}</params>
694
+ </tool_call>
695
+
696
+ **write** - Write content to a file (creates or overwrites)
697
+ Parameters:
698
+ - path (required): Absolute path to the file
699
+ - content (required): Content to write
700
+ - encoding (optional): File encoding - "utf8" (default), "binary", or "base64"
701
+
702
+ Example:
703
+ <tool_call>
704
+ <tool>filesystem</tool>
705
+ <action>write</action>
706
+ <params>{"path": "/path/to/output.txt", "content": "Hello, World!"}</params>
707
+ </tool_call>
708
+
709
+ **list** - List files and directories in a path
710
+ Parameters:
711
+ - path (required): Directory path to list
712
+ - recursive (optional): List recursively (default: false)
713
+ - filter (optional): Glob pattern to filter results (e.g., "*.ts")
714
+
715
+ Example:
716
+ <tool_call>
717
+ <tool>filesystem</tool>
718
+ <action>list</action>
719
+ <params>{"path": "/path/to/dir", "recursive": true, "filter": "*.ts"}</params>
720
+ </tool_call>
721
+
722
+ **exists** - Check if a file or directory exists
723
+ Parameters:
724
+ - path (required): Path to check
725
+
726
+ Example:
727
+ <tool_call>
728
+ <tool>filesystem</tool>
729
+ <action>exists</action>
730
+ <params>{"path": "/path/to/check"}</params>
731
+ </tool_call>
732
+
733
+ **mkdir** - Create a directory
734
+ Parameters:
735
+ - path (required): Directory path to create
736
+ - recursive (optional): Create parent directories if needed (default: true)
737
+
738
+ Example:
739
+ <tool_call>
740
+ <tool>filesystem</tool>
741
+ <action>mkdir</action>
742
+ <params>{"path": "/path/to/new/dir"}</params>
743
+ </tool_call>
744
+
745
+ **delete** - Delete a file or directory
746
+ Parameters:
747
+ - path (required): Path to delete
748
+ - recursive (optional): For directories, delete recursively (default: false)
749
+
750
+ Example:
751
+ <tool_call>
752
+ <tool>filesystem</tool>
753
+ <action>delete</action>
754
+ <params>{"path": "/path/to/delete", "recursive": true}</params>
755
+ </tool_call>
756
+
757
+ **copy** - Copy a file to a new location
758
+ Parameters:
759
+ - source (required): Source file path
760
+ - destination (required): Destination file path
761
+
762
+ Example:
763
+ <tool_call>
764
+ <tool>filesystem</tool>
765
+ <action>copy</action>
766
+ <params>{"source": "/path/to/source.txt", "destination": "/path/to/dest.txt"}</params>
767
+ </tool_call>
768
+
769
+ **move** - Move a file to a new location
770
+ Parameters:
771
+ - source (required): Source file path
772
+ - destination (required): Destination file path
773
+
774
+ Example:
775
+ <tool_call>
776
+ <tool>filesystem</tool>
777
+ <action>move</action>
778
+ <params>{"source": "/path/to/old.txt", "destination": "/path/to/new.txt"}</params>
779
+ </tool_call>
780
+
781
+ **stat** - Get file or directory statistics (size, dates, etc.)
782
+ Parameters:
783
+ - path (required): Path to get stats for
784
+
785
+ Example:
786
+ <tool_call>
787
+ <tool>filesystem</tool>
788
+ <action>stat</action>
789
+ <params>{"path": "/path/to/file.txt"}</params>
790
+ </tool_call>
791
+
792
+ **append** - Append content to a file
793
+ Parameters:
794
+ - path (required): Absolute path to the file
795
+ - content (required): Content to append
796
+
797
+ Example:
798
+ <tool_call>
799
+ <tool>filesystem</tool>
800
+ <action>append</action>
801
+ <params>{"path": "/path/to/log.txt", "content": "New log entry\\n"}</params>
802
+ </tool_call>
803
+
804
+ **tree** - Show directory structure as a tree
805
+ Parameters:
806
+ - path (required): Root directory path
807
+ - maxDepth (optional): Maximum depth to traverse (default: 3)
808
+ - filter (optional): Glob pattern to filter files
809
+ - showSizes (optional): Include file sizes in output (default: false)
810
+ - format (optional): Output format - "string" (default) or "json"
811
+
812
+ Example:
813
+ <tool_call>
814
+ <tool>filesystem</tool>
815
+ <action>tree</action>
816
+ <params>{"path": "/path/to/dir", "maxDepth": 2}</params>
817
+ </tool_call>
818
+
819
+ **glob** - Find files matching a glob pattern
820
+ Parameters:
821
+ - pattern (required): Glob pattern (e.g., "**/*.ts", "src/**/*.js")
822
+ - path (optional): Base path to search from
823
+
824
+ Example:
825
+ <tool_call>
826
+ <tool>filesystem</tool>
827
+ <action>glob</action>
828
+ <params>{"pattern": "**/*.ts", "path": "/path/to/project"}</params>
829
+ </tool_call>
830
+ `;
831
+ }
832
+
669
833
  public getCallSummary(action: string, params: Record<string, unknown>): string {
670
834
  switch (action) {
671
835
  case 'read': {
@@ -180,6 +180,84 @@ export class HttpTool extends BaseToolWrapper {
180
180
  }
181
181
  }
182
182
 
183
+ public getToolExplanation(): string {
184
+ return `## Tool: http
185
+ Make HTTP requests to web APIs and services.
186
+
187
+ ### Actions:
188
+
189
+ **get** - Make a GET request
190
+ Parameters:
191
+ - url (required): URL to request
192
+ - headers (optional): Request headers (key-value object)
193
+ - query (optional): Query parameters (key-value object)
194
+ - timeout (optional): Timeout in milliseconds
195
+
196
+ Example:
197
+ <tool_call>
198
+ <tool>http</tool>
199
+ <action>get</action>
200
+ <params>{"url": "https://api.example.com/data", "headers": {"Authorization": "Bearer token123"}}</params>
201
+ </tool_call>
202
+
203
+ **post** - Make a POST request with JSON body
204
+ Parameters:
205
+ - url (required): URL to request
206
+ - body (optional): JSON body to send
207
+ - headers (optional): Request headers (key-value object)
208
+ - query (optional): Query parameters (key-value object)
209
+ - timeout (optional): Timeout in milliseconds
210
+
211
+ Example:
212
+ <tool_call>
213
+ <tool>http</tool>
214
+ <action>post</action>
215
+ <params>{"url": "https://api.example.com/submit", "body": {"name": "test", "value": 123}}</params>
216
+ </tool_call>
217
+
218
+ **put** - Make a PUT request with JSON body
219
+ Parameters:
220
+ - url (required): URL to request
221
+ - body (required): JSON body to send
222
+ - headers (optional): Request headers (key-value object)
223
+ - timeout (optional): Timeout in milliseconds
224
+
225
+ Example:
226
+ <tool_call>
227
+ <tool>http</tool>
228
+ <action>put</action>
229
+ <params>{"url": "https://api.example.com/resource/1", "body": {"name": "updated"}}</params>
230
+ </tool_call>
231
+
232
+ **patch** - Make a PATCH request with JSON body
233
+ Parameters:
234
+ - url (required): URL to request
235
+ - body (required): JSON body to send
236
+ - headers (optional): Request headers (key-value object)
237
+ - timeout (optional): Timeout in milliseconds
238
+
239
+ Example:
240
+ <tool_call>
241
+ <tool>http</tool>
242
+ <action>patch</action>
243
+ <params>{"url": "https://api.example.com/resource/1", "body": {"status": "active"}}</params>
244
+ </tool_call>
245
+
246
+ **delete** - Make a DELETE request
247
+ Parameters:
248
+ - url (required): URL to request
249
+ - headers (optional): Request headers (key-value object)
250
+ - timeout (optional): Timeout in milliseconds
251
+
252
+ Example:
253
+ <tool_call>
254
+ <tool>http</tool>
255
+ <action>delete</action>
256
+ <params>{"url": "https://api.example.com/resource/1"}</params>
257
+ </tool_call>
258
+ `;
259
+ }
260
+
183
261
  public getCallSummary(action: string, params: Record<string, unknown>): string {
184
262
  const method = action.toUpperCase();
185
263
  let summary = `${method} request to "${params.url}"`;
@@ -175,6 +175,37 @@ export class JsonValidatorTool extends BaseToolWrapper {
175
175
  }
176
176
  }
177
177
 
178
+ public getToolExplanation(): string {
179
+ return `## Tool: json
180
+ Validate and format JSON data. Use this to verify your JSON output is valid before completing a task.
181
+
182
+ ### Actions:
183
+
184
+ **validate** - Validate that a string is valid JSON and optionally check required fields
185
+ Parameters:
186
+ - jsonString (required): The JSON string to validate
187
+ - requiredFields (optional): Array of field names that must be present
188
+
189
+ Example:
190
+ <tool_call>
191
+ <tool>json</tool>
192
+ <action>validate</action>
193
+ <params>{"jsonString": "{\\"invoice_number\\":\\"INV-001\\",\\"total\\":99.99}", "requiredFields": ["invoice_number", "total"]}</params>
194
+ </tool_call>
195
+
196
+ **format** - Parse and pretty-print JSON string
197
+ Parameters:
198
+ - jsonString (required): The JSON string to format
199
+
200
+ Example:
201
+ <tool_call>
202
+ <tool>json</tool>
203
+ <action>format</action>
204
+ <params>{"jsonString": "{\\"name\\":\\"test\\",\\"value\\":123}"}</params>
205
+ </tool_call>
206
+ `;
207
+ }
208
+
178
209
  getCallSummary(action: string, params: Record<string, unknown>): string {
179
210
  const jsonStr = (params.jsonString as string) || '';
180
211
  const preview = jsonStr.length > 50 ? jsonStr.substring(0, 50) + '...' : jsonStr;
@@ -148,6 +148,54 @@ export class ShellTool extends BaseToolWrapper {
148
148
  }
149
149
  }
150
150
 
151
+ public getToolExplanation(): string {
152
+ return `## Tool: shell
153
+ Execute shell commands securely. Uses execSpawn (shell:false) to prevent command injection.
154
+
155
+ ### Actions:
156
+
157
+ **execute** - Execute a command with arguments (secure, no shell injection possible)
158
+ Parameters:
159
+ - command (required): The command to execute (e.g., "ls", "cat", "grep", "node")
160
+ - args (optional): Array of arguments (each argument is properly escaped)
161
+ - cwd (optional): Working directory for the command
162
+ - timeout (optional): Timeout in milliseconds
163
+ - env (optional): Additional environment variables (key-value object)
164
+
165
+ Example - List files:
166
+ <tool_call>
167
+ <tool>shell</tool>
168
+ <action>execute</action>
169
+ <params>{"command": "ls", "args": ["-la", "/path/to/dir"]}</params>
170
+ </tool_call>
171
+
172
+ Example - Run Node script:
173
+ <tool_call>
174
+ <tool>shell</tool>
175
+ <action>execute</action>
176
+ <params>{"command": "node", "args": ["script.js"], "cwd": "/path/to/project"}</params>
177
+ </tool_call>
178
+
179
+ Example - Search in files:
180
+ <tool_call>
181
+ <tool>shell</tool>
182
+ <action>execute</action>
183
+ <params>{"command": "grep", "args": ["-r", "pattern", "src/"]}</params>
184
+ </tool_call>
185
+
186
+ **which** - Check if a command exists and get its path
187
+ Parameters:
188
+ - command (required): Command name to look up (e.g., "node", "git")
189
+
190
+ Example:
191
+ <tool_call>
192
+ <tool>shell</tool>
193
+ <action>which</action>
194
+ <params>{"command": "node"}</params>
195
+ </tool_call>
196
+ `;
197
+ }
198
+
151
199
  public getCallSummary(action: string, params: Record<string, unknown>): string {
152
200
  switch (action) {
153
201
  case 'execute': {