@flutchai/flutch-sdk 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +106 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -55
- package/dist/index.d.ts +79 -55
- package/dist/index.js +102 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1031,6 +1031,76 @@ declare function flutchHeaders(): Record<string, string>;
|
|
|
1031
1031
|
declare function flutchMistralHook(req: Request): Request;
|
|
1032
1032
|
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1033
1033
|
|
|
1034
|
+
interface IAgentToolConfig {
|
|
1035
|
+
toolName: string;
|
|
1036
|
+
enabled: boolean;
|
|
1037
|
+
config?: Record<string, any>;
|
|
1038
|
+
}
|
|
1039
|
+
interface IAgentToolConfiguration {
|
|
1040
|
+
toolName: string;
|
|
1041
|
+
enabled: boolean;
|
|
1042
|
+
config?: Record<string, any>;
|
|
1043
|
+
credentials?: Record<string, string>;
|
|
1044
|
+
useGlobalCredentials?: boolean;
|
|
1045
|
+
}
|
|
1046
|
+
interface ISystemToolCredentials {
|
|
1047
|
+
toolName: string;
|
|
1048
|
+
credentials: Record<string, string>;
|
|
1049
|
+
createdBy: string;
|
|
1050
|
+
createdAt: Date;
|
|
1051
|
+
updatedAt: Date;
|
|
1052
|
+
}
|
|
1053
|
+
interface IToolExecutionContext {
|
|
1054
|
+
toolName: string;
|
|
1055
|
+
config: Record<string, any>;
|
|
1056
|
+
credentials: Record<string, string>;
|
|
1057
|
+
agentId: string;
|
|
1058
|
+
userId: string;
|
|
1059
|
+
threadId?: string;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
declare function isReasoningModel(modelName: string): boolean;
|
|
1063
|
+
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1064
|
+
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1065
|
+
major: number;
|
|
1066
|
+
minor: number;
|
|
1067
|
+
}>;
|
|
1068
|
+
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1069
|
+
declare const PROMPT_CACHE_MIN_VERSIONS: Record<string, {
|
|
1070
|
+
major: number;
|
|
1071
|
+
minor: number;
|
|
1072
|
+
}>;
|
|
1073
|
+
type PromptCacheTtl = "5m" | "1h";
|
|
1074
|
+
interface PromptCacheControl {
|
|
1075
|
+
type: "ephemeral";
|
|
1076
|
+
ttl?: PromptCacheTtl;
|
|
1077
|
+
}
|
|
1078
|
+
declare function modelSupportsPromptCache(modelIdentifier?: string): boolean;
|
|
1079
|
+
declare function resolvePromptCacheControl(modelIdentifiers: (string | undefined)[], promptCache?: boolean, ttl?: PromptCacheTtl): PromptCacheControl | undefined;
|
|
1080
|
+
type ReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
1081
|
+
declare function buildEffortRequestFields(effort?: ReasoningEffort): {
|
|
1082
|
+
output_config: {
|
|
1083
|
+
effort: ReasoningEffort;
|
|
1084
|
+
};
|
|
1085
|
+
} | undefined;
|
|
1086
|
+
interface SamplingParams {
|
|
1087
|
+
temperature?: number;
|
|
1088
|
+
topP?: number;
|
|
1089
|
+
topK?: number;
|
|
1090
|
+
}
|
|
1091
|
+
interface ResolvedSamplingParams {
|
|
1092
|
+
params: SamplingParams;
|
|
1093
|
+
dropped: string[];
|
|
1094
|
+
accepted: boolean;
|
|
1095
|
+
}
|
|
1096
|
+
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1097
|
+
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1098
|
+
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1099
|
+
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1100
|
+
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1101
|
+
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1102
|
+
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1103
|
+
|
|
1034
1104
|
type ToolConfig = string | {
|
|
1035
1105
|
name: string;
|
|
1036
1106
|
enabled?: boolean;
|
|
@@ -1057,6 +1127,9 @@ interface ModelByIdConfig {
|
|
|
1057
1127
|
customTools?: DynamicStructuredTool[];
|
|
1058
1128
|
mcpServers?: Record<string, any>[];
|
|
1059
1129
|
mcpContext?: Record<string, any>;
|
|
1130
|
+
promptCache?: boolean;
|
|
1131
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1132
|
+
effort?: ReasoningEffort;
|
|
1060
1133
|
}
|
|
1061
1134
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1062
1135
|
interface ModelConfigWithToken {
|
|
@@ -1070,6 +1143,9 @@ interface ModelConfigWithToken {
|
|
|
1070
1143
|
supportsSamplingParams?: boolean;
|
|
1071
1144
|
useBedrock?: boolean;
|
|
1072
1145
|
bedrockModelId?: string;
|
|
1146
|
+
promptCache?: boolean;
|
|
1147
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1148
|
+
defaultEffort?: ReasoningEffort;
|
|
1073
1149
|
baseURL?: string;
|
|
1074
1150
|
}
|
|
1075
1151
|
type ApiKeyResolver = (provider: ModelProvider) => string | undefined;
|
|
@@ -1100,7 +1176,7 @@ interface IModelInitializer {
|
|
|
1100
1176
|
isModelTypeSupported(modelType: ModelType): boolean;
|
|
1101
1177
|
getSupportedModelTypes(): ModelType[];
|
|
1102
1178
|
}
|
|
1103
|
-
type ChatModelCreator = (config: ModelConfigWithTokenAndType) => BaseChatModel;
|
|
1179
|
+
type ChatModelCreator = (config: ModelConfigWithTokenAndType, promptCacheControl?: PromptCacheControl) => BaseChatModel;
|
|
1104
1180
|
type RerankModelCreator = (config: ModelConfigWithTokenAndType) => BaseDocumentCompressor;
|
|
1105
1181
|
type EmbeddingModelCreator = (config: ModelConfigWithTokenAndType) => Embeddings;
|
|
1106
1182
|
interface ModelCreators {
|
|
@@ -1152,59 +1228,6 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1152
1228
|
private fetchFromApi;
|
|
1153
1229
|
}
|
|
1154
1230
|
|
|
1155
|
-
interface IAgentToolConfig {
|
|
1156
|
-
toolName: string;
|
|
1157
|
-
enabled: boolean;
|
|
1158
|
-
config?: Record<string, any>;
|
|
1159
|
-
}
|
|
1160
|
-
interface IAgentToolConfiguration {
|
|
1161
|
-
toolName: string;
|
|
1162
|
-
enabled: boolean;
|
|
1163
|
-
config?: Record<string, any>;
|
|
1164
|
-
credentials?: Record<string, string>;
|
|
1165
|
-
useGlobalCredentials?: boolean;
|
|
1166
|
-
}
|
|
1167
|
-
interface ISystemToolCredentials {
|
|
1168
|
-
toolName: string;
|
|
1169
|
-
credentials: Record<string, string>;
|
|
1170
|
-
createdBy: string;
|
|
1171
|
-
createdAt: Date;
|
|
1172
|
-
updatedAt: Date;
|
|
1173
|
-
}
|
|
1174
|
-
interface IToolExecutionContext {
|
|
1175
|
-
toolName: string;
|
|
1176
|
-
config: Record<string, any>;
|
|
1177
|
-
credentials: Record<string, string>;
|
|
1178
|
-
agentId: string;
|
|
1179
|
-
userId: string;
|
|
1180
|
-
threadId?: string;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
declare function isReasoningModel(modelName: string): boolean;
|
|
1184
|
-
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1185
|
-
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1186
|
-
major: number;
|
|
1187
|
-
minor: number;
|
|
1188
|
-
}>;
|
|
1189
|
-
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1190
|
-
interface SamplingParams {
|
|
1191
|
-
temperature?: number;
|
|
1192
|
-
topP?: number;
|
|
1193
|
-
topK?: number;
|
|
1194
|
-
}
|
|
1195
|
-
interface ResolvedSamplingParams {
|
|
1196
|
-
params: SamplingParams;
|
|
1197
|
-
dropped: string[];
|
|
1198
|
-
accepted: boolean;
|
|
1199
|
-
}
|
|
1200
|
-
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1201
|
-
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1202
|
-
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1203
|
-
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1204
|
-
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1205
|
-
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1206
|
-
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1207
|
-
|
|
1208
1231
|
interface LangchainReasoningBlock {
|
|
1209
1232
|
type: "reasoning_content";
|
|
1210
1233
|
reasoningText?: {
|
|
@@ -1581,6 +1604,7 @@ interface StreamAccumulator {
|
|
|
1581
1604
|
traceStartedAt: number | null;
|
|
1582
1605
|
traceCompletedAt: number | null;
|
|
1583
1606
|
}
|
|
1607
|
+
declare function joinTextSteps(parts: string[]): string;
|
|
1584
1608
|
declare class EventProcessor {
|
|
1585
1609
|
private readonly logger;
|
|
1586
1610
|
createAccumulator(): StreamAccumulator;
|
|
@@ -1854,4 +1878,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1854
1878
|
private ensureIndex;
|
|
1855
1879
|
}
|
|
1856
1880
|
|
|
1857
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, type PostgresConfig, type RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
1881
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, PROMPT_CACHE_MIN_VERSIONS, type PostgresConfig, type PromptCacheControl, type PromptCacheTtl, type RateLimitConfig, type RateLimitResult, type ReasoningEffort, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildEffortRequestFields, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, joinTextSteps, loadOAuthProviders, modelAcceptsSamplingParams, modelSupportsPromptCache, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolvePromptCacheControl, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
package/dist/index.d.ts
CHANGED
|
@@ -1031,6 +1031,76 @@ declare function flutchHeaders(): Record<string, string>;
|
|
|
1031
1031
|
declare function flutchMistralHook(req: Request): Request;
|
|
1032
1032
|
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1033
1033
|
|
|
1034
|
+
interface IAgentToolConfig {
|
|
1035
|
+
toolName: string;
|
|
1036
|
+
enabled: boolean;
|
|
1037
|
+
config?: Record<string, any>;
|
|
1038
|
+
}
|
|
1039
|
+
interface IAgentToolConfiguration {
|
|
1040
|
+
toolName: string;
|
|
1041
|
+
enabled: boolean;
|
|
1042
|
+
config?: Record<string, any>;
|
|
1043
|
+
credentials?: Record<string, string>;
|
|
1044
|
+
useGlobalCredentials?: boolean;
|
|
1045
|
+
}
|
|
1046
|
+
interface ISystemToolCredentials {
|
|
1047
|
+
toolName: string;
|
|
1048
|
+
credentials: Record<string, string>;
|
|
1049
|
+
createdBy: string;
|
|
1050
|
+
createdAt: Date;
|
|
1051
|
+
updatedAt: Date;
|
|
1052
|
+
}
|
|
1053
|
+
interface IToolExecutionContext {
|
|
1054
|
+
toolName: string;
|
|
1055
|
+
config: Record<string, any>;
|
|
1056
|
+
credentials: Record<string, string>;
|
|
1057
|
+
agentId: string;
|
|
1058
|
+
userId: string;
|
|
1059
|
+
threadId?: string;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
declare function isReasoningModel(modelName: string): boolean;
|
|
1063
|
+
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1064
|
+
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1065
|
+
major: number;
|
|
1066
|
+
minor: number;
|
|
1067
|
+
}>;
|
|
1068
|
+
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1069
|
+
declare const PROMPT_CACHE_MIN_VERSIONS: Record<string, {
|
|
1070
|
+
major: number;
|
|
1071
|
+
minor: number;
|
|
1072
|
+
}>;
|
|
1073
|
+
type PromptCacheTtl = "5m" | "1h";
|
|
1074
|
+
interface PromptCacheControl {
|
|
1075
|
+
type: "ephemeral";
|
|
1076
|
+
ttl?: PromptCacheTtl;
|
|
1077
|
+
}
|
|
1078
|
+
declare function modelSupportsPromptCache(modelIdentifier?: string): boolean;
|
|
1079
|
+
declare function resolvePromptCacheControl(modelIdentifiers: (string | undefined)[], promptCache?: boolean, ttl?: PromptCacheTtl): PromptCacheControl | undefined;
|
|
1080
|
+
type ReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
1081
|
+
declare function buildEffortRequestFields(effort?: ReasoningEffort): {
|
|
1082
|
+
output_config: {
|
|
1083
|
+
effort: ReasoningEffort;
|
|
1084
|
+
};
|
|
1085
|
+
} | undefined;
|
|
1086
|
+
interface SamplingParams {
|
|
1087
|
+
temperature?: number;
|
|
1088
|
+
topP?: number;
|
|
1089
|
+
topK?: number;
|
|
1090
|
+
}
|
|
1091
|
+
interface ResolvedSamplingParams {
|
|
1092
|
+
params: SamplingParams;
|
|
1093
|
+
dropped: string[];
|
|
1094
|
+
accepted: boolean;
|
|
1095
|
+
}
|
|
1096
|
+
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1097
|
+
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1098
|
+
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1099
|
+
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1100
|
+
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1101
|
+
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1102
|
+
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1103
|
+
|
|
1034
1104
|
type ToolConfig = string | {
|
|
1035
1105
|
name: string;
|
|
1036
1106
|
enabled?: boolean;
|
|
@@ -1057,6 +1127,9 @@ interface ModelByIdConfig {
|
|
|
1057
1127
|
customTools?: DynamicStructuredTool[];
|
|
1058
1128
|
mcpServers?: Record<string, any>[];
|
|
1059
1129
|
mcpContext?: Record<string, any>;
|
|
1130
|
+
promptCache?: boolean;
|
|
1131
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1132
|
+
effort?: ReasoningEffort;
|
|
1060
1133
|
}
|
|
1061
1134
|
type ModelConfigFetcher = (modelId: string) => Promise<ModelConfigWithToken>;
|
|
1062
1135
|
interface ModelConfigWithToken {
|
|
@@ -1070,6 +1143,9 @@ interface ModelConfigWithToken {
|
|
|
1070
1143
|
supportsSamplingParams?: boolean;
|
|
1071
1144
|
useBedrock?: boolean;
|
|
1072
1145
|
bedrockModelId?: string;
|
|
1146
|
+
promptCache?: boolean;
|
|
1147
|
+
promptCacheTtl?: PromptCacheTtl;
|
|
1148
|
+
defaultEffort?: ReasoningEffort;
|
|
1073
1149
|
baseURL?: string;
|
|
1074
1150
|
}
|
|
1075
1151
|
type ApiKeyResolver = (provider: ModelProvider) => string | undefined;
|
|
@@ -1100,7 +1176,7 @@ interface IModelInitializer {
|
|
|
1100
1176
|
isModelTypeSupported(modelType: ModelType): boolean;
|
|
1101
1177
|
getSupportedModelTypes(): ModelType[];
|
|
1102
1178
|
}
|
|
1103
|
-
type ChatModelCreator = (config: ModelConfigWithTokenAndType) => BaseChatModel;
|
|
1179
|
+
type ChatModelCreator = (config: ModelConfigWithTokenAndType, promptCacheControl?: PromptCacheControl) => BaseChatModel;
|
|
1104
1180
|
type RerankModelCreator = (config: ModelConfigWithTokenAndType) => BaseDocumentCompressor;
|
|
1105
1181
|
type EmbeddingModelCreator = (config: ModelConfigWithTokenAndType) => Embeddings;
|
|
1106
1182
|
interface ModelCreators {
|
|
@@ -1152,59 +1228,6 @@ declare class ModelInitializer implements IModelInitializer {
|
|
|
1152
1228
|
private fetchFromApi;
|
|
1153
1229
|
}
|
|
1154
1230
|
|
|
1155
|
-
interface IAgentToolConfig {
|
|
1156
|
-
toolName: string;
|
|
1157
|
-
enabled: boolean;
|
|
1158
|
-
config?: Record<string, any>;
|
|
1159
|
-
}
|
|
1160
|
-
interface IAgentToolConfiguration {
|
|
1161
|
-
toolName: string;
|
|
1162
|
-
enabled: boolean;
|
|
1163
|
-
config?: Record<string, any>;
|
|
1164
|
-
credentials?: Record<string, string>;
|
|
1165
|
-
useGlobalCredentials?: boolean;
|
|
1166
|
-
}
|
|
1167
|
-
interface ISystemToolCredentials {
|
|
1168
|
-
toolName: string;
|
|
1169
|
-
credentials: Record<string, string>;
|
|
1170
|
-
createdBy: string;
|
|
1171
|
-
createdAt: Date;
|
|
1172
|
-
updatedAt: Date;
|
|
1173
|
-
}
|
|
1174
|
-
interface IToolExecutionContext {
|
|
1175
|
-
toolName: string;
|
|
1176
|
-
config: Record<string, any>;
|
|
1177
|
-
credentials: Record<string, string>;
|
|
1178
|
-
agentId: string;
|
|
1179
|
-
userId: string;
|
|
1180
|
-
threadId?: string;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
declare function isReasoningModel(modelName: string): boolean;
|
|
1184
|
-
declare function toOptionalNumber(value: unknown): number | undefined;
|
|
1185
|
-
declare const SAMPLING_PARAM_FREE_THRESHOLDS: Record<string, {
|
|
1186
|
-
major: number;
|
|
1187
|
-
minor: number;
|
|
1188
|
-
}>;
|
|
1189
|
-
declare function modelAcceptsSamplingParams(modelIdentifier?: string): boolean;
|
|
1190
|
-
interface SamplingParams {
|
|
1191
|
-
temperature?: number;
|
|
1192
|
-
topP?: number;
|
|
1193
|
-
topK?: number;
|
|
1194
|
-
}
|
|
1195
|
-
interface ResolvedSamplingParams {
|
|
1196
|
-
params: SamplingParams;
|
|
1197
|
-
dropped: string[];
|
|
1198
|
-
accepted: boolean;
|
|
1199
|
-
}
|
|
1200
|
-
declare function resolveSamplingParams(modelIdentifiers: (string | undefined)[], requested: SamplingParams, supportsSamplingParams?: boolean): ResolvedSamplingParams;
|
|
1201
|
-
declare function hashToolsConfig(toolsConfig: IAgentToolConfig[]): string;
|
|
1202
|
-
declare function normalizeToolConfigs(tools?: ToolConfig[]): IAgentToolConfig[] | undefined;
|
|
1203
|
-
declare const DEFAULT_ROUTER_URL = "https://router.flutch.ai";
|
|
1204
|
-
declare function resolveRouterURL(baseURL?: string): string | undefined;
|
|
1205
|
-
declare function generateModelCacheKey(modelId: string, temperature?: number, maxTokens?: number, toolsConfig?: IAgentToolConfig[], baseURL?: string): string;
|
|
1206
|
-
declare function buildOpenAIModelConfig(modelName: string, temperature: number | undefined, maxTokens: number | undefined, apiToken: string): Record<string, any>;
|
|
1207
|
-
|
|
1208
1231
|
interface LangchainReasoningBlock {
|
|
1209
1232
|
type: "reasoning_content";
|
|
1210
1233
|
reasoningText?: {
|
|
@@ -1581,6 +1604,7 @@ interface StreamAccumulator {
|
|
|
1581
1604
|
traceStartedAt: number | null;
|
|
1582
1605
|
traceCompletedAt: number | null;
|
|
1583
1606
|
}
|
|
1607
|
+
declare function joinTextSteps(parts: string[]): string;
|
|
1584
1608
|
declare class EventProcessor {
|
|
1585
1609
|
private readonly logger;
|
|
1586
1610
|
createAccumulator(): StreamAccumulator;
|
|
@@ -1854,4 +1878,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1854
1878
|
private ensureIndex;
|
|
1855
1879
|
}
|
|
1856
1880
|
|
|
1857
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, type PostgresConfig, type RateLimitConfig, type RateLimitResult, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
1881
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, type ApiKeyResolver, AttachmentType, type AuditEntry, type BaseGraphConfig, type BaseGraphContext, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, type BaseGraphState, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, type CallbackContext, CallbackController, type CallbackEntry, type CallbackHandler, type CallbackMetadata, CallbackMetrics, type CallbackPatch, type CallbackPatchHandler, CallbackPatchService, CallbackRateLimiter, type CallbackRecord, CallbackRegistry, type CallbackRequest, type CallbackResult, CallbackStore, CallbackTokenGuard, type CallbackUser, type ChannelState, type ChartType, ChatFeature, type ChatModelCreator, type ChatModelOrRunnable, type ChatModelWithTools, type CitationValue, type CompiledGraphFor, type CustomDocument, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, type DataEnvelope, ENDPOINT_METADATA_KEY, type EmbeddingModelCreator, Endpoint, type EndpointDescriptor, type EndpointHandler, type EndpointMetadata, type EndpointOptions, EndpointRegistry, EventProcessor, type ExecuteToolWithAttachmentsParams, type ExecuteToolWithAttachmentsResult, type ExtendedCallbackContext, type ExtendedCallbackHandler, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, type FlutchContext, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, type IAgentToolConfig, type IAgentToolConfiguration, type IAttachment, type IBaseEntity, type IChartDataPoint, type IChartDataset, type IChartValue, type IContentBlock, type IContentChain, type IDeletionInfo, type IGenericGraphType, type IGraphAttachment, type IGraphBuilder, type IGraphCompiler, type IGraphConfigurable, type IGraphEngine, type IGraphLogger, type IGraphManifest, type IGraphMetadata, type IGraphMetadataRegistry, type IGraphRequestPayload, type IGraphResponsePayload, type IGraphRunnableConfig, type IGraphService, type IGraphServiceRegistry, type IGraphSettingsRepository, type IGraphTraceEvent, type IGraphTracer, type IGraphTypeMetadata, type IGraphTypeRegistry, type ILangGraphConfig, type IModelInitializer, type IOAuthTokenStore, type IReasoningChain, type IReasoningStep, type IStoredMessageContent, type ISystemToolCredentials, type IToolCall, type IToolCatalog, type IToolConfigOption, type IToolExecutionContext, type ITracingEvent, type IUsageMetrics, type IUsageRecorder, type IdempotencyConfig, type IdempotencyEntry, IdempotencyManager, IdempotencyStatus, type KnowledgeBaseInfo, type LLMCallRecord, type LLMConfig, type LLModel, LangGraphEngine, type LangchainReasoningBlock, type MappedChannels, McpConverter, type McpRuntimeClient, McpRuntimeHttpClient, type McpTool, McpToolFilter, type Model, type ModelByIdConfig, type ModelByIdWithTypeConfig, type ModelConfig, type ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, PROMPT_CACHE_MIN_VERSIONS, type PostgresConfig, type PromptCacheControl, type PromptCacheTtl, type RateLimitConfig, type RateLimitResult, type ReasoningEffort, type RequestContext, type RerankModelCreator, type ResolvedSamplingParams, type RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, SAMPLING_PARAM_FREE_THRESHOLDS, type SamplingParams, type SanitizedHistory, type ServiceDiscoveryProvider, SmartCallbackRouter, StaticDiscovery, type StreamAccumulator, StreamChannel, type StrictGraphRunnableConfig, TelegramPatchHandler, type ToolConfig, type ToolExecutionResult, type TraceApiCallResult, type TracingLevel, UIDispatchController, type UIDispatchDto, UIEndpoint, type UIEndpointClassMetadata, type UIEndpointMethodMetadata, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, type UniversalGraphModuleOptions, UniversalGraphService, type VersionResolution, type VersionResolutionOptions, type VersionRoute, VersionedGraphService, type VersioningConfig, VoyageAIRerank, type VoyageAIRerankConfig, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildEffortRequestFields, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, joinTextSteps, loadOAuthProviders, modelAcceptsSamplingParams, modelSupportsPromptCache, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolvePromptCacheControl, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
package/dist/index.js
CHANGED
|
@@ -5083,6 +5083,16 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
5083
5083
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5084
5084
|
}
|
|
5085
5085
|
__name(_ts_decorate21, "_ts_decorate");
|
|
5086
|
+
function joinTextSteps(parts) {
|
|
5087
|
+
let out = "";
|
|
5088
|
+
for (const part of parts) {
|
|
5089
|
+
if (!part) continue;
|
|
5090
|
+
if (!out || /\s$/.test(out) || /^\s/.test(part)) out += part;
|
|
5091
|
+
else out += "\n\n" + part;
|
|
5092
|
+
}
|
|
5093
|
+
return out;
|
|
5094
|
+
}
|
|
5095
|
+
__name(joinTextSteps, "joinTextSteps");
|
|
5086
5096
|
var EventProcessor = class _EventProcessor {
|
|
5087
5097
|
static {
|
|
5088
5098
|
__name(this, "EventProcessor");
|
|
@@ -5518,7 +5528,7 @@ var EventProcessor = class _EventProcessor {
|
|
|
5518
5528
|
totalEvents: acc.traceEvents.length
|
|
5519
5529
|
} : null;
|
|
5520
5530
|
const textChain = allChains.find((c) => c.channel === "text");
|
|
5521
|
-
const text = textChain ? textChain.steps.filter((step) => step.type === "text").map((step) => step.text || "")
|
|
5531
|
+
const text = textChain ? joinTextSteps(textChain.steps.filter((step) => step.type === "text").map((step) => step.text || "")) : "";
|
|
5522
5532
|
this.logger.log("\u{1F4CA} [EventProcessor] Final result assembled", {
|
|
5523
5533
|
totalChains: allChains.length,
|
|
5524
5534
|
textChains: allChains.filter((c) => c.channel === "text").length,
|
|
@@ -7083,6 +7093,48 @@ function modelAcceptsSamplingParams(modelIdentifier) {
|
|
|
7083
7093
|
return !atOrAboveThreshold;
|
|
7084
7094
|
}
|
|
7085
7095
|
__name(modelAcceptsSamplingParams, "modelAcceptsSamplingParams");
|
|
7096
|
+
var PROMPT_CACHE_MIN_VERSIONS = {
|
|
7097
|
+
opus: {
|
|
7098
|
+
major: 4,
|
|
7099
|
+
minor: 0
|
|
7100
|
+
},
|
|
7101
|
+
sonnet: {
|
|
7102
|
+
major: 4,
|
|
7103
|
+
minor: 0
|
|
7104
|
+
},
|
|
7105
|
+
haiku: {
|
|
7106
|
+
major: 4,
|
|
7107
|
+
minor: 5
|
|
7108
|
+
}
|
|
7109
|
+
};
|
|
7110
|
+
function modelSupportsPromptCache(modelIdentifier) {
|
|
7111
|
+
if (!modelIdentifier) return false;
|
|
7112
|
+
const match = CLAUDE_FAMILY_VERSION.exec(modelIdentifier.toLowerCase());
|
|
7113
|
+
if (!match) return false;
|
|
7114
|
+
const [, family, majorRaw, minorRaw] = match;
|
|
7115
|
+
const threshold = PROMPT_CACHE_MIN_VERSIONS[family];
|
|
7116
|
+
if (!threshold) return false;
|
|
7117
|
+
const major = Number(majorRaw);
|
|
7118
|
+
const minor = minorRaw === void 0 ? 0 : Number(minorRaw);
|
|
7119
|
+
return major > threshold.major || major === threshold.major && minor >= threshold.minor;
|
|
7120
|
+
}
|
|
7121
|
+
__name(modelSupportsPromptCache, "modelSupportsPromptCache");
|
|
7122
|
+
function resolvePromptCacheControl(modelIdentifiers, promptCache, ttl) {
|
|
7123
|
+
const enabled = promptCache ?? modelIdentifiers.some((id) => modelSupportsPromptCache(id));
|
|
7124
|
+
return enabled ? {
|
|
7125
|
+
type: "ephemeral",
|
|
7126
|
+
ttl: ttl ?? "5m"
|
|
7127
|
+
} : void 0;
|
|
7128
|
+
}
|
|
7129
|
+
__name(resolvePromptCacheControl, "resolvePromptCacheControl");
|
|
7130
|
+
function buildEffortRequestFields(effort) {
|
|
7131
|
+
return effort ? {
|
|
7132
|
+
output_config: {
|
|
7133
|
+
effort
|
|
7134
|
+
}
|
|
7135
|
+
} : void 0;
|
|
7136
|
+
}
|
|
7137
|
+
__name(buildEffortRequestFields, "buildEffortRequestFields");
|
|
7086
7138
|
function resolveSamplingParams(modelIdentifiers, requested, supportsSamplingParams) {
|
|
7087
7139
|
const accepted = supportsSamplingParams ?? modelIdentifiers.every((id) => modelAcceptsSamplingParams(id));
|
|
7088
7140
|
if (accepted) {
|
|
@@ -7413,7 +7465,9 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7413
7465
|
generateModelCacheKey(config) {
|
|
7414
7466
|
const base = generateModelCacheKey(config.modelId, config.temperature, config.maxTokens, config.toolsConfig, config.baseURL);
|
|
7415
7467
|
const withMcp = config.mcpServers && config.mcpServers.length > 0 ? `${base}:mcp:${JSON.stringify(config.mcpServers)}` : base;
|
|
7416
|
-
|
|
7468
|
+
const withSampling = config.supportsSamplingParams === void 0 ? withMcp : `${withMcp}:sp:${config.supportsSamplingParams}`;
|
|
7469
|
+
const withCache = config.promptCache === void 0 && config.promptCacheTtl === void 0 ? withSampling : `${withSampling}:pc:${config.promptCache ?? "auto"}:${config.promptCacheTtl ?? "default"}`;
|
|
7470
|
+
return config.effort === void 0 ? withCache : `${withCache}:eff:${config.effort}`;
|
|
7417
7471
|
}
|
|
7418
7472
|
// Chat model creators
|
|
7419
7473
|
chatModelCreators = {
|
|
@@ -7428,7 +7482,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7428
7482
|
}
|
|
7429
7483
|
return new ChatOpenAI(config);
|
|
7430
7484
|
},
|
|
7431
|
-
[ModelProvider.ANTHROPIC]: ({ modelName, defaultTemperature, defaultMaxTokens, apiToken, baseURL }) => {
|
|
7485
|
+
[ModelProvider.ANTHROPIC]: ({ modelName, defaultTemperature, defaultMaxTokens, apiToken, baseURL }, promptCacheControl) => {
|
|
7432
7486
|
const routerURL = resolveRouterURL(baseURL);
|
|
7433
7487
|
return new ChatAnthropic({
|
|
7434
7488
|
modelName,
|
|
@@ -7438,6 +7492,13 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7438
7492
|
temperature: defaultTemperature
|
|
7439
7493
|
},
|
|
7440
7494
|
maxTokens: defaultMaxTokens,
|
|
7495
|
+
// Top-level prompt caching: one breakpoint on the last cacheable block,
|
|
7496
|
+
// advanced automatically as the conversation grows. Survives the router
|
|
7497
|
+
// (which forwards the Anthropic body untouched) and is accepted by
|
|
7498
|
+
// Bedrock's InvokeModel schema behind it.
|
|
7499
|
+
...promptCacheControl && {
|
|
7500
|
+
cache_control: promptCacheControl
|
|
7501
|
+
},
|
|
7441
7502
|
anthropicApiKey: apiToken || this.resolveApiKey(ModelProvider.ANTHROPIC),
|
|
7442
7503
|
...routerURL && {
|
|
7443
7504
|
anthropicApiUrl: routerURL,
|
|
@@ -7642,9 +7703,17 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7642
7703
|
defaultMaxTokens: toOptionalNumber(config.maxTokens) ?? toOptionalNumber(modelConfig.defaultMaxTokens),
|
|
7643
7704
|
baseURL: config.baseURL ?? modelConfig.baseURL
|
|
7644
7705
|
};
|
|
7706
|
+
const promptCacheControl = resolvePromptCacheControl([
|
|
7707
|
+
finalConfig.bedrockModelId,
|
|
7708
|
+
finalConfig.modelName
|
|
7709
|
+
], config.promptCache ?? modelConfig.promptCache, config.promptCacheTtl ?? modelConfig.promptCacheTtl);
|
|
7710
|
+
if (promptCacheControl) {
|
|
7711
|
+
this.logger.debug(`Prompt caching enabled for ${finalConfig.bedrockModelId ?? finalConfig.modelName} (ttl=${promptCacheControl.ttl})`);
|
|
7712
|
+
}
|
|
7645
7713
|
this.logger.debug(`Creating new chat model instance: ${cacheKey}`);
|
|
7646
7714
|
let model;
|
|
7647
7715
|
if (finalConfig.useBedrock && finalConfig.bedrockModelId) {
|
|
7716
|
+
const effortFields = buildEffortRequestFields(config.effort ?? modelConfig.defaultEffort);
|
|
7648
7717
|
model = new FlutchChatBedrockConverse({
|
|
7649
7718
|
model: finalConfig.bedrockModelId,
|
|
7650
7719
|
region: this.resolveBedrockRegion(),
|
|
@@ -7652,6 +7721,9 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7652
7721
|
...finalConfig.defaultTemperature !== void 0 && {
|
|
7653
7722
|
temperature: finalConfig.defaultTemperature
|
|
7654
7723
|
},
|
|
7724
|
+
...effortFields && {
|
|
7725
|
+
additionalModelRequestFields: effortFields
|
|
7726
|
+
},
|
|
7655
7727
|
maxTokens: finalConfig.defaultMaxTokens,
|
|
7656
7728
|
streaming: true
|
|
7657
7729
|
});
|
|
@@ -7660,14 +7732,24 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7660
7732
|
if (!creator) {
|
|
7661
7733
|
throw new Error(`Chat models not supported for provider: ${modelConfig.provider}`);
|
|
7662
7734
|
}
|
|
7663
|
-
model = creator(finalConfig);
|
|
7735
|
+
model = creator(finalConfig, promptCacheControl);
|
|
7664
7736
|
}
|
|
7665
7737
|
model.metadata = {
|
|
7666
7738
|
...model.metadata,
|
|
7667
7739
|
modelId: config.modelId
|
|
7668
7740
|
};
|
|
7669
7741
|
if (config.toolsConfig || config.customTools || config.mcpServers && config.mcpServers.length > 0) {
|
|
7670
|
-
const boundModel = await this.bindToolsToModel(
|
|
7742
|
+
const boundModel = await this.bindToolsToModel(
|
|
7743
|
+
model,
|
|
7744
|
+
config.toolsConfig,
|
|
7745
|
+
config.customTools,
|
|
7746
|
+
config.mcpServers,
|
|
7747
|
+
config.mcpContext,
|
|
7748
|
+
// Converse takes cache control as a per-call option; the Anthropic
|
|
7749
|
+
// client already got it as a constructor field, and handing it the
|
|
7750
|
+
// same value twice would put an unknown key in its call options.
|
|
7751
|
+
finalConfig.useBedrock ? promptCacheControl : void 0
|
|
7752
|
+
);
|
|
7671
7753
|
this.modelInstanceCache.set(cacheKey, boundModel);
|
|
7672
7754
|
return boundModel;
|
|
7673
7755
|
}
|
|
@@ -7679,11 +7761,20 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7679
7761
|
* For toolsConfig: fetch tool executors from MCP Runtime
|
|
7680
7762
|
* For customTools: use as-is (already prepared DynamicStructuredTool)
|
|
7681
7763
|
*
|
|
7764
|
+
* `promptCacheControl` is the **Bedrock-only** half of prompt caching: it is
|
|
7765
|
+
* bound alongside the tools as a default call option, and `ChatBedrockConverse`
|
|
7766
|
+
* turns it into `cachePoint` blocks after the tool schemas, the system prompt
|
|
7767
|
+
* and the last message. Tool schemas dominate the request, so this is the one
|
|
7768
|
+
* place worth caching — a model with no tools keeps its plain `BaseChatModel`
|
|
7769
|
+
* type and no cache points (callers there rely on `withStructuredOutput` and
|
|
7770
|
+
* friends). The Anthropic client takes its cache settings in the constructor
|
|
7771
|
+
* instead and must not be handed them again here.
|
|
7772
|
+
*
|
|
7682
7773
|
* Returns:
|
|
7683
7774
|
* - Runnable when tools are bound (model.bindTools returns Runnable)
|
|
7684
7775
|
* - BaseChatModel when no tools
|
|
7685
7776
|
*/
|
|
7686
|
-
async bindToolsToModel(model, toolsConfig, customTools, mcpServers, mcpContext) {
|
|
7777
|
+
async bindToolsToModel(model, toolsConfig, customTools, mcpServers, mcpContext, promptCacheControl) {
|
|
7687
7778
|
const allTools = [];
|
|
7688
7779
|
const enabledToolsConfig = (toolsConfig || []).filter((tc) => tc.enabled !== false);
|
|
7689
7780
|
const hasInlineServers = !!(mcpServers && mcpServers.length > 0);
|
|
@@ -7704,7 +7795,10 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
7704
7795
|
}
|
|
7705
7796
|
if (allTools.length > 0) {
|
|
7706
7797
|
this.logger.debug(`Binding ${allTools.length} tools to model`);
|
|
7707
|
-
const
|
|
7798
|
+
const boundOptions = {
|
|
7799
|
+
cache_control: promptCacheControl
|
|
7800
|
+
};
|
|
7801
|
+
const modelWithTools = promptCacheControl ? model.bindTools(allTools, boundOptions) : model.bindTools(allTools);
|
|
7708
7802
|
return modelWithTools;
|
|
7709
7803
|
}
|
|
7710
7804
|
return model;
|
|
@@ -8497,6 +8591,6 @@ var MongoTokenStore = class {
|
|
|
8497
8591
|
}
|
|
8498
8592
|
};
|
|
8499
8593
|
|
|
8500
|
-
export { AbstractGraphBuilder, AttachmentType, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, CallbackController, CallbackMetrics, CallbackPatchService, CallbackRateLimiter, CallbackRegistry, CallbackStore, CallbackTokenGuard, ChatFeature, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, ENDPOINT_METADATA_KEY, Endpoint, EndpointRegistry, EventProcessor, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, RetrieverSearchType, RetrieverService, SAMPLING_PARAM_FREE_THRESHOLDS, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, loadOAuthProviders, modelAcceptsSamplingParams, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
8594
|
+
export { AbstractGraphBuilder, AttachmentType, GraphController as BaseGraphServiceController, UniversalGraphModule as BaseGraphServiceModule, BuilderRegistryService, Callback, CallbackACL, CallbackAuditAction, CallbackAuditor, CallbackController, CallbackMetrics, CallbackPatchService, CallbackRateLimiter, CallbackRegistry, CallbackStore, CallbackTokenGuard, ChatFeature, DEFAULT_ATTACHMENT_THRESHOLD, DEFAULT_ROUTER_URL, DEFAULT_TRACER_OPTIONS, ENDPOINT_METADATA_KEY, Endpoint, EndpointRegistry, EventProcessor, ExternalGraphBuilder, FileBasedDiscovery, FileTokenStore, FlutchChatBedrockConverse, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, PROMPT_CACHE_MIN_VERSIONS, RetrieverSearchType, RetrieverService, SAMPLING_PARAM_FREE_THRESHOLDS, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, buildEffortRequestFields, buildOAuthAuthorizationUrl, buildOpenAIModelConfig, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, flutchFetch, flutchHeaders, flutchMistralHook, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getFlutchContext, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isInternalMode, isReasoningBlock, isReasoningModel, isSendableReasoningBlock, joinTextSteps, loadOAuthProviders, modelAcceptsSamplingParams, modelSupportsPromptCache, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolvePromptCacheControl, resolveRouterURL, resolveSamplingParams, sanitizeMessageReasoning, sanitizeReasoningForBedrock, sanitizeTraceData, storeAttachmentData, toOptionalNumber, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
8501
8595
|
//# sourceMappingURL=index.js.map
|
|
8502
8596
|
//# sourceMappingURL=index.js.map
|