x-dep / chat-bundle
Local storage for x-dep/ai-bundle chats: conversations, messages and photos with retention, owner-wide deletion and photo normalization
Requires
- php: ^8.4
- ext-exif: *
- ext-gd: *
- ext-mbstring: *
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.15 || ^3.0
- doctrine/doctrine-migrations-bundle: ^3.4 || ^4.0
- doctrine/orm: ^3.5
- psr/clock: ^1.0
- psr/log: ^2.0 || ^3.0
- symfony/clock: ^7.4 || ^8.1
- symfony/config: ^7.4.23 || ^8.1.11
- symfony/console: ^7.4 || ^8.1
- symfony/dependency-injection: ^7.4 || ^8.1
- symfony/framework-bundle: ^7.4.24 || ^8.1.12
- symfony/http-kernel: ^7.4.24 || ^8.1.12
- symfony/uid: ^7.4 || ^8.1
- x-dep/ai-bundle: ^2.1
Requires (Dev)
- phpunit/phpunit: ^12.0 || ^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 11:19:34 UTC
README
Local storage for x-dep/ai-bundle chats on Symfony: conversations, messages and photos in your own database and disk, with a retention period, owner-wide deletion and photo normalization. The documentation is in Russian.
The bundle sits on top of ai-bundle. ai-bundle runs the turn (model, budget, limits, photo inspection); chat-bundle keeps what the turn needs between requests and deletes it on time.
Features
- Conversations with an owner.
Chat::start()creates a conversation with a random UUID v4; a guest conversation gets its owner on sign-in (claim()).conversationsOf(),forget()andforgetOwner()serve "show my chats" and "delete my data" requests. - Messages. With
messages: true(default) the bundle becomesxdep_ai.conversation_storeand keeps messages inxdep_chat_message. Withmessages: falseyour own adapter (for example, a CRM) keeps messages and the bundle keeps only conversations and photos. - Photos.
PhotoStore::accept()checks size, signature and pixel count before decoding, enforces per-owner and total quotas, applies EXIF orientation, fills transparency with white and re-encodes to JPEG without metadata (no EXIF, XMP, ICC, no GPS). Files live outside the web root,0700folders and0600files, one folder per conversation. - Turns with photos.
Chat::reply()passes stored photos to the ai-bundle turn; a photo in which the inspection saw an identity document or a bank card is deleted right away.acceptedPhotos()lists photos the inspection accepted, for hand-over to a specialist. - Retention.
xdep:chat:purgedeletes conversations inactive longer thanretention_daystogether with their messages and photos, then cleans up rows and files left by failures. - Migration from ai-bundle storage. A migration moves
xdep_ai_message(ai-bundleconversation_store: doctrine) into the bundle tables at deploy time;xdep:chat:import-ai-messagescatches up with messages written during the deploy.
Requirements
- PHP 8.4+ with
gd(JPEG, PNG, WebP),exif,mbstring - Symfony 7.4 or 8.1+
- Doctrine ORM 3.5+, DBAL 4
- MySQL 8.0 or 8.4 (SQLite for tests only; PostgreSQL is not supported)
x-dep/ai-bundle^2.1 (installed automatically)
Installation
Create the configuration first: the retention period and the photo folder are required, so cache:clear at the end of composer require fails without them.
# config/packages/xdep_chat.yaml xdep_chat: retention_days: 90 storage_dir: '%kernel.project_dir%/var/chat-photos'
composer require x-dep/chat-bundle
php bin/console doctrine:migrations:migrate
# cron, once a day
php bin/console xdep:chat:purge
$id = $chat->start('client:42'); $photo = $photos->accept($id, $uploadedBytes); // PhotoRejected: $e->text() for the person $reply = $chat->reply($id, 'consultant', 'Что скажете?', [$photo->id]);
Controller templates (upload with rate limits, streaming reply, photo display) are in docs/install.md.
Documentation (in Russian)
| Document | Contents |
|---|---|
| docs/install.md | Installation, configuration, controller templates, CRM mode, moving from ai-bundle storage |
| docs/guarantees.md | What the bundle guarantees about photos, deletion and access, and what it does not |
| UPGRADE.md | Public contract, compatibility with x-dep/ai-bundle, upgrading |
| CHANGELOG.md | Changes by version |
Maintainer practices shared by the bundles (tests, contract snapshots, migrations, releases) are in docs/bundle-development.md of x-dep/ai-bundle.
Development
Tests are not part of the Composer package. Clone the repository and run:
make install
make test
If an ai-bundle checkout lies next to this one (../ai-bundle), make install uses it instead of the Packagist release. make tools && make qa runs the full quality gate, make test-mysql the tests against a real MySQL (XDEP_TEST_MYSQL_URL; the database is wiped).
License, security, contributing
- License: MIT, see LICENSE.
- Security issues: report privately via GitHub Security Advisories, see SECURITY.md; please do not open public issues for them.
- Contributing: see CONTRIBUTING.md.