daemon

package
v0.3.0-beta.27 Latest Latest
Warning

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

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

Documentation ¶

Overview ¶

Package daemon wires the Compozy runtime packages into a single long-lived process.

Index ¶

Constants ¶

View Source
const (
	DrainStateActive   = contract.DrainStateActive
	DrainStateDraining = contract.DrainStateDraining
)
View Source
const (
	// RestartOperationEnvKey carries the restart operation id from the helper to the replacement daemon.
	RestartOperationEnvKey = "COMPOZY_INTERNAL_RESTART_OPERATION_ID"
)

Variables ¶

View Source
var (
	// ErrAlreadyRunning reports that another daemon process currently owns the singleton lock.
	ErrAlreadyRunning = errors.New("daemon: already running")
)
View Source
var (
	// ErrRestartOperationNotFound reports a missing persisted restart operation.
	ErrRestartOperationNotFound = errors.New("daemon: restart operation not found")
)
View Source
var ErrRuntimeMutationInProgress = errors.New("daemon: runtime mutation in progress")

ErrRuntimeMutationInProgress reports that another process owns update.lock.

Functions ¶

func GracefulShutdownTimeout ¶

func GracefulShutdownTimeout(config *compozyconfig.Config) time.Duration

GracefulShutdownTimeout returns the daemon's complete shutdown budget for a config.

func RemoveInfo ¶

func RemoveInfo(path string) error

RemoveInfo removes daemon.json if it exists.

func RunRelaunchHelper ¶

func RunRelaunchHelper(ctx context.Context, cfg *RelaunchHelperConfig) error

RunRelaunchHelper runs the detached helper that waits for daemon shutdown resources to release and then launches the replacement daemon.

func WriteInfo ¶

func WriteInfo(path string, info Info) (returnErr error)

WriteInfo writes daemon.json atomically via temp file and rename.

Types ¶

type BridgeSecretResolver ¶

type BridgeSecretResolver interface {
	ResolveBridgeSecret(ctx context.Context, binding bridgepkg.BridgeSecretBinding) (string, error)
}

BridgeSecretResolver resolves daemon-owned bound secret material for one persisted bridge secret binding.

type ComposedAssembler ¶

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

ComposedAssembler assembles selected startup prompt sections around the base agent prompt.

func NewComposedAssembler ¶

func NewComposedAssembler(opts ...ComposedAssemblerOption) *ComposedAssembler

NewComposedAssembler constructs a ComposedAssembler from startup section descriptors.

func (*ComposedAssembler) Assemble ¶

Assemble renders the selected startup sections using a baseline startup context for callers that only know about the legacy assembler seam.

func (*ComposedAssembler) AssembleStartup ¶

AssembleStartup renders eligible prepend sections, the trimmed base prompt, and eligible append sections into one composed startup system prompt.

func (*ComposedAssembler) AssembleStartupWithManifest ¶

func (a *ComposedAssembler) AssembleStartupWithManifest(
	ctx context.Context,
	startup session.StartupPromptContext,
	agent compozyconfig.AgentDef,
	workspace *workspacepkg.ResolvedWorkspace,
) (string, acp.StartupManifest, error)

AssembleStartupWithManifest measures budgeted sections in their document order.

func (*ComposedAssembler) ResumeContextSection ¶

func (a *ComposedAssembler) ResumeContextSection(
	ctx context.Context,
	startup session.StartupPromptContext,
) (string, error)

ResumeContextSection gathers resume-only sections from the same selected startup providers used by normal prompt assembly.

type ComposedAssemblerOption ¶

type ComposedAssemblerOption func(*ComposedAssembler)

ComposedAssemblerOption customizes the prompt section chain for a ComposedAssembler.

func WithAppendPromptProviders ¶

func WithAppendPromptProviders(providers ...session.PromptProvider) ComposedAssemblerOption

WithAppendPromptProviders preserves the legacy append provider option by wrapping providers in explicit append descriptors.

func WithPrependPromptProviders ¶

func WithPrependPromptProviders(providers ...session.PromptProvider) ComposedAssemblerOption

WithPrependPromptProviders preserves the legacy prepend provider option by wrapping providers in explicit prepend descriptors.

func WithPromptSectionDescriptors ¶

func WithPromptSectionDescriptors(descriptors ...PromptSectionDescriptor) ComposedAssemblerOption

WithPromptSectionDescriptors appends explicit startup prompt section descriptors to the assembler.

func WithSectionSelector ¶

