session

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget interface {
	CanExecute(sessionID string) bool
}

type Config

type Config struct {
	InputBufferSize    int
	OutputBufferSize   int
	EnableQueue        bool
	QueueSize          int
	MaxPending         int
	PlannerEnabled     bool
	PlannerPrompt      string
	PlannerAutoApprove bool
}

func DefaultConfig

func DefaultConfig() *Config

type Event

type Event struct {
	Type       EventType      `json:"type"`
	SessionID  string         `json:"session_id"`
	Content    string         `json:"content,omitempty"`
	Thinking   string         `json:"thinking,omitempty"`
	ToolCallID string         `json:"tool_call_id,omitempty"`
	ToolName   string         `json:"tool_name,omitempty"`
	ToolInput  map[string]any `json:"tool_input,omitempty"`
	ToolOutput any            `json:"tool_output,omitempty"`
	Error      string         `json:"error,omitempty"`
	Approved   bool           `json:"approved,omitempty"`
	Usage      *Usage         `json:"usage,omitempty"`
	Plan       *Plan          `json:"plan,omitempty"`
	Timestamp  time.Time      `json:"timestamp"`
}

func (*Event) IsApproval

func (e *Event) IsApproval() bool

func (*Event) IsDone

func (e *Event) IsDone() bool

func (*Event) IsError

func (e *Event) IsError() bool

func (*Event) IsMessage

func (e *Event) IsMessage() bool

func (*Event) IsPlan

func (e *Event) IsPlan() bool

func (*Event) IsThinking

func (e *Event) IsThinking() bool

func (*Event) IsTokenUsage

func (e *Event) IsTokenUsage() bool

func (*Event) IsToolCall

func (e *Event) IsToolCall() bool

func (*Event) IsToolResult

func (e *Event) IsToolResult() bool

func (*Event) String

func (e *Event) String() string

type EventType

type EventType string
const (
	EventTypeMessage    EventType = "message"
	EventTypeThinking   EventType = "thinking"
	EventTypeToolCall   EventType = "tool_call"
	EventTypeToolResult EventType = "tool_result"
	EventTypeToolStart  EventType = "tool_start"
	EventTypeTokenUsage EventType = "token_usage"
	EventTypeError      EventType = "error"
	EventTypeDone       EventType = "done"
	EventTypeApproved   EventType = "approved"
	EventTypeApproval   EventType = "approval"
	EventTypePlan       EventType = "plan"
	EventTypePlanStep   EventType = "plan_step"
)

type ExecuteResponse

type ExecuteResponse struct {
	SessionID string
	Content   string
	ToolCalls []ToolCallInfo
	Usage     Usage
	Error     error
}

type Info

