Initial commit of the complete City10 virtual city simulation platform. Backend (Laravel 13): - REST API with Sanctum tokens and session-based web authentication - Role-based access control (admin/user) with middleware protection - AI agent CRUD with OpenRouter.ai integration restricted to free models - Store management with 3D coordinates and AI shopkeeper assignment - Versioned legal documents (Terms, Privacy, Cookies) with LGPD audit trail - Math CAPTCHA on public forms and multi-language support (pt_BR, en, es) Frontend: - Responsive Blade templates with Tailwind CSS v4 - Three.js 3D city viewer with SSE chat streaming to AI agents - Admin panel for store and user administration Infrastructure: - MariaDB/MySQL database with comprehensive migrations - Database seeders for demo content and test accounts - PHPUnit test suite and Laravel Pint code styling - Vite build configuration with hot reload
54 lines
1.4 KiB
PHP
Executable File
54 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\AiAgentFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* Autonomous AI agent entity.
|
|
*
|
|
* Drives NPCs and managers of the virtual city through the OpenRouter.ai
|
|
* API. Only allow-listed free models may be selected by administrators.
|
|
*/
|
|
#[Fillable([
|
|
'name', 'type', 'model', 'system_prompt', 'current_goal', 'last_decision',
|
|
'status', 'error_count', 'pos_x', 'pos_y', 'pos_z', 'rotation_y', 'last_think_at',
|
|
])]
|
|
class AiAgent extends Model
|
|
{
|
|
/** @use HasFactory<AiAgentFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Attributes that should be cast to native types.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'last_decision' => 'array',
|
|
'last_think_at' => 'datetime',
|
|
'pos_x' => 'float',
|
|
'pos_y' => 'float',
|
|
'pos_z' => 'float',
|
|
'rotation_y' => 'float',
|
|
'error_count' => 'integer',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Stores managed by this agent (shopkeepers, mayors, etc.).
|
|
*
|
|
* @return HasMany<Store, $this>
|
|
*/
|
|
public function stores(): HasMany
|
|
{
|
|
return $this->hasMany(Store::class, 'agent_id');
|
|
}
|
|
}
|