func WithSectionSelector(selector *SectionSelector) ComposedAssemblerOption

WithSectionSelector installs the daemon-owned startup section selector.

type ConfigLoader ¶

type ConfigLoader func() (compozyconfig.Config, error)

ConfigLoader resolves the daemon-level runtime configuration.

type CoordinatorRoleResolver ¶

type CoordinatorRoleResolver interface {
	ResolveCoordinatorRole(ctx context.Context, workspaceID string) (compozyconfig.ResolvedCoordinatorRole, error)
}

CoordinatorRoleResolver resolves coordinator routing and safety policy without starting behavior.

type Daemon ¶

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

Daemon is the sole Compozy composition root.

func New ¶

func New(opts ...Option) (*Daemon, error)

New constructs the daemon composition root.

func (*Daemon) Boundaries ¶

func (d *Daemon) Boundaries(context.Context) error

Boundaries performs a best-effort import boundary verification for local source checkouts.

func (*Daemon) Drain ¶

func (d *Daemon) Drain(ctx context.Context) error

Drain closes new-work admission without interrupting already admitted work.

func (*Daemon) DrainState ¶

func (d *Daemon) DrainState() DrainState

DrainState returns the current in-memory daemon admission state.

func (*Daemon) DrainStatus ¶

func (d *Daemon) DrainStatus(ctx context.Context) (contract.DrainStatusResponse, error)

DrainStatus returns the daemon-owned quiesce readout used before process stop.

func (*Daemon) GetRestartOperation ¶

func (d *Daemon) GetRestartOperation(_ context.Context, operationID string) (RestartOperation, error)

GetRestartOperation reads one persisted restart operation by id.

func (*Daemon) IsDraining ¶

func (d *Daemon) IsDraining() bool

IsDraining reports whether new-work admission is closed.

func (*Daemon) RequestRestart ¶

func (d *Daemon) RequestRestart(ctx context.Context) (RestartOperation, error)

RequestRestart creates the persisted restart operation, launches the detached relaunch helper, and signals the running daemon to enter its normal graceful shutdown path.

func (*Daemon) Run ¶

func (d *Daemon) Run(ctx context.Context) error

Run boots the daemon, blocks until signal or context cancellation, then performs graceful shutdown.

func (*Daemon) Shutdown ¶

func (d *Daemon) Shutdown(ctx context.Context) error

Shutdown gracefully tears down the daemon in the required order.

func (*Daemon) Undrain ¶

func (d *Daemon) Undrain(ctx context.Context) error

Undrain restores new-work admission.

type DetachedRunMetadata ¶

type DetachedRunMetadata struct {
	TaskID    string
	TaskRunID string
}

DetachedRunMetadata carries detached task-runtime correlation fields.

type DetachedRunMode ¶

type DetachedRunMode string

DetachedRunMode identifies detached task-runtime behavior for the resolved policy.

const (
	// DetachedRunModeNone means detached task-runtime behavior is not enabled.
	DetachedRunModeNone DetachedRunMode = "none"
	// DetachedRunModeTaskRuntime means detached work reuses the existing task runtime.
	DetachedRunModeTaskRuntime DetachedRunMode = "task_runtime"
)

type DrainState ¶

type DrainState = contract.DrainState

DrainState is the public daemon admission state.

type DreamTrigger ¶

type DreamTrigger = core.DreamTrigger

DreamTrigger exposes consolidation controls and health state to transport layers.

type GatewayTierServerFactory ¶

type GatewayTierServerFactory func(
	ctx context.Context,
	deps *RuntimeDeps,
	tier gateway.Tier,
	surfaces []gateway.Surface,
) (Server, error)

GatewayTierServerFactory constructs one daemon-owned loopback listener for a tier and its active surfaces.

type HarnessAugmenter ¶

type HarnessAugmenter string

HarnessAugmenter identifies a prompt input augmenter managed by harness policy.

const (
	// HarnessAugmenterWorkspaceKnowledge injects current workspace-owned knowledge.
	HarnessAugmenterWorkspaceKnowledge HarnessAugmenter = "workspace_knowledge"
	// HarnessAugmenterSituation injects fresh bounded Compozy situation context.
	HarnessAugmenterSituation HarnessAugmenter = "situation"
	// HarnessAugmenterSkills injects the current effective skills catalog.
	HarnessAugmenterSkills HarnessAugmenter = "skills"
	// HarnessAugmenterDurableMemory enables the durable memory recall augmenter.
	HarnessAugmenterDurableMemory HarnessAugmenter = "durable_memory"
)

