import type { PD_FILES } from './paths.js'; import type { PainConfig } from './config.js'; import type { EventLog } from './event-log.js'; import type { PainDictionary } from './dictionary.js'; import { HygieneTracker } from './hygiene/tracker.js'; import { EvolutionReducerImpl } from './evolution-reducer.js'; import type { TrajectoryDatabase } from './trajectory.js'; import { PrincipleLifecycleService } from './principle-internalization/principle-lifecycle-service.js'; import { type PrincipleSubtree, type LedgerPrinciple, type PrincipleValueMetrics } from './principle-tree-ledger.js'; import type { Principle as ActivePrinciple } from './evolution-types.js'; import { RuleHost } from './rule-host.js'; import type { RuleHostLogger } from './rule-host.js'; interface PrincipleTreeLedgerAccessor { getPrincipleSubtree(_principleId: string): PrincipleSubtree | undefined; updatePrinciple(_principleId: string, updates: Partial): LedgerPrinciple; updatePrincipleValueMetrics(principleId: string, _metrics: PrincipleValueMetrics): PrincipleValueMetrics; } /** * WorkspaceContext - Centralized management of workspace-specific paths and services. * Implements a cached singleton pattern per workspace directory. */ export declare class WorkspaceContext { private static readonly instances; private static readonly pathResolver; readonly workspaceDir: string; readonly stateDir: string; private _config?; private _eventLog?; private _dictionary?; private _hygiene?; private _evolutionReducer?; private _trajectory?; private _principleTreeLedger?; private _principleLifecycle?; private _ruleHost?; private constructor(); /** * Governance configuration for this workspace. */ get config(): PainConfig; /** * Event logging service for this workspace. */ get eventLog(): EventLog; /** * Pain dictionary service for this workspace. */ get dictionary(): PainDictionary; /** * Hygiene tracking service for this workspace. */ get hygiene(): HygieneTracker; /** * Evolution reducer singleton for this workspace. */ get evolutionReducer(): EvolutionReducerImpl; /** * Trajectory database for analytics and sample curation. * * PRI-647: TrajectoryService.stop() calls TrajectoryRegistry.dispose() * directly (closing the SQLite connection) without invalidating this * cached handle. If the cached database was closed underneath us, reacquire * a fresh instance instead of returning the dead connection (previously * threw TypeError: The database connection is not open and dropped every * injected principle on prompt build). */ get trajectory(): TrajectoryDatabase; getRuleHost(logger: RuleHostLogger): RuleHost; /** * Locked ledger access for principle tree reads and metric writes in this workspace. */ get principleTreeLedger(): PrincipleTreeLedgerAccessor; /** * Phase 15 lifecycle/read-model surface for metrics, assessments, and route recommendations. */ get principleLifecycle(): PrincipleLifecycleService; /** * Retrieve active Principle -> Rule -> Implementation subtrees without bypassing reducer authority. */ getActivePrincipleSubtrees(): { principle: ActivePrinciple; subtree: PrincipleSubtree; }[]; private getTrajectoryOptions; /** * Creates or retrieves a WorkspaceContext instance from an OpenClaw hook context. * Uses PathResolver to handle path normalization and fallback logic. * @throws Error if workspaceDir is missing and no fallback available. */ static fromHookContext(ctx: any): WorkspaceContext; /** * Creates a WorkspaceContext requiring explicit workspaceDir. * For Runtime V2 entrypoints where implicit PathResolver fallback is unacceptable. * @throws Error if workspaceDir is not provided in the context. */ static fromHookContextExplicit(ctx: { workspaceDir?: string; logger?: { error?: (...args: unknown[]) => void; warn?: (...args: unknown[]) => void; info?: (...args: unknown[]) => void; }; }): WorkspaceContext; /** * Resolves a PD file path within the workspace. */ resolve(fileKey: keyof typeof PD_FILES): string; /** * Resets internal caches for services and paths. */ invalidate(): void; /** * Removes a workspace from the cache. */ static dispose(workspaceDir: string): void; /** * Clears the instance cache (primarily for testing). */ static clearCache(): void; } export {};