temporalworker

package
v0.0.0-...-d7ee6d5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const TaskQueue = "pathwalk"

Variables

This section is empty.

Functions

func PathwayWorkflow

func PathwayWorkflow(ctx workflow.Context, input PathwayInput) (*pathwalk.RunResult, error)

PathwayWorkflow executes a pathwalk pathway as a Temporal workflow. It returns the final RunResult or an error.

func StartRun

func StartRun(ctx context.Context, c client.Client, input PathwayInput, opts RunOptions) (string, error)

StartRun kicks off a PathwayWorkflow and returns the workflow ID immediately. The caller can later use GetResult or WaitForResult with the returned workflow ID. Pass opts.WorkflowID for idempotency; if empty, Temporal generates a UUID.

func StartWorker

func StartWorker(c client.Client, acts *PathwayActivities) (worker.Worker, error)

StartWorker creates and starts a worker for the pathwalk task queue. It registers PathwayWorkflow and the provided PathwayActivities.

func WaitForResult

func WaitForResult(ctx context.Context, c client.Client, workflowID, runID string) (*pathwalk.RunResult, error)

WaitForResult blocks until the workflow finishes and returns the final RunResult. Pass runID="" to use the default empty run ID (appropriate for single-run workflows).

Types

type CompletionCallbackInput

type CompletionCallbackInput struct {
	Data   string              // echoes PathwayInput.CompletionData
	Result *pathwalk.RunResult // nil on workflow error
	Err    string              // set if workflow-level error occurred
}

CompletionCallbackInput is the input to the completion callback activity. Called by PathwayWorkflow after the pathway run finishes.

type PathwayActivities

type PathwayActivities struct {
	// LLMClientOverride optionally overrides the LLM client (for testing).
	// If nil, one is created from the input credentials.
	LLMClientOverride pathwalk.LLMClient
}

PathwayActivities holds the activity implementations.

func (*PathwayActivities) ExecuteStep

ExecuteStep is a Temporal activity that executes a single node step. It parses the pathway, creates an engine, and calls engine.Step().

type PathwayInput

type PathwayInput struct {
	PathwayJSON []byte // JSON-encoded pathway
	Task        string // Initial task description
	MaxSteps    int    // 0 = use engine default (50)
	Verbose     bool
	LLMModel    string
	LLMBaseURL  string
	LLMAPIKey   string

	// Optional completion callback. When set, PathwayWorkflow calls this activity
	// on CompletionTaskQueue after finishing (success or error), passing a
	// CompletionCallbackInput.
	CompletionTaskQueue    string
	CompletionActivityName string
	CompletionData         string // opaque caller data (e.g., execution ID)
}

PathwayInput contains the parameters for a PathwayWorkflow.

type RunOptions

type RunOptions struct {
	WorkflowID string // Optional; if empty, Temporal generates a UUID
}

RunOptions configures a pathway workflow run.

type RunSnapshot

type RunSnapshot struct {
	Status        string // "running" or terminal reason
	CurrentNodeID string
	Output        string
	Variables     map[string]any
	Steps         []pathwalk.Step
	Error         string
}

RunSnapshot captures the current state of a running or completed workflow.

func GetResult

func GetResult(ctx context.Context, c client.Client, workflowID string) (*RunSnapshot, error)

GetResult queries the current state of a running or completed workflow. It returns a RunSnapshot showing the current node, variables, steps, and status. This is non-blocking and safe to call at any time.

type StepActivityInput

type StepActivityInput struct {
	PathwayJSON   []byte          // JSON-encoded pathway
	State         *pathwalk.State // Current execution state
	CurrentNodeID string
	LLMModel      string
	LLMBaseURL    string
	LLMAPIKey     string
	Verbose       bool
}

StepActivityInput is the input to the ExecuteStep activity.

type StepActivityResult

type StepActivityResult struct {
	State      *pathwalk.State
	StepResult *pathwalk.StepResult
}

StepActivityResult is the output of the ExecuteStep activity.

Jump to

Keyboard shortcuts

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