Search by

x-dep / chat-bundle

x-dep

Local storage for x-dep/ai-bundle chats: conversations, messages and photos with retention, owner-wide deletion and photo normalization

Package info

github.com/x-dep-labs/chat-bundle

Documentation

Type:symfony-bundle

pkg:composer/x-dep/chat-bundle

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v1.0.0 2026-12-02 11:17 UTC

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() and forgetOwner() serve "show my chats" and "delete my data" requests.
  • Messages. With messages: true (default) the bundle becomes xdep_ai.conversation_store and keeps messages in xdep_chat_message. With messages: false your 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, 0700 folders and 0600 files, 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:purge deletes conversations inactive longer than retention_days together 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-bundle conversation_store: doctrine) into the bundle tables at deploy time; xdep:chat:import-ai-messages catches 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.