worker

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package worker runs tacklr sessions on Temporal: it registers the session workflow and its turn activities, and keeps each session's harness (VFS, MCP connections, tools) between steps. A host that only starts and talks to sessions uses package session/temporal instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Agent is the one agent the sessions run. Specialists on Agent are
	// assistants it can spawn. Jobs are named handlers, not agents.
	Agent tacklr.AgentOptions
	// TaskQueue is the queue the session workflows start on. Zero is
	// "tacklr".
	TaskQueue string
	// Store is the session record the steps save. It is required. Tokens
	// never go here.
	Store session.Store
	// Secrets holds work-item credentials for the steps. It is required.
	// Tokens never enter event history.
	Secrets session.SecretStorage
	// Fallback is the EventLog the steps write the durable events to when
	// DisableStreams is set. Zero is an in-memory log, which reaches no
	// client.
	Fallback session.EventLog
	// DisableStreams sends the durable events to Fallback instead of
	// Workflow Streams.
	DisableStreams bool
	// Live is where this worker serves the deltas of the sessions whose
	// harnesses it holds. A zero Live serves none: clients get whole
	// messages only.
	Live Live
	// Workspace is the agent's /workspace: the tree each turn mounts, and
	// the tools, skills and overflow the agent gets from it. A zero
	// Workspace is no workspace.
	Workspace workspace.Config
	// FuseRoot is the host directory under which the worker shows each
	// turn's workspace with FUSE, one directory per session, so run_command
	// can run there. Empty keeps the workspace in-process, and the harness
	// then has no run_command tool.
	FuseRoot string
	// Jobs are named background workers Schedule can start. A specialist
	// of the same name takes precedence.
	Jobs map[string]session.JobHandler
	// HarnessIdle is how long the worker keeps a session's harness after
	// its last step. Zero is 10 minutes.
	HarnessIdle time.Duration
	// MaxHarnesses is how many harnesses the worker keeps; past it, the
	// harness unused longest closes. Zero is 256.
	MaxHarnesses int
	// MaxConcurrentActivityExecutionSize caps the steps the worker runs at
	// once (Temporal worker.Options). Zero is Temporal's default.
	MaxConcurrentActivityExecutionSize int
	// HeartbeatThrottle is the longest a running step waits to send its
	// heartbeat (worker MaxHeartbeatThrottleInterval). A cancel reaches a
	// running step on a heartbeat's reply, so this bounds how long a cancel
	// takes; lower is faster and sends more heartbeats. Zero is 2 seconds.
	HeartbeatThrottle time.Duration
}

Config is the host config for New. Store, Secrets, Fallback, DisableStreams and TaskQueue must be the ones the session clients use.

type Live

type Live struct {
	// URL is how clients reach the handler Worker.LiveHandler returns,
	// which the host serves (with its own TLS).
	URL string
	// Key is the HMAC key clients and workers share (temporal.Config.Live).
	// It is required with URL.
	Key []byte
}

Live is a worker's live endpoint: where clients stream the deltas of the sessions whose model calls run on it. Deltas are never stored, so a client dials the worker that makes them.

type Worker

type Worker struct {
	sdkworker.Worker
	// contains filtered or unexported fields
}

Worker polls the shared task queue and this worker's own queue, where the steps of the sessions whose harnesses it holds arrive. Stopping it closes those harnesses.

func New

func New(c client.Client, cfg Config) *Worker

New returns a Temporal worker that registers the session workflow and the turn activities against cfg. It panics without c, Store or Secrets, or with a Live URL and no key.

func (*Worker) LiveHandler

func (w *Worker) LiveHandler() http.Handler

LiveHandler serves the deltas of the sessions whose harnesses this worker holds: GET protocol.LivePath plus the session id streams one JSON event per line until the client goes away. The request must carry the session's bearer token (temporal.Config.Live has the key). The host serves the handler at Config.Live.URL; without Config.Live it refuses every request.

func (*Worker) Run

func (w *Worker) Run(interruptCh <-chan any) error

func (*Worker) Start

func (w *Worker) Start() error

func (*Worker) Stop

func (w *Worker) Stop()

Jump to

Keyboard shortcuts

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