host

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildStartPrompt

func BuildStartPrompt(prompt string) string

BuildStartPrompt 将用户需求包装为 Coordinator 的启动 prompt。

func ReplayDeltaText

func ReplayDeltaText(item domain.RuntimeQueueItem) string

ReplayDeltaText 从运行时队列项中提取可回放的流式文本。

Types

type AgentContextSnapshot

type AgentContextSnapshot struct {
	Tokens          int
	ContextWindow   int
	Percent         float64
	Scope           string
	Strategy        string
	ActiveMessages  int
	SummaryMessages int
	CompactedCount  int
	KeptCount       int
}

AgentContextSnapshot 是 Agent 上下文使用情况。

type AgentSnapshot

type AgentSnapshot struct {
	Name             string
	State            string
	TaskID           string
	TaskKind         string
	Summary          string
	Tool             string
	Turn             int
	Context          AgentContextSnapshot
	RecentProjection AgentContextSnapshot
	UpdatedAt        time.Time
}

AgentSnapshot 是 Agent 状态的展示投影。

type CoCreateMessage

type CoCreateMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

CoCreateMessage 是共创对话的消息。

type CoCreateReply

type CoCreateReply struct {
	Message string
	Prompt  string
	Ready   bool
}

CoCreateReply 是共创对话的 LLM 回复。

type Event

type Event struct {
	Time     time.Time
	Category string // TOOL / SYSTEM / REVIEW / CHECK / ERROR / AGENT
	Summary  string
	Level    string // info / warn / error / success
}

Event 是 TUI 消费的结构化事件。

type Host

type Host struct {
	// contains filtered or unexported fields
}

Host 是运行时薄外壳。 职责:启动/恢复/干预注入/事件投影/模型管理。 不做任何调度决策,不做空闲续跑。

func New

func New(cfg bootstrap.Config, bundle assets.Bundle) (*Host, error)

New 创建 Host。

func (*Host) Abort

func (h *Host) Abort() bool

Abort 暂停当前 coordinator。

func (*Host) AskUser

func (h *Host) AskUser() *tools.AskUserTool

func (*Host) Close

func (h *Host) Close()

Close 终止 coordinator 并关闭事件通道。

func (*Host) CoCreateStream

func (h *Host) CoCreateStream(ctx context.Context, history []CoCreateMessage, onReply func(string)) (CoCreateReply, error)

func (*Host) ConfiguredModels

func (h *Host) ConfiguredModels(provider string) []string

func (*Host) ConfiguredProviders

func (h *Host) ConfiguredProviders() []string

func (*Host) Continue

func (h *Host) Continue(text string) error

Continue 用指定 prompt 继续。停机后用户在输入框输入时调用。

func (*Host) CurrentModelSelection

func (h *Host) CurrentModelSelection(role string) (string, string, bool)

func (*Host) Dir

func (h *Host) Dir() string

func (*Host) Done

func (h *Host) Done() <-chan struct{}

func (*Host) Events

func (h *Host) Events() <-chan Event

func (*Host) ReplayQueue

func (h *Host) ReplayQueue(afterSeq int64) ([]domain.RuntimeQueueItem, error)

func (*Host) Resume

func (h *Host) Resume() (string, error)

Resume 恢复模式:从 checkpoint + progress 生成 resume prompt 并启动。

func (*Host) Snapshot

func (h *Host) Snapshot() UISnapshot

func (*Host) Start

func (h *Host) Start(prompt string) error

Start 新建模式:初始化进度并启动 coordinator 长循环。

func (*Host) StartPrepared

func (h *Host) StartPrepared(promptText string) error

StartPrepared 使用已编排完成的启动 prompt 开始创作。

func (*Host) Steer

func (h *Host) Steer(text string)

Steer 提交用户干预。

func (*Host) Stream

func (h *Host) Stream() <-chan string

func (*Host) StreamClear

func (h *Host) StreamClear() <-chan struct{}

func (*Host) SwitchModel

func (h *Host) SwitchModel(role, provider, model string) error

type OutlineSnapshot

type OutlineSnapshot struct {
	Chapter   int
	Title     string
	CoreEvent string
}

OutlineSnapshot 是大纲条目的展示摘要。

type TaskSnapshot

type TaskSnapshot struct {
	ID        string
	Kind      string
	Owner     string
	Title     string
	Status    string
	Chapter   int
	Volume    int
	Arc       int
	Summary   string
	Tool      string
	OutputRef string
	UpdatedAt time.Time
}

TaskSnapshot 是任务状态的展示投影(从事件流投影,非事实层)。

type UISnapshot

type UISnapshot struct {
	Provider          string
	NovelName         string
	ModelName         string
	Style             string
	RuntimeState      string // idle / running / pausing / paused / completed
	StatusLabel       string
	Phase             string
	Flow              string
	CurrentChapter    int
	TotalChapters     int
	CompletedCount    int
	TotalWordCount    int
	InProgressChapter int
	PendingRewrites   []int
	RewriteReason     string
	PendingSteer      string
	RecoveryLabel     string
	IsRunning         bool
	Agents            []AgentSnapshot
	Tasks             []TaskSnapshot

	// 上下文
	ContextTokens         int
	ContextWindow         int
	ContextPercent        float64
	ContextScope          string
	ContextStrategy       string
	ProjectionTokens      int
	ProjectionWindow      int
	ProjectionPercent     float64
	ProjectionStrategy    string
	ProjectionCompacted   int
	ProjectionKept        int
	ContextActiveMessages int
	ContextSummaryCount   int
	ContextCompactedCount int
	ContextKeptCount      int

	// 基础设定
	Premise          string
	Outline          []OutlineSnapshot
	Characters       []string
	Layered          bool
	CurrentVolumeArc string
	NextVolumeTitle  string
	CompassDirection string
	CompassScale     string

	// 详情
	LastCommitSummary  string
	LastReviewSummary  string
	LastCheckpointName string
	RecentSummaries    []string
}

UISnapshot 是 TUI 渲染所需的聚合状态快照。

Jump to

Keyboard shortcuts

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