refactor: убрать дубли, развести слои, разбить тесты
- Support/FileWalker: один обход каталога вместо двух копий - Support/Bytes: форматирование размера вместо трёх копий - Support/UrlGuard: SSRF-проверки вынесены из HttpRequestTool - Support/AtomicWriter: запись вынесена из FileSandbox - HttpRequest: normalizeUrl/resolveRedirect — одна реализация URL-логики - AiClient поверх HttpTransport::request: один транспорт, одна TLS-логика (было две копии cURL-настроек), подсказка про AI_CAINFO переехала в HttpTransport - Http переименован в HttpTransport: транспорт/значение/инструмент больше не называются одинаково - Agent: удалён мёртвый withDefaults — ядро больше не зависит от tools - tests: раннер + support + cases по темам (agent, files, http, shell, logging, tools, architecture) - архитектурные тесты: src не импортирует Tools, tools не создают AiClient и не вызывают cURL напрямую - 100 тестов
This commit is contained in:
1 parent
74bb23c159
commit
76b3be7115
28 files changed
+2022
-1749
No files matched your search
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace AiSdk\Tools;
|
||||
|
||||
use AiSdk\Http;
|
||||
use AiSdk\HttpTransport;
|
||||
use AiSdk\Tool;
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ final class WeatherTool implements Tool
|
||||
'timezone' => 'auto',
|
||||
]);
|
||||
|
||||
[$status, $body] = Http::get('https://api.open-meteo.com/v1/forecast?' . $query);
|
||||
[$status, $body] = HttpTransport::get('https://api.open-meteo.com/v1/forecast?' . $query);
|
||||
$data = json_decode($body, true);
|
||||
$current = $data['current'] ?? null;
|
||||
|
||||
@@ -124,7 +124,7 @@ final class WeatherTool implements Tool
|
||||
'format' => 'json',
|
||||
]);
|
||||
|
||||
[$status, $body] = Http::get('https://geocoding-api.open-meteo.com/v1/search?' . $query);
|
||||
[$status, $body] = HttpTransport::get('https://geocoding-api.open-meteo.com/v1/search?' . $query);
|
||||
|
||||
if ($status >= 400) {
|
||||
return null;
|
||||
@@ -150,3 +150,4 @@ final class WeatherTool implements Tool
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user