<?php
namespace boru\ai\Runtime;

use boru\ai\Schema\Request;
use boru\ai\Schema\Response;
use boru\ai\Schema\ToolCall;

class ToolExecutionContext
{
    /** @var Request */
    protected $request;

    /** @var Response */
    protected $response;

    /** @var ToolCall */
    protected $toolCall;

    /** @var array */
    protected $values = array();

    public function __construct(Request $request = null, Response $response = null, ToolCall $toolCall = null, array $values = array())
    {
        $this->request = $request;
        $this->response = $response;
        $this->toolCall = $toolCall;
        $this->values = $values;
    }

    public function request(Request $value = null)
    {
        if ($value !== null) {
            $this->request = $value;
            return $this;
        }
        return $this->request;
    }

    public function response(Response $value = null)
    {
        if ($value !== null) {
            $this->response = $value;
            return $this;
        }
        return $this->response;
    }

    public function toolCall(ToolCall $value = null)
    {
        if ($value !== null) {
            $this->toolCall = $value;
            return $this;
        }
        return $this->toolCall;
    }

    public function get($key, $default = null)
    {
        return isset($this->values[$key]) ? $this->values[$key] : $default;
    }

    public function set($key, $value)
    {
        $this->values[$key] = $value;
        return $this;
    }

    public function values(array $values = null)
    {
        if ($values !== null) {
            $this->values = $values;
            return $this;
        }
        return $this->values;
    }
}