type Info struct {
	ID        string    `json:"id"`
	Title     string    `json:"title"`
	Summary   *Summary  `json:"summary,omitempty"`
	Time      Time      `json:"time"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func NewInfo

func NewInfo(id, title string) *Info

func (*Info) Archive

func (s *Info) Archive()

func (*Info) SetSummary

func (s *Info) SetSummary(additions, deletions, files int, diffs string)

func (*Info) SetTitle

func (s *Info) SetTitle(title string)

func (*Info) Touch

func (s *Info) Touch()

type Observer

type Observer interface {
	OnEvent(event *Event)
}

type ObserverFunc

type ObserverFunc func(event *Event)

func (ObserverFunc) OnEvent

func (f ObserverFunc) OnEvent(event *Event)

type Option

type Option func(*Config)

func WithInputBufferSize

func WithInputBufferSize(size int) Option

func WithOutputBufferSize

func WithOutputBufferSize(size int) Option

func WithPlannerEnabled

func WithPlannerEnabled(enabled bool, prompt string, autoApprove bool) Option

func WithQueueEnabled

func WithQueueEnabled(maxSize, maxPending int) Option

type Plan

type Plan struct {
	Goal      string     `json:"goal,omitempty"`
	Steps     []PlanStep `json:"steps"`
	Reasoning string     `json:"reasoning,omitempty"`
	Approved  bool       `json:"approved"`
}

type PlanApproval

type PlanApproval struct {
	Approved bool
	Plan     *Plan
}

type PlanMode

type PlanMode string
const (
	PlanModeAuto  PlanMode = "auto"
	PlanModeAsk   PlanMode = "ask"
	PlanModeNever PlanMode = "never"
)

type PlanStep

type PlanStep struct {
	Index     int                    `json:"index"`
	Tool      string                 `json:"tool"`
	Input     map[string]interface{} `json:"input"`
	Reasoning string                 `json:"reasoning"`
}

type PlannerHelper

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

func NewPlannerHelper

func NewPlannerHelper(enabled bool, prompt string, autoApprove bool, llmProvider types.LLMProvider, toolSchemas []map[string]interface{}) *PlannerHelper

func (*PlannerHelper) ApprovalChan

func (p *PlannerHelper) ApprovalChan() chan<- PlanApproval

func (*PlannerHelper) Approve

func (p *PlannerHelper) Approve(approved bool)

func (*PlannerHelper) CreatePlan

func (p *PlannerHelper) CreatePlan(ctx context.Context, input string) (*Plan, error)

func (*PlannerHelper) GetMode

func (p *PlannerHelper) GetMode() PlanMode

func (*PlannerHelper) IsEnabled

func (p *PlannerHelper) IsEnabled() bool

func (*PlannerHelper) RequestApproval

func (p *PlannerHelper) RequestApproval(ctx context.Context, plan *Plan) bool

func (*PlannerHelper) SetMode

func (p *PlannerHelper) SetMode(mode PlanMode)

func (*PlannerHelper) ShouldEnterPlanMode

func (p *PlannerHelper) ShouldEnterPlanMode(input string) bool

type Session

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

func NewSession

func NewSession(id string, agent *engine.AgentEngine, factory SessionFactory, ctx context.Context, cfg *Config, planner *PlannerHelper, budget interface{ CanExecute(sessionID string) bool }) *Session

func (*Session) ApprovePlan

func (s *Session) ApprovePlan(approved bool)

func (*Session) Close

func (s *Session) Close()

func (*Session) Context

func (s *Session) Context() context.Context

func (*Session) Enqueue

func (s *Session) Enqueue(content string, priority dinoQueue.Priority) (<-chan *dinoQueue.Result, error)

func (*Session) EnqueueBatch

func (s *Session) EnqueueBatch(contents []string, priority dinoQueue.Priority) ([]<-chan *dinoQueue.Result, error)

func (*Session) GetAgent added in v1.8.1

func (s *Session) GetAgent() *engine.AgentEngine

func (*Session) GetMemory added in v1.8.1

func (s *Session) GetMemory() types.MemoryProvider

func (*Session) ID

func (s *Session) ID() string

func (*Session) Input

func (s *Session) Input() chan<- interface{}

func (*Session) IsRunning

func (s *Session) IsRunning() bool

func (*Session) Output

func (s *Session) Output() <-chan *Event

func (*Session) QueuePending

func (s *Session) QueuePending() int

func (*Session) QueueSize

func (s *Session) QueueSize() int

func (*Session) QueueStats

func (s *Session) QueueStats() dinoQueue.Stats

func (*Session) Start

func (s *Session) Start()

func (*Session) Stop

func (s *Session) Stop()

func (*Session) Subscribe

func (s *Session) Subscribe(obs Observer) string

func (*Session) Unsubscribe

func (s *Session) Unsubscribe(id string)

type SessionFactory

type SessionFactory interface {
	RecordLoop(sessionID string, action agentutils.LoopDetectAction)
	RecordTokens(ctx context.Context, sessionID string, tokens int)
	Detect(ctx context.Context, sessionID string, action agentutils.LoopDetectAction) *agentutils.LoopDetectResult
}

type Summary

type Summary struct {
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Files     int    `json:"files"`
	Diffs     string `json:"diffs,omitempty"`
}

type Time

type Time struct {
	Created    int64 `json:"created"`
	Updated    int64 `json:"updated"`
	Compacting int64 `json:"compacting,omitempty"`
	Archived   int64 `json:"archived,omitempty"`
}

type ToolCallInfo

type ToolCallInfo struct {
	ID    string
	Name  string
	Input map[string]interface{}
}

type Usage

type Usage = agenttypes.Usage

Jump to

Keyboard shortcuts

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