Adds Phase 3 foundation: agent_profiles table (Postgres-compatible, FK-free),
AgentProfile Eloquent model with encrypted api_key_cipher cast, array
capability_tags cast, datetime last_dispatched_at cast, active() and
forClass(string) local scopes.
AX-10 Pest Feature test covers:
- active() returns only enabled+headroom>0 rows
- active()->forClass('A') chains correctly
- api_key_cipher round-trips via encrypted cast
- capability_tags round-trips as array
Codex note: php -l clean on all 3 files; pest+artisan unavailable at
repo root for runtime verification (composer + bootstrap live downstream
in lab/lthn.ai).
Closes tasks.lthn.sh/view.php?id=825
Co-authored-by: Codex <noreply@openai.com>
43 lines
992 B
PHP
43 lines
992 B
PHP
<?php
|
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Core\Mod\Agentic\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class AgentProfile extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'gateway_url',
|
|
'api_key_cipher',
|
|
'cost_class',
|
|
'capability_tags',
|
|
'quota_headroom_pct',
|
|
'enabled',
|
|
'last_dispatched_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'api_key_cipher' => 'encrypted',
|
|
'capability_tags' => 'array',
|
|
'quota_headroom_pct' => 'integer',
|
|
'enabled' => 'boolean',
|
|
'last_dispatched_at' => 'datetime',
|
|
];
|
|
|
|
public function scopeActive(Builder $query): Builder
|
|
{
|
|
return $query->where('enabled', true)
|
|
->where('quota_headroom_pct', '>', 0);
|
|
}
|
|
|
|
public function scopeForClass(Builder $query, string $class): Builder
|
|
{
|
|
return $query->where('cost_class', $class);
|
|
}
|
|
}
|