Files
picoclaw/pkg/commands/runtime.go
T
2026-05-04 08:41:17 +02:00

66 lines
1.8 KiB
Go

package commands
import (
"context"
"github.com/sipeed/picoclaw/pkg/config"
)
type MCPServerInfo struct {
Name string
Enabled bool
Deferred bool
Connected bool
ToolCount int
}
type MCPToolParameterInfo struct {
Name string
Type string
Description string
Required bool
}
type MCPToolInfo struct {
Name string
Description string
Parameters []MCPToolParameterInfo
}
// ContextStats describes current session context window usage.
type ContextStats struct {
UsedTokens int
TotalTokens int // model context window
CompressAtTokens int // compression threshold
UsedPercent int // 0-100
MessageCount int
}
// StopResult describes the outcome of a stop request for the current session.
type StopResult struct {
Stopped bool
TaskName string
}
// Runtime provides runtime dependencies to command handlers. It is constructed
// per-request by the agent loop so that per-request state (like session scope)
// can coexist with long-lived callbacks (like GetModelInfo).
type Runtime struct {
Config *config.Config
GetModelInfo func() (name, provider string)
AskSideQuestion func(ctx context.Context, question string) (string, error)
ListAgentIDs func() []string
ListDefinitions func() []Definition
ListSkillNames func() []string
ListMCPServers func(ctx context.Context) []MCPServerInfo
ListMCPTools func(ctx context.Context, serverName string) ([]MCPToolInfo, error)
GetEnabledChannels func() []string
GetActiveTurn func() any // Returning any to avoid circular dependency with agent package
GetContextStats func() *ContextStats
SwitchModel func(value string) (oldModel string, err error)
SwitchChannel func(value string) error
ClearHistory func() error
ReloadConfig func() error
StopActiveTurn func() (StopResult, error)
}