hydaelyn

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 6 Imported by: 0

README

Hydaelyn

Go Reference Go Report Card Go Version CI Release Module

Hydaelyn is a Run/Task runner for Go.

Embed it into your application with hydaelyn.New() to run durable workflows where every state change goes through Run/Task commands, policy, leases, typed reports, handoff, response outbox, and replay.

Install

go get github.com/Viking602/go-hydaelyn@latest

Quickstart

Start a run with the default in-memory runner and inspect the append-only event stream:

package main

import (
	"context"
	"fmt"

	"github.com/Viking602/go-hydaelyn"
	"github.com/Viking602/go-hydaelyn/api"
)

func main() {
	runner := hydaelyn.New()
	run, err := runner.QueueRun(context.Background(), api.StartRunCommand{
		Request: "compare options for a Go research assistant",
	})
	if err != nil {
		panic(err)
	}
	events, err := runner.RunEvents(context.Background(), run.ID)
	if err != nil {
		panic(err)
	}
	fmt.Println(run.ID, len(events))
}

Core Concepts

Hydaelyn centers on embeddable runner primitives. New work should model execution as Run + Task + TaskExecutionLease. The optional worker package bridges TaskEnvelope execution to agent.Engine. Flow adapters are presets only; they must not bypass TaskStore, PolicyEngine, TaskExecutionLease, handoff, ResponseLayer, or OutputGateway.

Use api.Config only when overriding defaults:

runner := hydaelyn.New(api.Config{
	PolicyEngine: policy.DenySideEffectsByDefault(),
})

The old Team + Pattern runtime has been removed from the v2 public surface. Compose new work around the root hydaelyn runner API.

Examples

Examples live under _examples/ (leading underscore) so they are skipped by go build ./.... Build or run one explicitly with go run ./_examples/research/.

Where Hydaelyn Fits

Hydaelyn is designed to live inside your Go application. Compose the root Runner, register stable provider/tool/policy/flow contracts, and drive work through Run/Task commands.

The CLI is useful for inspection and workflow support, but the library is the primary surface. MCP can be plugged in as one integration path, not as the core execution model. V1 stays single-process, and the intended extension model is composition around the runner rather than subclassing a framework.

Development

See CONTRIBUTING.md for coding standards and contribution guidelines.

Documentation

Overview

Package hydaelyn is the root facade for the go-hydaelyn runner. It owns construction and the Runner wrapper:

runner := hydaelyn.New()

Import api for public contracts such as Config, commands, store interfaces, policy requests, and Run/Task value types.

Public packages are grouped by stable extension concern:

  • hydaelyn — Runner construction, methods, and error re-exports
  • api — Config, commands, interfaces, Run/Task data contracts
  • [agent] — agent engine and profile contracts
  • [tool] — tool contract, effect types, and tooltest helpers
  • [flow] — flow preset contracts
  • [policy] — unified authorization contract
  • [blackboard] — blackboard item and selector contracts
  • [provider] — LLM provider drivers (anthropic, openai, scripted)
  • [message] — shared message/content data types
  • [hook] — pre/post-turn hook contracts
  • [transport] — integration transports such as MCP
  • [worker] — optional Runner-to-agent.Engine execution glue

Types under internal/ are implementation details. Core storage, mailbox, transition, command-handler, and replay internals are not public extension points and cannot be imported by consumers.

Package hydaelyn is the public façade for the Hydaelyn runner.

Import github.com/Viking602/go-hydaelyn/api for public contracts such as Config, commands, interfaces, and value types. The root package owns only construction, Runner methods, and sentinel error re-exports.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound                = api.ErrNotFound
	ErrTerminalState           = api.ErrTerminalState
	ErrStaleTaskVersion        = api.ErrStaleTaskVersion
	ErrLeaseHolderMismatch     = api.ErrLeaseHolderMismatch
	ErrLeaseNotActive          = api.ErrLeaseNotActive
	ErrOwnerMismatch           = api.ErrOwnerMismatch
	ErrActionTaskRequired      = api.ErrActionTaskRequired
	ErrActionReconcileRequired = api.ErrActionReconcileRequired
	ErrResponseTaskRequired    = api.ErrResponseTaskRequired
	ErrPolicyDenied            = api.ErrPolicyDenied
	ErrPolicyObligationFailed  = api.ErrPolicyObligationFailed
	ErrFlowBypass              = api.ErrFlowBypass
	ErrHandoffCycle            = api.ErrHandoffCycle
	ErrHandoffDepthExceeded    = api.ErrHandoffDepthExceeded
	ErrInvalidCommand          = api.ErrInvalidCommand
	ErrInvalidTransition       = api.ErrInvalidTransition
	ErrCompletionCriteriaUnmet = api.ErrCompletionCriteriaUnmet
	ErrDependencyUnmet         = api.ErrDependencyUnmet
	ErrDependencyFailed        = api.ErrDependencyFailed
	ErrInvalidConfiguration    = api.ErrInvalidConfiguration
	ErrInvalidAddress          = api.ErrInvalidAddress
	ErrNoRecipients            = api.ErrNoRecipients
	ErrSubscriptionClosed      = api.ErrSubscriptionClosed
	ErrWaitTimeout             = api.ErrWaitTimeout
)

