@flutchai/flutch-sdk 0.2.21 → 0.4.0
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 +182 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +181 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ import { BaseChannel, OverwriteValue, CompiledStateGraph, LangGraphRunnableConfi
|
|
|
6
6
|
import { MongoClient, Db } from 'mongodb';
|
|
7
7
|
import Redis from 'ioredis';
|
|
8
8
|
import { Registry } from 'prom-client';
|
|
9
|
-
import { Response, Request } from 'express';
|
|
9
|
+
import { Response, Request as Request$1 } from 'express';
|
|
10
10
|
import { DiscoveryService, MetadataScanner, ModuleRef } from '@nestjs/core';
|
|
11
11
|
import { AIMessageChunk, ToolMessage, AIMessage } from '@langchain/core/messages';
|
|
12
12
|
import { Runnable, RunnableConfig } from '@langchain/core/runnables';
|
|
@@ -822,7 +822,7 @@ declare function getCallbackMetadata(target: any): CallbackMetadata[];
|
|
|
822
822
|
declare function hasCallbacks(target: any): boolean;
|
|
823
823
|
declare function findCallbackMethod(target: any, handler: string): string | symbol | null;
|
|
824
824
|
|
|
825
|
-
interface CallbackRequest extends Request {
|
|
825
|
+
interface CallbackRequest extends Request$1 {
|
|
826
826
|
callbackRecord: CallbackRecord;
|
|
827
827
|
user?: CallbackUser;
|
|
828
828
|
}
|
|
@@ -1012,6 +1012,23 @@ declare enum ChatFeature {
|
|
|
1012
1012
|
JSON_MODE = "json_mode"
|
|
1013
1013
|
}
|
|
1014
1014
|
|
|
1015
|
+
interface FlutchContext {
|
|
1016
|
+
messageId?: string;
|
|
1017
|
+
threadId?: string;
|
|
1018
|
+
agentId?: string;
|
|
1019
|
+
userId?: string;
|
|
1020
|
+
nodeName?: string;
|
|
1021
|
+
companyId?: string;
|
|
1022
|
+
accountId?: string;
|
|
1023
|
+
}
|
|
1024
|
+
declare function withFlutchContext<T>(ctx: FlutchContext, fn: () => T): T;
|
|
1025
|
+
declare function getFlutchContext(): FlutchContext | undefined;
|
|
1026
|
+
declare function isInternalMode(): boolean;
|
|
1027
|
+
declare const flutchFetch: typeof fetch;
|
|
1028
|
+
declare function flutchHeaders(): Record<string, string>;
|
|
1029
|
+
declare function flutchMistralHook(req: Request): Request;
|
|
1030
|
+
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1031
|
+
|
|
1015
1032
|
type ToolConfig = string | {
|
|
1016
1033
|
name: string;
|
|
1017
1034
|
enabled?: boolean;
|
|
@@ -1545,10 +1562,12 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1545
1562
|
private deserializeInput;
|
|
1546
1563
|
invokeGraph(graph: any, preparedPayload: any, signal?: AbortSignal): Promise<any>;
|
|
1547
1564
|
streamGraph(graph: any, preparedPayload: any, onPartial: (chunk: string) => void, signal?: AbortSignal): Promise<any>;
|
|
1565
|
+
private streamGraphInner;
|
|
1548
1566
|
private sendTraceFromAccumulator;
|
|
1549
1567
|
private sendMetricsWebhook;
|
|
1550
1568
|
private sendTraceEventsBatch;
|
|
1551
1569
|
private extractThreadId;
|
|
1570
|
+
private extractFlutchContext;
|
|
1552
1571
|
private processGraphResult;
|
|
1553
1572
|
}
|
|
1554
1573
|
|
|
@@ -1784,4 +1803,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1784
1803
|
private ensureIndex;
|
|
1785
1804
|
}
|
|
1786
1805
|
|
|
1787
|
-
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, 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 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 RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, 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, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
1806
|
+
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, 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 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 RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, 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, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { BaseChannel, OverwriteValue, CompiledStateGraph, LangGraphRunnableConfi
|
|
|
6
6
|
import { MongoClient, Db } from 'mongodb';
|
|
7
7
|
import Redis from 'ioredis';
|
|
8
8
|
import { Registry } from 'prom-client';
|
|
9
|
-
import { Response, Request } from 'express';
|
|
9
|
+
import { Response, Request as Request$1 } from 'express';
|
|
10
10
|
import { DiscoveryService, MetadataScanner, ModuleRef } from '@nestjs/core';
|
|
11
11
|
import { AIMessageChunk, ToolMessage, AIMessage } from '@langchain/core/messages';
|
|
12
12
|
import { Runnable, RunnableConfig } from '@langchain/core/runnables';
|
|
@@ -822,7 +822,7 @@ declare function getCallbackMetadata(target: any): CallbackMetadata[];
|
|
|
822
822
|
declare function hasCallbacks(target: any): boolean;
|
|
823
823
|
declare function findCallbackMethod(target: any, handler: string): string | symbol | null;
|
|
824
824
|
|
|
825
|
-
interface CallbackRequest extends Request {
|
|
825
|
+
interface CallbackRequest extends Request$1 {
|
|
826
826
|
callbackRecord: CallbackRecord;
|
|
827
827
|
user?: CallbackUser;
|
|
828
828
|
}
|
|
@@ -1012,6 +1012,23 @@ declare enum ChatFeature {
|
|
|
1012
1012
|
JSON_MODE = "json_mode"
|
|
1013
1013
|
}
|
|
1014
1014
|
|
|
1015
|
+
interface FlutchContext {
|
|
1016
|
+
messageId?: string;
|
|
1017
|
+
threadId?: string;
|
|
1018
|
+
agentId?: string;
|
|
1019
|
+
userId?: string;
|
|
1020
|
+
nodeName?: string;
|
|
1021
|
+
companyId?: string;
|
|
1022
|
+
accountId?: string;
|
|
1023
|
+
}
|
|
1024
|
+
declare function withFlutchContext<T>(ctx: FlutchContext, fn: () => T): T;
|
|
1025
|
+
declare function getFlutchContext(): FlutchContext | undefined;
|
|
1026
|
+
declare function isInternalMode(): boolean;
|
|
1027
|
+
declare const flutchFetch: typeof fetch;
|
|
1028
|
+
declare function flutchHeaders(): Record<string, string>;
|
|
1029
|
+
declare function flutchMistralHook(req: Request): Request;
|
|
1030
|
+
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1031
|
+
|
|
1015
1032
|
type ToolConfig = string | {
|
|
1016
1033
|
name: string;
|
|
1017
1034
|
enabled?: boolean;
|
|
@@ -1545,10 +1562,12 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1545
1562
|
private deserializeInput;
|
|
1546
1563
|
invokeGraph(graph: any, preparedPayload: any, signal?: AbortSignal): Promise<any>;
|
|
1547
1564
|
streamGraph(graph: any, preparedPayload: any, onPartial: (chunk: string) => void, signal?: AbortSignal): Promise<any>;
|
|
1565
|
+
private streamGraphInner;
|
|
1548
1566
|
private sendTraceFromAccumulator;
|
|
1549
1567
|
private sendMetricsWebhook;
|
|
1550
1568
|
private sendTraceEventsBatch;
|
|
1551
1569
|
private extractThreadId;
|
|
1570
|
+
private extractFlutchContext;
|
|
1552
1571
|
private processGraphResult;
|
|
1553
1572
|
}
|
|
1554
1573
|
|
|
@@ -1784,4 +1803,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1784
1803
|
private ensureIndex;
|
|
1785
1804
|
}
|
|
1786
1805
|
|
|
1787
|
-
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, 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 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 RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, 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, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
1806
|
+
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, 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 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 RetrieveQueryOptions, type RetrieverConfig, RetrieverSearchType, RetrieverService, type RouterConfig, 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, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable, Inject, Get, Post, Body, Res, Param, Controller, UseGuards, Req, Logger, Optional, Module, UnauthorizedException, ValidationPipe, HttpException, HttpStatus, ForbiddenException, NotFoundException, InternalServerErrorException, Headers } from '@nestjs/common';
|
|
1
|
+
import { Injectable, Inject, Get, Post, Body, Res, Param, Controller, UseGuards, Req, Logger, Optional, Module, UnauthorizedException, ValidationPipe, HttpException, HttpStatus, ForbiddenException, NotFoundException, InternalServerErrorException, Headers as Headers$1 } from '@nestjs/common';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import { ApiOperation, ApiResponse, ApiParam, ApiTags, DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
4
4
|
import * as fs from 'fs';
|
|
@@ -14,6 +14,7 @@ import { createHash, randomUUID, randomBytes } from 'crypto';
|
|
|
14
14
|
import { Registry, collectDefaultMetrics, Counter, Histogram, Gauge } from 'prom-client';
|
|
15
15
|
import { ToolMessage, AIMessage } from '@langchain/core/messages';
|
|
16
16
|
import * as LangGraph from '@langchain/langgraph';
|
|
17
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
17
18
|
import { dispatchCustomEvent } from '@langchain/core/callbacks/dispatch';
|
|
18
19
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
19
20
|
import { z } from 'zod';
|
|
@@ -22,6 +23,7 @@ import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
|
22
23
|
import { parseCallbackConfigArg, CallbackManager } from '@langchain/core/callbacks/manager';
|
|
23
24
|
import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai';
|
|
24
25
|
import { ChatBedrockConverse } from '@langchain/aws';
|
|
26
|
+
import { fetcher } from 'cohere-ai/core';
|
|
25
27
|
import { ChatAnthropic } from '@langchain/anthropic';
|
|
26
28
|
import { ChatCohere, CohereRerank } from '@langchain/cohere';
|
|
27
29
|
import { CohereClient } from 'cohere-ai';
|
|
@@ -543,7 +545,7 @@ var init_ui_dispatch_controller = __esm({
|
|
|
543
545
|
ApiResponse({ status: 200, description: "Graph manifest" }),
|
|
544
546
|
ApiResponse({ status: 404, description: "Graph not found" }),
|
|
545
547
|
__decorateParam(0, Param("graphType")),
|
|
546
|
-
__decorateParam(1, Headers("x-user-id"))
|
|
548
|
+
__decorateParam(1, Headers$1("x-user-id"))
|
|
547
549
|
], UIDispatchController.prototype, "getGraphManifest", 1);
|
|
548
550
|
__decorateClass([
|
|
549
551
|
Get(":graphType/endpoints"),
|
|
@@ -554,7 +556,7 @@ var init_ui_dispatch_controller = __esm({
|
|
|
554
556
|
type: [String]
|
|
555
557
|
}),
|
|
556
558
|
__decorateParam(0, Param("graphType")),
|
|
557
|
-
__decorateParam(1, Headers("x-user-id"))
|
|
559
|
+
__decorateParam(1, Headers$1("x-user-id"))
|
|
558
560
|
], UIDispatchController.prototype, "listEndpoints", 1);
|
|
559
561
|
__decorateClass([
|
|
560
562
|
Get("catalog"),
|
|
@@ -563,8 +565,8 @@ var init_ui_dispatch_controller = __esm({
|
|
|
563
565
|
status: 200,
|
|
564
566
|
description: "List of graphs with basic info"
|
|
565
567
|
}),
|
|
566
|
-
__decorateParam(0, Headers("x-user-id")),
|
|
567
|
-
__decorateParam(1, Headers("x-company-id"))
|
|
568
|
+
__decorateParam(0, Headers$1("x-user-id")),
|
|
569
|
+
__decorateParam(1, Headers$1("x-company-id"))
|
|
568
570
|
], UIDispatchController.prototype, "getGraphCatalog", 1);
|
|
569
571
|
UIDispatchController = __decorateClass([
|
|
570
572
|
ApiTags("UI Dispatch"),
|
|
@@ -5272,6 +5274,92 @@ var EventProcessor = class {
|
|
|
5272
5274
|
EventProcessor = __decorateClass([
|
|
5273
5275
|
Injectable()
|
|
5274
5276
|
], EventProcessor);
|
|
5277
|
+
var als = new AsyncLocalStorage();
|
|
5278
|
+
function withFlutchContext(ctx, fn) {
|
|
5279
|
+
return als.run(ctx, fn);
|
|
5280
|
+
}
|
|
5281
|
+
function getFlutchContext() {
|
|
5282
|
+
return als.getStore();
|
|
5283
|
+
}
|
|
5284
|
+
var HEADER_MAP = {
|
|
5285
|
+
messageId: "x-flutch-message-id",
|
|
5286
|
+
threadId: "x-flutch-thread-id",
|
|
5287
|
+
agentId: "x-flutch-agent-id",
|
|
5288
|
+
userId: "x-flutch-user-id",
|
|
5289
|
+
nodeName: "x-flutch-node",
|
|
5290
|
+
companyId: "x-flutch-company-id",
|
|
5291
|
+
accountId: "x-flutch-account-id"
|
|
5292
|
+
};
|
|
5293
|
+
var INTERNAL_TOKEN_HEADER = "x-flutch-internal-token";
|
|
5294
|
+
function isInternalMode() {
|
|
5295
|
+
return !!process.env.FLUTCHROUTER_INTERNAL_TOKEN;
|
|
5296
|
+
}
|
|
5297
|
+
function internalToken() {
|
|
5298
|
+
const v = process.env.FLUTCHROUTER_INTERNAL_TOKEN;
|
|
5299
|
+
return v && v.length > 0 ? v : void 0;
|
|
5300
|
+
}
|
|
5301
|
+
var flutchFetch = (input, init) => {
|
|
5302
|
+
const ctx = als.getStore();
|
|
5303
|
+
const tok = internalToken();
|
|
5304
|
+
if (!ctx && !tok) {
|
|
5305
|
+
return fetch(input, init);
|
|
5306
|
+
}
|
|
5307
|
+
const headers = new Headers(init?.headers);
|
|
5308
|
+
if (ctx) {
|
|
5309
|
+
for (const key of Object.keys(HEADER_MAP)) {
|
|
5310
|
+
const value = ctx[key];
|
|
5311
|
+
if (value) {
|
|
5312
|
+
headers.set(HEADER_MAP[key], String(value));
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
if (tok) {
|
|
5317
|
+
headers.set(INTERNAL_TOKEN_HEADER, tok);
|
|
5318
|
+
}
|
|
5319
|
+
return fetch(input, { ...init, headers });
|
|
5320
|
+
};
|
|
5321
|
+
function flutchHeaders() {
|
|
5322
|
+
const ctx = als.getStore();
|
|
5323
|
+
const tok = internalToken();
|
|
5324
|
+
const out = {};
|
|
5325
|
+
if (ctx) {
|
|
5326
|
+
for (const key of Object.keys(HEADER_MAP)) {
|
|
5327
|
+
const value = ctx[key];
|
|
5328
|
+
if (value) {
|
|
5329
|
+
out[HEADER_MAP[key]] = String(value);
|
|
5330
|
+
}
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
if (tok) {
|
|
5334
|
+
out[INTERNAL_TOKEN_HEADER] = tok;
|
|
5335
|
+
}
|
|
5336
|
+
return out;
|
|
5337
|
+
}
|
|
5338
|
+
function flutchMistralHook(req) {
|
|
5339
|
+
const extras = flutchHeaders();
|
|
5340
|
+
if (Object.keys(extras).length === 0) {
|
|
5341
|
+
return req;
|
|
5342
|
+
}
|
|
5343
|
+
const headers = new Headers(req.headers);
|
|
5344
|
+
for (const [k, v] of Object.entries(extras)) {
|
|
5345
|
+
headers.set(k, v);
|
|
5346
|
+
}
|
|
5347
|
+
return new Request(req, { headers });
|
|
5348
|
+
}
|
|
5349
|
+
function wrapCohereFetcher(inner) {
|
|
5350
|
+
return ((args) => {
|
|
5351
|
+
const extras = flutchHeaders();
|
|
5352
|
+
if (Object.keys(extras).length === 0) {
|
|
5353
|
+
return inner(args);
|
|
5354
|
+
}
|
|
5355
|
+
return inner({
|
|
5356
|
+
...args,
|
|
5357
|
+
headers: { ...args.headers ?? {}, ...extras }
|
|
5358
|
+
});
|
|
5359
|
+
});
|
|
5360
|
+
}
|
|
5361
|
+
|
|
5362
|
+
// src/engines/langgraph/langgraph-engine.ts
|
|
5275
5363
|
process.setMaxListeners(0);
|
|
5276
5364
|
var LangGraphEngine = class {
|
|
5277
5365
|
constructor(eventProcessor, configService) {
|
|
@@ -5323,29 +5411,42 @@ var LangGraphEngine = class {
|
|
|
5323
5411
|
* Method to invoke LangGraph
|
|
5324
5412
|
*/
|
|
5325
5413
|
async invokeGraph(graph, preparedPayload, signal) {
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5414
|
+
return withFlutchContext(
|
|
5415
|
+
this.extractFlutchContext(preparedPayload),
|
|
5416
|
+
async () => {
|
|
5417
|
+
this.logger.debug("invokeGraph preparedPayload", preparedPayload);
|
|
5418
|
+
if (signal) {
|
|
5419
|
+
preparedPayload.signal = signal;
|
|
5420
|
+
this.logger.debug(
|
|
5421
|
+
"[ENGINE] Signal assigned to preparedPayload.signal"
|
|
5422
|
+
);
|
|
5423
|
+
}
|
|
5424
|
+
const input = await this.deserializeInput(preparedPayload.input || {});
|
|
5425
|
+
try {
|
|
5426
|
+
const result = await graph.invoke(input, {
|
|
5427
|
+
...preparedPayload.config,
|
|
5428
|
+
signal: preparedPayload.signal
|
|
5429
|
+
});
|
|
5430
|
+
return this.processGraphResult(result);
|
|
5431
|
+
} finally {
|
|
5432
|
+
const threadId = this.extractThreadId(preparedPayload);
|
|
5433
|
+
if (threadId) {
|
|
5434
|
+
clearAttachmentDataStore(threadId);
|
|
5435
|
+
this.logger.debug(
|
|
5436
|
+
`[ENGINE] Cleared attachment data store for thread: ${threadId}`
|
|
5437
|
+
);
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5345
5440
|
}
|
|
5346
|
-
|
|
5441
|
+
);
|
|
5347
5442
|
}
|
|
5348
5443
|
async streamGraph(graph, preparedPayload, onPartial, signal) {
|
|
5444
|
+
return withFlutchContext(
|
|
5445
|
+
this.extractFlutchContext(preparedPayload),
|
|
5446
|
+
() => this.streamGraphInner(graph, preparedPayload, onPartial, signal)
|
|
5447
|
+
);
|
|
5448
|
+
}
|
|
5449
|
+
async streamGraphInner(graph, preparedPayload, onPartial, signal) {
|
|
5349
5450
|
const acc = this.eventProcessor.createAccumulator();
|
|
5350
5451
|
let streamError = null;
|
|
5351
5452
|
this.logger.debug({
|
|
@@ -5461,8 +5562,8 @@ var LangGraphEngine = class {
|
|
|
5461
5562
|
async sendMetricsWebhook(payload) {
|
|
5462
5563
|
try {
|
|
5463
5564
|
const backendUrl = this.configService?.get("API_URL") || "http://amelie-service";
|
|
5464
|
-
const
|
|
5465
|
-
if (!
|
|
5565
|
+
const internalToken2 = this.configService?.get("INTERNAL_API_TOKEN");
|
|
5566
|
+
if (!internalToken2) {
|
|
5466
5567
|
this.logger.warn(
|
|
5467
5568
|
"[METRICS-WEBHOOK] INTERNAL_API_TOKEN not configured, skipping webhook"
|
|
5468
5569
|
);
|
|
@@ -5478,7 +5579,7 @@ var LangGraphEngine = class {
|
|
|
5478
5579
|
method: "POST",
|
|
5479
5580
|
headers: {
|
|
5480
5581
|
"Content-Type": "application/json",
|
|
5481
|
-
"x-internal-token":
|
|
5582
|
+
"x-internal-token": internalToken2
|
|
5482
5583
|
},
|
|
5483
5584
|
body: JSON.stringify(payload)
|
|
5484
5585
|
});
|
|
@@ -5501,8 +5602,8 @@ var LangGraphEngine = class {
|
|
|
5501
5602
|
async sendTraceEventsBatch(payload) {
|
|
5502
5603
|
try {
|
|
5503
5604
|
const backendUrl = this.configService?.get("API_URL") || "http://amelie-service";
|
|
5504
|
-
const
|
|
5505
|
-
if (!
|
|
5605
|
+
const internalToken2 = this.configService?.get("INTERNAL_API_TOKEN");
|
|
5606
|
+
if (!internalToken2) {
|
|
5506
5607
|
this.logger.warn(
|
|
5507
5608
|
"[TRACE-EVENTS-BATCH] INTERNAL_API_TOKEN not configured, skipping batch webhook"
|
|
5508
5609
|
);
|
|
@@ -5545,7 +5646,7 @@ var LangGraphEngine = class {
|
|
|
5545
5646
|
method: "POST",
|
|
5546
5647
|
headers: {
|
|
5547
5648
|
"Content-Type": "application/json",
|
|
5548
|
-
"x-internal-token":
|
|
5649
|
+
"x-internal-token": internalToken2
|
|
5549
5650
|
},
|
|
5550
5651
|
body: JSON.stringify(batchPayload)
|
|
5551
5652
|
});
|
|
@@ -5575,6 +5676,22 @@ var LangGraphEngine = class {
|
|
|
5575
5676
|
extractThreadId(preparedPayload) {
|
|
5576
5677
|
return preparedPayload.configurable?.thread_id || preparedPayload.configurable?.context?.threadId || preparedPayload.config?.configurable?.thread_id || preparedPayload.config?.configurable?.context?.threadId || void 0;
|
|
5577
5678
|
}
|
|
5679
|
+
/**
|
|
5680
|
+
* Extract Flutch billing/attribution context from the prepared payload.
|
|
5681
|
+
*
|
|
5682
|
+
* Read by `flutchFetch` (in node-sdk/src/models/flutch-context.ts) to
|
|
5683
|
+
* attach X-Flutch-* headers to every router-bound LLM call made during
|
|
5684
|
+
* this graph run.
|
|
5685
|
+
*/
|
|
5686
|
+
extractFlutchContext(preparedPayload) {
|
|
5687
|
+
const ctx = preparedPayload?.config?.configurable?.context || preparedPayload?.configurable?.context || {};
|
|
5688
|
+
return {
|
|
5689
|
+
messageId: ctx.messageId,
|
|
5690
|
+
threadId: ctx.threadId || preparedPayload?.config?.configurable?.thread_id,
|
|
5691
|
+
agentId: ctx.agentId,
|
|
5692
|
+
userId: ctx.userId
|
|
5693
|
+
};
|
|
5694
|
+
}
|
|
5578
5695
|
/**
|
|
5579
5696
|
* Process graph execution result
|
|
5580
5697
|
*/
|
|
@@ -6730,7 +6847,10 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6730
6847
|
);
|
|
6731
6848
|
const routerURL = resolveRouterURL(baseURL);
|
|
6732
6849
|
if (routerURL) {
|
|
6733
|
-
config.configuration = {
|
|
6850
|
+
config.configuration = {
|
|
6851
|
+
baseURL: `${routerURL}/v1`,
|
|
6852
|
+
fetch: flutchFetch
|
|
6853
|
+
};
|
|
6734
6854
|
}
|
|
6735
6855
|
return new ChatOpenAI(config);
|
|
6736
6856
|
},
|
|
@@ -6740,15 +6860,19 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6740
6860
|
defaultMaxTokens,
|
|
6741
6861
|
apiToken,
|
|
6742
6862
|
baseURL
|
|
6743
|
-
}) =>
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6863
|
+
}) => {
|
|
6864
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6865
|
+
return new ChatAnthropic({
|
|
6866
|
+
modelName,
|
|
6867
|
+
temperature: defaultTemperature,
|
|
6868
|
+
maxTokens: defaultMaxTokens,
|
|
6869
|
+
anthropicApiKey: apiToken || this.resolveApiKey("anthropic" /* ANTHROPIC */),
|
|
6870
|
+
...routerURL && {
|
|
6871
|
+
anthropicApiUrl: routerURL,
|
|
6872
|
+
clientOptions: { fetch: flutchFetch }
|
|
6873
|
+
}
|
|
6874
|
+
});
|
|
6875
|
+
},
|
|
6752
6876
|
["cohere" /* COHERE */]: ({
|
|
6753
6877
|
modelName,
|
|
6754
6878
|
defaultTemperature,
|
|
@@ -6761,7 +6885,13 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6761
6885
|
return routerURL ? new ChatCohere({
|
|
6762
6886
|
model: modelName,
|
|
6763
6887
|
temperature: defaultTemperature,
|
|
6764
|
-
client: new CohereClient({
|
|
6888
|
+
client: new CohereClient({
|
|
6889
|
+
token,
|
|
6890
|
+
baseUrl: routerURL,
|
|
6891
|
+
// Inject X-Flutch-* headers from the ALS context on every
|
|
6892
|
+
// outbound request via the wrapped default fetcher.
|
|
6893
|
+
fetcher: wrapCohereFetcher(fetcher)
|
|
6894
|
+
})
|
|
6765
6895
|
}) : new ChatCohere({
|
|
6766
6896
|
model: modelName,
|
|
6767
6897
|
temperature: defaultTemperature,
|
|
@@ -6781,7 +6911,13 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6781
6911
|
temperature: defaultTemperature,
|
|
6782
6912
|
maxTokens: defaultMaxTokens,
|
|
6783
6913
|
apiKey: apiToken || this.resolveApiKey("mistral" /* MISTRAL */),
|
|
6784
|
-
...routerURL && {
|
|
6914
|
+
...routerURL && {
|
|
6915
|
+
serverURL: `${routerURL}/v1`,
|
|
6916
|
+
// Mistral SDK doesn't accept a custom fetch directly — its
|
|
6917
|
+
// beforeRequestHooks let us mutate the outgoing Request to add
|
|
6918
|
+
// X-Flutch-* headers from the ALS context.
|
|
6919
|
+
beforeRequestHooks: [flutchMistralHook]
|
|
6920
|
+
}
|
|
6785
6921
|
});
|
|
6786
6922
|
},
|
|
6787
6923
|
["voyageai" /* VOYAGEAI */]: () => {
|
|
@@ -6836,7 +6972,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6836
6972
|
model: modelName,
|
|
6837
6973
|
apiKey: apiToken || this.resolveApiKey("openai" /* OPENAI */),
|
|
6838
6974
|
...routerURL && {
|
|
6839
|
-
configuration: { baseURL: `${routerURL}/v1
|
|
6975
|
+
configuration: { baseURL: `${routerURL}/v1`, fetch: flutchFetch }
|
|
6840
6976
|
}
|
|
6841
6977
|
});
|
|
6842
6978
|
},
|
|
@@ -7782,6 +7918,6 @@ var MongoTokenStore = class {
|
|
|
7782
7918
|
}
|
|
7783
7919
|
};
|
|
7784
7920
|
|
|
7785
|
-
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, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, RetrieverSearchType, RetrieverService, 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, generateAttachmentSummary, generateModelCacheKey, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, hashToolsConfig, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
7921
|
+
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, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, MongoTokenStore, OAuthTokenManager, RetrieverSearchType, RetrieverService, 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, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
7786
7922
|
//# sourceMappingURL=index.js.map
|
|
7787
7923
|
//# sourceMappingURL=index.js.map
|