How papi-ai/papi-core works
PapiAI Core is a framework-agnostic PHP library for building provider-neutral AI agents. The main workflow is an application prompt entering an Agent, which calls a provider, may dispatch model-requested tools over multiple turns, and returns a response; streaming is a separate agent path. The graph also preserves documented schemas, conversation handling, middleware, and the broader provider contracts visible in the tree. Some capabilities are represented only by interfaces or README descriptions, so their implementation links are not inferred.
Main entry points: Agent.php Agent · Tool.php Tool Definitions · Conversation.php Conversation · AgentBuilder.php Agent Builder
Components 22
Agent Runtime
- Agent
src/Agent.php - Agent Builder
src/AgentBuilder.php - Provider Contract
src/Contracts/ProviderInterface.php - Middleware
src/Contracts/MiddlewareInterface.php - Middleware Implementations
src/Middleware - Agent Request
src/AgentRequest.php
Tools & Middleware
- Tool Definitions
src/Tool.php - Tool Contract
src/Contracts/ToolInterface.php - Tool Attributes
src/Attributes
Conversation & Output
- Conversation
src/Conversation.php - Messages
src/Message.php - Structured Schemas
src/Schema/Schema.php - Agent Response
src/Response.php - Streaming Events
src/StreamEvent.php - Conversation Store
src/Storage/FileConversationStore.php
Provider Capabilities
- Media & Model Contracts
src/Contracts - Embedding Response
src/EmbeddingResponse.php - Vector Store
src/VectorStore/InMemoryVectorStore.php - Search Result
src/SearchResult.php - Token Optimisation Contract
src/Contracts/LLMTokenOptimisationProxyInterface.php
Other components
- Application
- Provider Service
Connections 21
- Application → Agent: runs prompt
README.md - Application → Agent Builder: configures agent
README.md - Agent Builder → Agent: constructs
src/AgentBuilder.php - Agent → Provider Service: requests completion
src/Agent.php - Agent → Tool Definitions: dispatches tool calls
src/Agent.php - Tool Definitions → Tool Contract: implements
src/Tool.php - Tool Definitions → Tool Attributes: reads attributes
src/Tool.php - Agent → Middleware: passes requests
src/Agent.php - Middleware Implementations → Middleware: implements
src/Middleware/CacheMiddleware.php - Agent → Agent Request: creates request
src/Agent.php - Agent → Structured Schemas: validates output
src/Agent.php - Agent → Agent Response: returns response
src/Agent.php - Agent → Streaming Events: emits events
README.md - Conversation → Messages: manages messages
src/Conversation.php - Application → Conversation: builds history
README.md - Conversation Store → Conversation: loads and saves
src/Storage/FileConversationStore.php - Provider Service → Provider Contract: implements contract
README.md - Provider Service → Media & Model Contracts: may implement
- Embedding Response → Media & Model Contracts: models embedding result
src/Contracts/EmbeddingProviderInterface.php - Vector Store → Search Result: returns matches
src/VectorStore/InMemoryVectorStore.php - Application → Token Optimisation Contract: may integrate
src/Contracts/LLMTokenOptimisationProxyInterface.php