type HarnessContextResolver ¶

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

HarnessContextResolver derives harness policy from durable session state plus turn-origin metadata.

func NewHarnessContextResolver ¶

func NewHarnessContextResolver(
	runtime HarnessRuntimeSignals,
	opts ...HarnessContextResolverOption,
) *HarnessContextResolver

NewHarnessContextResolver constructs a daemon-owned harness context resolver.

func (*HarnessContextResolver) Resolve ¶

Resolve derives one authoritative harness context from explicit inputs.

func (*HarnessContextResolver) ResolvePrompt ¶

func (r *HarnessContextResolver) ResolvePrompt(
	info *session.Info,
	source session.TurnSource,
	meta acp.PromptMeta,
) (ResolvedHarnessContext, error)

ResolvePrompt resolves one live prompt-turn policy from session metadata.

func (*HarnessContextResolver) ResolveStartup ¶

ResolveStartup resolves startup policy from durable session context.

type HarnessContextResolverOption ¶

type HarnessContextResolverOption func(*HarnessContextResolver)

HarnessContextResolverOption configures provider-native skill-root resolution.

func WithHarnessSkillInjectionEnvLookup ¶

func WithHarnessSkillInjectionEnvLookup(
	lookup func(string) (string, bool),
) HarnessContextResolverOption

WithHarnessSkillInjectionEnvLookup configures the effective provider environment lookup.

func WithHarnessSkillInjectionHome ¶

func WithHarnessSkillInjectionHome(homePaths compozyconfig.HomePaths) HarnessContextResolverOption

WithHarnessSkillInjectionHome configures the operator and managed provider homes.

func WithHarnessSkillInjectionLogger ¶

func WithHarnessSkillInjectionLogger(logger *slog.Logger) HarnessContextResolverOption

WithHarnessSkillInjectionLogger configures suppression decision logging.

type HarnessPromptSection ¶

type HarnessPromptSection string

HarnessPromptSection identifies a startup prompt section managed by harness policy.

const (
	// HarnessPromptSectionRuntimeIdentity injects the daemon-owned Compozy runtime envelope.
	HarnessPromptSectionRuntimeIdentity HarnessPromptSection = "runtime_identity"
	// HarnessPromptSectionSituation injects the bounded Compozy situation context.
	HarnessPromptSectionSituation HarnessPromptSection = "situation"
	// HarnessPromptSectionMemory injects durable memory prompt context.
	HarnessPromptSectionMemory HarnessPromptSection = "memory"
	// HarnessPromptSectionSkills injects the active skills catalog prompt context.
	HarnessPromptSectionSkills HarnessPromptSection = "skills"
	// HarnessPromptSectionTools injects Compozy-native tool discovery and invocation guidance.
	HarnessPromptSectionTools HarnessPromptSection = "tools"
	// HarnessPromptSectionNetwork injects the bundled Compozy network startup section.
	HarnessPromptSectionNetwork HarnessPromptSection = "network"
)

type HarnessResolutionInput ¶

type HarnessResolutionInput struct {
	Surface ResolutionSurface
	Session HarnessSessionInput
	Turn    HarnessTurnRequest
}

HarnessResolutionInput captures one resolver request.

type HarnessRuntimeSignals ¶

type HarnessRuntimeSignals struct {
	RuntimeIdentityPromptSectionEnabled bool
	SituationPromptSectionEnabled       bool
	MemoryPromptSectionEnabled          bool
	SkillsPromptSectionEnabled          bool
	ToolsPromptSectionEnabled           bool
	WorkspaceKnowledgeAugmenter         bool
	SkillsAugmenter                     bool
	SituationAugmenter                  bool
	DurableMemoryAugmenter              bool
	SyntheticTurnsEnabled               bool
	DetachedTaskRuntimeEnabled          bool
}

HarnessRuntimeSignals captures daemon-owned capability flags available to the resolver.

type HarnessSessionContext ¶

type HarnessSessionContext struct {
	SessionID            string
	Type                 session.Type
	SpawnRole            string
	SessionClass         SessionClass
	NetworkParticipation participation.Spec
	NetworkLive          bool
	WorkspaceID          string
	Workspace            string
	AgentName            string
	Provider             string
	ProviderHomePolicy   compozyconfig.ProviderHomePolicy
}

HarnessSessionContext is the normalized durable session context emitted by the resolver.

type HarnessSessionInput ¶

