situation

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSectionLimit is the MVP bound for list sections inside agent context.
	DefaultSectionLimit = 8
	// ProvenanceSource identifies the local daemon context assembler.
	ProvenanceSource = "daemon.situation"
)

Variables

This section is empty.

Functions

func RenderPrompt

func RenderPrompt(payload *contract.AgentContextPayload) (string, error)

RenderPrompt renders a deterministic JSON context block in the required `/agent/context` section order, omitting unavailable sections.

Types

type AgentResolver

type AgentResolver interface {
	ResolveAgent(name string, resolved *workspacepkg.ResolvedWorkspace) (compozyconfig.AgentDef, error)
}

AgentResolver resolves one agent definition for a workspace.

type Deps

type Deps struct {
	Subagents func() SubagentProvider
	Now       func() time.Time

	SectionLimit int

	WorkspaceResolver     WorkspaceResolver
	WorkspaceResolverFunc func() WorkspaceResolver
	AgentResolver         AgentResolver
	AgentResolverFunc     func() AgentResolver
	SkillRegistry         SkillRegistry
	SkillRegistryFunc     func() SkillRegistry
	TaskStore             TaskStore
	TaskStoreFunc         func() TaskStore

	SoulSnapshots     SoulSnapshotStore
	SoulSnapshotsFunc func() SoulSnapshotStore

	SpawnAllowance     SpawnAllowanceResolver
	SpawnAllowanceFunc func() SpawnAllowanceResolver
}

Deps wires situation context to daemon-owned services. Function fields are evaluated at render time so daemon boot can install the provider before late runtime services are available.

type Service

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

Service assembles contract.AgentContextPayload and renders prompt sections.

func NewService

func NewService(deps Deps) *Service

NewService constructs a deterministic situation context assembler.

func (*Service) Augment

func (s *Service) Augment(
	ctx context.Context,
	sess *session.Session,
	message string,
) (string, error)

Augment prefixes a live prompt with fresh situation context.

func (*Service) BundleForActiveLease

func (s *Service) BundleForActiveLease(
	ctx context.Context,
	req taskpkg.ContextRequest,
) (taskpkg.ContextBundle, error)

func (*Service) BundleForOperatorTask

func (s *Service) BundleForOperatorTask(
	ctx context.Context,
	req taskpkg.OperatorTaskContextRequest,
) (taskpkg.ContextBundle, error)

func (*Service) ContextForSession

func (s *Service) ContextForSession(
	ctx context.Context,
	info *session.Info,
) (contract.AgentContextPayload, error)

ContextForSession assembles the bounded context for an active session.

func (*Service) ContextForStartup

func (s *Service) ContextForStartup(
	ctx context.Context,
	startup session.StartupPromptContext,
	agent compozyconfig.AgentDef,
	resolvedWorkspace *workspacepkg.ResolvedWorkspace,
) (contract.AgentContextPayload, error)

ContextForStartup assembles the bounded context available before the agent driver starts.

func (*Service) PromptStartupSection

func (s *Service) PromptStartupSection(
	ctx context.Context,
	startup session.StartupPromptContext,
	agent compozyconfig.AgentDef,
	workspace *workspacepkg.ResolvedWorkspace,
) (string, error)

PromptStartupSection renders the startup prompt section with full startup metadata.

func (*Service) TaskRunPromptOverlay

func (s *Service) TaskRunPromptOverlay(
	ctx context.Context,
	taskRecord taskpkg.Task,
	run taskpkg.Run,
	profile *taskpkg.ExecutionProfile,
) (string, error)

func (*Service) TaskRunPromptOverlayByID

func (s *Service) TaskRunPromptOverlayByID(ctx context.Context, taskID string, runID string) (string, error)

type SkillRegistry

type SkillRegistry interface {
	ForWorkspace(ctx context.Context, resolved *workspacepkg.ResolvedWorkspace) ([]*skillspkg.Skill, error)
	ForAgent(
		ctx context.Context,
		resolved *workspacepkg.ResolvedWorkspace,
		agentName string,
	) ([]*skillspkg.Skill, error)
}

SkillRegistry resolves the active skill set for a workspace.

type SoulSnapshotStore

type SoulSnapshotStore interface {
	GetSoulSnapshot(ctx context.Context, id string) (soul.Snapshot, error)
}

SoulSnapshotStore loads immutable Soul snapshots for compact context projection.

type SpawnAllowanceResolver

type SpawnAllowanceResolver interface {
	ChildSpawnAllowance(ctx context.Context, info *session.Info) (session.ChildSpawnAllowance, error)
}

SpawnAllowanceResolver resolves a session's child-spawn allowance with the spawn engine's ancestor walk.

type SubagentProvider

type SubagentProvider interface {
	GetSubagentByChild(context.Context, string) (store.SessionSubagent, error)
	Summaries(context.Context, []string) (map[string]store.SubagentSummary, error)
}

SubagentProvider supplies persisted subagent counts without owning their lifecycle.

type TaskStore

type TaskStore interface {
	GetTask(ctx context.Context, id string) (taskpkg.Task, error)
	GetTaskRun(ctx context.Context, id string) (taskpkg.Run, error)
	ListTaskRuns(ctx context.Context, query taskpkg.RunQuery) ([]taskpkg.Run, error)
	ListTaskEvents(ctx context.Context, query taskpkg.EventQuery) ([]taskpkg.Event, error)
	ListTaskEventRecords(ctx context.Context, query taskpkg.EventRecordQuery) ([]taskpkg.EventRecord, error)
	GetExecutionProfile(ctx context.Context, taskID string) (taskpkg.ExecutionProfile, error)
	GetRunReview(ctx context.Context, reviewID string) (taskpkg.RunReview, error)
	LookupRunReviewBySession(ctx context.Context, sessionID string) (taskpkg.RunReview, error)
	ListRunReviews(ctx context.Context, query taskpkg.RunReviewQuery) ([]taskpkg.RunReview, error)
}

TaskStore is the narrowed task read surface required by agent context.

type WorkspaceResolver

type WorkspaceResolver interface {
	Resolve(ctx context.Context, idOrPath string) (workspacepkg.ResolvedWorkspace, error)
}

WorkspaceResolver resolves persisted workspaces into runtime snapshots.

Jump to

Keyboard shortcuts

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