Documentation
¶
Overview ¶
Package chat runs a session as a chat (api/chat.go): its provider's CLI in the CLI's structured mode, Claude Code's stream-json, Codex's app-server or the Agent Client Protocol, read into items the window draws. A session runs either its chat or its terminal, never both, and switching between them resumes the same conversation on the other side.
Index ¶
- Variables
- type Service
- func (s *Service) Agents(ctx context.Context, opts api.SessionIDOptions) (api.ChatAgentList, error)
- func (s *Service) Answer(_ context.Context, opts api.ChatAnswerOptions) (api.None, error)
- func (s *Service) Background(ctx context.Context, opts api.SessionIDOptions) (api.None, error)
- func (s *Service) BackgroundWork(id string) bool
- func (s *Service) Cancel(_ context.Context, opts api.SessionIDOptions) (api.None, error)
- func (s *Service) Commands(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatCommand, error)
- func (s *Service) CreateMemory(ctx context.Context, opts api.ChatPathOptions) (api.None, error)
- func (s *Service) Drawn(id string) bool
- func (s *Service) End(id string)
- func (s *Service) History(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatItem, error)
- func (s *Service) HookAct(ctx context.Context, opts api.ChatHookActOptions) (api.None, error)
- func (s *Service) Hooks(ctx context.Context, opts api.SessionIDOptions) (api.ChatHookList, error)
- func (s *Service) Kinds(context.Context, api.None) ([]string, error)
- func (s *Service) LastAnswer(id string) string
- func (s *Service) MCP(ctx context.Context, opts api.SessionIDOptions) (api.ChatMCPList, error)
- func (s *Service) MCPAct(ctx context.Context, opts api.ChatMCPActOptions) (api.ChatMCPActResult, error)
- func (s *Service) Memory(ctx context.Context, opts api.SessionIDOptions) (api.ChatMemoryList, error)
- func (s *Service) New(ctx context.Context, opts api.SessionIDOptions) (api.None, error)
- func (s *Service) NewAgent(ctx context.Context, opts api.ChatNewAgentOptions) (api.ChatNewAgentResult, error)
- func (s *Service) Open(ctx context.Context, id string) error
- func (s *Service) Opened(id string) bool
- func (s *Service) Options(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatOption, error)
- func (s *Service) PermissionAct(ctx context.Context, opts api.ChatPermissionActOptions) (api.ChatPermissionActResult, error)
- func (s *Service) Permissions(ctx context.Context, opts api.SessionIDOptions) (api.ChatPermissionList, error)
- func (s *Service) PluginAct(ctx context.Context, opts api.ChatPluginActOptions) (api.ChatPluginActResult, error)
- func (s *Service) Plugins(ctx context.Context, opts api.SessionIDOptions) (api.ChatPluginList, error)
- func (s *Service) Prompt(ctx context.Context, opts api.ChatPromptOptions) (api.None, error)
- func (s *Service) Reply(_ context.Context, opts api.ChatReplyOptions) (api.None, error)
- func (s *Service) RunShell(ctx context.Context, opts api.ChatRunShellOptions) (api.None, error)
- func (s *Service) SetMemory(ctx context.Context, opts api.ChatSetMemoryOptions) (api.None, error)
- func (s *Service) SetOption(ctx context.Context, opts api.ChatSetOptionOptions) (api.None, error)
- func (s *Service) SetSkill(ctx context.Context, opts api.ChatSetSkillOptions) (api.None, error)
- func (s *Service) SetView(ctx context.Context, opts api.ChatViewOptions) (api.None, error)
- func (s *Service) ShellOutput(ctx context.Context, opts api.ChatShellOptions) (string, error)
- func (s *Service) Shells(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatShell, error)
- func (s *Service) Shutdown()
- func (s *Service) Skills(ctx context.Context, opts api.SessionIDOptions) (api.ChatSkillList, error)
- func (s *Service) Steer(ctx context.Context, opts api.ChatPromptOptions) (api.None, error)
- func (s *Service) StopShell(ctx context.Context, opts api.ChatShellOptions) (api.None, error)
- func (s *Service) Take(id, text string) (relay.HandedPrompt, error)
- func (s *Service) Workflows(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatWorkflow, error)
Constants ¶
This section is empty.
Variables ¶
var Kinds = []string{providers.Claude, providers.OpenCode, providers.OMP, providers.Antigravity, providers.Kiro, providers.Cursor, providers.Codex}
Kinds is the providers whose sessions can be drawn as a chat. Crush is out: its server speaks HTTP, not stdio. Cursor's ACP server is in unmeasured, behind a login (docs/ceilings.md).
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs every session's chat.
func New ¶
func New(term *terminal.Service, db *store.Service, hub *events.Hub, lang func() prompt.Lang) *Service
New is a chat service running its providers through term, and the way the relay's prompts reach a session term runs as a chat.
func (*Service) Agents ¶
func (s *Service) Agents(ctx context.Context, opts api.SessionIDOptions) (api.ChatAgentList, error)
Agents answers api.ChatAgents.
func (*Service) Background ¶
Background answers api.ChatBackground.
func (*Service) BackgroundWork ¶
BackgroundWork is whether session id's agent has work running in the background (terminal.ChatSink): only Claude Code's chat reports it (docs/ceilings.md).
func (*Service) Commands ¶
func (s *Service) Commands(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatCommand, error)
Commands answers api.ChatCommands.
func (*Service) CreateMemory ¶
CreateMemory answers api.ChatCreateMemory: only a file the agent itself lists as missing, so the window cannot have lich write anywhere else.
func (*Service) Hooks ¶
func (s *Service) Hooks(ctx context.Context, opts api.SessionIDOptions) (api.ChatHookList, error)
Hooks answers api.ChatHooks.
func (*Service) LastAnswer ¶
LastAnswer is the final message of session id's last turn, "" when that turn wrote none or no chat runs there (terminal.ChatSink).
func (*Service) MCP ¶
func (s *Service) MCP(ctx context.Context, opts api.SessionIDOptions) (api.ChatMCPList, error)
MCP answers api.ChatMCP.
func (*Service) MCPAct ¶
func (s *Service) MCPAct(ctx context.Context, opts api.ChatMCPActOptions) (api.ChatMCPActResult, error)
MCPAct answers api.ChatMCPAct.
func (*Service) Memory ¶
func (s *Service) Memory(ctx context.Context, opts api.SessionIDOptions) (api.ChatMemoryList, error)
Memory answers api.ChatMemory.
func (*Service) New ¶
New answers api.ChatNew: the chat's process is started again with nothing to resume, which every provider opens as an empty conversation, on the model, effort and mode it ran. The conversation it leaves stays the provider's, for the palette's History to reopen; the session forgets it before the new process starts, so a restart before the first message cannot bring it back.
func (*Service) NewAgent ¶
func (s *Service) NewAgent(ctx context.Context, opts api.ChatNewAgentOptions) (api.ChatNewAgentResult, error)
NewAgent answers api.ChatNewAgent: a file of its own name, never over one that is there.
func (*Service) Open ¶
Open starts session id's chat on its conversation, unless it runs already, and returns once the conversation is open.
func (*Service) Opened ¶
Opened is whether session id's chat runs and has opened its conversation (terminal.ChatSink).
func (*Service) Options ¶
func (s *Service) Options(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatOption, error)
Options answers api.ChatOptions.
func (*Service) PermissionAct ¶
func (s *Service) PermissionAct(ctx context.Context, opts api.ChatPermissionActOptions) (api.ChatPermissionActResult, error)
PermissionAct answers api.ChatPermissionAct.
func (*Service) Permissions ¶
func (s *Service) Permissions(ctx context.Context, opts api.SessionIDOptions) (api.ChatPermissionList, error)
Permissions answers api.ChatPermissions.
func (*Service) PluginAct ¶
func (s *Service) PluginAct(ctx context.Context, opts api.ChatPluginActOptions) (api.ChatPluginActResult, error)
PluginAct answers api.ChatPluginAct.
func (*Service) Plugins ¶
func (s *Service) Plugins(ctx context.Context, opts api.SessionIDOptions) (api.ChatPluginList, error)
Plugins answers api.ChatPlugins.
func (*Service) Prompt ¶
Prompt answers api.ChatPrompt. The attachments are read before anything else, so a file that cannot be read refuses the message whole.
func (*Service) RunShell ¶
RunShell answers api.ChatRunShell: the command runs in a turn of its own, one at a time, as Claude Code allows only one at once (measured on 2.1.330). An agent that runs none (opencode 2, which runs no server) gets the line as typed.
func (*Service) SetOption ¶
SetOption answers api.ChatSetOption: over the protocol when the provider takes the change in flight, by resuming the conversation in a process started for it when not. The choice is recorded for the session's later spawns.
func (*Service) SetView ¶
SetView switches session opts.ID between its terminal and its chat: the side it leaves stops and is waited out, then the other resumes the conversation, and the window hears of the switch once the new side runs.
func (*Service) ShellOutput ¶
ShellOutput answers api.ChatShellOutput.
func (*Service) Shutdown ¶
func (s *Service) Shutdown()
Shutdown stops every chat, on the way out of lich.
func (*Service) Skills ¶
func (s *Service) Skills(ctx context.Context, opts api.SessionIDOptions) (api.ChatSkillList, error)
Skills answers api.ChatSkills.
func (*Service) Steer ¶
Steer answers api.ChatSteer: the message goes to the agent in the turn running, by its driver's follow (Claude Code reads it mid-turn, Codex steers the turn, ACP stops it and sends the message after); with no turn running it is a prompt.
func (*Service) Take ¶
func (s *Service) Take(id, text string) (relay.HandedPrompt, error)
Take sends text as session id's next message: now when no turn runs, after the turns before it otherwise (terminal.ChatSink). Its receipt is acked when the turn carrying it starts.
func (*Service) Workflows ¶
func (s *Service) Workflows(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatWorkflow, error)
Workflows answers api.ChatWorkflows: none for a provider that has no workflows to report (docs/ceilings.md).
Source Files
¶
- acp.go
- acp_commands.go
- acp_compact.go
- acp_options.go
- acp_question.go
- acp_suggest.go
- acp_title.go
- attach.go
- changes.go
- claude.go
- claude_commands.go
- claude_compact.go
- claude_hooks.go
- claude_memory.go
- claude_options.go
- claude_permissions.go
- claude_plan.go
- claude_plugins.go
- claude_proposal.go
- claude_question.go
- claude_shell.go
- claude_shells.go
- claude_tools.go
- claude_usage.go
- claude_workflows.go
- codex.go
- codex_commands.go
- codex_compact.go
- codex_hooks.go
- codex_items.go
- codex_memory.go
- codex_options.go
- codex_plugins.go
- codex_question.go
- codex_suggest.go
- codex_tools.go
- commands.go
- compaction.go
- conversation.go
- diff.go
- files.go
- frontmatter.go
- history.go
- local_command.go
- memory.go
- new.go
- opencode_question.go
- opencode_shell.go
- options.go
- permissions.go
- plugins.go
- question.go
- relay.go
- service.go
- session.go
- shell.go
- shells.go
- suggest.go
- title.go
- tool.go
- tools.go