adapter

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package adapter is the Runtime wait-loop glue. Hosts use durable.Runtime, not these functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbandonTurn added in v0.3.3

func AbandonTurn(h *tacklr.TurnManager, workspace, skills *vfs.MountSession)

AbandonTurn closes a harness and its turn-scoped trees after a failed construct.

func AbsorbAll added in v0.3.3

func AbsorbAll(ctx context.Context, absorb func(context.Context, *tacklr.Message, chan tacklr.StreamEvent) error, msgs []*tacklr.Message, out chan tacklr.StreamEvent) (consumed int, err error)

AbsorbAll writes msgs into the window in order. consumed is how many absorb calls ran (including a failed one). Absorb failure is terminal for the batch: leftover messages are not put back.

func AppendMessages added in v0.3.3

func AppendMessages(box []*tacklr.Message, msgs ...*tacklr.Message) []*tacklr.Message

AppendMessages is the unlocked FIFO append. Temporal wait-loop only.

func ApplyAuth

func ApplyAuth(recipes []durable.MountRecipe, auth durable.AuthContext) []durable.MountRecipe

ApplyAuth updates cached recipes from a work-item AuthContext. Drop is applied first. Bindings with an alias upsert that recipe. Tokens are not stored on the returned recipes.

func BindingsForTurn

func BindingsForTurn(recipes []durable.MountRecipe, auth durable.AuthContext) []vfs.Binding

BindingsForTurn builds the secret-bearing mounts for one activity/turn. Each cached recipe is included when a token for its provider is on auth.

func ChildJobMessage added in v0.3.3

func ChildJobMessage(st durable.SessionStatus) *tacklr.Message

ChildJobMessage is JobSteer for a nested session job.

func ChildState

func ChildState(st durable.SessionState) string

ChildState is the tool-facing running/completed/failed for a session.

func CloseTurnTrees

func CloseTurnTrees(workspace, skills *vfs.MountSession)

CloseTurnTrees closes the agent workspace tree and the host-only skills tree.

func CloseTurnVFS

func CloseTurnVFS(ms *vfs.MountSession)

CloseTurnVFS unmounts a turn-scoped MountSession (FUSE telemetry, Close, host dir).

func ConstructTurn added in v0.3.3

func ConstructTurn(ctx context.Context, spec durable.AgentSpec, threadID string, bindings []vfs.Binding, proj vfs.Projection, extraMCP []mcp.MCPConfig) (*tacklr.TurnManager, *vfs.MountSession, *vfs.MountSession, error)

ConstructTurn opens VFS trees and builds a TurnManager. On NewTurnManager failure the trees are closed.

func EncodeUserState

func EncodeUserState(state map[string]any) (map[string]any, error)

EncodeUserState JSON-roundtrips host session state so checkpoint types are stable (numbers become float64) and non-serializable values fail now.

func HasSpecialist added in v0.3.3

func HasSpecialist(cat durable.Catalog, agentID, name string) bool

HasSpecialist reports whether agentID's catalog spec names a specialist.

func InboxSafe added in v0.3.3

func InboxSafe(runnable int, parked bool) bool

InboxSafe reports whether queued user and job messages may enter the window. Drain only when this is true. Pass leftover unstarted tools as runnable (they are unpaired function_calls). Parked HITL is never safe.

func JobSteer added in v0.3.3

func JobSteer(id, name, body string, failed bool) *tacklr.Message

JobSteer is the RoleUser inbox text when a non-blocking job reaches complete or failed. It is a new message, not a second RoleTool for the schedule call_id.

func MergeUserState

func MergeUserState(base, overlay map[string]any) map[string]any

MergeUserState copies overlay onto a clone of base. Overlay wins on conflict.

func NormalizeSpawn

func NormalizeSpawn(specialist, task string) (string, string, error)

NormalizeSpawn trims spawn_specialist arguments. Specialist is required; empty task allowed for idempotent retry of the same callID.

func OpenSkillsVFS

func OpenSkillsVFS(ctx context.Context, threadID string, spec durable.AgentSpec) (*vfs.MountSession, error)

OpenSkillsVFS builds the host-only skills MountSession from AgentSpec.OpenSkills. It does not attach a FUSE projection. The agent never receives this session.

func OpenTurnSessions

func OpenTurnSessions(ctx context.Context, threadID string, spec durable.AgentSpec, bindings []vfs.Binding, proj vfs.Projection) (workspace, skills *vfs.MountSession, err error)

OpenTurnSessions opens the agent workspace and the host-only skills tree. On OpenSkills failure the workspace session is closed.

func OpenTurnVFS

func OpenTurnVFS(ctx context.Context, threadID string, spec durable.AgentSpec, bindings []vfs.Binding, proj vfs.Projection) (*vfs.MountSession, error)

OpenTurnVFS builds the turn-scoped MountSession from AgentSpec.OpenVFS. Nil when OpenVFS is nil or the projection is unavailable.

func OverlaySpecialist

func OverlaySpecialist(parent durable.AgentSpec, specialist string) (durable.AgentSpec, error)

OverlaySpecialist copies the parent catalog spec and applies the named Specialist.

func RestoreTurn added in v0.3.3

func RestoreTurn(ctx context.Context, store durable.SnapshotStore, id durable.SessionID, h *tacklr.TurnManager, state map[string]any) (durable.Revision, error)

RestoreTurn reloads a snapshot (if any) and applies host session state.

func TakeMessages added in v0.3.3

func TakeMessages(box *[]*tacklr.Message) []*tacklr.Message

TakeMessages is the unlocked FIFO take. Temporal wait-loop only.

func UnknownChild

func UnknownChild(id string) error

UnknownChild is cancel/wait with an id that is not this session's job.

func UserFromPrompt added in v0.3.3

func UserFromPrompt(text string, msg *tacklr.Message) *tacklr.Message

UserFromPrompt is the Prompt text or UserMessage for the window.

Types

type Inbox added in v0.3.3

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

Inbox is the wait-loop FIFO for steers and auto-collected job results. All methods are safe for concurrent callers. In-process uses this so the session loop (Prompt), the turn goroutine (drain), and Cancel/Close cannot race the slice. Hold sessionProc.mu around terminal checks plus Push so a Cancel Drop cannot lose the ordering with Queue.

Temporal workflows must not use Inbox: replay is single-threaded and must not park on sync.Mutex. Use AppendMessages / TakeMessages on a local slice.

func (*Inbox) Drop added in v0.3.3

func (b *Inbox) Drop()

Drop discards unread messages (Cancel / Close).

func (*Inbox) Push added in v0.3.3

func (b *Inbox) Push(msgs ...*tacklr.Message)

Push appends non-nil messages in call order.

func (*Inbox) Take added in v0.3.3

func (b *Inbox) Take() []*tacklr.Message

Take removes and returns all queued messages.

Jump to

Keyboard shortcuts

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