client

package
v0.0.0-...-7ad5d0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Set to 5 minutes to allow for long running queries or slow MCP connections
	DefaultTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddConnectionRequest

type AddConnectionRequest struct {
	Name        string              `json:"name"`
	Description string              `json:"description,omitempty"`
	Command     string              `json:"command,omitempty"`
	Args        []string            `json:"args,omitempty"`
	Remote      bool                `json:"remote,omitempty"`
	URL         string              `json:"url,omitempty"`
	Headers     map[string]string   `json:"headers,omitempty"`
	OAuth       *config.OAuthConfig `json:"oauth,omitempty"`
}

type AddMCPServerRequest

type AddMCPServerRequest = AddConnectionRequest

AddMCPServerRequest is an alias for backwards compatibility

type AgentConfig

type AgentConfig struct {
	ModelID             *llm.ModelID       `json:"model,omitempty"`
	AgentMode           *llm.AgentMode     `json:"mode,omitempty"`
	PersonaType         *string            `json:"type,omitempty"`
	Thinking            *bool              `json:"thinking,omitempty"`
	InterleavedThinking *bool              `json:"interleaved_thinking,omitempty"`
	SystemPrompt        *string            `json:"system_prompt,omitempty"`
	Tools               []llm.ToolID       `json:"tools,omitempty"`
	ToolChoice          llm.ToolChoiceType `json:"tool_choice,omitempty"`
	ParallelToolUse     *bool              `json:"parallel_tool_use,omitempty"`
	Yolo                bool               `json:"yolo,omitempty"`
	NoClarify           bool               `json:"no_clarify,omitempty"`
	NoTimeout           bool               `json:"no_timeout,omitempty"`
	Debug               bool               `json:"debug,omitempty"`
}

type ClientEmitter

type ClientEmitter struct {
	Client *TimClient
	// contains filtered or unexported fields
}

ClientEmitter adapts the client for terminal emitter interface

func NewClientEmitter

func NewClientEmitter(client *TimClient) *ClientEmitter

func (*ClientEmitter) Close

func (e *ClientEmitter) Close()

func (*ClientEmitter) DetachProcess

func (e *ClientEmitter) DetachProcess(processID string)

func (*ClientEmitter) EmitInputResponse

func (e *ClientEmitter) EmitInputResponse(requestID, response string)

func (*ClientEmitter) EmitInputResponseFailed

func (e *ClientEmitter) EmitInputResponseFailed(requestID string, err error)

func (*ClientEmitter) EmitOpsProgress

func (e *ClientEmitter) EmitOpsProgress(requestID string, progressType events.OpsProgressType, data events.OpsProgress)

func (*ClientEmitter) EmitOpsResponse

func (e *ClientEmitter) EmitOpsResponse(requestID string, result events.OpsResult)

func (*ClientEmitter) EmitOpsResponseFailed

func (e *ClientEmitter) EmitOpsResponseFailed(requestID string, err error)

type ConfigResponse

type ConfigResponse struct {
	HasAnthropicAPIKey  bool          `json:"has_anthropic_api_key"`
	HasOpenAIAPIKey     bool          `json:"has_openai_api_key"`
	HasGeminiAPIKey     bool          `json:"has_gemini_api_key"`
	HasXaiAPIKey        bool          `json:"has_xai_api_key"`
	AnthropicAPIBaseURL string        `json:"anthropic_api_base_url,omitempty"`
	OpenAIAPIBaseURL    string        `json:"openai_api_base_url,omitempty"`
	XaiAPIBaseURL       string        `json:"xai_api_base_url,omitempty"`
	DefaultModelID      string        `json:"default_model,omitempty"`
	DefaultMode         llm.AgentMode `json:"default_mode,omitempty"`
	DefaultShell        string        `json:"default_shell,omitempty"`
	ConflictingApps     []string      `json:"conflicting_apps,omitempty"`
	AmbiguousCommands   []string      `json:"ambiguous_commands,omitempty"`
}

type ConnectionOperationResponse

type ConnectionOperationResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Server  string `json:"server,omitempty"`
}

type ConnectionsResponse

type ConnectionsResponse struct {
	Servers []MCPServerInfo `json:"servers"`
	Count   int             `json:"count"`
}

type CreateSessionRequest

type CreateSessionRequest struct {
	Name    string `json:"name,omitempty"`
	RootDir string `json:"root_dir,omitempty"`
}

