@mastra/core
Version:
37 lines • 2.07 kB
TypeScript
import type { Adapter, Thread } from 'chat';
import type { IMastraLogger } from '../logger/logger.js';
import type { AgentChunkType } from '../stream/types.js';
import type { PendingApprovalRecord } from './stream-helpers.js';
import type { ToolDisplayFn } from './types.js';
export interface StaticDriverArgs {
stream: AsyncIterable<AgentChunkType<any>>;
chatThread: Thread;
adapter: Adapter;
/** After `resolveToolDisplay`, non-streaming tool display is one of these. */
toolDisplay: 'cards' | 'text' | 'hidden';
/**
* Optional function-form `toolDisplay` callback. When set, the built-in
* renderers are bypassed and this is called once per tool lifecycle event
* (running, result, error, approval).
*/
toolDisplayFn?: ToolDisplayFn;
channelToolNames: Set<string>;
logger?: IMastraLogger;
onApprovalPosted: (toolCallId: string, record: PendingApprovalRecord) => void;
getPendingApproval: (toolCallId: string) => PendingApprovalRecord | undefined;
takePendingApproval: (toolCallId: string) => PendingApprovalRecord | undefined;
/** Optional adapter-supplied formatter for `error` chunks; defaults to a plain prefix. */
formatError?: (error: Error) => unknown;
}
/**
* Static (non-streaming) driver: consumes `AgentChunkType<any>` chunks and
* renders them through discrete `chatThread.post` / `adapter.editMessage`
* calls. Handles `'cards'` (per-tool "Running…" → "Result" cards) and
* `'hidden'` (silent tool execution, one final text post) tool-display modes.
*
* No streaming session is opened — text accumulates in a buffer and flushes
* on any side-effect (tool call, file, finish, error). OM `data-om-*` chunks
* are intentionally ignored: OM widgets only render inside a streaming Plan.
*/
export declare function runStaticDriver({ stream, chatThread, adapter, toolDisplay, toolDisplayFn, channelToolNames, logger, onApprovalPosted, getPendingApproval, takePendingApproval, formatError, }: StaticDriverArgs): Promise<void>;
//# sourceMappingURL=chat-driver-static.d.ts.map