orchestrator

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ThinkingSep = "\x02"

ThinkingSep 是思考文本与正文之间的分隔标记。 streamFilter 在思考文本段前插入此标记,TUI 据此切换渲染样式。

Variables

This section is empty.

Functions

func BuildCoordinator

func BuildCoordinator(
	cfg bootstrap.Config,
	store *store.Store,
	models *bootstrap.ModelSet,
	bundle assets.Bundle,
	emit emitFn,
) (*agentcore.Agent, *tools.AskUserTool)

BuildCoordinator 组装 Coordinator Agent 及其 SubAgent。 返回 Agent 和 AskUserTool(供调用方注入 handler)。

Types

type CoCreateMessage added in v0.0.3

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

type CoCreateReply added in v0.0.3

type CoCreateReply struct {
	Message string
	Prompt  string
	Ready   bool
}

type OutlineSnapshot

type OutlineSnapshot struct {
	Chapter   int
	Title     string
	CoreEvent string
}

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

type Runtime

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

Runtime 封装协调器生命周期,提供 TUI 所需的非阻塞接口。

func NewRuntime

func NewRuntime(cfg bootstrap.Config, bundle assets.Bundle) (*Runtime, error)

NewRuntime 创建 Runtime:初始化 store/model/coordinator,注册事件订阅,但不启动 Prompt。

func (*Runtime) AskUser

func (rt *Runtime) AskUser() *tools.AskUserTool

AskUser 返回 ask_user 工具实例,供 TUI 注入交互 handler。

func (*Runtime) Close

func (rt *Runtime) Close()

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

func (*Runtime) CoCreateStream added in v0.0.3

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

CoCreateStream 使用多轮对话帮助用户澄清创作需求。 ctx 由调用方控制生命周期,取消时 LLM 请求立即终止。

func (*Runtime) ConfiguredModels added in v0.0.2

func (rt *Runtime) ConfiguredModels(provider string) []string

ConfiguredModels 返回某个 provider 下已配置的模型列表。

func (*Runtime) ConfiguredProviders added in v0.0.2

func (rt *Runtime) ConfiguredProviders() []string

ConfiguredProviders 返回已配置的 provider 列表。

func (*Runtime) CurrentModelSelection added in v0.0.2

func (rt *Runtime) CurrentModelSelection(role string) (provider, model string, explicit bool)

CurrentModelSelection 返回指定 role 当前生效的 provider/model。 role 为空或 "default" 时返回默认模型。

func (*Runtime) Dir

func (rt *Runtime) Dir() string

Dir 返回当前运行时的输出目录。

func (*Runtime) Done

func (rt *Runtime) Done() <-chan struct{}

Done 返回完成信号通道。

func (*Runtime) Events

func (rt *Runtime) Events() <-chan UIEvent

Events 返回只读事件通道。

func (*Runtime) Resume

func (rt *Runtime) Resume() (string, error)

Resume 恢复模式:根据 Progress/RunMeta 自动判断恢复类型并启动。 返回恢复标签(空字符串表示无法恢复,应走新建模式)。

func (*Runtime) Snapshot

func (rt *Runtime) Snapshot() UISnapshot

Snapshot 读取 store 聚合为状态快照。

func (*Runtime) Start

func (rt *Runtime) Start(prompt string) error

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

func (*Runtime) Steer

func (rt *Runtime) Steer(text string)

Steer 提交用户干预。 如果 coordinator 正在运行,通过 Steer 注入消息。 如果 coordinator 已停止(出错),通过 Prompt 重启 agent 循环。

func (*Runtime) Stream

func (rt *Runtime) Stream() <-chan string

Stream 返回只读流式 token 通道。

func (*Runtime) StreamClear

func (rt *Runtime) StreamClear() <-chan struct{}

StreamClear 返回只读流式清空信号通道。

func (*Runtime) SwitchModel added in v0.0.2

func (rt *Runtime) SwitchModel(role, provider, model string) error

SwitchModel 热切换默认模型或指定角色模型。 role 为空或 "default" 时更新默认模型;否则写入角色级会话覆盖。

type UIEvent

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

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

type UISnapshot

type UISnapshot struct {
	Provider          string
	NovelName         string
	ModelName         string
	Style             string
	StatusLabel       string // READY / RUNNING / REVIEW / REWRITE / COMPLETE / ERROR
	Phase             string
	Flow              string
	CurrentChapter    int
	TotalChapters     int
	CompletedCount    int
	TotalWordCount    int
	InProgressChapter int
	PendingRewrites   []int
	RewriteReason     string
	PendingSteer      string
	RecoveryLabel     string // 恢复类型描述,空表示新建
	IsRunning         bool

	// 基础设定
	Premise          string            // 前提概要
	Outline          []OutlineSnapshot // 大纲(每章标题 + 核心事件)
	Characters       []string          // 角色列表(名字 + 身份)
	Layered          bool              // 是否分层模式(滚动规划)
	CurrentVolumeArc string            // 当前卷弧位置(如"第1卷·第1弧")
	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