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
- Variables
- func ActivityName(agentID string) (string, error)
- func Register[Input any, Output any](registry worker.Registry, agentID string, ...) error
- func RegisterAI(_ worker.Worker, runtimes *AIRegistry, agentID string, ...) error
- func WorkflowID(sessionID, runID string) (string, error)
- func WorkflowName(agentID string) (string, error)
- type AIRegistry
- type Client
- type ClientFactory
- type Dispatcher
- func (dispatcher *Dispatcher) Cancel(ctx context.Context, _ httpruntime.Adapter, call httpruntime.CancelCall, ...) error
- func (dispatcher *Dispatcher) Close()
- func (dispatcher *Dispatcher) Respond(ctx context.Context, adapter httpruntime.Adapter, call httpruntime.RespondCall, ...) error
- func (dispatcher *Dispatcher) Start(ctx context.Context, adapter httpruntime.Adapter, call httpruntime.StartCall, ...) error
- type Options
Constants ¶
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 ¶
var (
ErrClosed = errors.New("agent Temporal dispatcher is closed")
)
Functions ¶
func ActivityName ¶
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 ¶
WorkflowID returns the stable Temporal execution ID for one session run.
func WorkflowName ¶
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 ¶
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 ¶
func (dispatcher *Dispatcher) Cancel(ctx context.Context, _ httpruntime.Adapter, call httpruntime.CancelCall, _ httpruntime.EventEmitter) error
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 ¶
func (dispatcher *Dispatcher) Respond(ctx context.Context, adapter httpruntime.Adapter, call httpruntime.RespondCall, _ httpruntime.EventEmitter) error
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.