@push.rocks/smartagent 1.3.0 → 1.4.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/smartagent.classes.dualagent.js +21 -3
- package/dist_ts/smartagent.tools.base.d.ts +7 -1
- package/dist_ts/smartagent.tools.base.js +3 -6
- package/dist_ts/smartagent.tools.browser.d.ts +1 -0
- package/dist_ts/smartagent.tools.browser.js +53 -1
- package/dist_ts/smartagent.tools.deno.d.ts +1 -0
- package/dist_ts/smartagent.tools.deno.js +39 -1
- package/dist_ts/smartagent.tools.filesystem.d.ts +1 -0
- package/dist_ts/smartagent.tools.filesystem.js +164 -1
- package/dist_ts/smartagent.tools.http.d.ts +1 -0
- package/dist_ts/smartagent.tools.http.js +78 -1
- package/dist_ts/smartagent.tools.json.d.ts +1 -0
- package/dist_ts/smartagent.tools.json.js +31 -1
- package/dist_ts/smartagent.tools.shell.d.ts +1 -0
- package/dist_ts/smartagent.tools.shell.js +48 -1
- package/package.json +1 -1
- package/readme.hints.md +29 -5
- package/readme.md +145 -9
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/smartagent.classes.dualagent.ts +20 -2
- package/ts/smartagent.tools.base.ts +9 -6
- package/ts/smartagent.tools.browser.ts +53 -0
- package/ts/smartagent.tools.deno.ts +39 -0
- package/ts/smartagent.tools.filesystem.ts +164 -0
- package/ts/smartagent.tools.http.ts +78 -0
- package/ts/smartagent.tools.json.ts +31 -0
- package/ts/smartagent.tools.shell.ts +48 -0
|
@@ -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': {
|