import { ServiceBroker } from 'moleculer';
import { TRPCLink } from '@trpc/client';
import { AnyRouter } from '@trpc/server';
/**
 * Resolver for in-process capability providers.
 *
 * The localProviderLink calls this on every operation to check whether
 * a provider exists in the local process. Implementations differ:
 *   - Worker: reads from `localProviderRegistry` + `preferredProviderRegistry`
 *   - Hub: reads from `CapabilityRegistry`
 */
/**
 * Shared interface — also re-exported by `broker-api-proxy.ts`.
 * Single method is sufficient: the link only needs to resolve the
 * first matching provider. Singleton vs collection distinction is
 * a registry concern, not a transport concern.
 */
export interface LocalProviderResolver {
    /** First matching provider (active singleton or first collection member). */
    getByName(capabilityName: string): unknown | null;
}
/**
 * Non-terminating tRPC link that intercepts calls when the target
 * capability has a provider registered in the local process.
 *
 * When a local provider is found and implements the requested method,
 * the call is made directly (zero serialization). When no local
 * provider exists, the call passes through to `next(op)`.
 *
 * This is the mechanism that makes `ctx.api.streamBroker.getBrokerStats.query()`
 * resolve in-process on the hub without going through Moleculer, and
 * makes `ctx.api.pipelineExecutor.runPipeline.mutate()` resolve locally
 * on a forked worker that has a co-located pipeline-executor.
 */
export declare function localProviderLink<TRouter extends AnyRouter>(resolver: LocalProviderResolver): TRPCLink<TRouter>;
export declare function brokerTransportLink<TRouter extends AnyRouter>(broker: ServiceBroker, serviceMap?: Readonly<Record<string, string>>): TRPCLink<TRouter>;
export type LinkChainTarget = {
    type: 'local-router';
    terminatingLink: TRPCLink<AnyRouter>;
} | {
    type: 'ws';
    terminatingLink: TRPCLink<AnyRouter>;
} | {
    type: 'broker';
    broker: ServiceBroker;
    serviceMap?: Readonly<Record<string, string>>;
};
/**
 * Build the tRPC link chain for an addon context.
 *
 * Always starts with `localProviderLink` (if a resolver is provided),
 * then falls through to the appropriate terminating link based on the
 * deployment context.
 */
export declare function buildLinkChain(target: LinkChainTarget, localResolver?: LocalProviderResolver): TRPCLink<AnyRouter>[];
//# sourceMappingURL=trpc-links.d.ts.map