taskplan

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package taskplan 提供 task_plan 工具:模型提交任务规划后中断等待 用户处置——执行 / 拒绝 / 按修改意见调整后重新提交。 实现与 approve 同构:OnToolStart 阻塞在 Decisions channel 上, 处置意见作为工具结果进入消息历史,由模型据此继续或修订。 task_plan 工具由 hook 在 OnStart 自动注册,core.WithHooks(New()) 即可, 无需再 core.WithTools(Tool())。

tools.go 定义 task_plan 壳工具:schema 是唯一实体(planArgs tag 反射生成), 真正的"执行体"是 Hook.OnToolStart 拦截后等用户处置,Invoke 不会被走到。

Index

Constants

View Source
const EventRequest = event.EventType("taskplan.request")

EventRequest 是规划提交事件,Data 为 *types.ToolCall(Args.plan 为规划全文)。

View Source
const ToolName = "task_plan"

ToolName 是规划提交工具的注册名。

Variables

This section is empty.

Functions

func Tool

func Tool() types.Tool

Tool 返回 task_plan 壳工具:仅提供 schema 供模型发现, 真正的"执行体"是 Hook 拦截后等用户处置,Invoke 不会被走到。 hook 已在 OnStart 自动注册本工具,通常无需手动调用。

Types

type Decision

type Decision struct {
	CallID string
	Kind   Kind
	// Input:Revise 时为修改意见;Reject 时可选理由;Execute 时可选补充说明。
	Input string
}

Decision 是对一次规划提交的回应。CallID 留空视为回应当前请求。

type Hook

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

func New

func New() (*Hook, chan<- Decision)

New 创建 hook 并返回决策 channel 的发送端。 task_plan 工具由 hook 在 OnStart 自动注册,无需再 core.WithTools(Tool())。 决策必须从其他 goroutine 发送,理由同 approve.New。

func (*Hook) Name

func (h *Hook) Name() string

func (*Hook) OnStart added in v1.1.0

func (h *Hook) OnStart(_ context.Context, state *types.LoopState) error

OnStart 自动注册 task_plan 工具。仍导出 Tool() 以便显式装配。

func (*Hook) OnToolStart

func (h *Hook) OnToolStart(ctx context.Context, state *types.LoopState, call *types.ToolCall) (hook.Action, error)

type Kind

type Kind int

Kind 是用户对规划的处置。

const (
	Execute Kind = iota // 批准,按原规划执行
	Reject              // 否决,不执行
	Revise              // 按修改意见调整后重新提交
)

Jump to

Keyboard shortcuts

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