Files
ars-backend/app/Services/Tool/Tools/BashTool.php
Roog 71226c255b 添加新的工具功能和测试覆盖:
- 注册 `LsTool` 和 `BashTool` 工具,支持目录操作和命令执行
- 增强工具调用逻辑,添加日志记录以提升调试能力
- 增加 `ToolRegistry` 和 `RunLoop` 的增量累积与排序优化
- 完善单元测试覆盖新工具的执行与行为验证
2025-12-23 17:26:27 +08:00

60 lines
1.4 KiB
PHP

<?php
namespace App\Services\Tool\Tools;
use App\Services\Tool\Tool;
class BashTool implements Tool
{
public function name(): string
{
return 'bash';
}
public function description(): string
{
return 'Execute bash commands';
}
/**
* @inheritDoc
*/
public function parameters(): array
{
return [
'type' => 'object',
'properties' => [
'directory' => [
'type' => 'string',
'description' => 'The directory to list',
'default' => '.',
],
'file' => [
'type' => 'string',
'description' => 'The file to read',
],
'command' => [
'type' => 'string',
'description' => 'The command to execute',
],
'user_confirmation_message' => [
'type' => 'string',
'description' => ' A message describing the purpose of this command, shown to the user for approval before execution ',
]
],
'required' => [],
];
}
/**
* @inheritDoc
*/
public function execute(array $arguments): array|string
{
return [
'output' => shell_exec($arguments['command']),
];
}
}