Versions in this module Expand all Collapse all v0 v0.1.0 Feb 2, 2026 Changes in this version + const DefaultMaxSessions + const DefaultSessionTTL + func ParamsAs[T any](r *Response, action string) (T, bool) + type Action struct + Description string + Example string + Name string + Schema map[string]any + type ActionRegistry struct + func NewActionRegistry() *ActionRegistry + func (r *ActionRegistry) Actions() []Action + func (r *ActionRegistry) IsEmpty() bool + func (r *ActionRegistry) Names() []string + func (r *ActionRegistry) Register(name string, prototype any) *ActionRegistry + func (r *ActionRegistry) RegisterWithDesc(name, description string, prototype any) *ActionRegistry + func (r *ActionRegistry) ToToolDefs() []ToolDef + func (r *ActionRegistry) ValidateAction(name string) bool + type Adapter interface + Call func(ctx context.Context, system, user string) (string, error) + Stream func(ctx context.Context, system, user string) (<-chan string, error) + func WithHooks(inner Adapter, hook CallHook) Adapter + type Cache interface + Delete func(key string) + Get func(key string) (string, bool) + Set func(key string, value string) + type CachingAdapter struct + func WithCache(inner Adapter, cache Cache, enabled bool) *CachingAdapter + func (c *CachingAdapter) Call(ctx context.Context, system, user string) (string, error) + func (c *CachingAdapter) CallWithSession(ctx context.Context, system, user, previousResponseID string) (string, string, error) + func (c *CachingAdapter) CallWithTools(ctx context.Context, system, user string, tools []ToolDef) (*ToolCall, error) + func (c *CachingAdapter) CallWithToolsAndSession(ctx context.Context, system, user, previousResponseID string, tools []ToolDef) (*ToolCall, string, error) + func (c *CachingAdapter) DeleteSession(ctx context.Context, responseID string) error + func (c *CachingAdapter) IsEnabled() bool + func (c *CachingAdapter) SetEnabled(enabled bool) + func (c *CachingAdapter) Stream(ctx context.Context, system, user string) (<-chan string, error) + type CallHook struct + OnEnd func(ctx context.Context, system, user, response string, err error) + OnStart func(ctx context.Context, system, user string) + type ContextBuilder struct + func NewContextBuilder() *ContextBuilder + func (b *ContextBuilder) Add(name, content string) *ContextBuilder + func (b *ContextBuilder) AddIf(condition bool, name, content string) *ContextBuilder + func (b *ContextBuilder) AddTemplate(name, template string) *ContextBuilder + func (b *ContextBuilder) Build() string + func (b *ContextBuilder) String() string + type DecideCase struct + func Otherwise(r Runnable) DecideCase + func When(action string, r Runnable) DecideCase + func WhenFunc(condition func(data map[string]any) bool, r Runnable) DecideCase + func WhenParam(key string, value any, r Runnable) DecideCase + type Engine struct + func New(adapter Adapter, opts ...EngineOption) *Engine + func (e *Engine) Adapter() Adapter + func (e *Engine) Close() + func (e *Engine) DeleteSession(ctx context.Context, sessionID string) error + func (e *Engine) Run(ctx context.Context, r Runnable, metadata Metadata) (*FlowContext, *Response, error) + func (e *Engine) RunWithSession(ctx context.Context, sessionID string, r Runnable, metadata Metadata) (*FlowContext, *Response, error) + func (e *Engine) Sessions() *SessionManager + func (e *Engine) Stream(ctx context.Context, step *Step, metadata Metadata) (<-chan string, error) + type EngineOption func(*Engine) + func WithDefaultRetries(n int) EngineOption + type FlowContext struct + func NewFlowContext(ctx context.Context, engine *Engine, metadata Metadata) *FlowContext + func (fc *FlowContext) Engine() *Engine + func (fc *FlowContext) GetNodeData(name string) (NodeData, bool) + func (fc *FlowContext) GetNodes() []NodeData + func (fc *FlowContext) Metadata() Metadata + func (fc *FlowContext) MetadataSnapshot() Metadata + func (fc *FlowContext) PrevAction() string + func (fc *FlowContext) PrevParams() map[string]any + func (fc *FlowContext) PrevResponse() *Response + func (fc *FlowContext) RecordNode(name, action string, params map[string]any) + func (fc *FlowContext) Session() *Session + func (fc *FlowContext) WithSession(sess *Session) *FlowContext + type Guide struct + AutoRPC bool + Constraints []string + type Logger interface + Debug func(msg string, args ...any) + Error func(msg string, args ...any) + Info func(msg string, args ...any) + type MemoryCache struct + func NewMemoryCache() *MemoryCache + func (c *MemoryCache) Delete(key string) + func (c *MemoryCache) Get(key string) (string, bool) + func (c *MemoryCache) Set(key string, value string) + type Message struct + Content string + Role string + type Metadata map[string]any + func (m Metadata) Get(key string) (any, bool) + func (m Metadata) GetInt64(key string) int64 + func (m Metadata) GetString(key string) string + func (m Metadata) Merge(others ...Metadata) Metadata + type MetricsCollector interface + IncrementCalls func() + IncrementErrors func() + RecordLatency func(milliseconds int64) + type Middleware func(Adapter) Adapter + func ChainMiddleware(middlewares ...Middleware) Middleware + func WithLogging(logger Logger) Middleware + func WithMetrics(collector MetricsCollector) Middleware + type MockAdapter struct + func NewMockAdapter(response string) *MockAdapter + func NewMockAdapterSequence(responses ...string) *MockAdapter + func NewMockAdapterWithToolCall(name string, args map[string]any) *MockAdapter + func (m *MockAdapter) Call(ctx context.Context, system, user string) (string, error) + func (m *MockAdapter) CallCount() int + func (m *MockAdapter) CallWithSession(ctx context.Context, system, user, previousResponseID string) (string, string, error) + func (m *MockAdapter) CallWithTools(ctx context.Context, system, user string, tools []ToolDef) (*ToolCall, error) + func (m *MockAdapter) CallWithToolsAndSession(ctx context.Context, system, user, previousResponseID string, tools []ToolDef) (*ToolCall, string, error) + func (m *MockAdapter) DeleteSession(ctx context.Context, responseID string) error + func (m *MockAdapter) Reset() + func (m *MockAdapter) Stream(ctx context.Context, system, user string) (<-chan string, error) + type NamedRunnable interface + GetName func() string + type NodeData struct + Action string + Metadata Metadata + Name string + Params map[string]any + type ParallelError struct + Errors []error + Responses []*Response + func (e *ParallelError) Error() string + func (e *ParallelError) FailedIndexes() []int + func (e *ParallelError) Unwrap() []error + type Response struct + Action string + Message string + Params map[string]any + Raw string + Type ResponseType + func (r *Response) Is(action string) bool + func (r *Response) IsMessage() bool + func (r *Response) IsMethod() bool + func (r *Response) ParseParams(dest any) error + type ResponseType string + const ResponseMessage + const ResponseMethod + type Runnable interface + Run func(fc *FlowContext) (*Response, error) + func Chain(steps ...Runnable) Runnable + func Decide(cases ...DecideCase) Runnable + func Guard(condition func(*FlowContext) bool, then Runnable) Runnable + func Iterate(step Runnable, until func(*Response) bool) Runnable + func IterateMax(step Runnable, until func(*Response) bool, max int) Runnable + func Parallel(steps ...Runnable) Runnable + func Transform(fn func(*Response) *Response) Runnable + type RunnableFunc func(fc *FlowContext) (*Response, error) + func (f RunnableFunc) Run(fc *FlowContext) (*Response, error) + type Session struct + func NewSession(id string) *Session + func (s *Session) AppendMessage(role, content string) + func (s *Session) Chain() []string + func (s *Session) Clear() + func (s *Session) GetResponseID(stepName string) (string, bool) + func (s *Session) ID() string + func (s *Session) LastAccessed() time.Time + func (s *Session) LastResponseID() string + func (s *Session) Messages() []Message + func (s *Session) RecordNode(stepName, responseID string) + func (s *Session) RootResponseID() string + func (s *Session) SetRootResponseID(id string) + type SessionAdapter interface + CallWithSession func(ctx context.Context, system, user, previousResponseID string) (resp string, responseID string, err error) + DeleteSession func(ctx context.Context, responseID string) error + type SessionManager struct + func NewSessionManager(opts ...SessionManagerOption) *SessionManager + func (m *SessionManager) Clear() + func (m *SessionManager) Count() int + func (m *SessionManager) Delete(id string) + func (m *SessionManager) Exists(id string) bool + func (m *SessionManager) Get(id string) *Session + func (m *SessionManager) GetIfExists(id string) *Session + func (m *SessionManager) MaxSize() int + func (m *SessionManager) Stop() + func (m *SessionManager) TTL() time.Duration + type SessionManagerOption func(*SessionManager) + func WithMaxSessions(max int) SessionManagerOption + func WithTTL(ttl time.Duration) SessionManagerOption + type Step struct + Actions *ActionRegistry + Context string + Guide *Guide + Input string + MaxRetries int + Name string + Task string + Validator Validator + func SimpleStep(name, context, input string) *Step + func (s *Step) ActionNames() []string + func (s *Step) BuildSystemPrompt(fc *FlowContext) (string, error) + func (s *Step) BuildUserPrompt(fc *FlowContext, hint string) (string, error) + func (s *Step) GetName() string + func (s *Step) Run(fc *FlowContext) (*Response, error) + func (s *Step) ToolDefs() []ToolDef + func (s *Step) ValidateAction(name string) bool + type StepBuilder struct + func NewStep(name string) *StepBuilder + func (b *StepBuilder) Action(name string, prototype any) *StepBuilder + func (b *StepBuilder) ActionWithDesc(name, description string, prototype any) *StepBuilder + func (b *StepBuilder) Build() *Step + func (b *StepBuilder) Context(template string) *StepBuilder + func (b *StepBuilder) Guide(constraints ...string) *StepBuilder + func (b *StepBuilder) Input(template string) *StepBuilder + func (b *StepBuilder) Role(r string) *StepBuilder + func (b *StepBuilder) Task(description string) *StepBuilder + func (b *StepBuilder) WithRetries(n int) *StepBuilder + func (b *StepBuilder) WithValidator(v Validator) *StepBuilder + type ToolAdapter interface + CallWithTools func(ctx context.Context, system, user string, tools []ToolDef) (*ToolCall, error) + CallWithToolsAndSession func(ctx context.Context, system, user, previousResponseID string, tools []ToolDef) (call *ToolCall, responseID string, err error) + type ToolCall struct + Arguments map[string]any + Name string + type ToolDef struct + Description string + Name string + Parameters map[string]any + type ValidationError struct + Attempt int + Err error + Response *Response + func (e *ValidationError) Error() string + func (e *ValidationError) Unwrap() error + type Validator func(*Response) error