@mastra/core
Version:
54 lines • 2.49 kB
TypeScript
import type { MastraServerCache } from '../../cache/base.js';
import type { PubSub } from '../../events/pubsub.js';
export interface ResolveRunBusInput {
/** The agent's own bus (user-provided, or the default). */
agentBus: PubSub;
/** Whether `agentBus` was provided by the user. */
hasCustomBus: boolean;
/** The Mastra-level bus, once the agent is registered. */
sharedBus?: PubSub;
/**
* Whether run frames must live on `sharedBus` even when the user provided
* `agentBus` (steps publish from any worker). Only called when `sharedBus`
* is set and `agentBus` is the user's, so it may resolve state that needs
* registration.
*/
requiresSharedBus: () => boolean;
warn: (message: string) => void;
}
/**
* The bus a run's frames live on. A registered agent publishes on `sharedBus`
* so other Mastra instances on that bus can observe its runs. A user-provided
* `agentBus` takes precedence unless the run's steps publish on `sharedBus`.
* Unregistered agents keep their own bus.
*/
export declare function resolveRunBus({ agentBus, hasCustomBus, sharedBus, requiresSharedBus, warn, }: ResolveRunBusInput): PubSub;
export interface ResolveAgentStreamBusInput {
/** The bus run frames are published on (see {@link resolveRunBus}). */
runBus: PubSub;
/** User cache config: `undefined` inherits, `false` disables replay. */
cache?: MastraServerCache | false;
/** User per-topic cache policy. */
shouldCache?: (topic: string) => boolean;
/** The Mastra-level cache, once the agent is registered. */
serverCache?: MastraServerCache;
/**
* Whether run frames must share `serverCache` because other processes
* append to the same log. Only called when `serverCache` differs from the
* resolved cache, so it may resolve state that needs registration.
*/
requiresServerCache: () => boolean;
warn: (message: string) => void;
}
export interface ResolvedAgentStreamBus {
/** The bus to publish and subscribe run frames on. */
pubsub: PubSub;
/** The replay cache backing `pubsub`, or `null` when replay is disabled. */
cache: MastraServerCache | null;
}
/**
* Resolve the bus an agent publishes run frames on and the replay cache
* behind it.
*/
export declare function resolveAgentStreamBus({ runBus, cache, shouldCache, serverCache, requiresServerCache, warn, }: ResolveAgentStreamBusInput): ResolvedAgentStreamBus;
//# sourceMappingURL=resolve.d.ts.map