@mastra/core
Version:
46 lines • 2.06 kB
TypeScript
import type { IMastraLogger } from '../logger/index.js';
import type { ToolAction } from '../tools/types.js';
import type { ToolProvider, ToolProviders } from './types.js';
/**
* Lookup function the runtime uses to resolve a registered provider by id.
*/
export type ToolProviderLookup = (providerId: string) => ToolProvider;
export interface ResolveStoredToolProvidersOpts {
/** Per-request context plumbed to each `provider.resolveToolsVNext` call. */
requestContext?: Record<string, unknown>;
/**
* Agent author's user id. Used as the provider user bucket for
* `kind: 'author'` connections so pinned credentials work for any invoker.
*/
authorId?: string;
/** Optional logger for non-fatal per-connection warnings. */
logger?: IMastraLogger;
}
/**
* Sanitize a connection label into the suffix segment appended to a tool slug
* (`__<SUFFIX>`).
*
* Rules:
* - Uppercase.
* - Non-`[A-Z0-9_]` characters become `_`.
* - On collision with `usedSuffixes`, append `_2`, `_3`, ... until unique.
* - The returned suffix is added to `usedSuffixes` in place.
*/
export declare function buildConnectionSuffix(label: string | undefined, usedSuffixes: Set<string>): string;
/**
* Provider-agnostic runtime fan-out.
*
* For every stored `toolProviders[providerId].connections[toolkit]`
* entry, calls `provider.resolveToolsVNext` once per connection, then renames
* the resulting tools with a `__<LABEL>` suffix when more than one
* connection is bound to the same toolkit. Single-connection toolkits keep
* the natural slug.
*
* Each renamed tool also gets a routing hint appended to its description so
* the LLM can disambiguate between connections.
*
* Errors from one connection do **not** poison sibling connections — they are
* logged and skipped.
*/
export declare function resolveStoredToolProviders(toolProviders: ToolProviders | undefined, lookup: ToolProviderLookup, opts?: ResolveStoredToolProvidersOpts): Promise<Record<string, ToolAction<any, any, any>>>;
//# sourceMappingURL=runtime.d.ts.map