UNPKG

@mastra/core

Version:
66 lines • 3.51 kB
import type { ToolSet } from '../../../_types/@internal_ai-sdk-v5@0.0.98/dist/index.js'; import type { IMastraLogger } from '../../../logger/index.js'; import type { RequestContext } from '../../../request-context/index.js'; import type { RequireToolApproval } from '../../../tools/index.js'; import type { ToolApprovalContext } from '../../../tools/types.js'; import type { ToolCallConcurrency, ToolCallConcurrencyStrategy } from '../../types.js'; export type ToolCallForeachOptions = { concurrency: number; }; /** * Normalize the public `toolCallConcurrency` option (a number or an object with * `limit`/`strategy`) into a resolved `{ limit, strategy }` pair. */ export declare function normalizeToolCallConcurrency(toolCallConcurrency: ToolCallConcurrency | undefined): { limit: number; strategy: ToolCallConcurrencyStrategy; }; /** * Prepares an agent's default options for merging under call options. A call that passes * `toolCallConcurrency` as an object (e.g. `{ strategy: 'called' }`) would replace a numeric * default outright, so the number becomes the object's `limit` and the call's own fields win. */ export declare function withDefaultToolCallConcurrencyLimit<T extends { toolCallConcurrency?: ToolCallConcurrency; }>(defaults: T, options: { toolCallConcurrency?: ToolCallConcurrency; } | undefined): T; export declare function resolveConfiguredToolCallConcurrency(toolCallConcurrency: ToolCallConcurrency | undefined): number; export declare function effectiveToolSetRequiresSequentialExecution({ requireToolApproval, tools, activeTools, strategy, calledToolNames, dynamicApprovalEvaluated, }: { requireToolApproval?: RequireToolApproval; tools?: ToolSet; activeTools?: readonly string[]; strategy?: ToolCallConcurrencyStrategy; calledToolNames?: readonly string[]; dynamicApprovalEvaluated?: boolean; }): boolean; export declare function resolveToolCallConcurrency({ requireToolApproval, tools, activeTools, configuredConcurrency, strategy, calledToolNames, }: { requireToolApproval?: RequireToolApproval; tools?: ToolSet; activeTools?: readonly string[]; configuredConcurrency: number; strategy?: ToolCallConcurrencyStrategy; calledToolNames?: readonly string[]; }): number; export declare function updateToolCallForeachConcurrency(options: ToolCallForeachOptions, args: Parameters<typeof resolveToolCallConcurrency>[0]): void; /** * Resolves concurrency for a step once the model's tool calls are known. * * Each called tool's approval policy is evaluated with the call's actual arguments (the same rule * the tool-call step applies), so a function policy that returns `false` does not force sequential * execution. Called tools with a suspend schema, or whose policy requires approval for this call, * still force sequential execution. Under `'available'`, any active tool with a static approval * flag or suspend schema also forces sequential execution, as before. */ export declare function resolveEmittedToolCallConcurrency({ toolCalls, approvalVerdicts, requestContext, workspace, logger, ...args }: Parameters<typeof resolveToolCallConcurrency>[0] & { toolCalls: readonly { toolCallId?: string; toolName: string; args?: unknown; }[]; approvalVerdicts?: Map<string, boolean>; requestContext?: RequestContext; workspace?: ToolApprovalContext['workspace']; logger?: IMastraLogger; }): Promise<number>; //# sourceMappingURL=tool-call-concurrency.d.ts.map