util

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeMessagesContextLength added in v0.7.0

func ComputeMessagesContextLength(ctx *lmcli.Context, conv *conversation.Conversation, messages []conversation.Message) []int

ComputeMessagesContextLength computes token counts for messages in a conversation. For system messages, the conversation's agent tools are included in the count. Returns a slice of token counts aligned with the messages slice.

func FormatForExternalPrompt

func FormatForExternalPrompt(messages []conversation.Message, system bool) string

func LookupConversation

func LookupConversation(ctx *lmcli.Context, shortName string) *conversation.Conversation

LookupConversation either returns the conversation found by the short name or exits the program

func LookupConversationE

func LookupConversationE(ctx *lmcli.Context, shortName string) (*conversation.Conversation, error)

func RenderConversation

func RenderConversation(ctx *lmcli.Context, messages []conversation.Message, spaceForResponse bool)

RenderConversation renders the given messages to TTY, with optional space for a subsequent message. spaceForResponse controls how many '\n' characters are printed immediately after the final message (1 if false, 2 if true). Message blocks are built in parallel for faster rendering.

func RenderMessage

func RenderMessage(ctx *lmcli.Context, m *conversation.Message)

func RunCompletionLoop added in v0.7.0

func RunCompletionLoop(
	ctx context.Context,
	appCtx *lmcli.Context,
	sess *session.Session,
	showThinking bool,
	perm api.PermissionMode,
) error

RunCompletionLoop drives the agent completion + tool-call loop for CLI commands. The session must have its agent set before calling. It starts a completion step, renders chunks to stdout, evaluates tool calls against the permission mode, executes them (with user confirmation when needed), and continues until a response has no tool calls or all tools are rejected. Cancelling ctx stops the loop.

func RunSession added in v0.7.0

func RunSession(cmd *cobra.Command, ctx *lmcli.Context, sess *session.Session)

RunSession configures the session from the application context, renders existing messages, and runs the agent completion loop (streaming output to stdout with auto-approved tool calls).

Types

This section is empty.

Jump to

Keyboard shortcuts

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