vested-ai / connector-sdk-php
Official PHP SDK for the Vested AI ConnectorHub.
Requires
- php: ^8.3
- ext-json: *
- ext-openssl: *
- ext-swoole: ^5.1 || ^6.0
- firebase/php-jwt: ^6.10
- google/protobuf: ^4.0
- opis/json-schema: ^2.6
- psr/log: ^3.0
- symfony/console: ^7.0
Requires (Dev)
- mockery/mockery: ^1.6
- open-telemetry/sdk: ^1.0
- pestphp/pest: ^4.6
- phpstan/phpstan: ^1.11
- psr/container: ^2.0
Suggests
- open-telemetry/sdk: Enables tracing of connector lifecycle and tool calls
- psr/container: Required for DI-resolved class-based tool handlers
README
Connect any PHP service to the Vested AI platform. The SDK opens a long-lived gRPC stream to the hub, declares agents and tools over that stream, and dispatches tool calls to your handler code — no polling, no webhook setup, no managing your own LLM client. The hub handles model selection, prompt composition, and conversation state; your connector owns the business logic.
Install
composer require vested-ai/connector-sdk-php
Or pull the pre-built Docker image (PHP 8.3 + Swoole bundled):
docker pull vestedai/vested-ai-connector-sdk-php:0.2.4
30-Second Example
<?php // bootstrap.php require_once __DIR__ . '/vendor/autoload.php'; use Vested\Connect\Sdk\ConnectorApp; use Vested\Connect\Sdk\Attribute\{Agent, Model, Instruction, Tool}; use Vested\Connect\Sdk\Tool\{ToolHandler, ToolContext}; #[Agent(key: 'myapp.orders', name: 'Orders')] #[Model(provider: 'openai', name: 'gpt-4o')] #[Instruction(type: 'system', position: 0, body: 'You help users look up their orders.')] class OrdersAgent {} #[Tool( agentKey: 'myapp.orders', key: 'myapp.orders.get', name: 'Get order', description: 'Returns an order by ID.', inputSchema: ['type' => 'object', 'properties' => ['id' => ['type' => 'string']], 'required' => ['id']], outputSchema: ['type' => 'object', 'properties' => ['status' => ['type' => 'string']], 'required' => ['status']], )] final class GetOrder implements ToolHandler { public function handle(array $args, ToolContext $ctx): array { return ['status' => 'shipped']; // replace with a real lookup } } return ConnectorApp::create() ->scanNamespace('', __DIR__) ->build();
VESTED_CONNECTOR_TOKEN=eyJ… VESTED_CONNECTOR_HUB=hub.example.com:4443 \ vendor/bin/vested-connect worker --bootstrap=./bootstrap.php
What This Is
A connector is a long-lived worker process that registers one or more agents with the Vested AI hub. Each agent carries a model selection, a set of instruction blocks, and a set of tool definitions. Admins can override instruction bodies and disable tools in the admin UI; the connector's declared baseline is the floor that overrides are layered on top of. The hub routes LLM tool calls back to the connector over the same stream; the connector dispatches them to your handler code and returns results.
This differs from writing your own LLM client. The connector does not call the LLM directly. It registers capability and responds to callbacks. Prompt composition, model routing, conversation history, streaming to end users — all of that lives in the hub. The connector's surface area is: "declare what agents exist, implement what the tools do."
Documentation
| Document | What's in it |
|---|---|
| Quickstart | Install, write your first agent + tool, run the worker, verify in the admin UI |
| Concepts | Agents, tools, instructions, baselines vs overrides, inheritance state machine, reconciliation |
| API reference | ConnectorApp, AgentBuilder, attributes, ToolHandler, ToolContext |
| Operations | Docker, env vars, observability, reconnect supervisor, DB pool sizing, gotchas |
| Upgrading | v0.1 → v0.2 migration; v0.2.x patch notes |
| Doc index | Full table of contents including protocol reference |
License + Status
MIT. Current release: v0.3.0 (Swoole runtime, supervisor reconnect, PDO pool guidance, connector-declared tool sensitivity). Production-ready; used in the alsaif Magento connector.
Other language SDKs
Same wire protocol, same hub — all four SDKs are at feature parity (including connector-declared tool sensitivity):