chat

package
v0.93.0-rc.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 42 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

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

Agents answers api.ChatAgents.

func (*Service) Answer

func (s *Service) Answer(_ context.Context, opts api.ChatAnswerOptions) (api.None, error)

Answer answers api.ChatAnswer.

func (*Service) Background

func (s *Service) Background(ctx context.Context, opts api.SessionIDOptions) (api.None, error)

Background answers api.ChatBackground.

func (*Service) BackgroundWork

func (s *Service) BackgroundWork(id string) bool

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) Cancel

func (s *Service) Cancel(_ context.Context, opts api.SessionIDOptions) (api.None, error)

Cancel answers api.ChatCancel.

func (*Service) Commands

func (s *Service) Commands(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatCommand, error)

Commands answers api.ChatCommands.

func (*Service) CreateMemory

func (s *Service) CreateMemory(ctx context.Context, opts api.ChatPathOptions) (api.None, error)

CreateMemory answers api.ChatCreateMemory: only a file the agent itself lists as missing, so the window cannot have lich write anywhere else.

func (*Service) Drawn

func (s *Service) Drawn(id string) bool

Drawn is whether session id is drawn as a chat (spawn.Chat).

func (*Service) End

func (s *Service) End(id string)

End stops session id's chat, for a card that closed.

func (*Service) History

func (s *Service) History(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatItem, error)

History answers api.ChatHistory.

func (*Service) HookAct

func (s *Service) HookAct(ctx context.Context, opts api.ChatHookActOptions) (api.None, error)

HookAct answers api.ChatHookAct.

func (*Service) Hooks

Hooks answers api.ChatHooks.

func (*Service) Kinds

func (s *Service) Kinds(context.Context, api.None) ([]string, error)

Kinds answers api.ChatKinds.

func (*Service) LastAnswer

func (s *Service) LastAnswer(id string) string

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

MCP answers api.ChatMCP.

func (*Service) MCPAct

MCPAct answers api.ChatMCPAct.

func (*Service) Memory

Memory answers api.ChatMemory.

func (*Service) New

func (s *Service) New(ctx context.Context, opts api.SessionIDOptions) (api.None, error)

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

NewAgent answers api.ChatNewAgent: a file of its own name, never over one that is there.

func (*Service) Open

func (s *Service) Open(ctx context.Context, id string) error

Open starts session id's chat on its conversation, unless it runs already, and returns once the conversation is open.

func (*Service) Opened

func (s *Service) Opened(id string) bool

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

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

PluginAct answers api.ChatPluginAct.

func (*Service) Plugins

Plugins answers api.ChatPlugins.

func (*Service) Prompt

func (s *Service) Prompt(ctx context.Context, opts api.ChatPromptOptions) (api.None, error)

Prompt answers api.ChatPrompt. The attachments are read before anything else, so a file that cannot be read refuses the message whole.

func (*Service) Reply

func (s *Service) Reply(_ context.Context, opts api.ChatReplyOptions) (api.None, error)

Reply answers api.ChatReply.

func (*Service) RunShell

func (s *Service) RunShell(ctx context.Context, opts api.ChatRunShellOptions) (api.None, error)

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) SetMemory

func (s *Service) SetMemory(ctx context.Context, opts api.ChatSetMemoryOptions) (api.None, error)

SetMemory answers api.ChatSetMemory.

func (*Service) SetOption

func (s *Service) SetOption(ctx context.Context, opts api.ChatSetOptionOptions) (api.None, error)

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) SetSkill

func (s *Service) SetSkill(ctx context.Context, opts api.ChatSetSkillOptions) (api.None, error)

SetSkill answers api.ChatSetSkill.

func (*Service) SetView

func (s *Service) SetView(ctx context.Context, opts api.ChatViewOptions) (api.None, error)

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

func (s *Service) ShellOutput(ctx context.Context, opts api.ChatShellOptions) (string, error)

ShellOutput answers api.ChatShellOutput.

func (*Service) Shells

func (s *Service) Shells(ctx context.Context, opts api.SessionIDOptions) ([]api.ChatShell, error)

Shells answers api.ChatShells.

func (*Service) Shutdown

func (s *Service) Shutdown()

Shutdown stops every chat, on the way out of lich.

func (*Service) Skills

Skills answers api.ChatSkills.

func (*Service) Steer

func (s *Service) Steer(ctx context.Context, opts api.ChatPromptOptions) (api.None, error)

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) StopShell

func (s *Service) StopShell(ctx context.Context, opts api.ChatShellOptions) (api.None, error)

StopShell answers api.ChatStopShell.

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL