Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Mcp\Tools;
|
|
|
|
use App\Ingest\ManualEvents;
|
|
use App\Models\Event;
|
|
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
|
use Laravel\Mcp\Request;
|
|
use Laravel\Mcp\Response;
|
|
use Laravel\Mcp\ResponseFactory;
|
|
use Laravel\Mcp\Server\Tools\Annotations\IsDestructive;
|
|
|
|
#[IsDestructive]
|
|
class DeleteEvent extends AgentTool
|
|
{
|
|
protected string $name = 'delete_event';
|
|
|
|
protected string $description = 'Снять своё событие (editable: true): оно уходит в withdrawn и больше не напоминает. Это не «Сделано» — для закрытия любого события есть mark_done.';
|
|
|
|
public function __construct(private readonly ManualEvents $manual) {}
|
|
|
|
public function schema(JsonSchema $schema): array
|
|
{
|
|
return ['id' => $schema->integer()->required()];
|
|
}
|
|
|
|
public function handle(Request $request): Response|ResponseFactory
|
|
{
|
|
return $this->withOwnEvent($request, function (Event $event) {
|
|
$this->manual->withdraw($event);
|
|
|
|
return $this->respond(['id' => $event->id, 'state' => $event->fresh()->state->value]);
|
|
});
|
|
}
|
|
}
|