Add Document Loader tool plugin using Tool API
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3573322. -->
Reported by: [marcus_johansson](https://www.drupal.org/user/385947)
Related to !15
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>[One-line status update for stakeholders]<br>
<strong>Short Description: </strong>Add Document Loader tool plugin using Tool API<br>
<strong>Check-in Date: </strong>MM/DD/YYYY<br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>The <code>document_loader</code> module provides normalized document loading and output transformation, but it is not currently exposed as a Tool API plugin. This limits its usability in AI agents, automation pipelines, and other Tool-based integrations.</p>
<p>We need a Tool plugin named <strong>Document Loader</strong> that extends the base class defined in <a href="https://git.drupalcode.org/project/tool/-/blob/1.0.x/src/Tool/ToolBase.php?ref_type=heads">ToolBase</a>.</p>
<p>The tool should allow consumers to declaratively define:</p>
<p>- Which <code>DocumentLoaderTypeInterface</code>(s) are accepted as input types.<br>
- Which <code>DocumentLoaderOutputInterface</code>(s) are requested as output types.<br>
- The actual input value to process.</p>
<p>The input value handling is dependent on <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/tool/-/work_items/3572774" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/tool/-/work_items/3572774</a></span>, and the implementation must align with the resolution of that issue.</p>
<p>Without this Tool plugin, document loading cannot be consistently orchestrated via the Tool API, reducing composability and reusability across AI modules.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>- Create a new Tool plugin named <strong>Document Loader</strong> extending <code>ToolBase</code>.</li>
<li>- Define input definitions that always include one or more <code>DocumentLoaderTypeInterface</code> implementations.</li>
<li>- Define output definitions that require one or more <code>DocumentLoaderOutputInterface</code> implementations.</li>
<li>- Add an input value parameter whose handling depends on the outcome of <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/tool/-/work_items/3572774" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/tool/-/work_items/3572774</a></span>.</li>
<li>- Ensure the tool delegates actual loading and normalization to the existing document_loader services.</li>
<li>- Validate that requested output types are supported, including any non-destructive transformations provided by the transformation manager.</li>
<li>- Throw clear exceptions when unsupported combinations are requested.</li>
<li>- Add unit and kernel tests covering successful transformations, invalid type combinations, and dependency-related failures.</li>
<li>- Document how this tool can be used in AI Agents and other Tool API consumers.</li>
</ul>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<p>[x] AI Assisted Issue<br>
This issue was generated with AI assistance, but was reviewed and refined by the creator.</p>
<p>[ ] AI Assisted Code<br>
This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p>
<p>[ ] AI Generated Code<br>
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</p>
<p>[ ] Vibe Coded<br>
This code was generated by an AI and has only been functionally tested.</p>
<p>- <strong>This issue was created with the help of AI</strong></p>
> Related issue: [Issue #3572774](https://www.drupal.org/node/3572774)
issue