Download the PHP package asterixcapri/neuron-interaction without Composer

On this page you can find all versions of the php package asterixcapri/neuron-interaction. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package neuron-interaction

Neuron Interaction

Neuron Interaction is a PHP library providing sessions, commands, selections and user preferences for applications built with Neuron AI.

Use it to save and resume conversations, offer reusable commands, ask users to choose an option, recall previous inputs and persist their preferences. The same modules work with a terminal, web backend or another delivery mechanism. Each Host Application supplies an Adapter for its UI and response model, and controls presentation, Agent execution and response streaming.

Installation

Requires PHP 8.4.1+. The 0.8.x branch supports Neuron AI 3.

Run this command in your application's directory:

Composer also installs Neuron AI as a required dependency. If you install Neuron TUI, Neuron Interaction is already included as its dependency.

What it provides

Design strengths

SessionStore and Storage

Host Applications explicitly install a History from create() or read($key) on the Agent when they want that conversation managed by this SessionStore. SessionStore does not import arbitrary Agent Histories or automatically select the latest conversation. Only Histories managed through this Store appear in its listing, subject to the existing title rules.

Use InMemoryStorage for transient state, or implement StorageInterface for application-specific persistence. Storage holds namespaced JSON documents identified by logical keys. It preserves string metadata together with data; StoredDocument::size() reports the JSON size of its data.

SessionStore::create() creates a distinct empty History. SessionStore::summaries() returns Sessions with user-authored text, ordered by most recent use and then key. Titles preserve the first non-blank user-authored textual content without terminal placeholders, escaping or truncation. SessionStore::read($key) reopens its stored History or returns null for absent or other-user keys. SessionStore::delete($key) deletes only the current user’s Session and is a no-op when absent. Sessions expose getKey() and getUserId(); History updates persist automatically. Supply a stable local or authenticated identity when constructing the Store. Ownerless documents are never assigned implicitly.

Application metadata use camelCase names and string values. Pass initial values when creating a Session, then update individual values; these changes persist immediately and preserve its messages. Application fields named userId or lastUsedAt remain ordinary metadata and cannot change ownership or ordering.

Multiple filters are combined with AND using exact string equality. Missing keys do not match; extra metadata are ignored. Results always belong to the Store's user and retain the same title, empty-conversation and ordering rules. Metadata edits preserve the last History-use time; adding or clearing messages updates it and retains application metadata.

Input history

Adapters record original submissions, including their Command invocation syntax, and exclude prompts generated by Commands. Blank inputs are ignored; only consecutive exact duplicates collapse. Each read and append uses the current Storage sequence, so existing instances see one another's submissions. Simultaneous writes are not coordinated by this module; Adapters must serialize them when sharing Storage across concurrent writers.

The same InputHistory instance optionally provides recall navigation:

Each instance keeps its own position and draft in memory; only the input sequence is persisted and shared. Adapters own keyboard handling and decide when to leave navigation, such as on editing or submitting input. A web frontend can use only entries() and navigate locally in JavaScript, without a backend call for each arrow key.

No Neuron TUI dependency, legacy reader, format fallback or automatic migration is supplied. Existing legacy files are left untouched.

Commands

Commands let users perform actions such as starting a new conversation or reopening a saved one. The library includes:

Command What it does
/clear Start an empty Session, keeping the previous conversation.
/resume Choose a saved conversation, or reopen one by its key.
/help List the available Commands.
/exit Ask the application to end the interaction.

Choose which Commands your application offers and mount them explicitly:

The Adapter decides how to display messages, offer choices and end the interaction. A terminal Adapter can update the screen; a backend Adapter can return response data. The Commands work with either.

To reopen a known Session, pass its key as the arguments:

Write a Command

A Command provides its name, a short description and the action to perform:

See the Command and Adapter reference for custom Adapters, mounting, execution outcomes and error handling.

Backend examples

These examples use BackendAdapter to collect Command messages and choices into response data. They run locally without an HTTP server, API credentials or model requests.

Each backend example is self-contained and demonstrates one flow:

Example What it shows
help.php Execute Help and print the response.
exit.php Return the stop effect to the Host Application.
clear.php Start an empty Session while keeping the previous conversation.
resume-by-key.php Reopen a conversation whose key is already known.
resume-selection.php Offer conversations, then receive the user's choice in a second request.

Run any file after installing development dependencies:

In resume-selection.php, the first request offers saved conversations. The second simulates the user's choice and reopens that conversation with a fresh Agent and Adapter. The example provides its own sample data in memory.

Configuration in Commands

Commands access the Host Application's configuration store through CommandAdapterInterface::configurationStore(), just as they access conversations through sessionStore(). Adapters must provide the same ConfigurationStore instance throughout the interaction, including selection continuations.

Read individual preferences with $store->read('model', 'default-model'), write with $store->write('model', 'chosen-model'), remove with $store->delete('model'), and inspect original values with $store->entries(). The fallback selects the read type: read('retries', 3) accepts integers, while read('model', 'default-model') accepts non-empty strings. Missing or incompatible values return the fallback; reads without one return a non-empty string or null. Writes persist through the supplied Storage immediately. See ConfigurationStore for value validation, user isolation and compatibility: old named configurations remain untouched and are not automatically imported.

Development

Commands during Agent work

ConcurrentCommandInterface extends CommandInterface without adding methods. Implement it when a Command can execute while the Agent is working without interfering with state used by that work. Help and Leave implement this marker. Adapters decide whether to admit these Commands and still provide the ordinary CommandAdapterInterface; the marker does not enforce restricted controls.


All versions of neuron-interaction with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4.1
neuron-core/neuron-ai Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package asterixcapri/neuron-interaction contains the following files

Loading the files please wait ...