event

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Noop

func Noop(Event)

Noop 供无事件消费时使用。

Types

type Emitter added in v1.0.1

type Emitter func(typ EventType, data any)

Emitter 是事件出口的最小接口面:warp 链在每次 Run 组装时由引擎注入,

节点内部(重试、降级、防护等)经它发事件——只观察,不碰 state。

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	Iteration int
	// ForkID 标识事件所属的 fork 子循环(core.Fork);主循环事件为空串。
	// 工具并发、fork 也并发,消费方以 ForkID 区分多个并行 fork 的事件归属。
	ForkID string
	Data   any
}

Event 只做观察(含流式 chunk),不用于修改状态——修改状态是 Hook 的职责。

func (Event) String

func (e Event) String() string

type EventType

type EventType string
const (
	EventLoopStart  EventType = "loop_start"
	EventLoopEnd    EventType = "loop_end"
	EventModelStart EventType = "model_start"
	EventModelChunk EventType = "model_chunk"
	EventModelEnd   EventType = "model_end"
	// EventReasoningChunk 流式思考过程增量(推理模型的 reasoning_content),
	// data 为 string,与 EventModelChunk 分开透出。
	EventReasoningChunk EventType = "reasoning_chunk"
	EventToolStart      EventType = "tool_start"
	EventToolEnd        EventType = "tool_end"
	// EventToolChunk 流式工具调用增量(大参数调用构造期的实时反馈),
	// data 为 types.ToolCallDelta。
	EventToolChunk    EventType = "tool_chunk"
	EventIterationEnd EventType = "iteration_end"
	EventError        EventType = "error"
	// EventStreamFallback 警告:WithStreaming(true) 但链上无 StreamProvider,
	// 已降级为非流式调用(降级不静默)。
	EventStreamFallback EventType = "stream_fallback"
)

type OnEvent

type OnEvent func(Event)

OnEvent 是事件回调。并发契约:工具并发执行时回调可能被多个 goroutine

同时调用——实现必须并发安全且快速返回;免锁消费用 RunAsync 的 Events 通道。

Jump to

Keyboard shortcuts

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