temporalruntime

package
v0.1.0-alpha.39 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package temporalruntime dispatches durable agent runs to compiler-generated Temporal workflows. Workflow and activity worker registration remains owned by generated project code.

Index

Constants

View Source
const (
	EnvAddress          = "GOBEYOND_TEMPORAL_ADDRESS"
	EnvNamespace        = "GOBEYOND_TEMPORAL_NAMESPACE"
	EnvEnvironment      = "GOBEYOND_TEMPORAL_ENVIRONMENT"
	EnvHostedRuntime    = "GOBEYOND_HOSTED_RUNTIME"
	EnvHostReportSocket = "GOBEYOND_HOST_REPORT_SOCKET"

	DefaultAddress   = "localhost:7233"
	DefaultNamespace = "default"
)

Variables

View Source
var (
	ErrClosed = errors.New("agent Temporal dispatcher is closed")
)

Functions

func ActivityName

func ActivityName(agentID string) (string, error)

ActivityName returns the stable name generated workers must register for an agent's typed execution activity.

func Register

func Register[Input any, Output any](registry worker.Registry, agentID string, definition agents.Definition[Input, Output]) error

Register installs the stable workflow and typed execution activity for one compiler-discovered durable agent. Generated worker code calls this helper, keeping Temporal types and serialization out of authored agent packages.

func RegisterAI

func RegisterAI(_ worker.Worker, runtimes *AIRegistry, agentID string, definition agents.AIDefinition) error

func WorkflowID

func WorkflowID(sessionID, runID string) (string, error)

WorkflowID returns the stable Temporal execution ID for one session run.

func WorkflowName

func WorkflowName(agentID string) (string, error)

WorkflowName returns the stable name generated workers must register for an agent's durable workflow.

Types

type AIRegistry

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

AIRegistry is the queue-wide worker runtime resolver for compiled AI agents. The Temporal AI SDK registers its stable workflow and activity names once per polling process, then selects provider/tools by AgentID and revision.

func NewAIRegistry

func NewAIRegistry() *AIRegistry

func (*AIRegistry) Register

func (runtimes *AIRegistry) Register(registry worker.Worker) error

Register installs the stable SDK workflow and activities exactly once for a generated queue worker. It is a no-op when the queue contains no AI agents.

func (*AIRegistry) ResolveAgentRuntime

func (runtimes *AIRegistry) ResolveAgentRuntime(_ context.Context, scope activities.RuntimeScope) (activities.AgentRuntime, error)

type Client

type Client interface {
	ExecuteWorkflow(context.Context, client.StartWorkflowOptions, interface{}, ...interface{}) (client.WorkflowRun, error)
	SignalWorkflow(context.Context, string, string, string, interface{}) error
	CancelWorkflow(context.Context, string, string) error
	Close()
}

Client is the narrow Temporal client surface used by Dispatcher. The SDK's client.Client implements this interface directly.

type ClientFactory

type ClientFactory func(context.Context, client.Options) (Client, error)

ClientFactory creates a client from non-secret connection options. It is injectable so hosted construction and tests do not require a package-global Temporal connection.

type Dispatcher

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

Dispatcher implements httpruntime.Dispatcher for compiler-generated durable agent workflows.

func New

func New(ctx context.Context, options Options) (*Dispatcher, error)

New constructs a dispatcher and dials Temporal when Client is not supplied.

func NewLazyLocalFromEnv

func NewLazyLocalFromEnv(ctx context.Context) (*Dispatcher, error)

NewLazyLocalFromEnv constructs the local dispatcher without requiring Temporal to be reachable at site startup. The first durable invocation establishes the connection; direct agents and the rest of the site remain usable while a local Temporal server is starting.

func NewLocalFromEnv

func NewLocalFromEnv(ctx context.Context) (*Dispatcher, error)

NewLocalFromEnv dials a local/plaintext Temporal client. It reads only the address, namespace, and queue environment slug; it never reads or logs API keys or certificate material.

func (*Dispatcher) Cancel

Cancel requests cancellation of the stable workflow execution for the run.

func (*Dispatcher) Close

func (dispatcher *Dispatcher) Close()

Close releases the Temporal client. It is safe to call more than once.

func (*Dispatcher) Respond

Respond signals a pending durable AI tool approval. Typed handler agents keep their legacy unsupported response behavior.

func (*Dispatcher) Start

func (dispatcher *Dispatcher) Start(ctx context.Context, adapter httpruntime.Adapter, call httpruntime.StartCall, emit httpruntime.EventEmitter) error

Start launches the generated workflow, waits for its JSON result, and emits the canonical agent.output event through the HTTP runtime.

type Options

type Options struct {
	Client      Client
	Factory     ClientFactory
	Address     string
	Namespace   string
	Environment string
}

Options configures a dispatcher. Client and Factory are mutually exclusive. Dispatcher takes ownership of Client and closes it from Close.

Jump to

Keyboard shortcuts

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