exec

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package exec implements the runtime's private plan compiler and scheduler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyBindings

func ApplyBindings(input map[string]any, evidence map[string]any, bindings []Binding) (map[string]any, error)

func Lookup

func Lookup(value any, path string) (any, bool)

Lookup resolves an RFC 6901 JSON Pointer. For model-facing convenience it also accepts a dotted field path and converts it to a pointer before handing resolution to jsonpointer.

Types

type AgenticExecutor

type AgenticExecutor func(context.Context, Step, json.RawMessage) (AgenticResult, error)

type AgenticResult

type AgenticResult struct {
	Content          any
	Action           *tool.ActionReceipt
	ToolCalls        int
	ModelCalls       int
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
	PendingArguments json.RawMessage
}

type Approval

type Approval struct {
	ToolID    string
	Arguments json.RawMessage
}

type Barrier

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

type Batch

type Batch struct {
	Index int
	Steps []Step
}

type Binding

type Binding = plan.InputBinding

type DeadlinePolicy

type DeadlinePolicy struct {
	TargetLatency  time.Duration
	HardTimeout    time.Duration
	OptionalCutoff time.Duration
}

type Deterministic

type Deterministic struct{}

func (Deterministic) Resolve

type ExecutionPlan

type ExecutionPlan struct {
	Steps        []Step
	Batches      []Batch
	CriticalPath []string
}

func Compile

func Compile(p plan.Plan) (ExecutionPlan, error)

Compile creates dependency-safe parallel batches. Steps in one batch have no dependency on another step in the same batch, so a scheduler can run them concurrently.

type InputResolver

type InputResolver func(Step) json.RawMessage

type Request

type Request struct {
	Input    string
	Step     any
	Tool     model.ToolSpec
	Evidence map[string]any
}

type Resolver

type Resolver interface {
	Resolve(context.Context, Request) (json.RawMessage, error)
}

type Scheduler

type Scheduler struct {
	Registry    *tool.Registry
	MaxParallel int
	Policy      policy.Runner
	Guard       func(context.Context, tool.Tool) error
	// Confirm is called before a tool that declares a confirmation policy is
	// executed. Returning false produces a confirmation-required receipt and
	// leaves the external system untouched.
	Confirm  func(context.Context, tool.Spec, json.RawMessage) (bool, error)
	Deadline DeadlinePolicy
	Barrier  *Barrier
	Observe  func(policy.Event)
	// Completed replays successful checkpointed steps without executing them.
	Completed map[string]StepResult
	// Approvals bind resume authorization to an exact step, tool and arguments.
	Approvals map[string]Approval
	Agentic   AgenticExecutor
}

func (Scheduler) Run

func (s Scheduler) Run(ctx context.Context, execution ExecutionPlan, resolve InputResolver) ([]StepResult, error)

type Step

type Step struct {
	ID              string
	Kind            plan.StepKind
	Importance      plan.StepImportance
	Title           string
	Description     string
	Capability      string
	DependsOn       []string
	Optional        bool
	Input           map[string]any
	Bindings        []plan.InputBinding
	Condition       *plan.Condition
	Mode            plan.StepMode
	Goal            string
	SuccessCriteria string
	Capabilities    []string
	ToolBudget      plan.ToolCallBudget
	ApprovedToolID  string
	ApprovedInput   []byte
}

type StepResult

type StepResult struct {
	StepID              string
	RequestedCapability string
	Capability          string
	ToolID              string
	Content             any
	Receipt             bool
	Action              *tool.ActionReceipt
	Err                 error
	Duration            time.Duration
	Attempts            int
	Fallbacks           int
	Skipped             bool
	ConditionUnknown    bool
	Input               json.RawMessage
	ModelCalls          int
	PromptTokens        int
	CompletionTokens    int
	TotalTokens         int
}

Jump to

Keyboard shortcuts

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