Public sentinel errors are owned by api and re-exported here for callers that only need root-level construction and error checks.

Functions

func DefaultConfig added in v0.7.0

func DefaultConfig() api.Config

DefaultConfig returns an empty api.Config; useful as a baseline before overriding individual fields.

Types

type Runner added in v0.7.0

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

Runner is the public façade over the internal runtime. All public contract values crossing this boundary use api package types, not internal/core types.

func New

func New(configs ...api.Config) *Runner

New constructs the primary Run/Task runner. With no arguments it uses the default in-memory configuration; pass api.Config values to override defaults.

func (*Runner) AckEnvelope added in v0.7.0

func (r *Runner) AckEnvelope(ctx context.Context, cmd api.AckEnvelopeCommand) error

func (*Runner) AcquireTaskExecution added in v0.7.0

func (r *Runner) AcquireTaskExecution(ctx context.Context, cmd api.AcquireTaskExecutionCommand) (api.TaskExecutionLease, bool, error)

func (*Runner) ActiveLeaseCount added in v0.7.0

func (r *Runner) ActiveLeaseCount(runID, taskID string) int

func (*Runner) AdvanceRun added in v0.7.0

func (r *Runner) AdvanceRun(ctx context.Context, cmd api.AdvanceRunCommand) (api.Run, error)

func (*Runner) Agents added in v0.7.0

func (r *Runner) Agents() []api.AgentProfile

func (*Runner) AppendEvent added in v0.7.0

func (r *Runner) AppendEvent(ctx context.Context, event api.Event) error

func (*Runner) Begin added in v0.7.0

func (r *Runner) Begin(ctx context.Context) (api.UnitOfWork, error)

func (*Runner) CompleteActionAttempt added in v0.7.0

func (r *Runner) CompleteActionAttempt(ctx context.Context, cmd api.CompleteActionAttemptCommand) (api.ActionAttempt, error)

func (*Runner) CreateTask added in v0.7.0

func (r *Runner) CreateTask(ctx context.Context, cmd api.CreateTaskCommand) (api.Task, error)

func (*Runner) DeadLetter added in v0.7.0

func (r *Runner) DeadLetter(ctx context.Context, cmd api.DeadLetterCommand) error

func (*Runner) DecideApproval added in v0.7.0

func (r *Runner) DecideApproval(ctx context.Context, cmd api.DecideApprovalCommand) error

func (*Runner) DispatchTask added in v0.7.0

func (r *Runner) DispatchTask(ctx context.Context, cmd api.DispatchTaskCommand) (api.TaskEnvelope, error)

func (*Runner) DispatchTaskFanOut added in v0.7.0

func (r *Runner) DispatchTaskFanOut(ctx context.Context, cmd api.FanOutDispatchTaskCommand) ([]api.TaskEnvelope, error)

func (*Runner) DrainResponseOutbox added in v0.7.0

func (r *Runner) DrainResponseOutbox(ctx context.Context) (int, error)

func (*Runner) EndTraceSpan added in v0.7.0

func (r *Runner) EndTraceSpan(ctx context.Context, cmd api.EndTraceSpanCommand) error

func (*Runner) Events added in v0.7.0

func (r *Runner) Events(runID string) []api.Event

func (*Runner) ExecuteCommand added in v0.7.0

func (r *Runner) ExecuteCommand(ctx context.Context, command api.Command) (any, error)

func (*Runner) HeartbeatTaskExecution added in v0.7.0

func (r *Runner) HeartbeatTaskExecution(ctx context.Context, cmd api.HeartbeatTaskExecutionCommand) error

func (*Runner) InvokeTool added in v0.7.0

