Files
picoclaw/pkg/commands/runtime.go
T
程智超0668000959 7a7e205cc8 fix(context): expose history tokens and remove leaked state files
Address remaining review feedback: 1) Add HistoryTokens field to ContextUsage/ContextStats, showing history-only token count in /context and frontend UI alongside SummarizeAtTokens so users can see the actual summarization trigger comparison. 2) Remove .codebuddy/github-contribute/ state files accidentally included in the PR.
2026-06-06 00:28:32 +08:00

68 lines
2.0 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
HistoryTokens int // history-only tokens (what maybeSummarize checks)
CompressAtTokens int // hard budget compression threshold
SummarizeAtTokens int // soft summarization trigger
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)
}