core

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ActionContinueSession = "continue_session"

ActionContinueSession is the only action kind in the core plan; the field exists because the spec defines action.kind as extensible.

Variables

This section is empty.

Functions

func NewID

func NewID(prefix string) string

NewID returns prefix + "-" + 12 random hex chars, e.g. "evt-a1b2c3d4e5f6".

func ValidatePromptTemplate

func ValidatePromptTemplate(s string) error

ValidatePromptTemplate checks template syntax WITHOUT executing it. Execution-time errors (missing payload keys) are legitimate at validation time — they surface later as failed continuations.

Types

type Continuation

type Continuation struct {
	ID        string `json:"id"`
	RuleID    string `json:"ruleId"`
	EventID   string `json:"eventId"`
	SessionID string `json:"sessionId"`
	Prompt    string `json:"prompt"`
	// Label is denormalized from the originating rule so that
	// continuation.* result events can carry it as their source even if
	// the rule has since been removed (spec §4.5).
	Label         string            `json:"label,omitempty"`
	State         ContinuationState `json:"state"`
	Command       string            `json:"command,omitempty"`
	ExitCode      *int              `json:"exitCode,omitempty"`
	OutputSummary string            `json:"outputSummary,omitempty"`
	CreatedAt     time.Time         `json:"createdAt"`
	UpdatedAt     time.Time         `json:"updatedAt"`
}

Continuation is a resumed execution with injected context — never a push. Command/ExitCode/OutputSummary are filled by the dispatcher (next plan).

type ContinuationState

type ContinuationState string
const (
	ContinuationPending   ContinuationState = "pending"
	ContinuationRunning   ContinuationState = "running"
	ContinuationCompleted ContinuationState = "completed"
	ContinuationFailed    ContinuationState = "failed"
)

type Event

type Event struct {
	ID        string            `json:"id"`
	Type      string            `json:"type"`
	Source    string            `json:"source"`
	Payload   map[string]string `json:"payload,omitempty"`
	Timestamp time.Time         `json:"timestamp"`
}

Event is an immutable fact about the environment. Payload values are short machine-generated fields only (see security posture in docs/PROJECT.md §9) — never free-form external text.

type EventSelector

type EventSelector struct {
	Type   string `json:"type"`
	Source string `json:"source,omitempty"` // empty matches any source
}

EventSelector matches events by type and (optionally) source.

func (EventSelector) Matches

func (s EventSelector) Matches(ev Event) bool

type Rule

type Rule struct {
	ID             string        `json:"id"`
	Selector       EventSelector `json:"eventSelector"`
	ActionKind     string        `json:"actionKind"`
	SessionID      string        `json:"sessionId"`
	PromptTemplate string        `json:"promptTemplate"`
	Label          string        `json:"label,omitempty"`
	OneShot        bool          `json:"oneShot"`
	Consumed       bool          `json:"consumed"`
	ExpiresAt      *time.Time    `json:"expiresAt,omitempty"`
	CreatedAt      time.Time     `json:"createdAt"`
}

Rule binds an event selector to a continuation action.

func (Rule) Active

func (r Rule) Active(now time.Time) bool

func (Rule) RenderPrompt

func (r Rule) RenderPrompt(ev Event) (string, error)

RenderPrompt renders the rule's prompt template with the event as {{.Event}}. Only machine-generated event fields enter the context.

type Session

type Session struct {
	SessionID string       `json:"sessionId"`
	Agent     string       `json:"agent"` // claude | cursor | codex | opencode
	RepoPath  string       `json:"repoPath"`
	State     SessionState `json:"state"`
	CreatedAt time.Time    `json:"createdAt"`
	UpdatedAt time.Time    `json:"updatedAt"`
}

Session is an agent execution context known to the registry.

type SessionState

type SessionState string
const (
	SessionWaiting  SessionState = "waiting"
	SessionQueued   SessionState = "queued"
	SessionResuming SessionState = "resuming"
	SessionRunning  SessionState = "running"
	SessionDone     SessionState = "done"
)

Jump to

Keyboard shortcuts

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