import type { MonoAgentConfig } from "@mono-agent/config"; import type { AgentResponder, NotifyDeliveryContext, ProcessJobProjection } from "@mono-agent/agent-contracts"; import type { TraceSourceHandle, TraceSourceMemoryHealth } from "@mono-agent/observability"; import type { MonoRuntimeLike, RuntimeExecutionMode, RuntimeModelReference } from "@mono-agent/runtime-adapter"; import type { SandboxEngine } from "@mono-agent/runtime-adapter"; import type { AppTraceDefaults, ResolvedExporter } from "./app-config.js"; import type { createConfiguredMemory } from "./configured-agent.js"; import type { ConfiguredAgentSessionEvent } from "./configured-agent.js"; import type { ChannelDriver, ChannelId, ChannelStatus, MonoAgentAppLogger, RunningChannel } from "./channels.js"; import type { NotifyDeliveryResult } from "./proactive-notify.js"; import type { InteractionBridgeHandle } from "./interaction-bridge.js"; import type { ContinuationServiceHandle } from "./continuation-service.js"; import type { ContinuationHealthSnapshot, ContinuationHistoryRecordResult, ContinuationNativeDeliveryResult, ContinuationStatusSnapshot, ContinuationSynthesisInput } from "./continuations.js"; import type { RunningRituals } from "./memory-rituals.js"; import type { RunningArtifactRetentionScheduler } from "./artifact-retention.js"; import type { MemoryRetrievalService } from "./memory-retrieval.js"; import type { RuntimeOptionsExtension } from "./runtime-option-extensions.js"; import type { NotifyDestination } from "./notify-destinations.js"; import type { BackgroundSnapshot } from "./background-snapshot.js"; import type { ManagedRuntimeLaunchVerification } from "./background-runtime.js"; import type { ProcessJobsServiceHandle } from "./process-jobs-service.js"; import { type AgentRootOwnership } from "./agent-root-coordinator.js"; import type { ProcessJobsRootRegistrationProof, ProcessJobsRootRegistrySnapshot } from "./process-jobs-root-registry.js"; import type { ProcessJobsSettings } from "./process-jobs-config.js"; import type { ProcessJobsProtectionPosture, ProcessJobsProtectionStatus } from "./process-jobs-protection.js"; import type { ConfigApplyResult, ExporterStatus, SandboxStatus, SessionTraceMetadata, TraceabilityStatus } from "./app-controller-types.js"; export type { ConfigApplyResult, ExporterStatus, SandboxStatus, TraceabilityStatus, } from "./app-controller-types.js"; /** * Outcome of a live config re-apply (`applyConfigChange`). Consumed by callers * that trigger a reload and by demos that surface the result. */ export interface MonoAgentAppOptions { readonly env?: Record; readonly cwd?: string; /** Path to mono-agent.config.json; defaults to /mono-agent.config.json. */ readonly configPath?: string; /** * Optional immutable read source for managed workers. The public app and * trace metadata continue to identify `configPath`; every runtime/channel * config loader reads this path instead. */ readonly configReadPath?: string; readonly logger?: MonoAgentAppLogger; /** Channel drivers to run. Defaults to every built-in channel. */ readonly drivers?: readonly ChannelDriver[]; /** Shared runtime override (testing / advanced composition). */ readonly runtime?: MonoRuntimeLike; /** Sandbox engine override (testing / advanced composition). */ readonly sandboxEngine?: SandboxEngine; readonly traceDefaults?: AppTraceDefaults; /** Secret-free proof of the durable files/environment observed by this worker. */ readonly backgroundSnapshot?: BackgroundSnapshot; } /** * Best-effort observability exporter status. `configured` does not assert * reachability (Phoenix may start later — only `validate` probes); export * failures during runs surface as `lastWarning`/`lastError` without changing the * run outcome. */ export interface MonoAgentApp { readonly configPath: string; readonly traceabilityStatus: TraceabilityStatus; readonly exporterStatus: ExporterStatus; readonly sandboxStatus: SandboxStatus; readonly processJobsProtection?: ProcessJobsProtectionStatus | undefined; readonly memoryHealth?: TraceSourceMemoryHealth; readonly selectedSkills: readonly string[] | undefined; channelStatus(id: ChannelId): ChannelStatus; channelStatuses(): ReadonlyMap; continuationHealth?(): Promise; listContinuations?(): Promise; capturedContinuationText?(id: string): Promise; retryContinuation?(id: string, options?: { readonly allowUnknown?: boolean; }): Promise; cancelContinuation?(id: string): Promise; listProcessJobs?(): Promise; getProcessJob?(id: string): Promise; cancelProcessJob?(id: string): Promise; resolveContinuationDelivery?(id: string, outcome: { readonly kind: "delivered"; readonly deliveryId?: string; } | { readonly kind: "not_delivered"; } | { readonly kind: "dead_lettered"; }): Promise; startChannelIfConfigured(id: ChannelId, reason: string): Promise; applyConfigChange(reason: string): Promise; stop(): Promise; } /** * Starts a config-first mono-agent host in `cwd`: traceability first, then every * configured channel in parallel. Channels with incomplete config report * `waiting_for_config` instead of blocking the rest. The host runs headless; * config changes take effect on the next restart. */ export declare function startMonoAgentApp(options?: MonoAgentAppOptions): Promise; /** Internal managed-worker entrypoint; deliberately not re-exported by app.ts. */ export declare function startVerifiedManagedMonoAgentApp(options: MonoAgentAppOptions, verification: ManagedRuntimeLaunchVerification): Promise; interface MonoAgentAppControllerInput { readonly cwd: string; readonly agentRootOwnership: AgentRootOwnership; readonly configPath: string; readonly configReadPath: string; readonly env: Record; readonly drivers: readonly ChannelDriver[]; readonly logger?: MonoAgentAppLogger; readonly runtime?: MonoRuntimeLike; readonly sandboxEngine?: SandboxEngine; readonly traceDefaults?: AppTraceDefaults; readonly backgroundSnapshot?: BackgroundSnapshot; readonly trustedRuntimeReadRoots: readonly string[]; } export declare class MonoAgentAppController implements MonoAgentApp { readonly configPath: string; readonly cwd: string; readonly configReadPath: string; readonly env: Record; readonly drivers: readonly ChannelDriver[]; readonly driversById: ReadonlyMap; readonly logger: MonoAgentAppLogger | undefined; readonly runtime: MonoRuntimeLike | undefined; readonly sandboxEngine: SandboxEngine | undefined; readonly traceDefaults: AppTraceDefaults | undefined; readonly backgroundSnapshot: BackgroundSnapshot | undefined; readonly trustedRuntimeReadRoots: readonly string[]; readonly agentRootOwnership: AgentRootOwnership; private agentRootOwnershipReleased; private trustedSrtSandboxEngine; readonly activeRuntimes: MonoRuntimeLike[]; readonly statuses: Map; readonly running: Map; readonly channelStartGenerations: Map; readonly startsInFlight: Map>; /** Captured at construction (~process start): the cutoff for reclaiming orphaned "running" runs. */ readonly processStartMs: number; staleRunsReconciled: boolean; traceabilityStatusValue: TraceabilityStatus; exporterStatusValue: ExporterStatus; sandboxStatusValue: SandboxStatus; memoryHealthValue: TraceSourceMemoryHealth; memoryHealthRefreshInFlight: Promise | undefined; memoryHealthRefreshTimer: ReturnType | undefined; memoryHealthRefreshLoopActive: boolean; memoryHealthRefreshIntervalMs: number; /** Monotonic completion time for the current generation's cached full audit. */ memoryHealthLastCompletedAtMs: number | undefined; /** One bounded forced refresh reserved by a due timer tick. */ memoryHealthRefreshDue: boolean; memoryHealthGeneration: number; /** Durable trace fact published only after the full current lifecycle completes. */ startupCompleted: boolean; startupTimingValue: { readonly durationMs: number; readonly phases: Readonly>; } | undefined; selectedSkillsValue: readonly string[] | undefined; sessionMetadataValue: SessionTraceMetadata | undefined; /** The exporter the responder threads into agent-host (first configured exporter). */ resolvedExporter: ResolvedExporter | undefined; traceSource: TraceSourceHandle | undefined; /** * Whole-publication single flight. A slow health probe must not let periodic * heartbeat ticks build an unbounded promise tail behind it. */ traceRefreshInFlight: Promise | undefined; traceRefreshDirty: boolean; traceRefreshLatestReason: string | undefined; globalTraceSource: TraceSourceHandle | undefined; artifactRetentionScheduler: RunningArtifactRetentionScheduler | undefined; artifactRetentionGeneration: number; memoryRituals: RunningRituals | undefined; sharedMemory: Awaited>; sharedMemoryRetrieval: MemoryRetrievalService | undefined; sharedMemoryBuilt: boolean; sharedMemoryBuild: Promise>> | undefined; configApplyTail: Promise; stopped: boolean; interactionBridge: InteractionBridgeHandle | undefined; interactionBridgeStart: Promise | undefined; continuationService: ContinuationServiceHandle | undefined; continuationServiceStart: Promise | undefined; processJobsService: ProcessJobsServiceHandle | undefined; processJobsServiceStart: Promise | undefined; processJobsServiceStartFlight: symbol | undefined; /** Configured private root; retained even when the durable store cannot open. */ processJobsStateDir: string | undefined; processJobsDegradation: { readonly stateDir: string; readonly reason: string; } | undefined; processJobsRegistry: ProcessJobsRootRegistrySnapshot | undefined; processJobsProtectionPosture: ProcessJobsProtectionPosture | undefined; preparedProcessJobs: { readonly settings: ProcessJobsSettings; readonly workspace: string; readonly protectionPosture: ProcessJobsProtectionPosture; readonly registration?: ProcessJobsRootRegistrationProof; } | undefined; /** One bounded scan cache for artifact-derived native-notify destinations. */ readonly seenNotifyDestinations: import("./seen-conversations.js").SeenNotifyDestinationCache; constructor(input: MonoAgentAppControllerInput); get traceabilityStatus(): TraceabilityStatus; get exporterStatus(): ExporterStatus; get sandboxStatus(): SandboxStatus; get processJobsProtection(): ProcessJobsProtectionStatus | undefined; get memoryHealth(): TraceSourceMemoryHealth; get selectedSkills(): readonly string[] | undefined; sandboxEngineFor(coreConfig: MonoAgentConfig): SandboxEngine | undefined; channelStatus(id: ChannelId): ChannelStatus; channelStatuses(): ReadonlyMap; continuationHealth(): Promise; listContinuations(): Promise; capturedContinuationText(id: string): Promise; retryContinuation(id: string, options?: { readonly allowUnknown?: boolean; }): Promise; cancelContinuation(id: string): Promise; listProcessJobs(): Promise; getProcessJob(id: string): Promise; cancelProcessJob(id: string): Promise; resolveContinuationDelivery(id: string, outcome: { readonly kind: "delivered"; readonly deliveryId?: string; } | { readonly kind: "not_delivered"; } | { readonly kind: "dead_lettered"; }): Promise; applyConfigChange(reason: string): Promise; startChannelIfConfigured(id: ChannelId, reason: string): Promise; startTraceability(reason: string): Promise; refreshSandboxStatus(reason: string): Promise; /** * One-shot at startup: a process that crashed mid-run leaves its summary stuck at "running" * forever (a ghost run in `status`/observability). Reclaim those — any "running" summary that * began before THIS process started — by rewriting them to "interrupted". Gated so a config * reload (which re-runs startTraceability) does not repeat the scan. Best-effort: never fatal. */ reconcileStaleRunsOnce(artifactDir: string): Promise; /** * Resolve the configured observability exporter(s) and publish the export * status. No reachability probe runs here — Phoenix may start after the agent, * so an unreachable endpoint must not block startup (that probe runs in * `validate`). A present-but-invalid exporter config surfaces as `failed`. */ startExporters(reason: string): Promise; /** Record a best-effort export warning so `status` can surface it without failing the run. */ recordExporterWarning(warning: { phase: string; message: string; }): void; refreshTraceSource(reason: string): Promise; /** * Refresh the content-free memory snapshot once for all concurrent trace * publishers. The cached value is the only memory state read by synchronous * manifest composition; provider/native errors collapse to a closed unknown * shape and never escape into registry metadata. */ refreshMemoryHealthSnapshot(reason: string, lifecycleForce?: boolean): Promise; computeMemoryHealth(): Promise; startMemoryHealthRefreshLoop(intervalMs: number): void; scheduleMemoryHealthRefresh(delayOverrideMs?: number): void; recordMemoryHealthCompletion(generation: number): void; refreshMemoryHealthOnTimer(): void; /** * Re-audit after channel responders and the shared memory store have started. * The trace source is registered first, so its registration audit can only * observe the previous/stopped runtime snapshot. This one lifecycle force is * generation-fenced and uses the same health/trace single-flights as timer * work; ordinary session and trace events continue to reuse the 30s cache. */ refreshMemoryHealthAfterLifecycle(reason: string, beforePublish?: () => void): Promise; clearMemoryHealthRefreshTimer(): void; invalidateMemoryHealthRefresh(): void; /** * Start the interaction bridge once, when a blocking ask tool is allowed by * the tool policy, a request-context MCP needs scoped progress, or the operator * configured the `interaction` block. The master bearer remains app-owned. */ ensureInteractionBridge(coreConfig: MonoAgentConfig): Promise; stopInteractionBridge(): Promise; /** Start one durable continuation service shared by all channel responders. */ ensureContinuationService(coreConfig: MonoAgentConfig): Promise; startContinuationServiceIfConfigured(reason: string): Promise; stopContinuationService(): Promise; ensureProcessJobsService(): Promise; startProcessJobsIfConfigured(reason: string): Promise; prepareProcessJobsProtection(reason: string): Promise; activateProcessJobWakes(): Promise; stopProcessJobsService(): Promise; requireContinuationService(): ContinuationServiceHandle; synthesizeContinuation(input: ContinuationSynthesisInput): Promise<{ readonly text: string; readonly actionable?: boolean; }>; continuationSynthesisAvailability(input: ContinuationSynthesisInput): { readonly ready: true; } | { readonly ready: false; readonly code: string; readonly reason: string; readonly retryAfterMs: number; }; deliverContinuation(conversationId: string, text: string, deliveryKey: string): Promise; recordContinuationHistory(conversationId: string, text: string, deliveryKey: string): Promise; stop(): Promise; releaseAgentRootOwnership(): Promise; startMemoryRitualsIfConfigured(reason: string): Promise; stopMemoryRituals(): void; restartArtifactRetentionScheduler(artifactDir: string, reason: string): void; stopArtifactRetentionScheduler(): void; /** * Deliver a native cron/webhook notification to whichever running channel owns * the destination conversationId. With `verbatim`, the channel posts `text` * unchanged (no model call) and records it to history; otherwise it runs `text` * as a turn. Best-effort: an unavailable/unsupported destination is warned and * skipped, never thrown back to the cron/webhook trigger. */ notifyDestination(conversationId: string, text: string, options?: { readonly verbatim?: boolean; readonly deliveryKey?: string; readonly deliveryContext?: NotifyDeliveryContext; }): Promise; /** * Candidate destinations for native cron/webhook notification delivery, used to * infer a target when a job/endpoint sets no explicit `notifyConversationId`. */ listNotifyDestinations(): Promise; startChannel(driver: ChannelDriver, reason: string): Promise; stopChannel(id: ChannelId, reason: string): Promise; buildResponder(coreConfig: MonoAgentConfig, channelId?: ChannelId, processJobConversationScheme?: string): Promise; /** * Per-request extension that applies a cron/webhook/tui per-trigger model + * effort override (validated, warn-and-ignore on bad input). Threads the * configured local providers so a LOCAL-model override recomputes its endpoint * block for the OVERRIDE model (see request-model-override doc). Composed * alongside the memory/adapter extensions. */ requestModelOverrideRuntimeOptions(coreConfig: MonoAgentConfig, compatibility: { readonly mcpSources: readonly string[]; readonly indexSkillsActive: boolean; }): { readonly extension: RuntimeOptionsExtension; readonly targetsDirectOpenCode: (metadata: Record | undefined) => boolean; readonly targetsUnsupportedHistoryTool: (metadata: Record | undefined) => boolean; readonly targetsPiNative: (metadata: Record | undefined) => boolean; readonly targetsProcessJobsPiNative: (metadata: Record | undefined) => boolean; }; /** * Memoized factory for runtimes bound to a per-request override model. Reuses * createConfiguredAgentRuntime so the override becomes the fallback-chain * primary with the configured backups after it (override + keep fallbacks). * Built runtimes register in `activeRuntimes`, which is disposed on `stop()` * (config reload rebuilds the responder but does not drain prior runtimes — * same lifetime as the base runtime built in `buildResponder`). */ buildRuntimeForModel(coreConfig: MonoAgentConfig): (model: RuntimeModelReference, executionMode?: RuntimeExecutionMode) => MonoRuntimeLike; /** * Run-identifying context threaded onto exported spans (Phoenix shows the same * source/run identifiers as the local trace-source registry, so local artifact * lookup stays possible). Resolved with the same source-id/label resolvers the * trace source uses. */ observabilityContext(): Promise<{ readonly sourceId?: string; readonly sourceLabel?: string; readonly configPath?: string; }>; reportMemoryRecallStatus(coreConfig: MonoAgentConfig, service: MemoryRetrievalService | undefined): boolean; /** * Optional CLOUD-ONLY escape hatch: when `memory.supermemory.exposeMcpServer` is on, ALSO inject * Supermemory's hosted MCP server alongside the in-app `MemoryRecall` tool. The hosted MCP cannot * point at a self-hosted instance, so self-hosters rely on the in-app recall tool; this just adds * the cloud server's richer tools for cloud deployments. Requires an apiKey (skipped + warned if * absent). */ supermemoryMcpRuntimeOptions(coreConfig: MonoAgentConfig): RuntimeOptionsExtension | undefined; adapterSendToolsRuntimeOptions(coreConfig: MonoAgentConfig): Promise<{ readonly createExtension?: (targetsDirectOpenCode: (metadata: Record | undefined) => boolean) => RuntimeOptionsExtension; readonly blockingToolNames: readonly string[]; }>; /** Build the configured memory store once and share it across responders + the ritual scheduler. */ memoryStore(coreConfig: MonoAgentConfig): Promise>>; /** Close + clear the shared memory store (on config reload or stop) so the next build is fresh. */ resetSharedMemory(): Promise; /** @internal Test-only seam: seed the shared memory store without going through config. */ __setSharedMemoryForTest(store: Awaited>): void; ensureSharedMemoryRetrieval(coreConfig: MonoAgentConfig, store: Awaited>): MemoryRetrievalService | undefined; setStatus(id: ChannelId, status: ChannelStatus): ChannelStatus; applyResult(): ConfigApplyResult; stopTraceSource(reason: string): Promise; activeTransports(): readonly string[]; refreshSelectedSkillsSnapshot(reason: string): Promise; rememberSelectedSkills(coreConfig: MonoAgentConfig): void; recordSessionEvent(event: ConfiguredAgentSessionEvent, coreConfig: MonoAgentConfig): void; traceMetadata(reason: string): Record; } //# sourceMappingURL=app-controller.d.ts.map