func (*Runner) ListEnvelopes added in v0.7.0

func (r *Runner) ListEnvelopes(ctx context.Context, runID string) ([]api.TaskEnvelope, error)

func (*Runner) ListEvents added in v0.7.0

func (r *Runner) ListEvents(ctx context.Context, runID string) ([]api.Event, error)

func (*Runner) ListMessages added in v0.7.0

func (r *Runner) ListMessages(ctx context.Context, runID string) ([]api.UserMessage, error)

func (*Runner) ListQueuedMessages added in v0.7.0

func (r *Runner) ListQueuedMessages(ctx context.Context) ([]api.UserMessage, error)

func (*Runner) ListTasks added in v0.7.0

func (r *Runner) ListTasks(ctx context.Context, runID string) ([]api.Task, error)

func (*Runner) ListTraceSpans added in v0.7.0

func (r *Runner) ListTraceSpans(ctx context.Context, runID string) ([]api.TraceSpan, error)

func (*Runner) LoadEnvelope added in v0.7.0

func (r *Runner) LoadEnvelope(ctx context.Context, envelopeID string) (api.TaskEnvelope, error)

func (*Runner) LoadMessage added in v0.7.0

func (r *Runner) LoadMessage(ctx context.Context, runID, messageID string) (api.UserMessage, error)

func (*Runner) LoadRun added in v0.7.0

func (r *Runner) LoadRun(ctx context.Context, runID string) (api.Run, error)

func (*Runner) LoadTask added in v0.7.0

func (r *Runner) LoadTask(ctx context.Context, runID, taskID string) (api.Task, error)

func (*Runner) PublishResponse added in v0.7.0

func (r *Runner) PublishResponse(ctx context.Context, cmd api.PublishResponseCommand) error

func (*Runner) QueueEnvelope added in v0.7.0

func (r *Runner) QueueEnvelope(ctx context.Context, env api.TaskEnvelope) error

func (*Runner) QueueMessage added in v0.7.0

func (r *Runner) QueueMessage(ctx context.Context, message api.UserMessage) error

func (*Runner) QueueRun added in v0.7.0

func (r *Runner) QueueRun(ctx context.Context, cmd api.StartRunCommand) (api.Run, error)

func (*Runner) ReadyTasks added in v0.7.0

func (r *Runner) ReadyTasks(runID string) []api.Task

func (*Runner) Recover added in v0.7.0

func (r *Runner) Recover(ctx context.Context, runID string) (api.Projection, error)

func (*Runner) RecoverResumeToken added in v0.7.0

func (r *Runner) RecoverResumeToken(ctx context.Context, cmd api.RecoverResumeTokenCommand) (api.ResumeToken, error)

func (*Runner) RegisterAgent added in v0.7.0

func (r *Runner) RegisterAgent(profile api.AgentProfile)

func (*Runner) RegisterFlow added in v0.7.0

func (r *Runner) RegisterFlow(flow api.Flow) error

func (*Runner) RegisterTool added in v0.7.0

func (r *Runner) RegisterTool(tool api.Tool)

func (*Runner) ReleaseTaskExecution added in v0.7.0

func (r *Runner) ReleaseTaskExecution(ctx context.Context, cmd api.ReleaseTaskExecutionCommand) error

func (*Runner) Replay added in v0.7.0

func (r *Runner) Replay(runID string, mode api.ReplayMode) (api.Projection, error)

func (*Runner) ReplayRunState added in v0.7.0

func (r *Runner) ReplayRunState(runID string) (api.Projection, error)

func (*Runner) RequestApproval added in v0.7.0

func (*Runner) RequestHandoff added in v0.7.0

func (r *Runner) RequestHandoff(ctx context.Context, cmd api.HandoffCommand) error

func (*Runner) ResponseOutbox added in v0.7.0

func (r *Runner) ResponseOutbox(runID string) []api.UserMessage

func (*Runner) ResumeTokens added in v0.7.0

func (r *Runner) ResumeTokens() map[string]api.ResumeToken

func (*Runner) Run added in v0.7.0

func (r *Runner) Run(ctx context.Context, runID string) (api.Run, error)

func (*Runner) RunEvents added in v0.7.0

func (r *Runner) RunEvents(ctx context.Context, runID string) ([]api.Event, error)

func (*Runner) RunTimeline added in v0.7.0

func (r *Runner) RunTimeline(ctx context.Context, runID string) ([]api.RunTimelineItem, error)

