engine

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataPayload

type DataPayload struct {
	Chunk    interface{} `json:"chunk"`
	Sequence int64       `json:"sequence"`
	Total    *int64      `json:"total,omitempty"`
}

DataPayload contains data event payload

type Emitter

type Emitter interface {
	// EmitData sends a data chunk
	EmitData(data interface{}) error

	// EmitProgress sends a progress update
	EmitProgress(current, total int64, message string) error

	// Context returns the execution context (for cancellation)
	Context() context.Context
}

Emitter is the interface provided to streaming tools for emitting events

type EndPayload

type EndPayload struct {
	Duration   time.Duration `json:"duration_ms"`
	EventCount int64         `json:"event_count,omitempty"`
	Summary    string        `json:"summary,omitempty"`
}

EndPayload contains completion event data

type ErrorPayload

type ErrorPayload struct {
	Error     error  `json:"-"`
	Message   string `json:"message"`
	Retryable bool   `json:"retryable"`
}

ErrorPayload contains error event data

type Event

type Event struct {
	Type      EventType
	Timestamp time.Time
	Data      interface{}
}

Event represents a streaming event

func NewDataEvent

func NewDataEvent(chunk interface{}, sequence int64) Event

NewDataEvent creates a data event

func NewEndEvent

func NewEndEvent(duration time.Duration, eventCount int64, summary string) Event

NewEndEvent creates an end event

func NewErrorEvent

func NewErrorEvent(err error, message string, retryable bool) Event

NewErrorEvent creates an error event

func NewProgressEvent

func NewProgressEvent(current, total int64, message string) Event

NewProgressEvent creates a progress event

func NewStartEvent

func NewStartEvent(toolName, requestID string, args map[string]interface{}) Event

NewStartEvent creates a start event

type EventType

type EventType int

EventType represents the type of streaming event

const (
	// EventStart indicates execution has started
	EventStart EventType = iota

	// EventData indicates a data chunk
	EventData

	// EventProgress indicates progress update
	EventProgress

	// EventEnd indicates successful completion
	EventEnd

	// EventError indicates an error occurred
	EventError
)

func (EventType) String

func (t EventType) String() string

String returns the string representation of EventType

type Executor

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

Executor manages streaming tool execution

func NewExecutor

func NewExecutor(config ExecutorConfig, logger *slog.Logger) *Executor

NewExecutor creates a new executor

func (*Executor) Execute

func (e *Executor) Execute(
	ctx context.Context,
	toolName string,
	requestID string,
	args map[string]interface{},
	handler StreamingToolHandler,
) <-chan Event

Execute runs a streaming tool and returns an event channel

func (*Executor) State

func (e *Executor) State() ExecutorState

State returns the current execution state

type ExecutorConfig

type ExecutorConfig struct {
	BufferSize    int
	Timeout       time.Duration
	MaxEvents     int64
	MaxConcurrent int // v2 feature: semaphore-based concurrency control
}

ExecutorConfig configures the executor

func DefaultExecutorConfig

func DefaultExecutorConfig() ExecutorConfig

DefaultExecutorConfig returns default configuration

type ExecutorState

type ExecutorState string

ExecutorState represents the execution state

const (
	StateInit     ExecutorState = "init"
	StateRunning  ExecutorState = "running"
	StateDone     ExecutorState = "done"
	StateError    ExecutorState = "error"
	StateCanceled ExecutorState = "canceled"
)

func (ExecutorState) String

func (s ExecutorState) String() string

String implements fmt.Stringer

type ProgressPayload

type ProgressPayload struct {
	Current    int64   `json:"current"`
	Total      int64   `json:"total"`
	Percentage float64 `json:"percentage"`
	Message    string  `json:"message,omitempty"`
}

ProgressPayload contains progress event data

type StartPayload

type StartPayload struct {
	ToolName  string                 `json:"tool_name"`
	RequestID string                 `json:"request_id"`
	Args      map[string]interface{} `json:"args,omitempty"`
}

StartPayload contains start event data

type StreamingToolHandler

type StreamingToolHandler func(ctx context.Context, args map[string]interface{}, emit Emitter) error

StreamingToolHandler is the function signature for streaming tools

Jump to

Keyboard shortcuts

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