UNPKG

@mastra/core

Version:
51 lines 2.38 kB
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. A provider * whose default scope is `caller-supplied` is also called once for each * selected toolkit without a pinned connection, using the request resource id * as its dynamic connection bucket. This lets connection-management and other * connectionless tools bootstrap a caller's first OAuth connection. * * Tools resolved through multiple pinned connections are renamed with a * `__<LABEL>` suffix. Single-connection and unpinned caller-supplied 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