client

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package client is a thin Go surface over Trajectory IR primitives.

Python mapping (client/python/trajectory_client.py):

OpenTrajectory  ~ open_trajectory
Resume          ~ resume
Project         ~ project
SealDecision    ~ seal_decision
ExecTool        ~ exec_tool
CommitStep      ~ commit_step
RunStep         ~ full sealed step (resume.RunStep convenience)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	StepN int
	Plan  map[string]any
}

Decision is returned by SealDecision.

type Options

type Options struct {
	// WorkDir holds default relative paths for sqlite files when set.
	WorkDir string
	// NodesPath is the NodeLog sqlite path. Default: WorkDir/nodes.sqlite or nodes.sqlite.
	NodesPath string
	// MemoPath is the LocalSQLite durable memo path. Default: WorkDir/memo.sqlite or memo.sqlite.
	MemoPath string
	// WorkflowID scopes durable memo keys. Default: TrajectoryID.
	WorkflowID string
	// Backend overrides LocalSQLite when non nil. Caller owns Close unless Open created it.
	Backend durable.Backend
	// Mode is live (default) or sandbox (R06).
	Mode sandbox.Mode
}

Options configure workdir paths and optional durable backend injection.

type ProjectContext

type ProjectContext struct {
	StepN   int
	Context map[string]any
}

ProjectContext is returned by Project.

type RunStepOpts

type RunStepOpts struct {
	OnDecisionSealed func()
}

RunStepOpts are optional hooks for RunStep (demo and tests).

type ToolResult

type ToolResult struct {
	StepN  int
	Result any
}

ToolResult is returned by ExecTool.

type Trajectory

type Trajectory struct {
	TrajectoryID string
	TenantID     string
	WorkflowID   string
	Mode         sandbox.Mode
	// contains filtered or unexported fields
}

Trajectory is an open IR run handle.

func OpenTrajectory

func OpenTrajectory(tenantID, trajectoryID string, opts Options) (*Trajectory, error)

OpenTrajectory opens or creates log and durable memo stores for a trajectory.

func Resume

func Resume(tenantID, trajectoryID string, opts Options) (*Trajectory, error)

Resume reattaches to a trajectory that already has NodeLog history. Unlike OpenTrajectory, empty history is an error (wrong workdir or id). Crash safety still comes from NodeLog idempotency and gated tool claims; callers re-drive the same step_n/seq work against the reopened log.

func (*Trajectory) Backend

func (t *Trajectory) Backend() durable.Backend

Backend exposes the durable backend for advanced tests.

func (*Trajectory) Close

func (t *Trajectory) Close() error

Close releases owned resources.

func (*Trajectory) CommitStep

func (t *Trajectory) CommitStep(stepN, seq int) error

CommitStep appends COMMIT_STEP at seq (typically 2+2*numTools).

func (*Trajectory) ExecTool

func (t *Trajectory) ExecTool(stepN, seq int, tool resume.Tool, args map[string]any) (*ToolResult, error)

ExecTool runs one tool at the given seq (caller supplies unique seq; 2+2*i is typical). NON_IDEMPOTENT_WRITE tools use claim gate logging. Other effect classes still append TOOL_CALL / TOOL_RESULT so the IR history matches the Python client.

func (*Trajectory) Log

func (t *Trajectory) Log() *nodelog.NodeLog

Log exposes the underlying NodeLog for advanced tests.

func (*Trajectory) Project

func (t *Trajectory) Project(stepN int, context map[string]any) (*ProjectContext, error)

Project appends PROJECT_CONTEXT at seq 0 for the step.

func (*Trajectory) RunStep

func (t *Trajectory) RunStep(
	ctx context.Context,
	stepN int,
	model resume.ModelFunc,
	tools map[string]resume.Tool,
	stepContext map[string]any,
	opts ...RunStepOpts,
) ([]any, error)

RunStep runs a full sealed step via resume.RunStep (project, infer, decision, tools, commit).

func (*Trajectory) SealDecision

func (t *Trajectory) SealDecision(stepN int, plan map[string]any) (*Decision, error)

SealDecision appends DECISION at seq 1 for the step.

Jump to

Keyboard shortcuts

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