Documentation
¶
Overview ¶
Package capability is search, describe, and invoke. MCP and JSON call Server.
Index ¶
- Constants
- func RunJSON(ctx context.Context, s *Server, r io.Reader, w io.Writer) error
- func Sanitize(msg string) string
- type Capability
- type DescribeArgs
- type Help
- type InputField
- type InvokeArgs
- type InvokeResult
- type Line
- type NextCall
- type Params
- type PinArgs
- type SearchArgs
- type SearchHit
- type Server
- func (s *Server) Call(ctx context.Context, req runtime.Request) (InvokeResult, error)
- func (s *Server) Describe(operationID string) ([]byte, error)
- func (s *Server) Encode(v any) ([]byte, error)
- func (s *Server) EncodeInvoke(ctx context.Context, req runtime.Request) (InvokeResult, []byte, error)
- func (s *Server) EncodePreview(ctx context.Context, req runtime.Request) (runtime.Preview, []byte, error)
- func (s *Server) EncodeResult(res InvokeResult, callErr error) (InvokeResult, []byte, error)
- func (s *Server) Handle(ctx context.Context, line Line) ([]byte, error)
- func (s *Server) Preview(ctx context.Context, req runtime.Request) (runtime.Preview, error)
- func (s *Server) RunDescribe(args DescribeArgs) ([]byte, error)
- func (s *Server) RunInvoke(ctx context.Context, args InvokeArgs) ([]byte, error)
- func (s *Server) RunSearch(args SearchArgs) ([]byte, error)
- func (s *Server) Search(query string, offset, limit int) []SearchHit
Constants ¶
const ( SearchName = "capabilities_search" SearchCommand = "search" SearchDescription = "Search operations. Hits include id, call, related ids, related_calls, and confirmation. Paginate with offset and limit." DescribeName = "capabilities_describe" DescribeCommand = "describe" DescribeDescription = "Describe one operation by id. Returns the operation, the call line, related ids, and the relation note." InvokeName = "capabilities_invoke" InvokeCommand = "invoke" InvokeDescription = "" /* 1123-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Capability ¶
type Capability struct {
Name string `json:"name"`
Command string `json:"command"`
Description string `json:"description"`
Input []InputField `json:"input"`
}
func All ¶
func All() []Capability
func ByCommand ¶
func ByCommand(name string) (Capability, bool)
type DescribeArgs ¶
type DescribeArgs struct {
OperationID string `json:"operation_id" jsonschema:"operation id"`
}
type Help ¶
type Help struct {
Capabilities []Capability `json:"capabilities"`
}
type InputField ¶
type InvokeArgs ¶
type InvokeArgs struct {
OperationID string `json:"operation_id" jsonschema:"operation id"`
Params Params `json:"params,omitempty" jsonschema:"parameters; strings, or a JSON object for body"`
ApprovalID string `json:"approval_id,omitempty" jsonschema:"approved id from veto approve; a pending id does not run the call"`
Token string `json:"token,omitempty" jsonschema:"user token for this call when the scheme source is invoke"`
Preview bool `` /* 128-byte string literal not displayed */
Fields []string `json:"fields,omitempty" jsonschema:"response fields to return; omit them to keep the whole body"`
Offset int `json:"offset,omitempty" jsonschema:"page offset when fields are set"`
Limit int `json:"limit,omitempty" jsonschema:"page size when fields are set"`
Idempotency string `json:"idempotency_key,omitempty" jsonschema:"stable key for a retry after sent without a response"`
}
func DecodeInvoke ¶
func DecodeInvoke(raw []byte) (InvokeArgs, error)
DecodeInvoke reads tool arguments from the raw JSON the host sent.
func (InvokeArgs) Request ¶
func (a InvokeArgs) Request() runtime.Request
Request is the runtime call for these arguments. Caller is set by the adapter.
type InvokeResult ¶
type InvokeResult struct {
Status string `json:"status"`
ApprovalID string `json:"approval_id,omitempty"`
OperationID string `json:"operation_id,omitempty"`
HTTPStatus int `json:"http_status,omitempty"`
Body string `json:"body,omitempty"`
Code string `json:"code,omitempty"`
Retryable bool `json:"retryable"`
RetryAfter string `json:"retry_after,omitempty"`
Error string `json:"error,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Page *result.Page `json:"page,omitempty"`
Why string `json:"why,omitempty"`
Caller string `json:"caller,omitempty"`
HTTP bool `json:"http"`
Sent bool `json:"sent,omitempty"`
NextCalls []NextCall `json:"next_calls,omitempty"`
}
type Line ¶
type Line struct {
Search *SearchArgs `json:"search,omitempty"`
Describe *DescribeArgs `json:"describe,omitempty"`
Invoke *InvokeArgs `json:"invoke,omitempty"`
Caller string `json:"caller,omitempty"`
}
Line is one skill request. Exactly one of Search, Describe, or Invoke is set.
type NextCall ¶ added in v0.1.8
type NextCall struct {
OperationID string `json:"operation_id"`
Params map[string]string `json:"params,omitempty"`
}
NextCall is one later operation a successful response can name.
type Params ¶
Params is invoke arguments. Numbers stay digits, not float64.
func (*Params) UnmarshalJSON ¶
type PinArgs ¶
type PinArgs struct {
Params Params `json:"params,omitempty" jsonschema:"parameters; strings, or a JSON object for body"`
ApprovalID string `json:"approval_id,omitempty" jsonschema:"approved id from veto approve; a pending id does not run the call"`
Token string `json:"token,omitempty" jsonschema:"user token for this call when the scheme source is invoke"`
Preview bool `` /* 128-byte string literal not displayed */
Fields []string `json:"fields,omitempty" jsonschema:"response fields to return; omit them to keep the whole body"`
Offset int `json:"offset,omitempty" jsonschema:"page offset when fields are set"`
Limit int `json:"limit,omitempty" jsonschema:"page size when fields are set"`
Idempotency string `json:"idempotency_key,omitempty" jsonschema:"stable key for a retry after sent without a response"`
}
PinArgs is invoke for a pinned tool. The pin is the operation.
func (PinArgs) Invoke ¶
func (a PinArgs) Invoke(operationID string) InvokeArgs
Invoke binds a pinned tool to the shared invoke arguments.
type SearchArgs ¶
type SearchHit ¶
type SearchHit struct {
ID string `json:"id"`
Call string `json:"call"`
Related []string `json:"related,omitempty"`
RelatedCalls []string `json:"related_calls,omitempty"`
Confirmation bool `json:"confirmation,omitempty"`
Task bool `json:"task,omitempty"`
}
SearchHit is one search result on the wire. Describe still returns the operation.
type Server ¶
type Server struct {
Catalog *catalog.Catalog
Semantics semantics.Notes
Calls *runtime.Runtime
Flows map[string]*flow.Definition
// contains filtered or unexported fields
}
func (*Server) EncodeInvoke ¶
func (s *Server) EncodeInvoke(ctx context.Context, req runtime.Request) (InvokeResult, []byte, error)
EncodeInvoke runs Call, redacts, and encodes. Adapters share this body.
func (*Server) EncodePreview ¶
func (s *Server) EncodePreview(ctx context.Context, req runtime.Request) (runtime.Preview, []byte, error)
EncodePreview runs Preview and encodes. A failed preview still returns the body.
func (*Server) EncodeResult ¶
func (s *Server) EncodeResult(res InvokeResult, callErr error) (InvokeResult, []byte, error)
EncodeResult redacts and encodes one invoke result.
func (*Server) Preview ¶
Preview runs the shared runtime and stops before a token URL and upstream HTTP.
func (*Server) RunDescribe ¶
func (s *Server) RunDescribe(args DescribeArgs) ([]byte, error)