type HarnessSessionInput struct {
	SessionID            string
	Type                 session.Type
	SpawnRole            string
	NetworkParticipation participation.Spec
	WorkspaceID          string
	Workspace            string
	AgentName            string
	Provider             string
	ProviderHomePolicy   compozyconfig.ProviderHomePolicy
}

HarnessSessionInput carries durable session metadata into the resolver.

type HarnessTurnContext ¶

type HarnessTurnContext struct {
	Origin     TurnOrigin
	PromptMeta acp.PromptMeta
	Synthetic  *SyntheticTurnMetadata
	Detached   *DetachedRunMetadata
}

HarnessTurnContext is the normalized turn context emitted by the resolver.

type HarnessTurnRequest ¶

type HarnessTurnRequest struct {
	Source     session.TurnSource
	PromptMeta acp.PromptMeta
	Synthetic  *SyntheticTurnMetadata
	Detached   *DetachedRunMetadata
}

HarnessTurnRequest carries turn-time metadata into the resolver.

type Info ¶

type Info struct {
	PID       int          `json:"pid"`
	Port      int          `json:"port"`
	StartedAt time.Time    `json:"started_at"`
	Network   *NetworkInfo `json:"network,omitempty"`
}

Info is the persisted daemon discovery record written to daemon.json.

func ReadInfo ¶

func ReadInfo(path string) (_ Info, returnErr error)

ReadInfo loads daemon.json from disk.

func (Info) Validate ¶

func (i Info) Validate() error

Validate ensures the persisted daemon info remains usable for discovery.

type Lock ¶

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

Lock owns the singleton daemon file lock.

func AcquireLock ¶

func AcquireLock(path string, pid int) (*Lock, error)

AcquireLock acquires the singleton daemon lock and records the current PID in the lock file.

func (*Lock) Path ¶

func (l *Lock) Path() string

Path reports the on-disk daemon lock file path.

func (*Lock) Release ¶

func (l *Lock) Release() error

Release clears the lock file contents and releases the advisory file lock.

func (*Lock) StalePID ¶

func (l *Lock) StalePID() int

StalePID reports the recovered stale daemon PID, if any.

type NetworkInfo ¶

type NetworkInfo struct {
	Enabled bool   `json:"enabled"`
	Status  string `json:"status"`
}

NetworkInfo is the persisted daemon-safe network diagnostics snapshot.

func (NetworkInfo) Validate ¶

func (n NetworkInfo) Validate() error

Validate ensures the persisted network diagnostics remain usable.

type Observer ¶

type Observer interface {
	core.Observer
	session.Notifier
	Reconcile(ctx context.Context) (store.ReconcileResult, error)
}

Observer is the daemon observer surface used for transport wiring and reconciliation.

type Option ¶

type Option func(*Daemon)

Option customizes daemon construction.

func WithBoundaryVerification ¶

func WithBoundaryVerification(enabled bool) Option

WithBoundaryVerification enables best-effort import boundary verification on boot.

func WithBridgeSecretResolver ¶

func WithBridgeSecretResolver(resolver BridgeSecretResolver) Option

WithBridgeSecretResolver injects the daemon-owned resolver used to convert bridge secret bindings into launch-time bound secret material. When this option is not supplied, daemon boot wires the canonical vault-backed resolver.

func WithCompozyExecutableResolver ¶

func WithCompozyExecutableResolver(resolver func() (string, error)) Option

WithCompozyExecutableResolver supplies the executable used by bundled extension commands.

func WithConfig ¶

func WithConfig(cfg *compozyconfig.Config) Option

WithConfig overrides daemon-level configuration loading.

func WithConfigLoader ¶

func WithConfigLoader(loader ConfigLoader) Option

WithConfigLoader overrides daemon-level configuration loading.

func WithGatewayProviderEffects ¶

func WithGatewayProviderEffects(effects gateway.EffectDriver) Option

WithGatewayProviderEffects injects the provider preflight, establish, verify, advertise, withdraw, teardown, and health-supervision lifecycle used by gateway reconciliation.

func WithGatewayTierServerFactory ¶

func WithGatewayTierServerFactory(factory GatewayTierServerFactory) Option

WithGatewayTierServerFactory overrides daemon-owned tier listener construction.

func WithHTTPServerFactory ¶

func WithHTTPServerFactory(factory ServerFactory) Option

WithHTTPServerFactory overrides HTTP server construction.

func WithHomePaths ¶

func WithHomePaths(homePaths compozyconfig.HomePaths) Option

WithHomePaths overrides the resolved Compozy home layout.

func WithLogger ¶

