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 { MessageListInput } from './message-list/index.js'; import type { AgentMessageInput, AgentStateSignalInput, CreatedAgentSignal } from './signals.js'; import type { AgentSignal, AgentSubscribeToThreadOptions, AgentThreadSubscription, QueueAgentMessageOptions, QueueAgentMessageResult, SendAgentMessageOptions, SendAgentMessageResult, SendAgentSignalOptions, SendAgentSignalResult, SendAgentStateSignalOptions, SendAgentStateSignalResult } from './types.js'; export declare let defaultAgentThreadPubSub: PubSub; export type AgentThreadState = 'active' | 'idle'; export declare class AgentThreadStreamRuntime { #private; getThreadState(options: { resourceId?: string; threadId: string; }, pubsub?: PubSub): AgentThreadState; prepareRunOptions(options: AgentExecutionOptions, pubsub?: PubSub): AgentExecutionOptions; abortRun(runId: string, pubsub?: PubSub): boolean; getActiveThreadRunId(options: AgentSubscribeToThreadOptions, pubsub?: PubSub): string | undefined; abortThread(options: AgentSubscribeToThreadOptions, pubsub?: PubSub): boolean; /** @internal */ resetForTests(): void; registerRun(agent: Agent, output: MastraModelOutput, streamOptions: AgentExecutionOptions, pubsub?: PubSub): void; continueWithMessages(agent: Agent, messages: MessageListInput, target: { resourceId: string; threadId: string; streamOptions?: AgentExecutionOptions; runId?: string; }, pubsub?: PubSub): { accepted: true; runId: string; }; drainPendingSignals(runId: string, pubsub?: PubSub): CreatedAgentSignal[]; waitForCrossAgentThreadRun(agent: Agent, options: { memory?: AgentExecutionOptions['memory']; requestContext?: RequestContext; }, pubsub?: PubSub): Promise; subscribeToThread(agent: Agent, options: AgentSubscribeToThreadOptions, pubsub?: PubSub): Promise>; sendMessage(agent: Agent, message: AgentMessageInput, target: SendAgentMessageOptions, pubsub?: PubSub): SendAgentMessageResult; queueMessage(agent: Agent, message: AgentMessageInput, target: QueueAgentMessageOptions, pubsub?: PubSub): QueueAgentMessageResult; sendStateSignal(agent: Agent, stateInput: AgentStateSignalInput, target: SendAgentStateSignalOptions, pubsub?: PubSub): Promise; /** * 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(agent: Agent, signalInput: AgentSignal, target: SendAgentSignalOptions, pubsub?: PubSub): SendAgentSignalResult; } export declare const agentThreadStreamRuntime: AgentThreadStreamRuntime; //# sourceMappingURL=thread-stream-runtime.d.ts.map