/** * In-Process Runtime Registry * * Module-level registry that tracks active in-process Crewly Agent runtimes * by session name. Provides a lightweight lookup mechanism for callers (such * as `orchestrator-status.service.ts`) that need to determine whether an * in-process runtime is alive without holding a reference to the * `AgentRegistrationService` instance. * * Why this exists (B0 hot-fix): * The PTY-based `sessionExists()` check returns `false` for in-process * Crewly Agent runtimes because they have no PTY session. Before this * registry, the orchestrator-status service had no runtime-aware fallback, * so `isActive` would report `false` for healthy in-process orchestrators * — causing SlackBridge to incorrectly route messages to the offline path. * * The `AgentRegistrationService` already maintains an internal * `inProcessRuntimes` map for in-process runtime routing. This module * mirrors that knowledge at module scope so any caller can probe runtime * health without a service-locator dance. * * @module services/agent/crewly-agent/in-process-runtime-registry */ import type { CrewlyAgentExternalRuntimeService } from './crewly-agent-external-runtime.service.js'; /** * Register an in-process Crewly Agent runtime. * * Called by `AgentRegistrationService` after `initializeInProcess()` * succeeds. If a runtime is already registered for the same session, it is * replaced — the old reference is discarded but not shut down (the caller * is responsible for the lifecycle). * * @param sessionName - Session name owning the runtime (e.g. 'crewly-orc') * @param runtime - The initialized CrewlyAgentExternalRuntimeService instance * * @example * ```typescript * registerInProcessRuntime('crewly-orc', crewlyRuntime); * ``` */ export declare function registerInProcessRuntime(sessionName: string, runtime: CrewlyAgentExternalRuntimeService): void; /** * Unregister an in-process runtime by session name. * * Called when a runtime is shut down or the session is destroyed. * Idempotent — safe to call when the session is not registered. * * @param sessionName - Session name to remove * @returns True if a runtime was removed, false if none was registered */ export declare function unregisterInProcessRuntime(sessionName: string): boolean; /** * Look up an in-process runtime by session name. * * @param sessionName - Session name to look up * @returns The CrewlyAgentExternalRuntimeService if registered, undefined otherwise */ export declare function getInProcessRuntime(sessionName: string): CrewlyAgentExternalRuntimeService | undefined; /** * Check whether an in-process runtime exists and is ready to handle * messages for the given session. * * Returns `true` only when both: * - A runtime is registered for the session * - The runtime's `isReady()` returns `true` * * This is the function callers should use when answering "is this * session alive?" — it correctly handles both the worker-process and * direct in-process modes of `CrewlyAgentExternalRuntimeService`. * * @param sessionName - Session name to check * @returns True when the runtime exists and is ready */ export declare function isInProcessRuntimeActive(sessionName: string): boolean; /** * Child pid → session name for the registered runtimes that have a live * child process (#1024: the process-tree identity check treats a call from * a Crewly Agent child as that session's). * * @returns Map (empty when none) */ export declare function inProcessRuntimePids(): Map; /** * Reset the registry. Test-only helper. * * Leaves any actually-running runtimes untouched — only clears the * registry's bookkeeping. Production code must never call this. * * @internal */ export declare function _resetInProcessRuntimeRegistryForTesting(): void; /** * Get the current registry size. Test-only helper. * * @returns Number of registered runtimes * @internal */ export declare function _getInProcessRuntimeRegistrySize(): number; //# sourceMappingURL=in-process-runtime-registry.d.ts.map