func WithLogger(logger *slog.Logger) Option

WithLogger injects the daemon logger.

func WithNow ¶

func WithNow(now func() time.Time) Option

WithNow overrides the daemon clock, mainly for tests.

func WithSignalBridge ¶

func WithSignalBridge(ch <-chan os.Signal) Option

WithSignalBridge overrides OS signal delivery, mainly for tests.

func WithUDSServerFactory ¶

func WithUDSServerFactory(factory ServerFactory) Option

WithUDSServerFactory overrides UDS server construction.

type PromptSectionBudgetBehavior ¶

type PromptSectionBudgetBehavior string

PromptSectionBudgetBehavior controls how an oversized section is handled.

const (
	// PromptSectionBudgetBehaviorTrim truncates the section to its declared budget.
	PromptSectionBudgetBehaviorTrim PromptSectionBudgetBehavior = "trim"
	// PromptSectionBudgetBehaviorOmit drops the section when it exceeds budget.
	PromptSectionBudgetBehaviorOmit PromptSectionBudgetBehavior = "omit"
)

type PromptSectionDescriptor ¶

type PromptSectionDescriptor struct {
	Name             string
	Position         PromptSectionPosition
	Order            int
	Budget           int
	BudgetBehavior   PromptSectionBudgetBehavior
	Provider         any
	Predicate        SectionPredicate
	StartupPredicate StartupSectionPredicate
}

PromptSectionDescriptor describes one startup prompt section provider plus its ordering, policy eligibility, and budget behavior.

type PromptSectionPosition ¶

type PromptSectionPosition string

PromptSectionPosition identifies whether a startup section renders before or after the base agent prompt.

const (
	// PromptSectionPositionPrepend renders the section before the base prompt.
	PromptSectionPositionPrepend PromptSectionPosition = "prepend"
	// PromptSectionPositionAppend renders the section after the base prompt.
	PromptSectionPositionAppend PromptSectionPosition = "append"
)

type ReentryMode ¶

type ReentryMode string

ReentryMode identifies how a resolved policy participates in synthetic reentry.

const (
	// ReentryModeNone means the turn is not synthetic reentry.
	ReentryModeNone ReentryMode = "none"
	// ReentryModeSynthetic means the turn is a validated synthetic reentry path.
	ReentryModeSynthetic ReentryMode = "synthetic"
)

type Registry ¶

type Registry interface {
	store.SkillExposureRepository
	gateway.Store
	store.OnboardingStore
	looppkg.ReconciliationStore
	VerifyDefaultProfile(context.Context) error
	// contains filtered or unexported methods
}

Registry is the composition-root database surface grouped by owning domain. Consumers depend on their local narrow interfaces instead of this aggregate.

type RelaunchHelperConfig ¶

type RelaunchHelperConfig struct {
	HomePaths      compozyconfig.HomePaths
	OperationID    string
	Executable     func() (string, error)
	Sandbox        []string
	PollInterval   time.Duration
	ReleaseTimeout time.Duration
	ReadyTimeout   time.Duration
	ExitDrainWait  time.Duration
}

RelaunchHelperConfig configures one internal `compozy daemon relaunch` execution.

type ResolutionSurface ¶

type ResolutionSurface string

ResolutionSurface identifies which runtime seam is consuming the resolver.

const (
	// ResolutionSurfaceStartup resolves startup prompt policy.
	ResolutionSurfaceStartup ResolutionSurface = "startup"
	// ResolutionSurfaceTurn resolves live prompt-turn policy.
	ResolutionSurfaceTurn ResolutionSurface = "turn"
)

type ResolvedHarnessContext ¶

type ResolvedHarnessContext struct {
	Surface ResolutionSurface
	Session HarnessSessionContext
	Turn    HarnessTurnContext
	Policy  ResolvedHarnessPolicy
}

ResolvedHarnessContext captures the normalized inputs plus the derived policy.

type ResolvedHarnessPolicy ¶

type ResolvedHarnessPolicy struct {
	SessionClass         SessionClass
	TurnOrigin           TurnOrigin
	IncludeSections      []HarnessPromptSection
	EnableAugmenters     []HarnessAugmenter
	ReentryMode          ReentryMode
	DetachedRunMode      DetachedRunMode
	DiagnosticLabel      string
	ObservabilityTags    map[string]string
	SkillInjectionFilter SkillInjectionFilter
}

ResolvedHarnessPolicy is the authoritative daemon-owned harness runtime policy.

type ResolvedRole ¶