func (*Runner) SaveRun added in v0.7.0

func (r *Runner) SaveRun(ctx context.Context, run api.Run) error

func (*Runner) SaveTask added in v0.7.0

func (r *Runner) SaveTask(ctx context.Context, task api.Task) error

func (*Runner) SaveTraceSpan added in v0.7.0

func (r *Runner) SaveTraceSpan(ctx context.Context, span api.TraceSpan) error

func (*Runner) SelectItems added in v0.7.0

func (r *Runner) SelectItems(ctx context.Context, runID string, selector api.BlackboardSelector) ([]api.BlackboardItem, error)

func (*Runner) SetMessagePolicy added in v0.7.0

func (r *Runner) SetMessagePolicy(policy api.MessagePolicyChecker)

func (*Runner) SetOutputGateway added in v0.7.0

func (r *Runner) SetOutputGateway(gateway api.OutputGateway)

func (*Runner) SetPipeline added in v0.7.0

func (r *Runner) SetPipeline(components api.PipelineComponents)

func (*Runner) SetPolicyEngine added in v0.7.0

func (r *Runner) SetPolicyEngine(policy api.PolicyEngine)

func (*Runner) StartActionAttempt added in v0.7.0

func (r *Runner) StartActionAttempt(ctx context.Context, cmd api.StartActionAttemptCommand) (api.ActionAttempt, error)

func (*Runner) StartRun added in v0.7.0

func (r *Runner) StartRun(ctx context.Context, cmd api.StartRunCommand) (api.Run, api.Task, error)

func (*Runner) StartTraceSpan added in v0.7.0

func (r *Runner) StartTraceSpan(ctx context.Context, cmd api.StartTraceSpanCommand) (api.TraceSpan, error)

func (*Runner) StoreProvider added in v0.7.0

func (r *Runner) StoreProvider() api.StoreProvider

func (*Runner) SubmitResponseOutput added in v0.7.0

func (r *Runner) SubmitResponseOutput(ctx context.Context, cmd api.SubmitResponseOutputCommand) error

func (*Runner) SubmitTypedReport added in v0.7.0

func (r *Runner) SubmitTypedReport(ctx context.Context, cmd api.SubmitTypedReportCommand) error

func (*Runner) SubmitUserInput added in v0.7.0

func (r *Runner) SubmitUserInput(ctx context.Context, cmd api.SubmitUserInputCommand) error

func (*Runner) Subscribe added in v0.7.0

func (r *Runner) Subscribe(ctx context.Context, runID string, filter api.BlackboardFilter) (<-chan api.BlackboardItem, func() error, error)

func (*Runner) Task added in v0.7.0

func (r *Runner) Task(ctx context.Context, runID, taskID string) (api.Task, error)

func (*Runner) TraceSpans added in v0.7.0

func (r *Runner) TraceSpans(runID string) []api.TraceSpan

func (*Runner) TransitionRun added in v0.7.0

func (r *Runner) TransitionRun(ctx context.Context, cmd api.TransitionRunCommand) error

func (*Runner) TransitionTask added in v0.7.0

func (r *Runner) TransitionTask(ctx context.Context, cmd api.TransitionTaskCommand) error

func (*Runner) UpdateEnvelope added in v0.7.0

func (r *Runner) UpdateEnvelope(ctx context.Context, env api.TaskEnvelope) error

func (*Runner) UpdateMessage added in v0.7.0

func (r *Runner) UpdateMessage(ctx context.Context, message api.UserMessage) error

func (*Runner) WaitForBlackboard added in v0.7.0

func (r *Runner) WaitForBlackboard(ctx context.Context, runID string, filter api.BlackboardFilter, predicate func([]api.BlackboardItem) bool, timeout time.Duration) ([]api.BlackboardItem, error)

func (*Runner) WriteItem added in v0.7.0

func (r *Runner) WriteItem(ctx context.Context, item api.BlackboardItem) error

Directories

