Search by

adachsoft / ai-agent-conversation-repository-json

Arkadiusz Adach

JSON filesystem implementation of the AdachSoft AI Agent conversation repository interface

Package info

gitlab.com/a.adach/ai-agent-conversation-repository-json

Issues

pkg:composer/adachsoft/ai-agent-conversation-repository-json

Statistics

Installs: 17

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.1 2026-11-27 22:08 UTC

This package is auto-updated.

Last update: 2026-11-27 21:09:08 UTC


README

This package stores AI agent conversation histories as JSON files. Each conversation is stored in a separate <conversation-id>.json file. It provides a filesystem-backed implementation of the AdachSoft AI Agent conversation repository interface.

Requirements

  • PHP 8.3 or later.
  • Composer.

Capabilities

  • Create, load, append to, list, and delete conversations.
  • Store each conversation independently as a JSON file.
  • Serialize current histories using the shared conversation model's versioned JSON format.
  • Read supported legacy message lists and normalize them when a non-empty append is persisted.

Installation

Install the package with Composer:

composer require adachsoft/ai-agent-conversation-repository-json

Usage

Install the dependency, create the repository with a persistent writable storage path, and call it through the repository interface. See the JSON file repository example for a complete workflow.

Integration

Create the repository through its factory and provide the resulting implementation wherever the AI Agent conversation repository interface is required:

use AdachSoft\AiAgentConversationRepositoryJson\JsonFileConversationRepositoryFactory;

$factory = new JsonFileConversationRepositoryFactory(__DIR__ . '/var/conversations');
$conversationRepository = $factory->create();

$conversationRepository->create('conversation-123');
$history = $conversationRepository->load('conversation-123');

The factory creates the storage directory if it does not exist. Keep the directory writable by the application process and choose a location appropriate for persistent application data.

File format

New and updated files use a versioned envelope with messages in the canonical adachsoft/ai-conversation-model array format:

{
  "format": "ai-conversation-model",
  "version": 1,
  "messages": []
}

The shared model preserves typed text and media content, tool calls, tool results, timestamps, roles, and metadata.

Legacy format

Existing files containing a top-level list of legacy messages remain readable. Legacy camelCase fields are converted to the shared conversation model, tool-result arrays are encoded as JSON text, and inconsistent histories are repaired when loaded. The next non-empty append writes the complete history in the versioned format.