PHP code example of milpa / agent

1. Go to this page and download the library: Download milpa/agent library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

milpa / agent example snippets


use Milpa\Agent\SessionStore;
use Milpa\EventStore\FileEventStore;

$sessions = new SessionStore(new FileEventStore(__DIR__ . '/var/agent-sessions.jsonl'));

$sessions->start('migrate-inventory', 'move the Inventario plugin to sqlite');
$sessions->recordTurn('migrate-inventory', 'user', 'start with the repository');
$sessions->recordToolCall('migrate-inventory', 'make', ['what' => 'entity'], 'ok: created');

// A different process, tomorrow:
$session = $sessions->load('migrate-inventory');
$session->goal;               // 'move the Inventario plugin to sqlite'
$session->window();           // provider messages: summary + current state + recent turns
$session->classifiedWindow(); // the same window with summary / briefing / turn declarations
$session->isRunnable();

$policy->decide($session, 'make', mutating: true, 

$store->ask($id, new PendingQuestion('perm:make', '…?', ['yes','no'], expiresAt: $deadline));
$store->expireIfDue($id, new DateTimeImmutable());   // true when it closed the window

$store->answer($id, 'perm:make', 'yes', new Principal('actor:member:42', verified: true));
$store->answer($id, 'perm:make', 'yes', Principal::fromTerminal($user, $host));  // verified: false

$compactor = new Compactor(maxTurns: 40, keepRecent: 12);
$compactor->compactIfNeeded($sessions, $session);   // returns the summary it appended, or null