Documentation
¶
Overview ¶
Package executor implements tool execution backends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor interface {
// Execute runs the tool logic and returns a message.
Execute(ctx context.Context, req Request) (string, error)
}
Executor executes a tool command.
type HTTP ¶ added in v1.2.0
type HTTP struct {
// URL is the executor endpoint.
URL string
// Method overrides HTTP method.
Method string
// Headers adds HTTP headers.
Headers map[string]string
// Timeout is the HTTP client timeout.
Timeout time.Duration
// Async enables webhook-based execution flow.
Async bool
// WebhookURL is the yaml-mcp-server callback URL.
WebhookURL string
// Pending stores async execution requests.
Pending *PendingStore
// Spec contains declarative executor settings.
Spec map[string]any
// Tool describes the tool metadata sent to external executor.
Tool protocol.ExecutorTool
// Lang defines the preferred language for messages.
Lang string
// Markup selects message formatting (markdown/html).
Markup string
}
HTTP calls an external HTTP executor.
type PendingStore ¶ added in v1.2.0
type PendingStore struct {
// contains filtered or unexported fields
}
PendingStore keeps async execution results.
func NewPendingStore ¶ added in v1.2.0
func NewPendingStore() *PendingStore
NewPendingStore creates a new async execution store.
func (*PendingStore) Cancel ¶ added in v1.2.0
func (s *PendingStore) Cancel(correlationID string)
Cancel removes a pending execution without a result.
func (*PendingStore) Register ¶ added in v1.2.0
func (s *PendingStore) Register(correlationID string) (<-chan asyncResult, error)
Register allocates a pending slot for correlationID.
func (*PendingStore) Resolve ¶ added in v1.2.0
func (s *PendingStore) Resolve(correlationID, status, result string) bool
Resolve delivers an async execution result for correlationID.
type Request ¶
type Request struct {
// ToolName is the tool being executed.
ToolName string
// Arguments are tool arguments.
Arguments map[string]any
// CorrelationID links related executions.
CorrelationID string
// TimeoutMessage is an optional timeout message.
TimeoutMessage string
}
Request contains tool execution inputs.
type Shell ¶
type Shell struct {
// Command is the shell command to execute.
Command string
// Args are command arguments.
Args []string
// Env adds environment variables.
Env map[string]string
}
Shell executes a command as a tool.
type WebhookHandler ¶ added in v1.2.0
type WebhookHandler struct {
Store *PendingStore
Logger *slog.Logger
}
WebhookHandler handles async executor callbacks.
func (*WebhookHandler) ServeHTTP ¶ added in v1.2.0
func (h *WebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP processes webhook callbacks from async executors.
Click to show internal directories.
Click to hide internal directories.