'array', ]; // Type constants public const TYPE_JSON = 'json'; public const TYPE_MARKDOWN = 'markdown'; public const TYPE_CODE = 'code'; public const TYPE_REFERENCE = 'reference'; // Relationships public function plan(): BelongsTo { return $this->belongsTo(AgentPlan::class, 'agent_plan_id'); } // Scopes public function scopeForPlan($query, AgentPlan|int $plan) { $planId = $plan instanceof AgentPlan ? $plan->id : $plan; return $query->where('agent_plan_id', $planId); } public function scopeOfType($query, string $type) { return $query->where('type', $type); } // Helpers public function isJson(): bool { return $this->type === self::TYPE_JSON; } public function isMarkdown(): bool { return $this->type === self::TYPE_MARKDOWN; } public function isCode(): bool { return $this->type === self::TYPE_CODE; } public function isReference(): bool { return $this->type === self::TYPE_REFERENCE; } public function getValue(): mixed { return $this->value; } public function getFormattedValue(): string { if ($this->isMarkdown() || $this->isCode()) { return is_string($this->value) ? $this->value : json_encode($this->value, JSON_PRETTY_PRINT); } return json_encode($this->value, JSON_PRETTY_PRINT); } // Output public function toMcpContext(): array { return [ 'key' => $this->key, 'type' => $this->type, 'description' => $this->description, 'value' => $this->value, 'updated_at' => $this->updated_at?->toIso8601String(), ]; } }