type CreateSessionResponse

type CreateSessionResponse struct {
	SessionID string `json:"session_id"`
}

type CreateTodoRequest

type CreateTodoRequest struct {
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	Priority    string `json:"priority,omitempty"`
}

RESTful Todo types

type CreateTodoResponse

type CreateTodoResponse struct {
	Todo    TodoItem `json:"todo"`
	Message string   `json:"message"`
}

type DeleteTodoResponse

type DeleteTodoResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

type DetachProcessResponse

type DetachProcessResponse struct {
	Success bool `json:"success"`
}

type EventWaiter

type EventWaiter struct {
	ID         string
	EventType  events.EventType
	Filter     events.EventFilter
	ResultChan chan *events.Event
}

type InputResponseRequest

type InputResponseRequest struct {
	RequestID string `json:"request_id"`
	Response  string `json:"response"`
}

type InputResponseResponse

type InputResponseResponse struct {
	Success bool `json:"success"`
}

type KillProcessResponse

type KillProcessResponse struct {
	Success bool `json:"success"`
}

type ListProcessesResponse

type ListProcessesResponse struct {
	Processes []ProcessResponse `json:"processes"`
	Count     int               `json:"count"`
}

type MCPOperationResponse

type MCPOperationResponse = ConnectionOperationResponse

MCPOperationResponse is an alias for backwards compatibility

type MCPServerInfo

type MCPServerInfo struct {
	Index            int      `json:"index"`
	Name             string   `json:"name"`
	Description      string   `json:"description,omitempty"`
	Command          string   `json:"command,omitempty"`
	Args             []string `json:"args,omitempty"`
	Env              []string `json:"env,omitempty"`
	Remote           bool     `json:"remote"`
	URL              string   `json:"url,omitempty"`
	Enabled          bool     `json:"enabled"`
	Connected        bool     `json:"connected"`
	EnabledStatus    string   `json:"enabledStatus"`
	ConnectionStatus string   `json:"connectionStatus"`
}

type MCPServersResponse

type MCPServersResponse = ConnectionsResponse

MCPServersResponse is an alias for backwards compatibility

type NewSessionQueryRequest

type NewSessionQueryRequest struct {
	Query       string      `json:"query"`
	AgentConfig AgentConfig `json:"agent,omitempty"`
}

type OAuthInitiateResponse

type OAuthInitiateResponse struct {
	AuthURL string `json:"auth_url"`
	State   string `json:"state"`
	Message string `json:"message"`
}

OAuthInitiateResponse represents the response from initiating OAuth

type OpsProgressBatchRequest

type OpsProgressBatchRequest struct {
	Progress []OpsProgressRequest `json:"progress"`
}

type OpsProgressBatchResponse

type OpsProgressBatchResponse struct {
	Success bool `json:"success"`
}

type OpsProgressRequest

type OpsProgressRequest struct {
	RequestID string                 `json:"request_id"`
	Type      events.OpsProgressType `json:"type"`
	Data      events.OpsProgress     `json:"data"`
}

type OpsResponseRequest

type OpsResponseRequest struct {
	RequestID string           `json:"request_id"`
	Result    events.OpsResult `json:"result,omitempty"`
	Error     string           `json:"error,omitempty"`
}

type OpsResponseResponse

type OpsResponseResponse struct {
	Success bool `json:"success"`
}

type ProcessResponse

type ProcessResponse struct {
	ProcessID string           `json:"process_id"`
	Index     int              `json:"index"`
	Command   string           `json:"command"`
	Status    string           `json:"status"`
	StartTime timeutil.ISOTime `json:"start_time"`
	Duration  int64            `json:"duration,omitempty"`
	ExitCode  *int             `json:"exit_code,omitempty"`
	WorkDir   string           `json:"work_dir"`
	Stdout    []string         `json:"stdout,omitempty"`
	Stderr    []string         `json:"stderr,omitempty"`
}

type QueryType

type QueryType string

QueryType represents the possible query type outcomes

const (
	QueryTypeValidShell        QueryType = "valid_shell"
	QueryTypeShellHelp         QueryType = "shell_help"
	QueryTypeCoding            QueryType = "coding"
	QueryTypeOther             QueryType = "other"
	QueryTypeSingleConflicting QueryType = "single_conflicting"
	QueryTypeMultiConflicting  QueryType = "multi_conflicting"
)

