/** * Shared base helpers for framework adapters (no third-party imports). * * Python parity: praisonaiagents/frameworks/base.py * * Python offloads a sync `run` to a bounded per-adapter thread pool so one * slow framework cannot starve the process-wide executor. JavaScript has no * threads to offload to, so the same bound is applied as a per-adapter * concurrency limit: at most `THREAD_OFFLOAD_MAX_WORKERS` runs are in flight * at once and the rest queue in order. Python's `__del__` best-effort cleanup * has no TypeScript equivalent; call {@link BaseFrameworkAdapter.cleanup}. */ import type { FrameworkAdapterProtocol, FrameworkLLMConfig, FrameworkResolveOptions, FrameworkRunOptions, FrameworkSetupOptions } from './protocols'; /** * Bounded FIFO concurrency limiter standing in for Python's * `ThreadPoolExecutor(max_workers=...)`. */ export declare class OffloadPool { readonly maxWorkers: number; private active; private readonly waiters; constructor(maxWorkers: number); /** Run `fn` once a worker slot is free. */ run(fn: () => T | Promise): Promise; /** Number of runs currently executing. */ get activeCount(): number; /** Number of runs waiting for a slot. */ get pendingCount(): number; } /** * Base class for framework adapters providing common functionality. * * Python parity: `BaseFrameworkAdapter`. Subclasses provide `isAvailable()` * and `run(...)`; `arun` offloads a sync `run` through the bounded pool. */ export declare abstract class BaseFrameworkAdapter implements FrameworkAdapterProtocol { name: string; installHint: string; requiresToolsExtra: boolean; isRouter: boolean; /** Adapters with a native async `run` path set this true and override `arun`. */ SUPPORTS_ASYNC: boolean; /** Adapter can execute native workflow YAML. */ SUPPORTS_WORKFLOW: boolean; /** Adapter supports cli_backend / runtime / models.*.runtime / providers.*.runtime_default. */ SUPPORTS_RUNTIME_FEATURES: boolean; /** Bound of the per-adapter offload pool (Python `_THREAD_OFFLOAD_MAX_WORKERS`). */ THREAD_OFFLOAD_MAX_WORKERS: number; DEFAULT_MODEL: string; private threadPool; /** True when this framework's optional dependencies are installed. */ abstract isAvailable(): boolean; /** Execute the framework with shared agents.yaml configuration. */ abstract run(config: Record, llmConfig: FrameworkLLMConfig, topic: string, options?: FrameworkRunOptions): string | Promise; /** * Resolve a model name from per-agent spec and shared llmConfig. * Python parity: `_resolve_llm(spec, llm_config)`. */ protected resolveLlm(spec: unknown, llmConfig: FrameworkLLMConfig | null | undefined): string; /** * Safely format a template string, preserving JSON-like braces whose name * is not in `kwargs`. Python parity: `_format_template(template, **kwargs)`. */ protected formatTemplate(template: string, kwargs?: Record): string; /** Pick a concrete adapter variant; the base returns itself. */ resolve(options?: FrameworkResolveOptions): FrameworkAdapterProtocol; /** Framework-specific pre-run hooks; the base does nothing. */ setup(options: FrameworkSetupOptions): void; /** Lazily create the bounded, per-adapter offload pool. Python parity: `_get_thread_pool`. */ protected getThreadPool(): OffloadPool; /** * Run `run` through this adapter's bounded pool. * Python parity: `_thread_offload_run(*args, **kwargs)`. */ protected threadOffloadRun(config: Record, llmConfig: FrameworkLLMConfig, topic: string, options?: FrameworkRunOptions): Promise; /** Async execution; offloads the sync `run` when there is no native async path. */ arun(config: Record, llmConfig: FrameworkLLMConfig, topic: string, options?: FrameworkRunOptions): Promise; /** Release the offload pool. Queued runs already accepted still complete. */ cleanup(): void; /** Return the concrete adapter name to dispatch to. */ resolveAlias(): string; }