runtime

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package runtime defines the capability execution pipeline.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode added in v0.4.0

func ExitCode(status string) int

ExitCode is the CLI contract for a capability envelope: 0 for a completed surface (ok/accepted/partial), 1 for blocked/failed, 2 is reserved for usage.

func LiveEvents added in v0.4.0

func LiveEvents(ctx context.Context) io.Writer

LiveEvents returns the writer attached by WithLiveEvents, if any.

func MarshalEnvelope added in v0.4.0

func MarshalEnvelope(result Result) ([]byte, error)

MarshalEnvelope encodes a capability result with the same keys the MCP wrappers emit. Empty slices stay arrays; trace_id is left as Execute set it.

func WithLiveEvents added in v0.4.0

func WithLiveEvents(ctx context.Context, w io.Writer) context.Context

WithLiveEvents tees the telemetry v2 envelope as NDJSON to w during Execute. jacu serve must not set this on stdout: stdout is JSON-RPC.

Types

type Capability

type Capability struct {
	ProjectID string
	Spec      ToolSpec
	Handler   Handler
}

type Handler

type Handler func(ctx context.Context, input json.RawMessage) (Result, error)

func RequireWorkTree

func RequireWorkTree(root string, next Handler) Handler

RequireWorkTree wraps a handler so it refuses to run outside a git work tree.

type Result

type Result struct {
	Status      string   `json:"status"`
	Summary     string   `json:"summary"`
	Data        any      `json:"data,omitempty"`
	Artifacts   []string `json:"artifacts"`
	Warnings    []string `json:"warnings"`
	NextActions []string `json:"next_actions"`
	TraceID     string   `json:"trace_id"`
}

func Execute

func Execute(ctx context.Context, c Capability, input json.RawMessage) (result Result)

func ExecuteInput added in v0.4.0

func ExecuteInput(ctx context.Context, c Capability, input any) Result

ExecuteInput marshals a typed input and runs Execute.

func WorkTreeBlock

func WorkTreeBlock(ctx context.Context, root string) (Result, bool)

WorkTreeBlock returns a blocked envelope when root is not inside a git work tree. Repo-scoped tools use this instead of inspecting the wrong directory.

type RiskLevel

type RiskLevel string
const (
	RiskSafe        RiskLevel = "safe"
	RiskWrite       RiskLevel = "write"
	RiskDestructive RiskLevel = "destructive"
)

type ToolSpec

type ToolSpec struct {
	Name           string
	Version        string
	Risk           RiskLevel
	ReadOnly       bool
	Idempotent     bool
	OpenWorld      bool
	Timeout        time.Duration
	MaxInputBytes  int64
	MaxOutputBytes int64
}

func (ToolSpec) Validate

func (s ToolSpec) Validate() error

Jump to

Keyboard shortcuts

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