temporal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package temporal is the Temporal adapter for session.Runtime. Hosts use Dial and Open. Zero Snapshots and Secrets use in-memory stores kept on the runtime. StartWorker registers SessionWorkflow and the turn activities against those stores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(opts client.Options) (client.Client, error)

Dial is client.Dial with Temporal's OpenTelemetry v2 plugin prepended. It installs a replay-safe tracer on the process. When telemetry.Init has already run, that tracer keeps the same export configuration.

func SessionWorkflow

func SessionWorkflow(ctx workflow.Context, in workflowInput) (string, error)

SessionWorkflow is the Temporal type name for the session wait loop. StartWorker registers it. Hosts call session.Runtime, not this function.

Types

type Config

type Config struct {
	// Agent is the one agent this runtime runs. Specialists on Agent are
	// assistants it can spawn. Jobs are named handlers, not agents.
	Agent     tacklr.AgentOptions
	TaskQueue string
	// Snapshots is the session record. Zero uses an in-memory store.
	// Tokens never go here. StartWorker uses this same store.
	Snapshots session.SnapshotStore
	Fallback  session.EventLog
	// Projection mounts the turn tree on the host kernel.
	// Nil leaves the MountSession in-process.
	Projection vfs.Projection
	// DisableStreams uses the fallback EventLog instead of Workflow Streams.
	DisableStreams bool
	// TurnLocality, when > 0, pins a turn's activities to one worker.
	TurnLocality time.Duration
	// ActivityTimeout is Inference/Tool StartToCloseTimeout. Zero is 10 minutes.
	ActivityTimeout time.Duration
	// HeartbeatTimeout is the activity heartbeat timeout. Zero is 30 seconds.
	HeartbeatTimeout time.Duration
	// ActivityAttempts is Temporal MaximumAttempts for a wrapped network
	// error, a model refusal, or a stale checkpoint. Zero is 3. 1 means no
	// retry. Any other activity error stops on the first attempt.
	ActivityAttempts int32
	// Secrets holds work-item credentials for activities. Zero uses an
	// in-memory store. StartWorker uses this same store. Tokens never
	// enter event history.
	Secrets session.SecretStorage
	// Jobs are named background workers Schedule can start. A specialist
	// of the same name takes precedence.
	Jobs map[string]session.JobHandler
}

Config is the host config for Open. StartWorker uses the stores Open kept.

type Runtime

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

Runtime implements session.Runtime with one Temporal workflow per session.

func Open

func Open(c client.Client, cfg Config) *Runtime

Open constructs a Temporal Runtime. Zero Snapshots and Secrets use in-memory stores kept on the runtime. StartWorker registers the worker against those same stores.

func (*Runtime) Cancel

func (r *Runtime) Cancel(ctx context.Context, sessionID session.SessionID) error

Cancel implements session.Runtime.

func (*Runtime) Children

func (r *Runtime) Children(ctx context.Context, parent session.SessionID) ([]session.SessionID, error)

Children implements session.Runtime.

func (*Runtime) Close

func (r *Runtime) Close(ctx context.Context, sessionID session.SessionID) error

Close implements session.Runtime.

func (*Runtime) CreateSession

func (r *Runtime) CreateSession(ctx context.Context, req session.CreateSession) (session.SessionID, error)

CreateSession implements session.Runtime.

func (*Runtime) Head

func (r *Runtime) Head(ctx context.Context, sessionID session.SessionID) (session.Seq, error)

Head implements session.Runtime. When Workflow Streams is on, this is the stream's next offset so Subscribe(after Head) skips prior-turn events.

func (*Runtime) Jobs

func (r *Runtime) Jobs(ctx context.Context, parent session.SessionID) ([]session.SessionStatus, error)

Jobs implements session.Runtime.

func (*Runtime) Prompt

func (r *Runtime) Prompt(ctx context.Context, sessionID session.SessionID, msg session.Prompt) error

func (*Runtime) Resume

func (r *Runtime) Resume(ctx context.Context, sessionID session.SessionID, resume session.Resume) error

func (*Runtime) StartWorker

func (r *Runtime) StartWorker() worker.Worker

StartWorker returns a Temporal worker for this runtime. It registers SessionWorkflow and the turn activities against the runtime's snapshot store, secret store, and agent.

func (*Runtime) Status

Status implements session.Runtime.

func (*Runtime) Subscribe

func (r *Runtime) Subscribe(ctx context.Context, sessionID session.SessionID, after session.Seq) (session.Subscription, error)

Subscribe implements session.Runtime.

Jump to

Keyboard shortcuts

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