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
61 lines
1.8 KiB
PHP
Executable File
61 lines
1.8 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
/**
|
|
* Validates creation and update payloads for AI agents.
|
|
*
|
|
* Enforces the allow-list of free OpenRouter models defined in
|
|
* config/ai.php so that no paid model can ever be activated.
|
|
*/
|
|
class AiAgentRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
// Authorization is enforced by admin role middleware in routes.
|
|
return $this->user()?->isAdmin() ?? false;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$allowed = config('ai.allowed_models', []);
|
|
|
|
return [
|
|
'name' => ['required', 'string', 'max:120'],
|
|
'type' => ['required', 'string', 'max:40'],
|
|
'model' => ['required', 'string', Rule::in($allowed)],
|
|
'system_prompt' => ['nullable', 'string', 'max:8000'],
|
|
'current_goal' => ['nullable', 'string', 'max:2000'],
|
|
'status' => ['nullable', Rule::in(['active', 'paused', 'thinking', 'error'])],
|
|
'pos_x' => ['nullable', 'numeric', 'between:-100000,100000'],
|
|
'pos_y' => ['nullable', 'numeric', 'between:-100000,100000'],
|
|
'pos_z' => ['nullable', 'numeric', 'between:-100000,100000'],
|
|
'rotation_y' => ['nullable', 'numeric', 'between:-6.2832,6.2832'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom messages for validation errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'model.in' => __('validation.model_not_allowed'),
|
|
];
|
|
}
|
|
}
|