type ResolvedRole struct {
	Role            compozyconfig.RoleName
	Enabled         bool
	AgentName       string
	Builtin         bool
	Inherit         bool
	AgentDef        compozyconfig.AgentDef
	Provider        string
	Model           string
	ReasoningEffort string

	Fallbacks  []compozyconfig.RoleFallback
	Provenance map[string]string
	// contains filtered or unexported fields
}

ResolvedRole is one invocation-time role routing decision.

type RestartOperation ¶

type RestartOperation struct {
	OperationID        string        `json:"operation_id"`
	Status             RestartStatus `json:"status"`
	OldPID             int           `json:"old_pid"`
	OldStartedAt       time.Time     `json:"old_started_at"`
	OldSocketPath      string        `json:"old_socket_path"`
	NewPID             int           `json:"new_pid,omitempty"`
	ActiveSessionCount int           `json:"active_session_count"`
	FailureReason      string        `json:"failure_reason,omitempty"`
	StartedAt          time.Time     `json:"started_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	CompletedAt        *time.Time    `json:"completed_at,omitempty"`
}

RestartOperation is the persisted restart status record stored under ~/.compozy/restarts/.

func ReadRestartOperation ¶

func ReadRestartOperation(homePaths compozyconfig.HomePaths, operationID string) (RestartOperation, error)

ReadRestartOperation reads restart progress without requiring a ready daemon.

func (RestartOperation) Validate ¶

func (o RestartOperation) Validate() error

Validate ensures the persisted restart operation is structurally usable.

type RestartStatus ¶

type RestartStatus string

RestartStatus is the durable lifecycle state of one daemon restart operation.

const (
	RestartStatusPending        RestartStatus = "pending"
	RestartStatusStopping       RestartStatus = "stopping"
	RestartStatusWaitingRelease RestartStatus = "waiting_release"
	RestartStatusStarting       RestartStatus = "starting"
	RestartStatusReady          RestartStatus = "ready"
	RestartStatusFailed         RestartStatus = "failed"
)

type RoleResolutionError ¶

type RoleResolutionError struct {
	Code  string
	Role  compozyconfig.RoleName
	Agent string
	Err   error
}

RoleResolutionError is a deterministic role-resolution failure.

func (*RoleResolutionError) DiagnosticCode ¶

func (e *RoleResolutionError) DiagnosticCode() string

DiagnosticCode returns the stable public code for transport projections.

func (*RoleResolutionError) Error ¶

func (e *RoleResolutionError) Error() string

func (*RoleResolutionError) Unwrap ¶

func (e *RoleResolutionError) Unwrap() error

type RoleResolver ¶

type RoleResolver interface {
	Resolve(ctx context.Context, workspaceID string, role compozyconfig.RoleName) (ResolvedRole, error)
}

type RuntimeDeps ¶

type RuntimeDeps struct {
	Config              compozyconfig.Config
	AgentProbeConfig    *agentProbeConfigState
	HomePaths           compozyconfig.HomePaths
	Logger              *slog.Logger
	Sessions            SessionManager
	DrainController     core.DaemonDrainController
	Tasks               taskpkg.Manager
	Network             core.NetworkService
	ToolRegistry        toolspkg.Registry
	Toolsets            core.ToolsetRegistry
	ToolArtifacts       toolspkg.ToolArtifactStore
	SessionAttachments  attachmentspkg.Store
	ToolApprovals       toolspkg.ApprovalTokenIssuer
	ApprovalCoordinator toolspkg.ApprovalCoordinator
	CmdPalette          cmdpalette.Registry
	ApprovalGrants      toolspkg.ApprovalGrantStore
	Clarify             toolspkg.ClarifyBroker
	HostedMCP           *mcppkg.HostedService
	MCPHostAPI          mcppkg.HostAPIInvoker
	Observer            Observer
	SchemaStreams       core.SchemaStreamStatusReader
	Automation          core.AutomationManager
	Loops               core.LoopService
	Bridges             core.BridgeService
	Notifications       core.NotificationPresetService
	Registry            Registry
	Profiles            *profile.Manager
	MemoryStore         *memory.Store
	MemoryExtractor     core.MemoryExtractorService
	MemoryProviders     core.MemoryProviderService
	MemorySessionLedger core.MemorySessionLedgerService
	RuntimeMemory       doctor.RuntimeMemorySnapshotSource
	DeadEntities        doctor.DeadEntitySource
	WorkspaceResolver   workspacepkg.RuntimeResolver
	WorkspaceService    core.WorkspaceService
	Worktrees           core.WorktreeService
	WorkspaceAccess     workspaceaccess.Policy
	AgentCatalog        core.AgentCatalog
	AgentResolver       session.AgentResolver
	AgentDefinitionSync core.AgentDefinitionSync
	ModelCatalog        core.ModelCatalogService
	MarketplaceCatalog  core.MarketplaceCatalogService
	AgentContext        *situation.Service
	SoulAuthoring       core.SoulAuthoringService
	SoulHistoryPurger   core.SoulHistoryPurger
	SoulRefresher       core.SoulRefresher
	HeartbeatAuthor     core.HeartbeatAuthoringService
	HeartbeatPurger     core.HeartbeatHistoryPurger
	HeartbeatStatus     core.HeartbeatStatusService
	HeartbeatWake       core.HeartbeatWakeService
	SessionHealth       core.SessionHealthReader
	WakeEvents          core.HeartbeatWakeEventReader
	CoordinatorRole     CoordinatorRoleResolver
	Roles               core.RolesStatusProvider
	SkillsRegistry      core.SkillsRegistry
	SkillResources      core.SkillResourceSyncer
	DreamTrigger        DreamTrigger
	Settings            core.SettingsService
	SettingsRestart     core.SettingsRestartController
	SettingsUpdate      core.SettingsUpdateController
	SupportBundles      core.SupportBundleService
	Vault               core.VaultService
	Extensions          udsapi.ExtensionService
	Resources           core.ResourceService
	WindowManagers      *windowManagerRegistry
	Terminals           *terminalpkg.Service
	Gateway             *gateway.Service
	GatewayChallenges   *gateway.ChallengeRegistry
	GatewayAuthLimiter  *gateway.AuthFailureLimiter
	StartedAt           time.Time

	OnProviderAuthSuccess func()
}

RuntimeDeps captures the composition-root dependencies available to server factories.

type SectionPredicate ¶

type SectionPredicate func(ResolvedHarnessPolicy) bool

SectionPredicate decides whether a prompt section is eligible for one resolved startup policy.

type SectionSelector ¶

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

SectionSelector resolves startup policy and selects eligible startup prompt sections before final assembly.

func NewSectionSelector ¶

func NewSectionSelector(
	resolver *HarnessContextResolver,
	recorder *harnessLifecycleRecorder,
) *SectionSelector

NewSectionSelector constructs a daemon-owned startup section selector.

func (*SectionSelector) Select ¶

Select resolves startup policy for the provided startup context and returns the eligible startup sections in deterministic order without duplicates.

type Server ¶

type Server interface {
	Start(ctx context.Context) error
	Shutdown(ctx context.Context) error
}

Server is a daemon-owned runtime component with explicit start and shutdown phases.

type ServerFactory ¶

type ServerFactory func(ctx context.Context, deps RuntimeDeps) (Server, error)

ServerFactory constructs runtime components such as HTTP and UDS servers.

type SessionClass ¶

type SessionClass string

SessionClass is the session-side harness axis derived from durable session metadata rather than a top-level profile enum.

const (
	// SessionClassInteractive identifies user-owned interactive sessions.
	SessionClassInteractive SessionClass = "interactive"
	// SessionClassDream identifies dream consolidation sessions.
	SessionClassDream SessionClass = "dream"
	// SessionClassSystem identifies daemon-owned system sessions.
	SessionClassSystem SessionClass = "system"
	// SessionClassCoordinator identifies daemon-owned workspace coordinator sessions.
	SessionClassCoordinator SessionClass = "coordinator"
	// SessionClassSpawned identifies bounded child worker sessions.
	SessionClassSpawned SessionClass = "spawned"
)

type SessionManager ¶

type SessionManager = core.SessionManager

SessionManager is the shared transport-facing session surface consumed by daemon/.

type SessionManagerDeps ¶

type SessionManagerDeps struct {
	HomePaths               compozyconfig.HomePaths
	Logger                  *slog.Logger
	Notifier                session.Notifier
	SpawnWakeNotifier       session.SpawnWakeNotifier
	Hooks                   session.HookSet
	PromptAssembler         session.PromptAssembler
	StartupPromptOverlay    session.StartupPromptOverlay
	PromptInputAugmenter    session.PromptInputAugmenter
	CommandService          session.CommandService
	WorkAdmission           admission.Checker
	MemoryStore             *memory.Store
	LedgerMaterializer      session.LedgerMaterializer
	AgentResolver           session.AgentResolver
	SkillRegistry           session.SkillRegistry
	MCPResolver             session.MCPResolver
	WorkspaceResolver       workspacepkg.RuntimeResolver
	WorktreeResolver        session.WorktreeResolver
	ParticipationResolver   participation.Resolver
	WindowReconciler        session.WindowReconciler
	SandboxRegistry         *sandbox.Registry
	SessionSupervision      compozyconfig.SessionSupervisionConfig
	SessionStop             compozyconfig.SessionStopConfig
	SessionBusyInput        compozyconfig.SessionBusyInputConfig
	SessionCompaction       compozyconfig.SessionCompactionConfig
	SessionInputQueue       store.SessionInputQueueStore
	SessionPromptAdmission  store.SessionPromptAdmissionStore
	SessionAttachments      session.AttachmentOpener
	SessionHealthConfig     compozyconfig.HeartbeatConfig
	AttentionConfig         compozyconfig.AttentionConfig
	AttentionWorkspaceMutes session.AttentionWorkspaceMuteReader
	SessionCatalog          store.SessionCatalog
	ProcessRegistry         *toolruntime.Registry
	Terminals               acp.TerminalHost
	HostedMCP               session.HostedMCPLauncher
	ProviderSecrets         session.ProviderSecretResolver
	ProfileNames            session.ProfileNameResolver
	ModelCatalog            modelcatalog.Service
	SoulStore               session.SoulSnapshotStore
	SoulRunChecker          session.SoulRunActivityChecker
	SessionHealthStore      session.HealthStore
}

SessionManagerDeps captures the composition-root dependencies needed to create a session manager.

type SessionPolicy ¶

type SessionPolicy struct {
	Sandbox SessionSandboxPolicy
	Runtime SessionRuntimePolicy
}

type SessionRuntimeMode ¶

type SessionRuntimeMode string
const (
	SessionRuntimeModeEvidence SessionRuntimeMode = "evidence"
)

type SessionRuntimePolicy ¶

type SessionRuntimePolicy struct {
	Mode        SessionRuntimeMode
	Permissions compozyconfig.PermissionMode
}

type SessionSandboxMode ¶

type SessionSandboxMode string
const (
	SessionSandboxModeNone SessionSandboxMode = "none"
	SessionSandboxModeRef  SessionSandboxMode = "ref"
)

type SessionSandboxPolicy ¶

type SessionSandboxPolicy struct {
	Mode       SessionSandboxMode
	SandboxRef string
}

type SkillInjectionFilter ¶

type SkillInjectionFilter func(*skillspkg.Skill) bool

SkillInjectionFilter decides whether one resolved skill remains in prompt catalogs.

type StartupSectionPredicate ¶

type StartupSectionPredicate func(session.StartupPromptContext) bool

StartupSectionPredicate decides whether a prompt section is eligible for the concrete startup context being assembled.

type SyntheticTurnMetadata ¶

type SyntheticTurnMetadata struct {
	Reason      string
	Trigger     string
	SourceTask  string
	SourceRunID string
}

SyntheticTurnMetadata carries validated daemon-only synthetic reentry metadata.

type TurnOrigin ¶

type TurnOrigin string

TurnOrigin identifies the resolved harness origin for one turn.

const (
	// TurnOriginUser identifies a standard user-driven turn.
	TurnOriginUser TurnOrigin = "user"
	// TurnOriginNetwork identifies a network-originated turn.
	TurnOriginNetwork TurnOrigin = "network"
	// TurnOriginSynthetic identifies a daemon-owned synthetic turn.
	TurnOriginSynthetic TurnOrigin = "synthetic"
)

type UpdateLock ¶

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

UpdateLock owns the cross-process runtime mutation lock.

func AcquireUpdateLock ¶

func AcquireUpdateLock(path string, owner UpdateLockOwner) (*UpdateLock, error)

AcquireUpdateLock locks update.lock and records the caller's process identity.

func (*UpdateLock) Release ¶

func (l *UpdateLock) Release() error

Release clears the owner payload, unlocks, and closes update.lock.

func (*UpdateLock) StaleOwner ¶

func (l *UpdateLock) StaleOwner() *UpdateLockOwner

StaleOwner reports the stale identity replaced during acquisition, if any.

type UpdateLockOwner ¶

type UpdateLockOwner struct {
	PID       int       `json:"pid"`
	StartedAt time.Time `json:"started_at"`
}

UpdateLockOwner is the durable process identity stored inside update.lock.

Source Files ¶

Jump to

Keyboard shortcuts

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