Documentation
¶
Overview ¶
Package mcptester contains the provider-neutral contracts and adapters used by the stateless MCP tester chat endpoint.
Index ¶
- Constants
- func BuildModelProxyRequest(request types.MCPTesterChatRequest, instruction string) ([]byte, error)
- func BuildModelRequest(request types.MCPTesterChatRequest, model ResolvedModel, ...) ([]byte, error)
- func IsModelResolutionError(err error, kind ModelResolutionErrorKind) bool
- func NewLLMProxyRequest(ctx context.Context, serverURL string, model ResolvedModel, body []byte, ...) (*http.Request, error)
- func NewModelProxyHTTPClient() *http.Client
- func NewModelProxyRequest(ctx context.Context, endpoint *url.URL, body []byte, ...) (*http.Request, error)
- func NewModelProxyUsageHTTPClient() *http.Client
- func NewModelProxyUsageRequest(ctx context.Context, responsesURL *url.URL, licenseKey, fingerprint string, ...) (*http.Request, error)
- func NormalizeStream(ctx context.Context, dialect llmtypes.Dialect, tools []types.MCPTesterTool, ...) error
- func ParseModelProxyURL(value string, development bool) (*url.URL, error)
- func ReadModelProxyUsage(response *http.Response) (types.ModelProxyUsage, error)
- func ValidateChatRequest(request types.MCPTesterChatRequest) error
- type EventEmitter
- type LicenseSource
- type ModelAccessResolver
- type ModelProxyAvailability
- type ModelProxySettingsReader
- type ModelProxyUsageError
- type ModelResolutionError
- type ModelResolutionErrorKind
- type ProviderConfigurationResolver
- type ResolvedModel
Constants ¶
const ( ModelProxyModel = "gpt-5.6-luna" ModelProxyMaxBodyBytes = 2 << 20 ModelProxyTimeout = 10 * time.Minute )
const (
ModelProxyUsageTimeout = 5 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func BuildModelProxyRequest ¶
func BuildModelProxyRequest(request types.MCPTesterChatRequest, instruction string) ([]byte, error)
func BuildModelRequest ¶
func BuildModelRequest(request types.MCPTesterChatRequest, model ResolvedModel, systemInstruction string) ([]byte, error)
BuildModelRequest validates the public request and converts it into the resolved model's native request dialect. The model and system instruction are server-owned and cannot be supplied by the browser.
func IsModelResolutionError ¶
func IsModelResolutionError(err error, kind ModelResolutionErrorKind) bool
func NewLLMProxyRequest ¶
func NewLLMProxyRequest(ctx context.Context, serverURL string, model ResolvedModel, body []byte, inbound http.Header) (*http.Request, error)
NewLLMProxyRequest builds the request the tester handler will send through Obot's existing LLM gateway. Reusing the browser request's authentication headers makes the gateway reconstruct the same user principal, so model access policies, message policies, usage metering, and audit identity remain on the established proxy path. serverURL must be Obot's own listener rather than its public hostname, which may be unreachable from inside Obot's host. The supplied context propagates cancellation.
func NewModelProxyHTTPClient ¶
func NewModelProxyRequest ¶
func NewModelProxyRequest(ctx context.Context, endpoint *url.URL, body []byte, licenseKey, fingerprint string, inbound http.Header) (*http.Request, error)
NewModelProxyRequest forwards only the inbound IP headers. The installation license and machine fingerprint authenticate the request.
func NewModelProxyUsageRequest ¶
func NewModelProxyUsageRequest(ctx context.Context, responsesURL *url.URL, licenseKey, fingerprint string, inbound http.Header) (*http.Request, error)
NewModelProxyUsageRequest derives the sibling endpoint from the validated Responses URL without losing a deployment prefix or its escaped path.
func NormalizeStream ¶
func NormalizeStream(ctx context.Context, dialect llmtypes.Dialect, tools []types.MCPTesterTool, input io.Reader, emit EventEmitter) error
NormalizeStream converts provider SSE into the MCP tester event contract. Provider event names and partial argument encoding never cross this boundary.
func ParseModelProxyURL ¶
ParseModelProxyURL validates local configuration without contacting the proxy. An empty value disables model proxy; callers supply the default only when unset.
func ReadModelProxyUsage ¶
func ReadModelProxyUsage(response *http.Response) (types.ModelProxyUsage, error)
func ValidateChatRequest ¶
func ValidateChatRequest(request types.MCPTesterChatRequest) error
Types ¶
type EventEmitter ¶
type EventEmitter func(types.MCPTesterStreamEvent) error
type LicenseSource ¶
type ModelAccessResolver ¶
type ModelProxyAvailability ¶
ModelProxyAvailability distinguishes confirmed provider absence from an unknown configuration. Only confirmed absence can permit the external model service.
func ResolveModelProxyAvailability ¶
func ResolveModelProxyAvailability(ctx context.Context, endpoint *url.URL, providers ProviderConfigurationResolver, settings ModelProxySettingsReader) (ModelProxyAvailability, error)
type ModelProxyUsageError ¶
ModelProxyUsageError contains only local messages, never upstream bodies or URLs.
func (*ModelProxyUsageError) Error ¶
func (e *ModelProxyUsageError) Error() string
type ModelResolutionError ¶
type ModelResolutionError struct {
Kind ModelResolutionErrorKind
Err error
}
func (*ModelResolutionError) Error ¶
func (e *ModelResolutionError) Error() string
func (*ModelResolutionError) Unwrap ¶
func (e *ModelResolutionError) Unwrap() error
type ModelResolutionErrorKind ¶
type ModelResolutionErrorKind string
const ( ModelResolutionErrorMissing ModelResolutionErrorKind = "missing" ModelResolutionErrorInactive ModelResolutionErrorKind = "inactive" ModelResolutionErrorInaccessible ModelResolutionErrorKind = "inaccessible" ModelResolutionErrorInvalid ModelResolutionErrorKind = "invalid" )
type ResolvedModel ¶
type ResolvedModel struct {
ID string
Target string
Provider string
Dialect llmtypes.Dialect
ProxyPath string
APIPath string
}
func ResolveDefaultModel ¶
func ResolveDefaultModel(ctx context.Context, client kclient.Client, helper ModelAccessResolver, user kuser.Info) (ResolvedModel, error)
ResolveDefaultModel resolves only the configured llm alias. It intentionally has no modelProxy: a missing, unbound, inactive, non-LLM, inaccessible, or unsupported model makes tester Chat unavailable while leaving MCP inspection unaffected.