Documentation
¶
Index ¶
- Variables
- type ACPAgent
- type Chat
- func (chat *Chat) Init() tea.Cmd
- func (chat *Chat) RequestPermission(_ context.Context, params acp.RequestPermissionRequest) (acp.RequestPermissionResponse, error)
- func (chat *Chat) Run(ctx context.Context) error
- func (chat *Chat) SessionUpdate(ctx context.Context, params acp.SessionNotification) error
- func (chat *Chat) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (chat *Chat) View() tea.View
- type InputBox
- func (box *InputBox) AddCommands(items []SelectorOption)
- func (box *InputBox) Blur()
- func (box *InputBox) Focus() tea.Cmd
- func (box *InputBox) Focused() bool
- func (box *InputBox) MultiLineMode() bool
- func (box *InputBox) Reset()
- func (box *InputBox) Update(msg tea.Msg) (*InputBox, tea.Cmd)
- func (box *InputBox) Value() string
- func (box *InputBox) View() string
- type MessageItem
- type MessageType
- type MessageViewport
- type MessagesList
- type Options
- type PromptResult
- type QuitError
- type Selector
- func (s *Selector) AddItems(items ...SelectorOption)
- func (s Selector) Enabled() bool
- func (s *Selector) RenewTable()
- func (s Selector) Selected() string
- func (s *Selector) SetEnabled(enabled bool)
- func (s *Selector) SetSearchKey(key string)
- func (s *Selector) SetWidth(width int)
- func (s Selector) Update(msg tea.Msg) (Selector, tea.Cmd)
- func (s Selector) View() string
- type SelectorOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MsgNFANote = &i18n.Message{ ID: "ui.chat.NFANote", Other: "NOTE: Any output should not be construed as financial advice.", } MsgCmdDescModel = &i18n.Message{ ID: "ui.chat.CmdDescModel", Other: "Set the AI model for NFA", } MsgCmdDescSkills = &i18n.Message{ ID: "ui.chat.CmdDescSkills", Other: "List loaded skills", } MsgCmdDescExit = &i18n.Message{ ID: "ui.chat.CmdDescExit", Other: "Exit the NFA", } MsgSkillsCount = &i18n.Message{ ID: "ui.chat.SkillsCount", One: "{{ .Count }} skill", Other: "{{ .Count }} skills", } MsgTokenUsage = &i18n.Message{ID: "ui.chat.TokenUsage", Other: "Token Usage:"} MsgSkills = &i18n.Message{ID: "ui.chat.Skills", Other: "Skills"} MsgBuiltinSkills = &i18n.Message{ID: "ui.chat.BuiltinSkills", Other: "Builtin skills"} MsgLocalSkills = &i18n.Message{ID: "ui.chat.LocalSkills", Other: "Local skills"} MsgSelectModel = &i18n.Message{ID: "ui.chat.SelectModel", Other: "Select {{ .Type }} model"} MsgMultilineMode = &i18n.Message{ID: "ui.chat.MultilineMode", Other: "MULTILINE MODE"} MsgTabToToggle = &i18n.Message{ID: "ui.chat.TabToToggle", Other: "(tab to toggle)"} MsgStopReason = &i18n.Message{ID: "ui.chat.StopReason", Other: "stop reason: {{ .Reason }}"} MsgToolCall = &i18n.Message{ID: "ui.chat.ToolCall", Other: "ToolCall:"} MsgSetModel = &i18n.Message{ID: "ui.chat.SetModel", Other: "set {{ .Type }} model:"} MsgResumeSession = &i18n.Message{ID: "ui.chat.ResumeSession", Other: "Resume this session with:"} MsgResumeCommand = &i18n.Message{ID: "ui.chat.ResumeCommand", Other: "nfa --resume {{ .SessionID }}"} )
Functions ¶
This section is empty.
Types ¶
type Chat ¶
type Chat struct {
acputil.NopFS
acputil.NopTerminal
// contains filtered or unexported fields
}
Chat 对话应用
func (*Chat) RequestPermission ¶
func (chat *Chat) RequestPermission( _ context.Context, params acp.RequestPermissionRequest, ) (acp.RequestPermissionResponse, error)
RequestPermission 请求授权
func (*Chat) SessionUpdate ¶
SessionUpdate 更新会话
type InputBox ¶
type InputBox struct {
// contains filtered or unexported fields
}
InputBox 输入框
func NewInputBox ¶
func NewInputBox(ctx context.Context, commands []SelectorOption, hist *history.History, histPath string) *InputBox
NewInputBox 创建输入框
func (*InputBox) AddCommands ¶ added in v0.3.0
func (box *InputBox) AddCommands(items []SelectorOption)
AddCommands 添加命令
func (*InputBox) MultiLineMode ¶
MultiLineMode 返回是否处于多行编辑模式
type MessageItem ¶
type MessageItem struct {
Type MessageType
Text string
WithFirstLine bool
}
MessageItem 消息项
type MessageType ¶
type MessageType int
MessageType 消息类型
const ( MessageTypeUser MessageType = iota MessageTypeAgent MessageTypeAgentThought MessageTypeToolCall MessageTypeToolCallUpdate MessageTypeError MessageTypeUnknown )
type MessageViewport ¶
type MessageViewport struct {
// contains filtered or unexported fields
}
MessageViewport 消息视窗
func NewMessageViewport ¶
func NewMessageViewport(ctx context.Context) (MessageViewport, error)
NewMessageViewport 创建消息视窗
func (MessageViewport) AgentProcessing ¶
func (vp MessageViewport) AgentProcessing() bool
AgentProcessing 返回是否 Agent 处理中
func (MessageViewport) Update ¶
func (vp MessageViewport) Update(msg tea.Msg) (MessageViewport, tea.Cmd)
Update 处理更新事件
type MessagesList ¶
type MessagesList []MessageItem
MessagesList 消息列表
func (MessagesList) Append ¶
func (l MessagesList) Append(item MessageItem) MessagesList
Append 追加消息
func (MessagesList) Split ¶ added in v0.5.0
func (l MessagesList) Split(agentProcessing bool) (MessagesList, MessagesList)
Split 将消息列表切分为前面的固定部分和最后的可追加部分
type Options ¶
type Options struct {
AgentIn io.Writer
AgentOut io.Reader
Agent ACPAgent
InitialPrompt string
AutoExitAfterResponse bool
ResumeSessionID string
Channels []channels.Channel
}
Options UI 运行选项
type PromptResult ¶
type PromptResult struct {
Response acp.PromptResponse
Error error
}
type Selector ¶
type Selector struct {
SuggestionPrefix string
ShowDescription bool
NamePadding int
// contains filtered or unexported fields
}
Selector 选择器
func NewSelector ¶
func NewSelector(items []SelectorOption, suggestionPrefix string, height, width int) Selector
NewSelector 创建选择器
func (*Selector) AddItems ¶ added in v0.3.0
func (s *Selector) AddItems(items ...SelectorOption)
AddItems 添加选项
type SelectorOption ¶
SelectorOption 选择器选项
Click to show internal directories.
Click to hide internal directories.