type SSEScanner

type SSEScanner struct {
	// contains filtered or unexported fields
}

func NewSSEScanner

func NewSSEScanner(r io.Reader) *SSEScanner

func (*SSEScanner) Err

func (s *SSEScanner) Err() error

func (*SSEScanner) Event

func (s *SSEScanner) Event() *events.Event

func (*SSEScanner) Scan

func (s *SSEScanner) Scan() bool

type SessionApplyChangesResponse

type SessionApplyChangesResponse struct {
	Success bool `json:"success"`
}

type SessionClearResponse

type SessionClearResponse struct {
	Success bool `json:"success"`
}

type SessionDeleteResponse

type SessionDeleteResponse struct {
	Success bool `json:"success"`
}

type SessionInfoResponse

type SessionInfoResponse struct {
	SessionID   string    `json:"session_id"`
	SessionName string    `json:"session_name"`
	RootDir     string    `json:"root_dir"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type SessionListResponse

type SessionListResponse struct {
	Sessions []SessionInfoResponse `json:"sessions"`
}

type SessionModelsResponse

type SessionModelsResponse struct {
	Models []llm.ModelID `json:"models"`
}

type SessionPersonasResponse

type SessionPersonasResponse struct {
	Personas []config.PersonaConfig `json:"personas"`
}

type SessionProposedChangesResponse

type SessionProposedChangesResponse struct {
	ProposedChanges map[string]string `json:"proposed_changes"`
}

type SessionQuery

type SessionQuery struct {
	ID          string            `json:"id"`
	State       SessionQueryState `json:"state"`
	Query       string            `json:"query"`
	AgentConfig AgentConfig       `json:"agent,omitempty"`
	Error       string            `json:"error,omitempty"`
	CreatedAt   timeutil.ISOTime  `json:"created_at"`
	StartedAt   timeutil.ISOTime  `json:"started_at,omitempty"`
	Duration    int64             `json:"duration,omitempty"`
	Result      string            `json:"result,omitempty"`
}

type SessionQueryCancelResponse

type SessionQueryCancelResponse struct {
	Success bool `json:"success"`
}

type SessionQueryResponse

type SessionQueryResponse struct {
	SessionQuery
}

type SessionQueryState

type SessionQueryState string
const (
	SessionQueryStateQueued     SessionQueryState = "queued"
	SessionQueryStateProcessing SessionQueryState = "processing"
	SessionQueryStateCompleted  SessionQueryState = "completed"
	SessionQueryStateFailed     SessionQueryState = "failed"
	SessionQueryStateCancelled  SessionQueryState = "cancelled"
)

type SessionQueryTypeRequest

type SessionQueryTypeRequest struct {
	Query string `json:"query"`
}

type SessionQueryTypeResponse

type SessionQueryTypeResponse struct {
	Type                     QueryType `json:"type"`
	SingleConflictingCommand *ShellCmd `json:"single_conflicting_command,omitempty"`
	MultiConflictingCommands []string  `json:"multi_conflicting_commands,omitempty"`
}

type SetSessionRootDirRequest

type SetSessionRootDirRequest struct {
	RootDir string `json:"root_dir"`
}

type SetSessionRootDirResponse

type SetSessionRootDirResponse struct {
	Success bool `json:"success"`
}

type ShellCmd

type ShellCmd struct {
	Command string            `json:"command"`  // The command name (e.g., "git")
	Args    []string          `json:"args"`     // Command arguments (e.g., ["status", "-s"])
	EnvVars map[string]string `json:"env_vars"` // Environment variable assignments (e.g., {"FOO": "bar"})
}

ShellCmd represents a parsed shell command with all its components

func (*ShellCmd) String

func (s *ShellCmd) String() string

type StreamAction

type StreamAction int
const (
	StreamEnd StreamAction = iota
	StreamReconnect
)

type StreamResult

type StreamResult struct {
	Action       StreamAction
	NewSessionID string
	Error        error
}

type TimClient

type TimClient struct {
	ServerAddress string
	SessionName   string
	RootDir       string
	// contains filtered or unexported fields
}

func NewTimClient

func NewTimClient(serverAddress string) (*TimClient, error)

func (*TimClient) AddConnection

func (c *TimClient) AddConnection(name, command string, args []string, description string) (*MCPOperationResponse, error)

func (*TimClient) AddConnectionWithConfig

func (c *TimClient) AddConnectionWithConfig(serverConfig config.ConnectionConfig) (*MCPOperationResponse, error)

func (*TimClient) AddRemoteConnection

func (c *TimClient) AddRemoteConnection(name, url string, description string) (*MCPOperationResponse, error)

func (*TimClient) AddRemoteConnectionWithConfig

func (c *TimClient) AddRemoteConnectionWithConfig(serverConfig config.ConnectionConfig) (*MCPOperationResponse, error)

func (*TimClient) AddTodo

func (c *TimClient) AddTodo(title, description, priority string) (*CreateTodoResponse, error)

func (*TimClient) ApplyProposedChanges

func (c *TimClient) ApplyProposedChanges() error

func (*TimClient) CallFuncAndWaitForEvent

func (c *TimClient) CallFuncAndWaitForEvent(
	fn func() error,
	eventType events.EventType,
	filter events.EventFilter,
	timeout time.Duration,
) (*events.Event, error)

func (*TimClient) CancelQuery

func (c *TimClient) CancelQuery(queryID string) error

func (*TimClient) ClearSession

func (c *TimClient) ClearSession() error

func (*TimClient) CreateSession

func (c *TimClient) CreateSession(name, rootDir string) error

func (*TimClient) DeleteSession

func (c *TimClient) DeleteSession(sessionID string) (*SessionDeleteResponse, error)

func (*TimClient) DetachProcess

func (c *TimClient) DetachProcess(processID string) (*DetachProcessResponse, error)

func (*TimClient) DetermineQueryType

func (c *TimClient) DetermineQueryType(query string) (*SessionQueryTypeResponse, error)

func (*TimClient) DisableConnection

func (c *TimClient) DisableConnection(name string) (*MCPOperationResponse, error)

func (*TimClient) EnableConnection

func (c *TimClient) EnableConnection(name string) (*MCPOperationResponse, error)

func (*TimClient) GetConfig

func (c *TimClient) GetConfig() (*ConfigResponse, error)

func (*TimClient) GetConnections

func (c *TimClient) GetConnections() (*MCPServersResponse, error)

func (*TimClient) GetModels

func (c *TimClient) GetModels() ([]llm.ModelID, error)

func (*TimClient) GetPersonas

func (c *TimClient) GetPersonas() ([]config.PersonaConfig, error)

func (*TimClient) GetProcess

func (c *TimClient) GetProcess(processID string) (*ProcessResponse, error)

func (*TimClient) GetProcesses

func (c *TimClient) GetProcesses() (*ListProcessesResponse, error)

func (*TimClient) GetProposedChanges

func (c *TimClient) GetProposedChanges() (map[string]string, error)

func (*TimClient) GetSessionInfo

func (c *TimClient) GetSessionInfo(sessionID string) (*SessionInfoResponse, error)

func (*TimClient) InitiateOAuth

func (c *TimClient) InitiateOAuth(integration string) (*OAuthInitiateResponse, error)

InitiateOAuth initiates OAuth flow for a supported integration

func (*TimClient) IsValidModel

func (c *TimClient) IsValidModel(model llm.ModelID) bool

func (*TimClient) IsValidPersona

func (c *TimClient) IsValidPersona(persona string) bool

func (*TimClient) KillProcess

func (c *TimClient) KillProcess(processID string) (*KillProcessResponse, error)

func (*TimClient) ListSessions

func (c *TimClient) ListSessions() (*SessionListResponse, error)

func (*TimClient) ListTodos

func (c *TimClient) ListTodos() (*TodoListResponse, error)

Todo methods

func (*TimClient) RemoveConnection

func (c *TimClient) RemoveConnection(name string) (*MCPOperationResponse, error)

func (*TimClient) RemoveTodo

func (c *TimClient) RemoveTodo(id string) (*DeleteTodoResponse, error)

RemoveTodo deletes a todo using RESTful DELETE endpoint

func (*TimClient) SendInput

func (c *TimClient) SendInput(requestID, response string) error

func (*TimClient) SendOpsProgress

func (c *TimClient) SendOpsProgress(batch []OpsProgressRequest) error

func (*TimClient) SendOpsResponse

func (c *TimClient) SendOpsResponse(requestID string, result events.OpsResult) error

func (*TimClient) SendOpsResponseError

func (c *TimClient) SendOpsResponseError(requestID string, error string) error

func (*TimClient) SessionID

func (c *TimClient) SessionID() string

func (*TimClient) SetClientType

func (c *TimClient) SetClientType(clientType string)

SetClientType sets the client type for analytics tracking

func (*TimClient) SetRootDir

func (c *TimClient) SetRootDir(rootDir string) error

func (*TimClient) SetSessionID

func (c *TimClient) SetSessionID(sessionID string)

func (*TimClient) StoreOAuthTokens

func (c *TimClient) StoreOAuthTokens(integration, accessToken, refreshToken string, expiresAt int64, clientID, clientSecret string) error

StoreOAuthTokens stores OAuth tokens for a direct integration

func (*TimClient) StreamEvents

func (c *TimClient) StreamEvents(ctx context.Context, eventChan chan<- *events.Event) error

func (*TimClient) SubmitQuery

func (c *TimClient) SubmitQuery(query string, agentConfig AgentConfig) (*SessionQuery, error)

func (*TimClient) UpdateConfig

func (c *TimClient) UpdateConfig(req UpdateConfigRequest) (*UpdateConfigResponse, error)

func (*TimClient) UpdateTodo

func (c *TimClient) UpdateTodo(id string, req UpdateTodoRequest) (*UpdateTodoResponse, error)

UpdateTodo updates a todo using RESTful PUT endpoint

func (*TimClient) UpdateTodoDescription

func (c *TimClient) UpdateTodoDescription(id, description string) (*UpdateTodoResponse, error)

UpdateTodoDescription updates only the description of a todo

func (*TimClient) UpdateTodoPriority

func (c *TimClient) UpdateTodoPriority(id, priority string) (*UpdateTodoResponse, error)

UpdateTodoPriority updates only the priority of a todo

func (*TimClient) UpdateTodoStatus

func (c *TimClient) UpdateTodoStatus(id, status string) (*UpdateTodoResponse, error)

UpdateTodoStatus updates only the status of a todo

func (*TimClient) UpdateTodoTitle

func (c *TimClient) UpdateTodoTitle(id, title string) (*UpdateTodoResponse, error)

UpdateTodoTitle updates only the title of a todo

type TodoItem

type TodoItem struct {
	ID          string               `json:"id"`
	Title       string               `json:"title"`
	Description string               `json:"description,omitempty"`
	Status      session.TodoStatus   `json:"status"`
	Priority    session.TodoPriority `json:"priority"`
	CreatedAt   timeutil.ISOTime     `json:"created_at"`
	UpdatedAt   timeutil.ISOTime     `json:"updated_at"`
}

Todo types

type TodoListResponse

type TodoListResponse struct {
	Todos []TodoItem `json:"todos"`
	Count int        `json:"count"`
}

type UpdateConfigRequest

type UpdateConfigRequest struct {
	AnthropicAPIKey     *string        `json:"anthropic_api_key,omitempty"`
	OpenAIAPIKey        *string        `json:"openai_api_key,omitempty"`
	GeminiAPIKey        *string        `json:"gemini_api_key,omitempty"`
	XaiAPIKey           *string        `json:"xai_api_key,omitempty"`
	AnthropicAPIBaseURL *string        `json:"anthropic_api_base_url,omitempty"`
	OpenAIAPIBaseURL    *string        `json:"openai_api_base_url,omitempty"`
	XaiAPIBaseURL       *string        `json:"xai_api_base_url,omitempty"`
	DefaultModelID      *string        `json:"default_model,omitempty"`
	DefaultMode         *llm.AgentMode `json:"default_mode,omitempty"`
	DefaultShell        *string        `json:"default_shell,omitempty"`
	ConflictingApps     *[]string      `json:"conflicting_apps,omitempty"`
	AmbiguousCommands   *[]string      `json:"ambiguous_commands,omitempty"`
}

type UpdateConfigResponse

type UpdateConfigResponse struct {
	Success bool `json:"success"`
}

type UpdateTodoRequest

type UpdateTodoRequest struct {
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
	Status      *string `json:"status,omitempty"`
	Priority    *string `json:"priority,omitempty"`
}

type UpdateTodoResponse

type UpdateTodoResponse struct {
	Todo    TodoItem `json:"todo"`
	Message string   `json:"message"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL