Files
picoclaw/pkg/commands/runtime.go
T
loveuer a7dba6859b feat: support fresh IM sessions and OpenAI reasoning controls
支持 /new 清空会话或携带新问题执行,忙碌时拒绝并保留原任务状态。
修复路由会话隔离及旧摘要回写,完善 OpenAI reasoning.effort 和 temperature 处理。
补充中英文文档与测试;相关包回归、race、lint 和 Gateway 构建通过。
2026-11-11 11:26:23 +08:00

69 lines
2.1 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
StartNewConversation func(ctx context.Context, prompt string) (string, error)
ReloadConfig func() error
StopActiveTurn func() (StopResult, error)
}