adachsoft / web-content-fetch-tool
web-content-fetch-tool
Package info
gitlab.com/a.adach/web-content-fetch-tool
pkg:composer/adachsoft/web-content-fetch-tool
Requires
- php: ^8.3
- ext-mbstring: *
- adachsoft/ai-tool-call: ^2.0
- adachsoft/web-content-fetch-contract: ^0.1
Requires (Dev)
- adachsoft/php-code-style: ^0.7.1
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12
- rector/rector: ^2.7
- symplify/phpstan-rules: ^14.9
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-26 08:40:06 UTC
README
adachsoft/web-content-fetch-tool adapts the provider-agnostic WebContentFetcherInterface to the adachsoft/ai-tool-call tool SPI. It validates model input, delegates fetching to an injected provider, and serializes content with a configurable output limit.
Requirements
- PHP 8.3 or newer
adachsoft/web-content-fetch-contract^0.1adachsoft/ai-tool-call^2.0
Installation
composer require adachsoft/web-content-fetch-tool
The package does not select or configure a provider. The consuming application must inject an implementation of WebContentFetcherInterface.
Usage
use AdachSoft\AiToolCall\SPI\Collection\ConfigMap;
use AdachSoft\WebContentFetchContract\WebContentFetcherInterface;
use AdachSoft\WebContentFetchTool\WebContentFetchToolFactory;
/** @var WebContentFetcherInterface $fetcher */
$factory = new WebContentFetchToolFactory($fetcher);
$tool = $factory->create(new ConfigMap([
'max_content_chars' => 50000,
]));
The factory is the supported creation path. If max_content_chars is missing, is not an integer, or is less than or equal to zero, the factory uses the default of 50,000 characters. The limit is configured by the application and cannot be overridden by tool-call input.
The tool accepts a required url and optional associative options object. Options are passed unchanged to the configured provider. The result contains url, content, output_truncated, original_size_chars, returned_size_chars, and note. Output size is measured in Unicode characters.
Malformed or unsupported URLs and provider options are reported as InvalidToolCallException. Content-fetch failures are reported as ToolExecutionException.
License
MIT