chat

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandTransport

func CommandTransport(cmd string, args []string, env ...string) mcp.Transport

CommandTransport creates a new transport for a command

Types

type Callbacks

type Callbacks struct {
	// OnStatus is called when there's a status update
	OnStatus func(status string)
	// OnReasoning is called when the agent is reasoning
	OnReasoning func(reasoning string)
	// OnToolCall is called when the agent wants to run a tool
	// Returns the user's decision
	OnToolCall func(req ToolCallRequest) ToolCallResponse
	// OnPlan is called when a plan needs user approval
	// Returns the user's decision
	OnPlan func(plan Plan) PlanResponse
	// OnResponse is called when the agent responds
	OnResponse func(response string)
	// OnError is called when an error occurs
	OnError func(err error)
}

Callbacks defines the interface for UI interactions

type Message

type Message struct {
	Role    string
	Content string
}

Message represents a chat message

type Plan added in v0.0.6

type Plan struct {
	Description string
	Subtasks    []string
}

Plan represents a plan with description and subtasks

type PlanResponse added in v0.0.6

type PlanResponse struct {
	Approved bool
}

PlanResponse represents the user's decision on a plan

type Session

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

Session represents a chat session with the AI assistant

func NewSession

func NewSession(ctx context.Context, cfg types.Config, callbacks Callbacks, transports ...mcp.Transport) (*Session, error)

NewSession creates a new chat session

func (*Session) ClearHistory

func (s *Session) ClearHistory()

func (*Session) Close

func (s *Session) Close() error

Close closes the session and cleans up resources

func (*Session) GetMessages

func (s *Session) GetMessages() []Message

GetMessages returns all messages in the conversation

func (*Session) GetPlanMode added in v0.0.6

func (s *Session) GetPlanMode() bool

GetPlanMode returns the current plan mode state

func (*Session) SendMessage

func (s *Session) SendMessage(text string) (string, error)

SendMessage sends a message to the assistant and processes the response

func (*Session) SetPlanMode added in v0.0.6

func (s *Session) SetPlanMode(enabled bool)

SetPlanMode sets the plan mode state

type ToolCallRequest

type ToolCallRequest struct {
	Name      string
	Arguments string
	Reasoning string
}

ToolCallRequest contains information about a tool the agent wants to run

type ToolCallResponse

type ToolCallResponse struct {
	Approved    bool
	Adjustment  string
	AlwaysAllow bool // Add tool to session allow list
}

ToolCallResponse represents the user's decision on a tool call

Jump to

Keyboard shortcuts

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