@tanstack/ai
Version:
Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.
48 lines (47 loc) • 7 kB
JavaScript
import { RUN_CANCEL_REASON, isCancelRequestedReason, requestRunCancel, wasCancelRequested } from "./activities/chat/cancel.js";
import { createCapability } from "./activities/chat/middleware/capabilities.js";
import { DetachableRunCapability, InMemoryRunStore, RunDetachedCapability, defineRunStore, getDetachableRun, getRunDetached, isRunStatus, isTerminalRunStatus, provideDetachableRun, provideRunDetached } from "./activities/chat/middleware/run-store.js";
import { memoryStream, replayRunStream, resolveResumeRunId } from "./stream-durability.js";
import { EventType } from "./types.js";
import { ConsoleLogger } from "./logger/console-logger.js";
import { RUN_ACCEPTED_EVENT, resumeHttpResponse, resumeServerSentEventsResponse, streamToText, toHttpResponse, toHttpStream, toServerSentEventsResponse, toServerSentEventsStream } from "./stream-to-response.js";
import { canonicalInterruptJson, cloneAndDeepFreezeJson, digestInterruptJson } from "./interrupt-serialization.js";
import { INTERRUPT_BINDING_VERSION, canonicalizeInterruptResolutions } from "./interrupts.js";
import { StandardSchemaValidationError, convertSchemaToJsonSchema, isStandardSchema, parseWithStandardSchema, validateWithStandardSchema } from "./activities/chat/tools/schema-converter.js";
import { hashSchemaInput, normalizeApprovalSchema } from "./activities/chat/tools/approval-schema.js";
import { INTERRUPT_BINDING_METADATA_KEY, InterruptResumeValidationError, interruptItemError, readInterruptBinding, readUnopenedInterruptBinding, validateInterruptResumeBatch, withInterruptBinding, withoutInterruptBinding } from "./interrupt-resume.js";
import { isContentPart, isContentPartArray, normalizeToolResult } from "./utilities/tool-result.js";
import { getProviderExecutedMetadata, isProviderExecutedToolCall } from "./utilities/provider-executed.js";
import { firstSentence, renderLazyCatalogEntry } from "./activities/chat/tools/lazy-tools.js";
import { DISCOVERY_TOOL_NAME } from "./activities/chat/tools/lazy-tool-manager.js";
import { ToolCallManager } from "./activities/chat/tools/tool-calls.js";
import { combineStrategies, maxIterations, untilFinishReason } from "./activities/chat/agent-loop-strategies.js";
import { convertMessagesToModelMessages, generateMessageId, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeToUIMessage, uiMessageToModelMessages } from "./activities/chat/messages.js";
import { MCPDuplicateToolNameError } from "./activities/chat/mcp/manager.js";
import { chat, createChatOptions } from "./activities/chat/index.js";
import { createSummarizeOptions, summarize } from "./activities/summarize/index.js";
import { resolveMediaPrompt } from "./utilities/media-prompt.js";
import { createImageOptions, generateImage } from "./activities/generateImage/index.js";
import { createAudioOptions, generateAudio } from "./activities/generateAudio/index.js";
import { createVideoOptions, generateVideo, getVideoJobStatus } from "./activities/generateVideo/index.js";
import { createSpeechOptions, generateSpeech } from "./activities/generateSpeech/index.js";
import { createTranscriptionOptions, generateTranscription } from "./activities/generateTranscription/index.js";
import { toolDefinition } from "./activities/chat/tools/tool-definition.js";
import { brandProviderTool } from "./tools/provider-tool.js";
import { createFrozenRegistry, createToolRegistry } from "./tool-registry.js";
import { defineChatMiddleware } from "./activities/chat/middleware/define.js";
import { createChatMiddleware } from "./activities/chat/middleware/builder.js";
import { CUSTOM_EVENT, isCustomEvent } from "./custom-events.js";
import { buildBaseUsage } from "./utilities/usage.js";
import { normalizeSystemPrompts } from "./system-prompts.js";
import { detectImageMimeType } from "./utils.js";
import { createRealtimeEventEmitter } from "./realtime/event-emitter.js";
import { realtimeToken } from "./realtime/index.js";
import { PartialJSONParser, defaultJSONParser, parsePartialJSON } from "./activities/chat/stream/json-parser.js";
import { BatchStrategy, CompositeStrategy, ImmediateStrategy, PunctuationStrategy, WordBoundaryStrategy } from "./activities/chat/stream/strategies.js";
import { StreamProcessor, createReplayStream } from "./activities/chat/stream/processor.js";
import { chatParamsFromRequest, chatParamsFromRequestBody, mergeAgentTools } from "./utilities/chat-params.js";
import { uiMessagesToWire } from "./utilities/ag-ui-wire.js";
import { generationParamsFromBody, generationParamsFromRequest } from "./client.js";
import { createModel, extendAdapter } from "./extend-adapter.js";
export { BatchStrategy, CUSTOM_EVENT, CompositeStrategy, ConsoleLogger, DISCOVERY_TOOL_NAME, DetachableRunCapability, EventType, INTERRUPT_BINDING_METADATA_KEY, INTERRUPT_BINDING_VERSION, ImmediateStrategy, InMemoryRunStore, InterruptResumeValidationError, MCPDuplicateToolNameError, PartialJSONParser, PunctuationStrategy, RUN_ACCEPTED_EVENT, RUN_CANCEL_REASON, RunDetachedCapability, StandardSchemaValidationError, StreamProcessor, ToolCallManager, WordBoundaryStrategy, brandProviderTool, buildBaseUsage, canonicalInterruptJson, canonicalizeInterruptResolutions, chat, chatParamsFromRequest, chatParamsFromRequestBody, cloneAndDeepFreezeJson, combineStrategies, convertMessagesToModelMessages, convertSchemaToJsonSchema, createAudioOptions, createCapability, createChatMiddleware, createChatOptions, createFrozenRegistry, createImageOptions, createModel, createRealtimeEventEmitter, createReplayStream, createSpeechOptions, createSummarizeOptions, createToolRegistry, createTranscriptionOptions, createVideoOptions, defaultJSONParser, defineChatMiddleware, defineRunStore, detectImageMimeType, digestInterruptJson, extendAdapter, firstSentence, generateAudio, generateImage, generateMessageId, generateSpeech, generateTranscription, generateVideo, generationParamsFromBody, generationParamsFromRequest, getDetachableRun, getProviderExecutedMetadata, getRunDetached, getVideoJobStatus, hashSchemaInput, interruptItemError, isCancelRequestedReason, isContentPart, isContentPartArray, isCustomEvent, isProviderExecutedToolCall, isRunStatus, isStandardSchema, isTerminalRunStatus, maxIterations, memoryStream, mergeAgentTools, modelMessageToUIMessage, modelMessagesToUIMessages, normalizeApprovalSchema, normalizeSystemPrompts, normalizeToUIMessage, normalizeToolResult, parsePartialJSON, parseWithStandardSchema, provideDetachableRun, provideRunDetached, readInterruptBinding, readUnopenedInterruptBinding, realtimeToken, renderLazyCatalogEntry, replayRunStream, requestRunCancel, resolveMediaPrompt, resolveResumeRunId, resumeHttpResponse, resumeServerSentEventsResponse, streamToText, summarize, toHttpResponse, toHttpStream, toServerSentEventsResponse, toServerSentEventsStream, toolDefinition, uiMessageToModelMessages, uiMessagesToWire, untilFinishReason, validateInterruptResumeBatch, validateWithStandardSchema, wasCancelRequested, withInterruptBinding, withoutInterruptBinding };