eino

package
v0.1.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package eino is the boundary between gridctl's agent runtime and the upstream cloudwego/eino library. Every reference to github.com/cloudwego/eino in the gridctl tree lives in this directory; the rest of pkg/agent/ imports only the gridctl-shaped types defined here.

The boundary is enforced by scripts/check-eino-boundary.sh, run from CI. Treat the constraint as load-bearing: it is what keeps an eino swap a 1–2 week project rather than a multi-month rewrite. New eino types are wrapped here before crossing out, never re-exported as-is.

The package is import-private (under internal/) so callers always go through the public re-exports in pkg/agent.

Index

Constants

END is the implicit graph exit vertex. Connect a node to END to make its output the graph's output.

View Source
const START = einocompose.START

START is the implicit graph entry vertex. Connect a node from START to receive the graph's input as that node's input.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph[I, O any] struct {
	// contains filtered or unexported fields
}

Graph is a typed graph composition. Nodes are added via AddLambdaNode or AddPassthroughNode; edges are wired with AddEdge. Compile produces a Runnable that executes the composition.

Phase A wraps only the surface needed to validate the boundary; later phases extend it (state nodes, branches, sub-graphs) as the runtime needs them.

func NewGraph

func NewGraph[I, O any]() *Graph[I, O]

NewGraph creates an empty typed graph keyed by its input and output types. The graph must be wired START → ... → END before Compile.

func (*Graph[I, O]) AddEdge

func (g *Graph[I, O]) AddEdge(from, to string) error

AddEdge connects two named nodes along the graph's data flow. Use START as the source to consume the graph's input; use END as the destination to surface a node's output as the graph's output.

func (*Graph[I, O]) AddLambdaNode

func (g *Graph[I, O]) AddLambdaNode(name string, fn func(ctx context.Context, in I) (O, error)) error

AddLambdaNode registers a function-shaped node under the given name. The function is invoked once per traversal with the upstream node's output as input and produces the downstream node's input.

func (*Graph[I, O]) AddPassthroughNode

func (g *Graph[I, O]) AddPassthroughNode(name string) error

AddPassthroughNode registers a node that forwards its input unchanged. Useful for boundary smoke tests and for graph topologies whose only purpose is to gate execution.

func (*Graph[I, O]) Compile

func (g *Graph[I, O]) Compile(ctx context.Context) (*Runnable[I, O], error)

Compile produces a Runnable that can Invoke or Stream the graph. The graph must be acyclic and fully connected from START to END; otherwise Compile returns an error describing the missing wiring.

type Runnable

type Runnable[I, O any] struct {
	// contains filtered or unexported fields
}

Runnable is a compiled, executable graph. Phase A exposes Invoke and Stream; Collect and Transform from the upstream Runnable interface are withheld from the v1 surface until a concrete caller needs them.

func (*Runnable[I, O]) Invoke

func (r *Runnable[I, O]) Invoke(ctx context.Context, in I) (O, error)

Invoke runs the graph synchronously and returns its final output.

func (*Runnable[I, O]) Stream

func (r *Runnable[I, O]) Stream(ctx context.Context, in I) (*StreamReader[O], error)

Stream runs the graph and returns a StreamReader emitting per-chunk outputs. The caller is responsible for calling Close on the reader when done; abandoning the reader leaks the underlying channel.

type StreamReader

type StreamReader[T any] struct {
	// contains filtered or unexported fields
}

StreamReader is a single-consumer reader over a typed chunk stream. EOF semantics match the upstream library: Recv returns io.EOF on stream completion. Close is safe to call multiple times.

func StreamReaderFromSlice

func StreamReaderFromSlice[T any](items []T) *StreamReader[T]

StreamReaderFromSlice wraps a finite slice of items as a StreamReader. It is the bridge Phase B provider adapters will use to expose non-streaming responses through the streaming interface, and it gives tests a stream they can fully drain without a goroutine.

func (*StreamReader[T]) Close

func (s *StreamReader[T]) Close()

Close releases resources held by the stream.

func (*StreamReader[T]) Recv

func (s *StreamReader[T]) Recv() (T, error)

Recv returns the next chunk in the stream. It returns io.EOF when the stream is closed and no further chunks are available.

Jump to

Keyboard shortcuts

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