feat: пакет Composer rsgrinko/ai-sdk, настройки без .env

- composer.json (PSR-4), лицензия MIT, export-ignore для тестов, примеров и docs.
- Config: настройки из массива. AiClient/Agent::fromArray() — только массив,
  ::create() — массив, недостающее из окружения; fromEnv() работает как раньше.
  Неизвестный ключ — InvalidArgumentException.
- verifySsl и caInfo из AiClient теперь действительно доходят до cURL
  (раньше транспорт читал только AI_VERIFY_SSL/AI_CAINFO). Проверка TLS
  по умолчанию выключена, включается verifySsl: true или AI_VERIFY_SSL=true.
- HttpRequestTool: свои verifySsl и caInfo.
- README: установка, способы настройки, лицензия.
This commit is contained in:
rsgrinko committed 2026-11-13 16:10:11 +03:00
1 parent 0f08f35ba4
commit e44ddc702f
13 files changed
+581 -39

No files matched your search

+6
View File
@@ -35,6 +35,8 @@ final class HttpRequestTool implements Tool
* @param array<string, array<string, string>> $auth креды по хосту:
* ['api.example.com' => ['user' => 'bot', 'pass' => '***']]
* или ['api.example.com' => ['type' => 'bearer', 'token' => '***']]
* @param bool|null $verifySsl проверять TLS-сертификат; null — из AI_VERIFY_SSL (по умолчанию нет)
* @param string|null $caInfo путь к CA-бандлу; null — из AI_CAINFO
*/
public function __construct(
array $auth = [],
@@ -42,6 +44,8 @@ final class HttpRequestTool implements Tool
private readonly int $defaultChars = 4000,
private readonly float $timeout = 10.0,
private readonly float $maxTimeout = 60.0,
private readonly ?bool $verifySsl = null,
private readonly ?string $caInfo = null,
) {
$normalized = [];
@@ -166,6 +170,8 @@ final class HttpRequestTool implements Tool
$request->headers,
$request->body,
$pinned,
$this->verifySsl,
$this->caInfo,
);
$isRedirect = in_array($response['status'], [301, 302, 303, 307, 308], true);