@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
83 lines • 5.51 kB
TypeScript
import type { EmbedManyResult as AiEmbedManyResult, EmbedResult as AiEmbedResult, CoreAssistantMessage as AiCoreAssistantMessage, CoreMessage as AiCoreMessage, CoreSystemMessage as AiCoreSystemMessage, CoreToolMessage as AiCoreToolMessage, CoreUserMessage as AiCoreUserMessage, UIMessage, streamText, streamObject, generateText, generateObject, StreamTextOnFinishCallback, StreamObjectOnFinishCallback } from '../_types/@internal_ai-sdk-v4/dist/index.js';
import type { SystemModelMessage } from '../_types/@internal_ai-sdk-v5/dist/index.js';
import type { ObservabilityContext } from '../observability/index.js';
import type { RequestContext } from '../request-context/index.js';
import type { Run } from '../run/types.js';
import type { StandardSchemaWithJSON } from '../schema/index.js';
import type { CoreTool } from '../tools/types.js';
import type { MastraLanguageModel } from './model/shared.types.js';
export type LanguageModel = MastraLanguageModel;
export type CoreMessage = AiCoreMessage;
export type CoreSystemMessage = AiCoreSystemMessage;
export type CoreAssistantMessage = AiCoreAssistantMessage;
export type CoreUserMessage = AiCoreUserMessage;
export type CoreToolMessage = AiCoreToolMessage;
export type EmbedResult<T> = AiEmbedResult<T>;
export type EmbedManyResult<T> = AiEmbedManyResult<T>;
export type BaseStructuredOutputType = 'string' | 'number' | 'boolean' | 'date';
export type StructuredOutputType = 'array' | 'string' | 'number' | 'object' | 'boolean' | 'date';
export type StructuredOutputArrayItem = {
type: BaseStructuredOutputType;
} | {
type: 'object';
items: StructuredOutput;
};
export type StructuredOutput = {
[key: string]: {
type: BaseStructuredOutputType;
} | {
type: 'object';
items: StructuredOutput;
} | {
type: 'array';
items: StructuredOutputArrayItem;
};
};
export type { GenerateReturn, StreamReturn, GenerateObjectResult, GenerateTextResult, StreamObjectResult, StreamTextResult, } from './model/base.types.js';
export type { TripwireProperties, MastraModelConfig, OpenAICompatibleConfig } from './model/shared.types.js';
export { ModelRouterLanguageModel, defaultGateways } from './model/router.js';
export { GatewayRegistry, PROVIDER_REGISTRY, parseModelString, getProviderConfig } from './model/provider-registry.js';
export type { ModelRouterModelId, Provider, ModelForProvider } from './model/provider-registry.js';
export { resolveModelConfig } from './model/resolve-model.js';
export type OutputType = StructuredOutput | StandardSchemaWithJSON | undefined;
export type SystemMessage = string | string[] | CoreSystemMessage | SystemModelMessage | CoreSystemMessage[] | SystemModelMessage[];
type GenerateTextOptions = Parameters<typeof generateText>[0];
type StreamTextOptions = Parameters<typeof streamText>[0];
type GenerateObjectOptions = Parameters<typeof generateObject>[0];
type StreamObjectOptions = Parameters<typeof streamObject>[0];
type MastraCustomLLMOptionsKeys = 'messages' | 'tools' | 'model' | 'onStepFinish' | 'experimental_output' | 'messages' | 'onFinish' | 'output';
export type DefaultLLMTextOptions = Omit<GenerateTextOptions, MastraCustomLLMOptionsKeys>;
export type DefaultLLMTextObjectOptions = Omit<GenerateObjectOptions, MastraCustomLLMOptionsKeys>;
export type DefaultLLMStreamOptions = Omit<StreamTextOptions, MastraCustomLLMOptionsKeys>;
export type DefaultLLMStreamObjectOptions = Omit<StreamObjectOptions, MastraCustomLLMOptionsKeys>;
type MastraCustomLLMOptions<Z extends StandardSchemaWithJSON | undefined = undefined> = ObservabilityContext & {
tools?: Record<string, CoreTool>;
onStepFinish?: (step: unknown) => Promise<void> | void;
experimental_output?: Z;
threadId?: string;
resourceId?: string;
requestContext: RequestContext;
} & Run;
export type LLMTextOptions<Z extends StandardSchemaWithJSON | undefined = undefined> = {
messages: UIMessage[] | CoreMessage[];
} & MastraCustomLLMOptions<Z> & DefaultLLMTextOptions;
export type LLMTextObjectOptions<T extends StandardSchemaWithJSON | undefined = undefined> = LLMTextOptions<T> & DefaultLLMTextObjectOptions & {
structuredOutput: StandardSchemaWithJSON | StructuredOutput;
};
export type LLMStreamOptions<Z extends StandardSchemaWithJSON | undefined = undefined> = {
output?: OutputType | Z;
onFinish?: StreamTextOnFinishCallback<any>;
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
export type LLMInnerStreamOptions<Z extends StandardSchemaWithJSON | undefined = undefined> = {
messages: UIMessage[] | CoreMessage[];
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
export type LLMStreamObjectOptions<Z extends StandardSchemaWithJSON | undefined = undefined> = {
structuredOutput: StandardSchemaWithJSON | StructuredOutput;
onFinish?: StreamObjectOnFinishCallback<any>;
} & LLMInnerStreamOptions<Z> & DefaultLLMStreamObjectOptions;
export type { ProviderConfig, GatewayLanguageModel } from './model/gateways/base.js';
export { MastraModelGateway, NetlifyGateway, ModelsDevGateway, AzureOpenAIGateway, MastraGateway, } from './model/gateways/index.js';
export type { AzureAccessToken, AzureOpenAIGatewayConfig, AzureTokenCredential, MastraGatewayConfig, } from './model/gateways/index.js';
export { GATEWAY_AUTH_HEADER } from './model/gateways/constants.js';
export { ModelRouterEmbeddingModel, type EmbeddingModelId, EMBEDDING_MODELS, type EmbeddingModelInfo } from './model/index.js';
//# sourceMappingURL=index.d.ts.map