Search by

adachsoft / web-content-fetch-tool

Arkadiusz Adach

web-content-fetch-tool

Package info

gitlab.com/a.adach/web-content-fetch-tool

Issues

pkg:composer/adachsoft/web-content-fetch-tool

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-10-26 09:31 UTC

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.1
  • adachsoft/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