package webmcp

// Code generated by cdproto-gen. DO NOT EDIT.

import (
	"fmt"
	"strings"

	"github.com/chromedp/cdproto/cdp"
	"github.com/chromedp/cdproto/runtime"
	"github.com/go-json-experiment/json/jsontext"
)

// Annotation tool annotations.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebMCP#type-Annotation
type Annotation struct {
	ReadOnly         bool `json:"readOnly"`         // A hint indicating that the tool does not modify any state.
	UntrustedContent bool `json:"untrustedContent"` // A hint indicating that the tool output may contain untrusted content, ex: UGC, 3rd party data.
	Autosubmit       bool `json:"autosubmit"`       // If the declarative tool was declared with the autosubmit attribute.
}

// InvocationStatus represents the status of a tool invocation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebMCP#type-InvocationStatus
type InvocationStatus string

// String returns the InvocationStatus as string value.
func (t InvocationStatus) String() string {
	return string(t)
}

// InvocationStatus values.
const (
	InvocationStatusCompleted InvocationStatus = "Completed"
	InvocationStatusCanceled  InvocationStatus = "Canceled"
	InvocationStatusError     InvocationStatus = "Error"
)

// UnmarshalJSON satisfies [json.Unmarshaler].
func (t *InvocationStatus) UnmarshalJSON(buf []byte) error {
	s := string(buf)
	s = strings.TrimSuffix(strings.TrimPrefix(s, `"`), `"`)

	switch InvocationStatus(s) {
	case InvocationStatusCompleted:
		*t = InvocationStatusCompleted
	case InvocationStatusCanceled:
		*t = InvocationStatusCanceled
	case InvocationStatusError:
		*t = InvocationStatusError
	default:
		return fmt.Errorf("unknown InvocationStatus value: %v", s)
	}
	return nil
}

// Tool definition of a tool that can be invoked.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebMCP#type-Tool
type Tool struct {
	Name          string              `json:"name"`        // Tool name.
	Description   string              `json:"description"` // Tool description.
	InputSchema   jsontext.Value      `json:"inputSchema,omitempty,omitzero"`
	Annotations   *Annotation         `json:"annotations,omitempty,omitzero"`   // Optional annotations for the tool.
	FrameID       cdp.FrameID         `json:"frameId"`                          // Frame identifier associated with the tool registration.
	BackendNodeID cdp.BackendNodeID   `json:"backendNodeId,omitempty,omitzero"` // Optional node ID for declarative tools.
	StackTrace    *runtime.StackTrace `json:"stackTrace,omitempty,omitzero"`    // The stack trace at the time of the registration.
}

// RemovedTool definition of a tool that was removed.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebMCP#type-RemovedTool
type RemovedTool struct {
	Name    string      `json:"name"`    // Tool name.
	FrameID cdp.FrameID `json:"frameId"` // Frame identifier associated with the tool registration.
}
