adachsoft/ai-agent-config-repository
Composer 安装命令:
composer require adachsoft/ai-agent-config-repository
包简介
AI agent configuration repository library for AdachSoft projects.
README 文档
README
Framework-agnostic library for storing and using AI agent configuration
for agents built with the adachsoft/ai-agent runtime.
This package provides:
- a model of agent configuration (VO/DTO/Collection/Exception),
- SPI repository layer with full CRUD for agent configurations and system prompts,
- a Public API for creating
AiAgentFacadeInterfaceinstances based on configuration loaded from repositories.
Requirements
- PHP:
^8.3 adachsoft/collection:^3.0adachsoft/ai-agent:^0.8adachsoft/ai-integration:^0.6.1adachsoft/ai-tool-call:^2.0
Installation
composer require adachsoft/ai-agent-config-repository
Package structure
Root namespace:
AdachSoft\AiAgentConfigRepository\...
Directory layout:
src/AiAgentConfigRepository/PublicApiVo– value objects (agent, prompt, tool, tool group identifiers)Dto– agent configuration DTO and policies DTOCollection– VO collections based onAbstractImmutableCollectionException– domain exceptions exposed by the Public APIAiAgentFromConfigFactoryInterface– factory creatingAiAgentFacadeInterfacefrom config
src/AiAgentConfigRepository/SPIRepository– repository interfaces for agent configs and system prompts (full CRUD)Mapper– mapper interface from agent definition to DTOs fromadachsoft/ai-agent
src/AiAgentConfigRepository/InfrastructureRepository/InMemory– in-memory reference implementations of repositoriesFactory– implementation ofAiAgentFromConfigFactoryInterface
Public API
Value Objects (VO)
AdachSoft\AiAgentConfigRepository\PublicApi\Vo\AgentIdAdachSoft\AiAgentConfigRepository\PublicApi\Vo\PromptIdAdachSoft\AiAgentConfigRepository\PublicApi\Vo\ToolIdAdachSoft\AiAgentConfigRepository\PublicApi\Vo\ToolGroupId
Each VO is a simple readonly wrapper around a string (public string $value).
DTOs
AdachSoft\AiAgentConfigRepository\PublicApi\Dto\AgentPoliciesDto- retry / backoff / limits / timeouts / trimming / tools-related policies
AdachSoft\AiAgentConfigRepository\PublicApi\Dto\AgentDefinitionDto- provider-agnostic, complete agent definition that contains:
- identifier, name, description,
- provider id and model id,
- prompt id and system prompt text,
- model parameters,
- timeout in seconds,
- allowed tool ids / tool group ids,
- agent policies (
AgentPoliciesDto), - conversation context strategy id and parameters.
- provider-agnostic, complete agent definition that contains:
Collections
AdachSoft\AiAgentConfigRepository\PublicApi\Collection\ToolIdCollectionAdachSoft\AiAgentConfigRepository\PublicApi\Collection\ToolGroupIdCollection
Both collections extend AdachSoft\Collection\AbstractImmutableCollection and are
strongly typed to ToolId and ToolGroupId respectively.
Exceptions
Namespace:
AdachSoft\AiAgentConfigRepository\PublicApi\Exception
Defined exceptions:
AgentNotFoundExceptionAgentAlreadyExistsExceptionSystemPromptNotFoundExceptionSystemPromptAlreadyExistsExceptionAgentRuntimeBuildFailedException
These exceptions are used by the Public API and SPI implementations to signal consistent error conditions.
SPI layer
AgentConfigRepositoryInterface
AdachSoft\AiAgentConfigRepository\SPI\Repository\AgentConfigRepositoryInterface
SPI repository contract for agent configuration with full CRUD, operating on
AgentDefinitionDto instances identified by AgentId.
SystemPromptRepositoryInterface
AdachSoft\AiAgentConfigRepository\SPI\Repository\SystemPromptRepositoryInterface
SPI repository contract for system prompts with full CRUD, operating on prompt
contents identified by PromptId.
AgentDefinitionMapperInterface
AdachSoft\AiAgentConfigRepository\SPI\Mapper\AgentDefinitionMapperInterface
Mapper responsible for transforming an AgentDefinitionDto into the DTOs
required by the adachsoft/ai-agent runtime:
AgentConfigDtoPortsConfigDtoPoliciesConfigDto
It also wires the ports (ToolCallingChatFacadeInterface, AiToolCallFacadeInterface).
In-memory implementations
The library ships with reference, in-memory repository implementations:
AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemoryAgentConfigRepository- implements
AgentConfigRepositoryInterface - stores
AgentDefinitionDtoinstances in an in-memory array
- implements
AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemorySystemPromptRepository- implements
SystemPromptRepositoryInterface - stores a
PromptId => systemPromptmap in memory
- implements
These are intended as reference implementations and for tests / simple setups. You are expected to provide your own persistence-backed repositories (database, filesystem, etc.) in your application.
Agent factory from configuration
Contract
AdachSoft\AiAgentConfigRepository\PublicApi\AiAgentFromConfigFactoryInterface
Public API for creating AiAgentFacadeInterface instances based on AgentId.
Method:
public function createById(AgentId $agentId, ?PublicEventPublisherInterface $publicEventPublisher = null): AiAgentFacadeInterface;
Exceptions:
AgentNotFoundException– when configuration for the given agent id does not exist,AgentRuntimeBuildFailedException– when the runtime agent cannot be built (e.g. missing prompt, failure inAiAgentBuilder).
Implementation
AdachSoft\AiAgentConfigRepository\Infrastructure\Factory\AiAgentFromConfigFactory
The factory uses:
AgentConfigRepositoryInterface– to loadAgentDefinitionDto,SystemPromptRepositoryInterface– to load the system prompt text,AgentDefinitionMapperInterface– to map the definition toadachsoft/ai-agentDTOs,ToolCallingChatFacadeInterfaceandAiToolCallFacadeInterface– provided ports,AiAgentBuilder– to build the finalAiAgentFacadeInterfaceinstance.
This keeps all mapping from configuration to runtime agent in a single place.
Usage example
use AdachSoft\AiAgentConfigRepository\Infrastructure\Factory\AiAgentFromConfigFactory;
use AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemoryAgentConfigRepository;
use AdachSoft\AiAgentConfigRepository\Infrastructure\Repository\InMemory\InMemorySystemPromptRepository;
use AdachSoft\AiAgentConfigRepository\PublicApi\Vo\AgentId;
use AdachSoft\AiAgentConfigRepository\SPI\Mapper\AgentDefinitionMapperInterface;
use AdachSoft\AiIntegration\PublicApi\ToolCalling\ToolCallingChatFacadeInterface;
use AdachSoft\AiToolCall\PublicApi\AiToolCallFacadeInterface;
$agentConfigRepository = new InMemoryAgentConfigRepository();
$systemPromptRepository = new InMemorySystemPromptRepository();
$mapper = /* your implementation of AgentDefinitionMapperInterface */;
$toolCallingChatFacade = /* your implementation of ToolCallingChatFacadeInterface */;
$aiToolCallFacade = /* your implementation of AiToolCallFacadeInterface */;
$factory = new AiAgentFromConfigFactory(
$agentConfigRepository,
$systemPromptRepository,
$mapper,
$toolCallingChatFacade,
$aiToolCallFacade,
);
$agentId = new AgentId('my-agent');
$agentFacade = $factory->createById($agentId);
$response = $agentFacade->chat('Hello!');
Tests and quality
The project is configured to work with:
- PHPUnit – unit tests in the
tests/directory, - PHPStan – static analysis configured via
phpstan.neon(coverssrc/andtests/), - Rector – automated refactoring rules configured in
rector.php.
Run tests:
vendor/bin/phpunit
Run PHPStan:
vendor/bin/phpstan analyse src tests
Run Rector in dry-run mode:
vendor/bin/rector process src tests --dry-run
adachsoft/ai-agent-config-repository 适用场景与选型建议
adachsoft/ai-agent-config-repository 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「configuration」 「repository」 「Agent」 「ai」 「adachsoft」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adachsoft/ai-agent-config-repository 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adachsoft/ai-agent-config-repository 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adachsoft/ai-agent-config-repository 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Configuration component
repository php library
Custom laravel monolog logger for datadog logs management, both api and agent ways
Laravel 5 - Repositories to the database layer
Utils to load, parse and work with configuration on Mezzio projects
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-06