ledger

package
v1.4.33 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLedgerUnavailable = errors.New("agent ledger unavailable")

Functions

func WithRun

func WithRun(ctx context.Context, writer Writer, runID string) context.Context

Types

type BlobWriter

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

func NewBlobWriter

func NewBlobWriter(provider storage.Provider, org string) *BlobWriter

func (*BlobWriter) Append

func (writer *BlobWriter) Append(ctx context.Context, entry Entry) (Entry, error)

func (*BlobWriter) Begin

func (writer *BlobWriter) Begin(ctx context.Context, trigger Trigger) error

func (*BlobWriter) Close

func (writer *BlobWriter) Close(ctx context.Context, runID string, outcome RunOutcome) error

type Entry

type Entry struct {
	RunID   string          `json:"run_id"`
	Seq     int64           `json:"seq"`
	Kind    EntryKind       `json:"kind"`
	At      time.Time       `json:"at"`
	State   string          `json:"state"`
	Ref     string          `json:"ref,omitempty"`
	Payload json.RawMessage `json:"payload,omitempty"`
	Prev    string          `json:"prev,omitempty"`
}

type EntryKind

type EntryKind string
const (
	EntryTrigger        EntryKind = "trigger"
	EntryTurn           EntryKind = "turn"
	EntryToolCall       EntryKind = "tool_call"
	EntryEvidence       EntryKind = "evidence"
	EntryDecision       EntryKind = "decision"
	EntryApproval       EntryKind = "approval"
	EntryActionProposed EntryKind = "action_proposed"
	EntryActionExecuted EntryKind = "action_executed"
	EntryActionVerified EntryKind = "action_verified"
	EntryGuideIssued    EntryKind = "guide_issued"
	EntryRunClosed      EntryKind = "run_closed"
	EntryOutcome        EntryKind = "outcome"
)

type LedgeredTool

type LedgeredTool struct {
	Tool core.Tool
}

func (LedgeredTool) ArgsSchema

func (tool LedgeredTool) ArgsSchema() map[string]any

func (LedgeredTool) Description

func (tool LedgeredTool) Description() string

func (LedgeredTool) Invoke

func (tool LedgeredTool) Invoke(ctx context.Context, args json.RawMessage) (*core.ToolResult, error)

func (LedgeredTool) Name

func (tool LedgeredTool) Name() string

type Run

type Run struct {
	Writer Writer
	RunID  string
}

func RunFromContext

func RunFromContext(ctx context.Context) (Run, bool)

type RunOutcome

type RunOutcome struct {
	State string `json:"state"`
	Code  string `json:"code,omitempty"`
}

type Subject

type Subject struct {
	Kind string `json:"kind,omitempty"`
	ID   string `json:"id,omitempty"`
}

type Trigger

type Trigger struct {
	TriggerID      string      `json:"trigger_id"`
	RunID          string      `json:"run_id"`
	ParentRunID    string      `json:"parent_run_id,omitempty"`
	Kind           TriggerKind `json:"kind"`
	Principal      string      `json:"principal"`
	Org            string      `json:"org"`
	Surface        string      `json:"surface"`
	ClientVersion  string      `json:"client_version,omitempty"`
	Subject        Subject     `json:"subject,omitempty"`
	PolicyVersion  string      `json:"policy_version"`
	ModelVersion   string      `json:"model_version,omitempty"`
	DeciderVersion string      `json:"decider_version,omitempty"`
	SkillVersions  []string    `json:"skill_versions,omitempty"`
	At             time.Time   `json:"at"`
}

type TriggerKind

type TriggerKind string
const (
	TriggerUser     TriggerKind = "user"
	TriggerIncident TriggerKind = "incident"
	TriggerSchedule TriggerKind = "schedule"
	TriggerCI       TriggerKind = "ci"
	TriggerMCP      TriggerKind = "mcp"
	TriggerSubagent TriggerKind = "subagent"
)

type Writer

type Writer interface {
	Begin(context.Context, Trigger) error
	Append(context.Context, Entry) (Entry, error)
	Close(context.Context, string, RunOutcome) error
}

Jump to

Keyboard shortcuts

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