Documentation
¶
Index ¶
- Constants
- Variables
- func IsApprovalPending() bool
- func NewEchoTools() taskengine.ToolsRepo
- func NewLocalExecTools(opts ...LocalExecOption) taskengine.ToolsRepo
- func NewLocalExecToolsWith(runner CommandRunner, opts ...LocalExecOption) taskengine.ToolsRepo
- func NewLocalFSTools(allowedDir string, db libdb.DBManager) taskengine.ToolsRepo
- func NewLocalFSToolsWith(allowedDir string, db libdb.DBManager, io FileIO, name string, ...) taskengine.ToolsRepo
- func NewPrint(tracker libtracker.ActivityTracker) taskengine.ToolsRepo
- func NewSSHTools(options ...SSHOption) (taskengine.ToolsRepo, error)
- func NewWebCaller(tracker libtracker.ActivityTracker, options ...WebtoolsOption) taskengine.ToolsRepo
- func PruneLocalFSReads(ctx context.Context, exec interface{ ... }, dialect SQLDialect, ...) error
- func RunOAuthFlow(ctx context.Context, o2cfg *oauth2.Config, oauthCfg *MCPOAuthConfig, ...) (*oauth2.Token, error)
- type AskApproval
- type AtomicFileIO
- type CommandRunner
- type CommandSpec
- type EchoTools
- func (e *EchoTools) Exec(ctx context.Context, startTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (e *EchoTools) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (e *EchoTools) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (e *EchoTools) Supports(ctx context.Context) ([]string, error)
- type FSOption
- type FileIO
- type FsSedResult
- type FsWriteResult
- type HITLWrapper
- func (h *HITLWrapper) Exec(ctx context.Context, startTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (h *HITLWrapper) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (h *HITLWrapper) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (h *HITLWrapper) Supports(ctx context.Context) ([]string, error)
- type HostKeyVerifier
- type LocalExecOption
- func WithLocalExecAllowedCommands(commands []string) LocalExecOption
- func WithLocalExecAllowedDir(dir string) LocalExecOption
- func WithLocalExecDeniedCommands(commands []string) LocalExecOption
- func WithLocalExecScrubEnv(scrub func([]string) []string) LocalExecOption
- func WithLocalExecShell(shell PlatformShell) LocalExecOption
- func WithLocalExecTimeout(d time.Duration) LocalExecOption
- type LocalExecResult
- type LocalExecTools
- func (h *LocalExecTools) Exec(ctx context.Context, startTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (h *LocalExecTools) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (h *LocalExecTools) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (h *LocalExecTools) Supports(ctx context.Context) ([]string, error)
- type LocalFSTools
- func (h *LocalFSTools) Exec(ctx context.Context, startTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (h *LocalFSTools) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (h *LocalFSTools) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (h *LocalFSTools) InvalidateSessionReads(ctx context.Context, sessionID string) error
- func (h *LocalFSTools) Supports(ctx context.Context) ([]string, error)
- type MCPAuthConfig
- type MCPAuthType
- type MCPOAuthConfig
- type MCPServerConfig
- type MCPSessionPool
- func (p *MCPSessionPool) CallTool(ctx context.Context, toolName string, args map[string]any) (any, error)
- func (p *MCPSessionPool) Close() error
- func (p *MCPSessionPool) Connect(ctx context.Context) error
- func (p *MCPSessionPool) ListTools(ctx context.Context) ([]*mcp.Tool, error)
- func (p *MCPSessionPool) Reconnect(ctx context.Context) error
- func (p *MCPSessionPool) Session(ctx context.Context) (*mcp.ClientSession, error)
- type MCPTransport
- type MockToolsRepo
- func (m *MockToolsRepo) CallCount() int
- func (m *MockToolsRepo) Exec(ctx context.Context, startingTime time.Time, input any, ...) (int, any, taskengine.DataType, string, error)
- func (m *MockToolsRepo) LastCall() *ToolsCallRecord
- func (m *MockToolsRepo) Reset()
- func (m *MockToolsRepo) Supports(ctx context.Context) ([]string, error)
- func (m *MockToolsRepo) WithErrorSequence(errors ...error) *MockToolsRepo
- func (m *MockToolsRepo) WithResponse(toolsType string, response ToolsResponse) *MockToolsRepo
- type PlatformShell
- func DetectPlatformShell() PlatformShell
- func DetectPlatformShellFor(goos string, getenv func(string) string, lookPath func(string) (string, error)) PlatformShell
- func NewCmdShell(command string) PlatformShell
- func NewPowerShellShell(command string) PlatformShell
- func NewShShell(command string) PlatformShell
- func (s PlatformShell) IsSet() bool
- func (s PlatformShell) ShellModeDescription() string
- func (s PlatformShell) Summary() string
- func (s PlatformShell) WithDefaults() PlatformShell
- func (s PlatformShell) WrapCommand(command string, args []string) (program string, wrappedArgs []string, script string)
- type Print
- func (h *Print) Exec(ctx context.Context, startTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (h *Print) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (h *Print) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (h *Print) Supports(ctx context.Context) ([]string, error)
- type SQLDialect
- type SSHClientCache
- type SSHConfig
- type SSHOption
- type SSHResult
- type SSHTools
- func (h *SSHTools) Close() error
- func (h *SSHTools) Exec(ctx context.Context, startTime time.Time, input any, debug bool, ...) (any, taskengine.DataType, error)
- func (h *SSHTools) GetSchemasForSupportedTools(ctx context.Context) (map[string]*openapi3.T, error)
- func (h *SSHTools) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
- func (h *SSHTools) Supports(ctx context.Context) ([]string, error)
- type ShellKind
- type StatFileIO
- type ToolsCallRecord
- type ToolsResponse
- type WebCaller
- func (h *WebCaller) Exec(ctx context.Context, _ time.Time, input any, _ bool, ...) (any, taskengine.DataType, error)
- func (h *WebCaller) GetSchemasForSupportedTools(_ context.Context) (map[string]*openapi3.T, error)
- func (h *WebCaller) GetToolsForToolsByName(_ context.Context, name string) ([]taskengine.Tool, error)
- func (h *WebCaller) Supports(_ context.Context) ([]string, error)
- type WebtoolsOption
Constants ¶
View Source
const (
DenyMessage = denyMessageUser
)
View Source
const LocalExecToolsName = localExecToolsName
LocalExecToolsName is the registered toolset name local_shell answers on.
View Source
const LocalFSToolsName = "local_fs"
View Source
const WebToolsName = "webtools"
Variables ¶
View Source
var ( ErrMCPToolCallFailed = errors.New("mcp tool call failed") ErrMCPListToolsFailed = errors.New("mcp list-tools failed") ErrMCPOAuthNotAuthenticated = errors.New("mcp oauth not authenticated") ErrOAuthNotAuthenticated = ErrMCPOAuthNotAuthenticated )
View Source
var ErrOutputBudgetExceeded = errors.New("local_shell: command output exceeded the remaining context budget")
Functions ¶
func IsApprovalPending ¶
func IsApprovalPending() bool
func NewEchoTools ¶
func NewEchoTools() taskengine.ToolsRepo
func NewLocalExecTools ¶
func NewLocalExecTools(opts ...LocalExecOption) taskengine.ToolsRepo
func NewLocalExecToolsWith ¶
func NewLocalExecToolsWith(runner CommandRunner, opts ...LocalExecOption) taskengine.ToolsRepo
func NewLocalFSTools ¶
func NewLocalFSTools(allowedDir string, db libdb.DBManager) taskengine.ToolsRepo
func NewLocalFSToolsWith ¶
func NewPrint ¶
func NewPrint(tracker libtracker.ActivityTracker) taskengine.ToolsRepo
func NewSSHTools ¶
func NewSSHTools(options ...SSHOption) (taskengine.ToolsRepo, error)
func NewWebCaller ¶
func NewWebCaller(tracker libtracker.ActivityTracker, options ...WebtoolsOption) taskengine.ToolsRepo
func PruneLocalFSReads ¶
func RunOAuthFlow ¶
func RunOAuthFlow(ctx context.Context, o2cfg *oauth2.Config, oauthCfg *MCPOAuthConfig, meta *mcpoauth.ServerMetadata) (*oauth2.Token, error)
Types ¶
type AskApproval ¶
type AskApproval func(ctx context.Context, req hitlservice.ApprovalRequest) (bool, error)
type AtomicFileIO ¶
type CommandRunner ¶
type CommandRunner interface {
Run(ctx context.Context, spec CommandSpec, stdout, stderr io.Writer) (exitCode int, err error)
}
func NewOSCommandRunner ¶
func NewOSCommandRunner() CommandRunner
func NewOSCommandRunnerWithShell ¶ added in v0.28.4
func NewOSCommandRunnerWithShell(shell PlatformShell) CommandRunner
func NewOSCommandRunnerWithShellAndScrub ¶
func NewOSCommandRunnerWithShellAndScrub(shell PlatformShell, scrub func([]string) []string) CommandRunner
type CommandSpec ¶
type EchoTools ¶
type EchoTools struct{}
func (*EchoTools) GetSchemasForSupportedTools ¶
func (*EchoTools) GetToolsForToolsByName ¶
type FSOption ¶
type FSOption func(*LocalFSTools)
func WithSQLDialect ¶
func WithSQLDialect(d SQLDialect) FSOption
type FileIO ¶
type FileIO interface {
ReadFile(ctx context.Context, path string) ([]byte, error)
WriteFile(ctx context.Context, path string, data []byte) error
}
func NewOSFileIO ¶
func NewOSFileIO() FileIO
type FsSedResult ¶ added in v0.29.0
type FsSedResult struct {
Path string `json:"path"`
Written bool `json:"written"`
Changed bool `json:"changed"`
Replacements int `json:"replacements"`
OldBytes int `json:"old_bytes"`
NewBytes int `json:"new_bytes"`
OldSHA256 string `json:"old_sha256"`
NewSHA256 string `json:"new_sha256"`
OldText string `json:"-"`
NewText string `json:"-"`
}
type FsWriteResult ¶
type HITLWrapper ¶
type HITLWrapper struct {
// contains filtered or unexported fields
}
func NewHITLWrapper ¶
func NewHITLWrapper(inner taskengine.ToolsRepo, ask AskApproval, policy hitlservice.PolicyEvaluator, tracker libtracker.ActivityTracker, eventSinks ...taskengine.TaskEventSink) *HITLWrapper
func (*HITLWrapper) Exec ¶
func (h *HITLWrapper) Exec( ctx context.Context, startTime time.Time, input any, debug bool, tools *taskengine.ToolsCall, ) (any, taskengine.DataType, error)
func (*HITLWrapper) GetSchemasForSupportedTools ¶
func (*HITLWrapper) GetToolsForToolsByName ¶
func (h *HITLWrapper) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
type HostKeyVerifier ¶
type HostKeyVerifier struct {
// contains filtered or unexported fields
}
func NewHostKeyVerifier ¶
func NewHostKeyVerifier(knownHostsFile string, strict bool) (*HostKeyVerifier, error)
func (*HostKeyVerifier) AddKnownHost ¶
func (v *HostKeyVerifier) AddKnownHost(host, key string)
func (*HostKeyVerifier) VerifyHostKey ¶
type LocalExecOption ¶
type LocalExecOption func(*LocalExecTools)
func WithLocalExecAllowedCommands ¶
func WithLocalExecAllowedCommands(commands []string) LocalExecOption
func WithLocalExecAllowedDir ¶
func WithLocalExecAllowedDir(dir string) LocalExecOption
func WithLocalExecDeniedCommands ¶
func WithLocalExecDeniedCommands(commands []string) LocalExecOption
func WithLocalExecScrubEnv ¶
func WithLocalExecScrubEnv(scrub func([]string) []string) LocalExecOption
func WithLocalExecShell ¶ added in v0.28.4
func WithLocalExecShell(shell PlatformShell) LocalExecOption
func WithLocalExecTimeout ¶
func WithLocalExecTimeout(d time.Duration) LocalExecOption
type LocalExecResult ¶
type LocalExecResult struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
DurationSeconds float64 `json:"duration_seconds"`
Command string `json:"command,omitempty"`
Shell string `json:"shell,omitempty"`
OS string `json:"os,omitempty"`
}
type LocalExecTools ¶
type LocalExecTools struct {
// contains filtered or unexported fields
}
func (*LocalExecTools) Exec ¶
func (h *LocalExecTools) Exec(ctx context.Context, startTime time.Time, input any, debug bool, tools *taskengine.ToolsCall) (any, taskengine.DataType, error)
func (*LocalExecTools) GetSchemasForSupportedTools ¶
func (*LocalExecTools) GetToolsForToolsByName ¶
func (h *LocalExecTools) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
type LocalFSTools ¶
type LocalFSTools struct {
// contains filtered or unexported fields
}
func (*LocalFSTools) Exec ¶
func (h *LocalFSTools) Exec(ctx context.Context, startTime time.Time, input any, debug bool, toolsCall *taskengine.ToolsCall) (any, taskengine.DataType, error)
func (*LocalFSTools) GetSchemasForSupportedTools ¶
func (*LocalFSTools) GetToolsForToolsByName ¶
func (h *LocalFSTools) GetToolsForToolsByName(ctx context.Context, name string) ([]taskengine.Tool, error)
func (*LocalFSTools) InvalidateSessionReads ¶
func (h *LocalFSTools) InvalidateSessionReads(ctx context.Context, sessionID string) error
type MCPAuthConfig ¶
type MCPAuthConfig struct {
Type MCPAuthType
Token string
APIKeyFromEnv string
}
func (*MCPAuthConfig) ResolveToken ¶
func (a *MCPAuthConfig) ResolveToken() string
type MCPAuthType ¶
type MCPAuthType string
const ( MCPAuthNone MCPAuthType = "" MCPAuthBearer MCPAuthType = "bearer" MCPAuthOAuth MCPAuthType = "oauth" )
type MCPOAuthConfig ¶
type MCPOAuthConfig struct {
ClientName string
ClientID string
ClientSecret string
Scopes []string
CallbackPort int
TokenStore mcpoauth.TokenStore
OpenBrowser func(url string) error
}
func (*MCPOAuthConfig) ResolveCallbackPort ¶
func (c *MCPOAuthConfig) ResolveCallbackPort() int
func (*MCPOAuthConfig) ResolveClientName ¶
func (c *MCPOAuthConfig) ResolveClientName() string
type MCPServerConfig ¶
type MCPServerConfig struct {
Name string
Transport MCPTransport
Command string
Args []string
URL string
Auth *MCPAuthConfig
OAuth *MCPOAuthConfig
ConnectTimeout time.Duration
MCPSessionID string
OnSessionID func(string)
Tracker libtracker.ActivityTracker
}
type MCPSessionPool ¶
type MCPSessionPool struct {
// contains filtered or unexported fields
}
func NewMCPSessionPool ¶
func NewMCPSessionPool(cfg MCPServerConfig) *MCPSessionPool
func (*MCPSessionPool) Close ¶
func (p *MCPSessionPool) Close() error
func (*MCPSessionPool) Session ¶
func (p *MCPSessionPool) Session(ctx context.Context) (*mcp.ClientSession, error)
type MCPTransport ¶
type MCPTransport string
const ( MCPTransportStdio MCPTransport = "stdio" MCPTransportSSE MCPTransport = "sse" MCPTransportHTTP MCPTransport = "http" )
type MockToolsRepo ¶
type MockToolsRepo struct {
Calls []ToolsCallRecord
ResponseMap map[string]ToolsResponse
DefaultResponse ToolsResponse
ErrorSequence []error
// contains filtered or unexported fields
}
func NewMockToolsRegistry ¶
func NewMockToolsRegistry() *MockToolsRepo
func (*MockToolsRepo) CallCount ¶
func (m *MockToolsRepo) CallCount() int
func (*MockToolsRepo) Exec ¶
func (m *MockToolsRepo) Exec( ctx context.Context, startingTime time.Time, input any, inputType taskengine.DataType, transition string, args *taskengine.ToolsCall, ) (int, any, taskengine.DataType, string, error)
func (*MockToolsRepo) LastCall ¶
func (m *MockToolsRepo) LastCall() *ToolsCallRecord
func (*MockToolsRepo) Reset ¶
func (m *MockToolsRepo) Reset()
func (*MockToolsRepo) Supports ¶
func (m *MockToolsRepo) Supports(ctx context.Context) ([]string, error)
func (*MockToolsRepo) WithErrorSequence ¶
func (m *MockToolsRepo) WithErrorSequence(errors ...error) *MockToolsRepo
func (*MockToolsRepo) WithResponse ¶
func (m *MockToolsRepo) WithResponse(toolsType string, response ToolsResponse) *MockToolsRepo
type PlatformShell ¶ added in v0.28.4
type PlatformShell struct {
OS string
Kind ShellKind
Command string
ArgsPrefix []string
DisplayName string
SyntaxHint string
}
func DetectPlatformShell ¶ added in v0.28.4
func DetectPlatformShell() PlatformShell
func DetectPlatformShellFor ¶ added in v0.28.4
func NewCmdShell ¶ added in v0.28.4
func NewCmdShell(command string) PlatformShell
func NewPowerShellShell ¶ added in v0.28.4
func NewPowerShellShell(command string) PlatformShell
func NewShShell ¶ added in v0.28.4
func NewShShell(command string) PlatformShell
func (PlatformShell) IsSet ¶ added in v0.28.4
func (s PlatformShell) IsSet() bool
func (PlatformShell) ShellModeDescription ¶ added in v0.28.4
func (s PlatformShell) ShellModeDescription() string
func (PlatformShell) Summary ¶ added in v0.28.4
func (s PlatformShell) Summary() string
func (PlatformShell) WithDefaults ¶ added in v0.28.4
func (s PlatformShell) WithDefaults() PlatformShell
func (PlatformShell) WrapCommand ¶ added in v0.28.4
type Print ¶
type Print struct {
// contains filtered or unexported fields
}
func (*Print) GetSchemasForSupportedTools ¶
func (*Print) GetToolsForToolsByName ¶
type SSHClientCache ¶
type SSHClientCache struct {
// contains filtered or unexported fields
}
func NewSSHClientCache ¶
func NewSSHClientCache() *SSHClientCache
func (*SSHClientCache) Clear ¶
func (c *SSHClientCache) Clear()
func (*SSHClientCache) IsAlive ¶
func (c *SSHClientCache) IsAlive(key string) bool
func (*SSHClientCache) Put ¶
func (c *SSHClientCache) Put(key string, client *ssh.Client, config *ssh.ClientConfig)
func (*SSHClientCache) Remove ¶
func (c *SSHClientCache) Remove(key string)
type SSHOption ¶
func WithClientCache ¶
func WithClientCache() SSHOption
func WithCustomHostKeyCallback ¶
func WithCustomHostKeyCallback(callback ssh.HostKeyCallback) SSHOption
func WithDefaultPort ¶
func WithDefaultTimeout ¶
func WithKnownHostsFile ¶
func WithStrictHostKey ¶
func WithStrictHostKey() SSHOption
type SSHResult ¶
type SSHResult struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Duration float64 `json:"duration_seconds"`
Command string `json:"command"`
Host string `json:"host"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
HostKey string `json:"host_key,omitempty"`
}
type SSHTools ¶
type SSHTools struct {
// contains filtered or unexported fields
}
func (*SSHTools) GetSchemasForSupportedTools ¶
func (*SSHTools) GetToolsForToolsByName ¶
type StatFileIO ¶
type ToolsCallRecord ¶
type ToolsCallRecord struct {
Args taskengine.ToolsCall
Input any
InputType taskengine.DataType
Transition string
}
type ToolsResponse ¶
type ToolsResponse struct {
Status int
Output any
OutputType taskengine.DataType
Transition string
}
type WebCaller ¶
type WebCaller struct {
// contains filtered or unexported fields
}
func (*WebCaller) GetSchemasForSupportedTools ¶
func (*WebCaller) GetToolsForToolsByName ¶
type WebtoolsOption ¶
type WebtoolsOption func(*WebCaller)
func WithDefaultHeader ¶
func WithDefaultHeader(key, value string) WebtoolsOption
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) WebtoolsOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.