core

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package core runs conversations: it picks the agent, queues prompts, applies the permission policy, tracks cost and takes git checkpoints. It knows nothing about Telegram; the frontend implements UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalView

type ApprovalView interface {
	Resolve(outcome string)
}

type Conv

type Conv struct {
	ChatID   int64
	ThreadID int
}

Conv identifies a conversation: a chat, or a forum topic inside one.

func (Conv) Key

func (c Conv) Key() string

type Core

type Core struct {
	STT stt.Transcriber
	TTS tts.Speaker
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Config, st *store.Store, agents map[string]agent.Agent, br *bridge.Bridge, tr stt.Transcriber, sp tts.Speaker) *Core

func (*Core) Agents

func (c *Core) Agents() []string

func (*Core) Answer

func (c *Core) Answer(id, optionID string) bool

Answer delivers the user's choice for approval id. It returns false if the request is no longer pending.

func (*Core) ApprovalConv

func (c *Core) ApprovalConv(id string) (Conv, bool)

ApprovalConv returns the conversation an approval belongs to.

func (*Core) Caps

func (c *Core) Caps(conv Conv) agent.Caps

func (*Core) Config

func (c *Core) Config() *config.Config

func (*Core) Diff

func (c *Core) Diff(ctx context.Context, conv Conv, all bool) (string, error)

Diff shows changes since the last checkpoint, or since HEAD when all is true.

func (*Core) Models

func (c *Core) Models(conv Conv) []string

func (*Core) NewSession

func (c *Core) NewSession(conv Conv)

func (*Core) ResumeSession

func (c *Core) ResumeSession(conv Conv, id string) (store.SessionRecord, error)

func (*Core) Running

func (c *Core) Running(conv Conv) (running bool, queued int)

func (*Core) Sessions

func (c *Core) Sessions(conv Conv) []store.SessionRecord

func (*Core) SetAgent

func (c *Core) SetAgent(conv Conv, name string) error

func (*Core) SetCwd

func (c *Core) SetCwd(conv Conv, dir string) (string, error)

func (*Core) SetMode

func (c *Core) SetMode(conv Conv, mode string) error

func (*Core) SetModel

func (c *Core) SetModel(conv Conv, model string)

func (*Core) SetProject

func (c *Core) SetProject(conv Conv, name string) error

func (*Core) SetUI

func (c *Core) SetUI(ui UI)

SetUI must be called before Submit.

func (*Core) Settings

func (c *Core) Settings(conv Conv) Settings

func (*Core) Stop

func (c *Core) Stop(conv Conv) (stopped bool, dropped int)

Stop cancels the current run and drops the queue.

func (*Core) Submit

func (c *Core) Submit(conv Conv, in Input)

Submit runs the input now, or queues it if the conversation is busy. While an approval is pending, text input denies it with that text as the reason.

func (*Core) ToggleVoice

func (c *Core) ToggleVoice(conv Conv) (bool, error)

func (*Core) Undo

func (c *Core) Undo(ctx context.Context, conv Conv) (store.Checkpoint, error)

Undo restores the working tree to the state before the last turn.

func (*Core) Usage

func (c *Core) Usage(user int64) (today, month float64)

type Input

type Input struct {
	User   int64
	Blocks []agent.Block
	Text   string // the text part, used for titles and "deny with reason"
}

Input is one user message.

type Progress

type Progress interface {
	Tool(title string)
	// Flush is called before agent text is sent, so tool lines stay above it.
	Flush()
	Done(summary string)
}

type Settings

type Settings struct {
	Agent, Model, Mode, Cwd, Project string
	SessionID                        string
	Voice                            bool
	AlwaysAllow                      []string
	TotalCost                        float64
}

Settings is a conversation's effective configuration.

type UI

type UI interface {
	// Reply sends agent Markdown. Long replies may become a file.
	Reply(conv Conv, md string)
	// Notice sends a short plain-text status line.
	Notice(conv Conv, text string)
	// Progress starts a compact "working" indicator for one turn.
	Progress(conv Conv) Progress
	// ShowApproval presents a permission request; the user's choice comes
	// back through Core.Answer(id, optionID).
	ShowApproval(conv Conv, id string, p agent.Permission) ApprovalView
	SendFile(ctx context.Context, conv Conv, path, caption string) error
	SendVoice(ctx context.Context, conv Conv, ogg []byte) error
}

UI is implemented by the chat frontend.

Jump to

Keyboard shortcuts

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