agent/php/Models/AgentProfile.php
Snider fc59aa02eb feat(agent/php): plugin-cc integration — column + sync command (#837)
Migration 2026_04_25_000002 adds nullable plugin_cc_name string column
to agent_profiles. AgentProfile::$fillable extended to allow it.

agentic:sync-plugins-cc artisan command:
- Scans ~/.claude/plugins via Storage::disk(...) local disk (Finder
  fallback) for directories with plugin.json
- Maps to enabled AgentProfile by name first, plugin_cc_name second
- Upserts plugin_cc_name on matches; emits mapped/unmapped table

Pest Feature test fakes HOME, creates plugin dirs, verifies both
mapping paths + disabled/non-matching profiles stay null.

Codex note: php -l clean; pest skipped (no vendor/). Boot.php command
registration deferred — new test registers the command directly to
verify behaviour; Boot wiring belongs to a follow-up that touches
existing Boot file.

Closes tasks.lthn.sh/view.php?id=837

Co-authored-by: Codex <noreply@openai.com>
2026-04-26 00:48:37 +01:00

44 lines
1,018 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',
'plugin_cc_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);
}
}