Path Synopsis
_examples
approval command
approval demonstrates the human-in-the-loop tool gate: a policy engine requires approval for any tool flagged RequiresActionTask, the runtime pauses, a human decides, and the call resumes.
approval demonstrates the human-in-the-loop tool gate: a policy engine requires approval for any tool flagged RequiresActionTask, the runtime pauses, a human decides, and the call resumes.
collab command
collab demonstrates handoff: agent A starts a task, decides B is the right owner, and transfers ownership via RequestHandoff.
collab demonstrates handoff: agent A starts a task, decides B is the right owner, and transfers ownership via RequestHandoff.
dataflow command
dataflow demonstrates blackboard read/write: producer task writes a finding, consumer task reads it via SelectItems.
dataflow demonstrates blackboard read/write: producer task writes a finding, consumer task reads it via SelectItems.
durable command
durable demonstrates event-sourced replay: after a run completes, ReplayRunState rebuilds the full projection from the event log alone.
durable demonstrates event-sourced replay: after a run completes, ReplayRunState rebuilds the full projection from the event log alone.
evaluation command
evaluation walks a finished run's event stream and computes simple metrics.
evaluation walks a finished run's event stream and computes simple metrics.
governed_tool command
governed_tool demonstrates policy-gated tool execution.
governed_tool demonstrates policy-gated tool execution.
incident_response command
Reference architecture: 用户 → 主控 → Blackboard → Mailbox → N 专家 → 归因 → 风险评审 → 处置.
Reference architecture: 用户 → 主控 → Blackboard → Mailbox → N 专家 → 归因 → 风险评审 → 处置.
mailbox_pingpong command
mailbox_pingpong shows the mailbox dispatch + ack primitive.
mailbox_pingpong shows the mailbox dispatch + ack primitive.
orchestrator command
panel command
panel demonstrates AwaitMode=Quorum: a synthesizer task unblocks once 2 of 3 panel experts succeed.
panel demonstrates AwaitMode=Quorum: a synthesizer task unblocks once 2 of 3 panel experts succeed.
recipes/collab command
Recipe: collab — multi-branch parallel work where each branch hands off from implementer to reviewer.
Recipe: collab — multi-branch parallel work where each branch hands off from implementer to reviewer.
recipes/deepsearch command
Recipe: deepsearch — research + verification stage gated by AwaitMode=All.
Recipe: deepsearch — research + verification stage gated by AwaitMode=All.
recipes/panel command
Recipe: panel — domain experts each tagged by Role.
Recipe: panel — domain experts each tagged by Role.
recipes/research command
Recipe: research — N parallel researchers contribute evidence, a supervisor waits for the corpus, then synthesizes a finding.
Recipe: research — N parallel researchers contribute evidence, a supervisor waits for the corpus, then synthesizes a finding.
research command
research demonstrates fan-out by group.
research demonstrates fan-out by group.
tooling command
tooling demonstrates the tool registration + invocation primitive: a read-effect tool runs through the policy gate without approval, and the runtime records a ToolInvocationResult on the run timeline.
tooling demonstrates the tool registration + invocation primitive: a read-effect tool runs through the policy gate without approval, and the runtime records a ToolInvocationResult on the run timeline.
worker command
worker demonstrates the optional AgentWorker glue.
worker demonstrates the optional AgentWorker glue.
Package blackboard exposes only the stable item and selector contracts used by the Hydaelyn runtime.
Package blackboard exposes only the stable item and selector contracts used by the Hydaelyn runtime.
cmd
hydaelyn command
Package flow exposes orchestrator flow presets.
Package flow exposes orchestrator flow presets.
internal
cli
Package cli implements the hydaelyn binary.
Package cli implements the hydaelyn binary.
compact
Package compact provides conversation compaction strategies for managing context window growth.
Package compact provides conversation compaction strategies for managing context window growth.
core/governance
Package governance provides pure policy-effect helpers that operate only through ports.UnitOfWork.
Package governance provides pure policy-effect helpers that operate only through ports.UnitOfWork.
errs
Package errs provides structured error types used across the framework.
Package errs provides structured error types used across the framework.
gate
Package gate provides concurrency and ordering primitives for transport and messaging layers.
Package gate provides concurrency and ordering primitives for transport and messaging layers.
run
Package policy exposes the stable authorization contract used by the Hydaelyn runner.
Package policy exposes the stable authorization contract used by the Hydaelyn runner.
kit
transport
mcp
mcp/client
Package mcpclient implements a Model Context Protocol (MCP) client over JSON-RPC, supporting both HTTP and stdio transports for talking to MCP servers.
Package mcpclient implements a Model Context Protocol (MCP) client over JSON-RPC, supporting both HTTP and stdio transports for talking to MCP servers.
Package worker provides optional glue between the Hydaelyn runner and the single-agent engine.
Package worker provides optional glue between the Hydaelyn runner and the single-agent engine.

Jump to

Keyboard shortcuts

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