UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

38 lines 2.49 kB
import type { PubSub } from '../events/pubsub.js'; import type { RequestContext } from '../request-context/index.js'; import type { MastraModelOutput } from '../stream/base/output.js'; import type { Agent } from './agent.js'; import type { AgentExecutionOptions } from './agent.types.js'; import type { CreatedAgentSignal } from './signals.js'; import type { AgentSignal, AgentSubscribeToThreadOptions, AgentThreadSubscription, SendAgentSignalOptions, SendAgentSignalResult } from './types.js'; export declare let defaultAgentThreadPubSub: PubSub; export declare class AgentThreadStreamRuntime { #private; prepareRunOptions<OUTPUT>(options: AgentExecutionOptions<OUTPUT>, pubsub?: PubSub): AgentExecutionOptions<OUTPUT>; abortRun(runId: string, pubsub?: PubSub): boolean; abortThread(options: AgentSubscribeToThreadOptions, pubsub?: PubSub): boolean; /** @internal */ resetForTests(): void; registerRun<OUTPUT>(agent: Agent<any, any, any, any>, output: MastraModelOutput<OUTPUT>, streamOptions: AgentExecutionOptions<OUTPUT>, pubsub?: PubSub): void; drainPendingSignals(runId: string, pubsub?: PubSub): CreatedAgentSignal[]; waitForCrossAgentThreadRun(agent: Agent<any, any, any, any>, options: { memory?: AgentExecutionOptions<any>['memory']; requestContext?: RequestContext; }, pubsub?: PubSub): Promise<void>; subscribeToThread<OUTPUT = unknown>(agent: Agent<any, any, any, any>, options: AgentSubscribeToThreadOptions, pubsub?: PubSub): Promise<AgentThreadSubscription<OUTPUT>>; /** * Routes a signal to an agent thread. * * Signals can land in three places: * - an active same-agent run, where they are queued for the execution loop to drain; * - a reserved thread run that has not registered its stream record yet; * - a new idle-started run, when the caller opts into `ifIdle`. * * Cross-agent active runs are intentionally not interrupted here. They either finish first * through `waitForCrossAgentThreadRun()` on the stream path, or this method falls through to * the idle-start path when the caller provided a resource/thread target and `ifIdle` options. */ sendSignal<OUTPUT = unknown>(agent: Agent<any, any, any, any>, signalInput: AgentSignal, target: SendAgentSignalOptions<OUTPUT>, pubsub?: PubSub): SendAgentSignalResult; } export declare const agentThreadStreamRuntime: AgentThreadStreamRuntime; //# sourceMappingURL=thread-stream-runtime.d.ts.map