/** Coordinates service start deduplication and stop-during-start settlement using the original runtime and its shared registries. */ import type { ServiceClass } from "../types/plugin.js"; import type { IAgentRuntime } from "../types/runtime.js"; import type { Service, ServiceTypeName } from "../types/service.js"; import type { RuntimeRetirement } from "./retirement.js"; export type ServiceResolver = (service: Service) => void; export type ServiceRejecter = (reason: Error | string) => void; export type ServicePromiseHandler = { resolve: ServiceResolver; reject: ServiceRejecter; }; export interface RuntimeServiceLifecycleHost { stopRequested(): boolean; initializationFailed(): boolean; resolveServiceTypeAlias(serviceType: ServiceTypeName | string): string; initResolver(): ((value?: void | PromiseLike) => void) | undefined; serviceTypes(): Map; serviceInstancesByClass(): Map; startingServiceClasses(): Map>; failedServiceClasses(): Set; startingServices(): Map>; serviceRegistrationStatus(): Map; servicePromiseHandlers(): Map; servicePromises(): Map>; stopped(): boolean; /** Runs one start through the runtime, so plugin-lifecycle can attribute * what start() registers to the service's plugin. */ runServiceStart(key: ServiceTypeName, serviceType: string, serviceClass: ServiceClass): Promise; } export declare class RuntimeServiceLifecycle { private readonly runtime; private readonly host; private readonly retirement; /** Retries eager startup after transient failures; shutdown terminates retries. */ startServiceEagerly(serviceType: ServiceTypeName | string, pluginName: string): Promise; constructor(runtime: IAgentRuntime, host: RuntimeServiceLifecycleHost, retirement: RuntimeRetirement); private readonly stopOperations; /** One stop() per instance, shared by runtime shutdown and plugin unload; * rejects with the stop() failure. */ stopServiceOnce(serviceType: string, service: Service): Promise; _stopServiceInstance(serviceType: string, service: Service | null | undefined, reason: string): Promise; /** Starts every pending implementation in parallel and waits for the full set. */ _ensureServiceStarted(serviceType: ServiceTypeName | string): Promise; /** Runs one service start under retirement ownership; _ensureServiceStarted dedupes callers. */ _runServiceStart(key: ServiceTypeName, serviceType: string, serviceDef: ServiceClass): Promise; }