Documentation
¶
Index ¶
- type Manager
- func (m *Manager) CallTool(ctx context.Context, name, argsJSON string) (*pb.CallToolResponse, error)
- func (m *Manager) CallToolStream(ctx context.Context, name, argsJSON string) (<-chan StreamEvent, error)
- func (m *Manager) Complete(ctx context.Context, refType, refName, argName, argValue string) (*pb.CompletionResponse, error)
- func (m *Manager) GetPrompt(ctx context.Context, name, argsJSON string) (*pb.GetPromptResponse, error)
- func (m *Manager) ListPrompts(ctx context.Context) ([]*pb.PromptDefinition, error)
- func (m *Manager) ListResourceTemplates(ctx context.Context) ([]*pb.ResourceTemplateDefinition, error)
- func (m *Manager) ListResources(ctx context.Context) ([]*pb.ResourceDefinition, error)
- func (m *Manager) Middlewares() []RegisteredMiddleware
- func (m *Manager) OnCrash() <-chan error
- func (m *Manager) OnDisableTools(fn func([]string))
- func (m *Manager) OnEnableTools(fn func([]string))
- func (m *Manager) OnListRoots(fn func(string))
- func (m *Manager) OnLog(fn func(*pb.LogMessage))
- func (m *Manager) OnProgress(fn func(*pb.ProgressNotification))
- func (m *Manager) OnSampling(fn func(*pb.SamplingRequest, string))
- func (m *Manager) ReadResource(ctx context.Context, uri string) (*pb.ReadResourceResponse, error)
- func (m *Manager) RegisterPending(reqID string) chan *pb.Envelope
- func (m *Manager) Reload(ctx context.Context) ([]*pb.ToolDefinition, error)
- func (m *Manager) SendListRootsResponse(reqID string, resp *pb.ListRootsResponse) error
- func (m *Manager) SendMiddlewareIntercept(ctx context.Context, mwName, phase, toolName, argsJSON, resultJSON string, ...) (*pb.MiddlewareInterceptResponse, error)
- func (m *Manager) SendSamplingResponse(reqID string, resp *pb.SamplingResponse) error
- func (m *Manager) Start(ctx context.Context) ([]*pb.ToolDefinition, error)
- func (m *Manager) StartReadLoop()
- func (m *Manager) Stop()
- func (m *Manager) Tools() []*pb.ToolDefinition
- type ManagerConfig
- type RegisteredMiddleware
- type StreamEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager spawns a tool process, communicates via protobuf over a unix socket, and handles handshake, tool calls, reload, and crash detection.
func NewManager ¶
func NewManager(cfg ManagerConfig) *Manager
NewManager creates a new process manager with the given configuration.
func NewManagerForTest ¶
func NewManagerForTest(cfg ManagerConfig, conn net.Conn) *Manager
NewManagerForTest creates a Manager with a pre-established connection.
func (*Manager) CallTool ¶
func (m *Manager) CallTool(ctx context.Context, name, argsJSON string) (*pb.CallToolResponse, error)
CallTool sends a CallToolRequest and waits for the matching CallToolResponse.
func (*Manager) CallToolStream ¶
func (m *Manager) CallToolStream(ctx context.Context, name, argsJSON string) (<-chan StreamEvent, error)
CallToolStream sends a CallToolRequest and returns a channel that receives stream events. If the tool responds with a single (non-chunked) message, the channel receives one StreamEvent with Result set. If the tool streams, it receives a Header event followed by Chunk events.
func (*Manager) Complete ¶
func (m *Manager) Complete(ctx context.Context, refType, refName, argName, argValue string) (*pb.CompletionResponse, error)
Complete sends a CompletionRequest and waits for the matching CompletionResponse.
func (*Manager) GetPrompt ¶
func (m *Manager) GetPrompt(ctx context.Context, name, argsJSON string) (*pb.GetPromptResponse, error)
GetPrompt sends a GetPromptRequest and waits for the matching GetPromptResponse.
func (*Manager) ListPrompts ¶
ListPrompts sends a ListPromptsRequest and waits for the matching PromptListResponse.
func (*Manager) ListResourceTemplates ¶
func (m *Manager) ListResourceTemplates(ctx context.Context) ([]*pb.ResourceTemplateDefinition, error)
ListResourceTemplates sends a ListResourceTemplatesRequest and waits for the matching ResourceTemplateListResponse.
func (*Manager) ListResources ¶
ListResources sends a ListResourcesRequest and waits for the matching ResourceListResponse.
func (*Manager) Middlewares ¶
func (m *Manager) Middlewares() []RegisteredMiddleware
Middlewares returns the list of middleware registered during handshake.
func (*Manager) OnCrash ¶
OnCrash returns a channel that receives an error when the child process exits unexpectedly.
func (*Manager) OnDisableTools ¶
OnDisableTools sets a callback for disable-tools requests from the tool process.
func (*Manager) OnEnableTools ¶
OnEnableTools sets a callback for enable-tools requests from the tool process.
func (*Manager) OnListRoots ¶
OnListRoots sets a callback for list-roots requests from the SDK process.
func (*Manager) OnLog ¶
func (m *Manager) OnLog(fn func(*pb.LogMessage))
OnLog sets a callback for log messages from the tool process.
func (*Manager) OnProgress ¶
func (m *Manager) OnProgress(fn func(*pb.ProgressNotification))
OnProgress sets a callback for progress notifications from the tool process.
func (*Manager) OnSampling ¶
func (m *Manager) OnSampling(fn func(*pb.SamplingRequest, string))
OnSampling sets a callback for sampling requests from the SDK process.
func (*Manager) ReadResource ¶
ReadResource sends a ReadResourceRequest and waits for the matching ReadResourceResponse.
func (*Manager) RegisterPending ¶
RegisterPending registers a pending request channel and returns it.
func (*Manager) Reload ¶
Reload sends a ReloadRequest, waits for ReloadResponse, then receives the updated ToolListResponse.
func (*Manager) SendListRootsResponse ¶
func (m *Manager) SendListRootsResponse(reqID string, resp *pb.ListRootsResponse) error
SendListRootsResponse sends a ListRootsResponse back to the SDK process.
func (*Manager) SendMiddlewareIntercept ¶
func (m *Manager) SendMiddlewareIntercept(ctx context.Context, mwName, phase, toolName, argsJSON, resultJSON string, isError bool) (*pb.MiddlewareInterceptResponse, error)
SendMiddlewareIntercept sends a middleware intercept request and waits for the response.
func (*Manager) SendSamplingResponse ¶
func (m *Manager) SendSamplingResponse(reqID string, resp *pb.SamplingResponse) error
SendSamplingResponse sends a SamplingResponse back to the SDK process.
func (*Manager) Start ¶
Start spawns the child process, performs the handshake (ListToolsRequest), and returns the list of tools the process provides.
func (*Manager) StartReadLoop ¶
func (m *Manager) StartReadLoop()
StartReadLoop starts the readLoop (blocking).
func (*Manager) Stop ¶
func (m *Manager) Stop()
Stop kills the child process and cleans up resources.
func (*Manager) Tools ¶
func (m *Manager) Tools() []*pb.ToolDefinition
Tools returns the current list of tool definitions.
type ManagerConfig ¶
type ManagerConfig struct {
File string
RuntimeCmd string
RuntimeArgs []string
SocketPath string
MaxRetries int
CallTimeout time.Duration
}
ManagerConfig configures how the process manager spawns and communicates with a tool process.
type RegisteredMiddleware ¶
RegisteredMiddleware represents a middleware registered by the tool process during handshake.
type StreamEvent ¶
type StreamEvent struct {
// Header is set for the first event (stream start).
Header *pb.StreamHeader
// Chunk is set for data events.
Chunk []byte
// Final is true when this is the last chunk.
Final bool
// Result is set when the tool returns a non-streamed response
// (payload was below threshold).
Result *pb.CallToolResponse
}
StreamEvent represents one event in a chunked tool call response.