@flutchai/flutch-sdk 0.2.20 → 0.3.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 +234 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +234 -42
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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,20 @@ 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
|
+
}
|
|
1022
|
+
declare function withFlutchContext<T>(ctx: FlutchContext, fn: () => T): T;
|
|
1023
|
+
declare function getFlutchContext(): FlutchContext | undefined;
|
|
1024
|
+
declare const flutchFetch: typeof fetch;
|
|
1025
|
+
declare function flutchHeaders(): Record<string, string>;
|
|
1026
|
+
declare function flutchMistralHook(req: Request): Request;
|
|
1027
|
+
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1028
|
+
|
|
1015
1029
|
type ToolConfig = string | {
|
|
1016
1030
|
name: string;
|
|
1017
1031
|
enabled?: boolean;
|
|
@@ -1517,6 +1531,7 @@ declare class EventProcessor {
|
|
|
1517
1531
|
private readonly logger;
|
|
1518
1532
|
createAccumulator(): StreamAccumulator;
|
|
1519
1533
|
private normalizeContentBlocks;
|
|
1534
|
+
private toolCallChunksToBlocks;
|
|
1520
1535
|
private extractAttachments;
|
|
1521
1536
|
private sendDelta;
|
|
1522
1537
|
private processContentStream;
|
|
@@ -1544,10 +1559,12 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1544
1559
|
private deserializeInput;
|
|
1545
1560
|
invokeGraph(graph: any, preparedPayload: any, signal?: AbortSignal): Promise<any>;
|
|
1546
1561
|
streamGraph(graph: any, preparedPayload: any, onPartial: (chunk: string) => void, signal?: AbortSignal): Promise<any>;
|
|
1562
|
+
private streamGraphInner;
|
|
1547
1563
|
private sendTraceFromAccumulator;
|
|
1548
1564
|
private sendMetricsWebhook;
|
|
1549
1565
|
private sendTraceEventsBatch;
|
|
1550
1566
|
private extractThreadId;
|
|
1567
|
+
private extractFlutchContext;
|
|
1551
1568
|
private processGraphResult;
|
|
1552
1569
|
}
|
|
1553
1570
|
|
|
@@ -1783,4 +1800,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1783
1800
|
private ensureIndex;
|
|
1784
1801
|
}
|
|
1785
1802
|
|
|
1786
|
-
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 };
|
|
1803
|
+
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, 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,20 @@ 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
|
+
}
|
|
1022
|
+
declare function withFlutchContext<T>(ctx: FlutchContext, fn: () => T): T;
|
|
1023
|
+
declare function getFlutchContext(): FlutchContext | undefined;
|
|
1024
|
+
declare const flutchFetch: typeof fetch;
|
|
1025
|
+
declare function flutchHeaders(): Record<string, string>;
|
|
1026
|
+
declare function flutchMistralHook(req: Request): Request;
|
|
1027
|
+
declare function wrapCohereFetcher<T extends (args: any) => any>(inner: T): T;
|
|
1028
|
+
|
|
1015
1029
|
type ToolConfig = string | {
|
|
1016
1030
|
name: string;
|
|
1017
1031
|
enabled?: boolean;
|
|
@@ -1517,6 +1531,7 @@ declare class EventProcessor {
|
|
|
1517
1531
|
private readonly logger;
|
|
1518
1532
|
createAccumulator(): StreamAccumulator;
|
|
1519
1533
|
private normalizeContentBlocks;
|
|
1534
|
+
private toolCallChunksToBlocks;
|
|
1520
1535
|
private extractAttachments;
|
|
1521
1536
|
private sendDelta;
|
|
1522
1537
|
private processContentStream;
|
|
@@ -1544,10 +1559,12 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1544
1559
|
private deserializeInput;
|
|
1545
1560
|
invokeGraph(graph: any, preparedPayload: any, signal?: AbortSignal): Promise<any>;
|
|
1546
1561
|
streamGraph(graph: any, preparedPayload: any, onPartial: (chunk: string) => void, signal?: AbortSignal): Promise<any>;
|
|
1562
|
+
private streamGraphInner;
|
|
1547
1563
|
private sendTraceFromAccumulator;
|
|
1548
1564
|
private sendMetricsWebhook;
|
|
1549
1565
|
private sendTraceEventsBatch;
|
|
1550
1566
|
private extractThreadId;
|
|
1567
|
+
private extractFlutchContext;
|
|
1551
1568
|
private processGraphResult;
|
|
1552
1569
|
}
|
|
1553
1570
|
|
|
@@ -1783,4 +1800,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
|
|
|
1783
1800
|
private ensureIndex;
|
|
1784
1801
|
}
|
|
1785
1802
|
|
|
1786
|
-
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 };
|
|
1803
|
+
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, 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"),
|
|
@@ -4787,6 +4789,36 @@ var EventProcessor = class {
|
|
|
4787
4789
|
}
|
|
4788
4790
|
return [];
|
|
4789
4791
|
}
|
|
4792
|
+
/**
|
|
4793
|
+
* Convert LangChain unified `tool_call_chunks` (Bedrock / OpenAI streaming
|
|
4794
|
+
* format) into Anthropic-style blocks so the rest of the pipeline can stay
|
|
4795
|
+
* uniform. The first chunk for a tool carries `name` (and usually `id`);
|
|
4796
|
+
* subsequent chunks carry partial `args` strings that need to accumulate.
|
|
4797
|
+
*
|
|
4798
|
+
* NOTE: assumes tool calls arrive sequentially. Parallel tool calls with
|
|
4799
|
+
* interleaved `args` chunks across different `index`es will misroute args
|
|
4800
|
+
* to the most recently opened tool_use block.
|
|
4801
|
+
*/
|
|
4802
|
+
toolCallChunksToBlocks(toolCallChunks) {
|
|
4803
|
+
const blocks = [];
|
|
4804
|
+
for (const tcc of toolCallChunks) {
|
|
4805
|
+
if (tcc.name) {
|
|
4806
|
+
blocks.push({
|
|
4807
|
+
type: "tool_use",
|
|
4808
|
+
id: tcc.id,
|
|
4809
|
+
name: tcc.name,
|
|
4810
|
+
input: ""
|
|
4811
|
+
});
|
|
4812
|
+
}
|
|
4813
|
+
if (typeof tcc.args === "string" && tcc.args.length > 0) {
|
|
4814
|
+
blocks.push({
|
|
4815
|
+
type: "input_json_delta",
|
|
4816
|
+
input: tcc.args
|
|
4817
|
+
});
|
|
4818
|
+
}
|
|
4819
|
+
}
|
|
4820
|
+
return blocks;
|
|
4821
|
+
}
|
|
4790
4822
|
/**
|
|
4791
4823
|
* Extract attachments from various input formats
|
|
4792
4824
|
* Handles both array format (IAttachment[]) and object format (Record<string, IGraphAttachment>)
|
|
@@ -4950,10 +4982,19 @@ var EventProcessor = class {
|
|
|
4950
4982
|
}
|
|
4951
4983
|
return;
|
|
4952
4984
|
}
|
|
4953
|
-
if (event.event === "on_chat_model_stream" && event.data?.chunk
|
|
4985
|
+
if (event.event === "on_chat_model_stream" && event.data?.chunk) {
|
|
4954
4986
|
const channel = event.metadata?.stream_channel ?? "text" /* TEXT */;
|
|
4955
|
-
const
|
|
4956
|
-
|
|
4987
|
+
const chunk = event.data.chunk;
|
|
4988
|
+
const blocks = [];
|
|
4989
|
+
if (chunk.content) {
|
|
4990
|
+
blocks.push(...this.normalizeContentBlocks(chunk.content));
|
|
4991
|
+
}
|
|
4992
|
+
if (Array.isArray(chunk.tool_call_chunks) && chunk.tool_call_chunks.length > 0) {
|
|
4993
|
+
blocks.push(...this.toolCallChunksToBlocks(chunk.tool_call_chunks));
|
|
4994
|
+
}
|
|
4995
|
+
if (blocks.length > 0) {
|
|
4996
|
+
this.processContentStream(acc, channel, blocks, onPartial);
|
|
4997
|
+
}
|
|
4957
4998
|
return;
|
|
4958
4999
|
}
|
|
4959
5000
|
if (event.event === "on_tool_start") {
|
|
@@ -4966,6 +5007,44 @@ var EventProcessor = class {
|
|
|
4966
5007
|
if (idx !== -1) {
|
|
4967
5008
|
const block = state.pendingToolBlocks.splice(idx, 1)[0];
|
|
4968
5009
|
state.toolBlocksByRunId.set(event.run_id, block);
|
|
5010
|
+
} else {
|
|
5011
|
+
const toolInput = event.data?.input;
|
|
5012
|
+
let inputString;
|
|
5013
|
+
try {
|
|
5014
|
+
inputString = typeof toolInput === "string" ? toolInput : JSON.stringify(toolInput ?? {});
|
|
5015
|
+
} catch {
|
|
5016
|
+
inputString = "";
|
|
5017
|
+
}
|
|
5018
|
+
const synthesizedBlock = {
|
|
5019
|
+
index: state.contentChain.length + (state.currentBlock ? 1 : 0),
|
|
5020
|
+
type: "tool_use",
|
|
5021
|
+
name: event.name,
|
|
5022
|
+
id: event.run_id,
|
|
5023
|
+
input: inputString,
|
|
5024
|
+
output: ""
|
|
5025
|
+
};
|
|
5026
|
+
if (state.currentBlock) {
|
|
5027
|
+
state.contentChain.push(state.currentBlock);
|
|
5028
|
+
state.currentBlock = null;
|
|
5029
|
+
}
|
|
5030
|
+
state.contentChain.push(synthesizedBlock);
|
|
5031
|
+
state.toolBlocksByRunId.set(event.run_id, synthesizedBlock);
|
|
5032
|
+
this.sendDelta(
|
|
5033
|
+
channel,
|
|
5034
|
+
{ type: "step_started", step: synthesizedBlock },
|
|
5035
|
+
onPartial
|
|
5036
|
+
);
|
|
5037
|
+
if (inputString.length > 0) {
|
|
5038
|
+
this.sendDelta(
|
|
5039
|
+
channel,
|
|
5040
|
+
{
|
|
5041
|
+
type: "tool_input_chunk",
|
|
5042
|
+
stepId: synthesizedBlock.id,
|
|
5043
|
+
chunk: inputString
|
|
5044
|
+
},
|
|
5045
|
+
onPartial
|
|
5046
|
+
);
|
|
5047
|
+
}
|
|
4969
5048
|
}
|
|
4970
5049
|
}
|
|
4971
5050
|
this.logger.log("\u{1F527} Tool execution started", {
|
|
@@ -5195,6 +5274,71 @@ var EventProcessor = class {
|
|
|
5195
5274
|
EventProcessor = __decorateClass([
|
|
5196
5275
|
Injectable()
|
|
5197
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
|
+
};
|
|
5291
|
+
var flutchFetch = (input, init) => {
|
|
5292
|
+
const ctx = als.getStore();
|
|
5293
|
+
if (!ctx) {
|
|
5294
|
+
return fetch(input, init);
|
|
5295
|
+
}
|
|
5296
|
+
const headers = new Headers(init?.headers);
|
|
5297
|
+
for (const key of Object.keys(HEADER_MAP)) {
|
|
5298
|
+
const value = ctx[key];
|
|
5299
|
+
if (value) {
|
|
5300
|
+
headers.set(HEADER_MAP[key], String(value));
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
return fetch(input, { ...init, headers });
|
|
5304
|
+
};
|
|
5305
|
+
function flutchHeaders() {
|
|
5306
|
+
const ctx = als.getStore();
|
|
5307
|
+
if (!ctx) return {};
|
|
5308
|
+
const out = {};
|
|
5309
|
+
for (const key of Object.keys(HEADER_MAP)) {
|
|
5310
|
+
const value = ctx[key];
|
|
5311
|
+
if (value) {
|
|
5312
|
+
out[HEADER_MAP[key]] = String(value);
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
return out;
|
|
5316
|
+
}
|
|
5317
|
+
function flutchMistralHook(req) {
|
|
5318
|
+
const extras = flutchHeaders();
|
|
5319
|
+
if (Object.keys(extras).length === 0) {
|
|
5320
|
+
return req;
|
|
5321
|
+
}
|
|
5322
|
+
const headers = new Headers(req.headers);
|
|
5323
|
+
for (const [k, v] of Object.entries(extras)) {
|
|
5324
|
+
headers.set(k, v);
|
|
5325
|
+
}
|
|
5326
|
+
return new Request(req, { headers });
|
|
5327
|
+
}
|
|
5328
|
+
function wrapCohereFetcher(inner) {
|
|
5329
|
+
return ((args) => {
|
|
5330
|
+
const extras = flutchHeaders();
|
|
5331
|
+
if (Object.keys(extras).length === 0) {
|
|
5332
|
+
return inner(args);
|
|
5333
|
+
}
|
|
5334
|
+
return inner({
|
|
5335
|
+
...args,
|
|
5336
|
+
headers: { ...args.headers ?? {}, ...extras }
|
|
5337
|
+
});
|
|
5338
|
+
});
|
|
5339
|
+
}
|
|
5340
|
+
|
|
5341
|
+
// src/engines/langgraph/langgraph-engine.ts
|
|
5198
5342
|
process.setMaxListeners(0);
|
|
5199
5343
|
var LangGraphEngine = class {
|
|
5200
5344
|
constructor(eventProcessor, configService) {
|
|
@@ -5246,29 +5390,42 @@ var LangGraphEngine = class {
|
|
|
5246
5390
|
* Method to invoke LangGraph
|
|
5247
5391
|
*/
|
|
5248
5392
|
async invokeGraph(graph, preparedPayload, signal) {
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5393
|
+
return withFlutchContext(
|
|
5394
|
+
this.extractFlutchContext(preparedPayload),
|
|
5395
|
+
async () => {
|
|
5396
|
+
this.logger.debug("invokeGraph preparedPayload", preparedPayload);
|
|
5397
|
+
if (signal) {
|
|
5398
|
+
preparedPayload.signal = signal;
|
|
5399
|
+
this.logger.debug(
|
|
5400
|
+
"[ENGINE] Signal assigned to preparedPayload.signal"
|
|
5401
|
+
);
|
|
5402
|
+
}
|
|
5403
|
+
const input = await this.deserializeInput(preparedPayload.input || {});
|
|
5404
|
+
try {
|
|
5405
|
+
const result = await graph.invoke(input, {
|
|
5406
|
+
...preparedPayload.config,
|
|
5407
|
+
signal: preparedPayload.signal
|
|
5408
|
+
});
|
|
5409
|
+
return this.processGraphResult(result);
|
|
5410
|
+
} finally {
|
|
5411
|
+
const threadId = this.extractThreadId(preparedPayload);
|
|
5412
|
+
if (threadId) {
|
|
5413
|
+
clearAttachmentDataStore(threadId);
|
|
5414
|
+
this.logger.debug(
|
|
5415
|
+
`[ENGINE] Cleared attachment data store for thread: ${threadId}`
|
|
5416
|
+
);
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5268
5419
|
}
|
|
5269
|
-
|
|
5420
|
+
);
|
|
5270
5421
|
}
|
|
5271
5422
|
async streamGraph(graph, preparedPayload, onPartial, signal) {
|
|
5423
|
+
return withFlutchContext(
|
|
5424
|
+
this.extractFlutchContext(preparedPayload),
|
|
5425
|
+
() => this.streamGraphInner(graph, preparedPayload, onPartial, signal)
|
|
5426
|
+
);
|
|
5427
|
+
}
|
|
5428
|
+
async streamGraphInner(graph, preparedPayload, onPartial, signal) {
|
|
5272
5429
|
const acc = this.eventProcessor.createAccumulator();
|
|
5273
5430
|
let streamError = null;
|
|
5274
5431
|
this.logger.debug({
|
|
@@ -5498,6 +5655,22 @@ var LangGraphEngine = class {
|
|
|
5498
5655
|
extractThreadId(preparedPayload) {
|
|
5499
5656
|
return preparedPayload.configurable?.thread_id || preparedPayload.configurable?.context?.threadId || preparedPayload.config?.configurable?.thread_id || preparedPayload.config?.configurable?.context?.threadId || void 0;
|
|
5500
5657
|
}
|
|
5658
|
+
/**
|
|
5659
|
+
* Extract Flutch billing/attribution context from the prepared payload.
|
|
5660
|
+
*
|
|
5661
|
+
* Read by `flutchFetch` (in node-sdk/src/models/flutch-context.ts) to
|
|
5662
|
+
* attach X-Flutch-* headers to every router-bound LLM call made during
|
|
5663
|
+
* this graph run.
|
|
5664
|
+
*/
|
|
5665
|
+
extractFlutchContext(preparedPayload) {
|
|
5666
|
+
const ctx = preparedPayload?.config?.configurable?.context || preparedPayload?.configurable?.context || {};
|
|
5667
|
+
return {
|
|
5668
|
+
messageId: ctx.messageId,
|
|
5669
|
+
threadId: ctx.threadId || preparedPayload?.config?.configurable?.thread_id,
|
|
5670
|
+
agentId: ctx.agentId,
|
|
5671
|
+
userId: ctx.userId
|
|
5672
|
+
};
|
|
5673
|
+
}
|
|
5501
5674
|
/**
|
|
5502
5675
|
* Process graph execution result
|
|
5503
5676
|
*/
|
|
@@ -6653,7 +6826,10 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6653
6826
|
);
|
|
6654
6827
|
const routerURL = resolveRouterURL(baseURL);
|
|
6655
6828
|
if (routerURL) {
|
|
6656
|
-
config.configuration = {
|
|
6829
|
+
config.configuration = {
|
|
6830
|
+
baseURL: `${routerURL}/v1`,
|
|
6831
|
+
fetch: flutchFetch
|
|
6832
|
+
};
|
|
6657
6833
|
}
|
|
6658
6834
|
return new ChatOpenAI(config);
|
|
6659
6835
|
},
|
|
@@ -6663,15 +6839,19 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6663
6839
|
defaultMaxTokens,
|
|
6664
6840
|
apiToken,
|
|
6665
6841
|
baseURL
|
|
6666
|
-
}) =>
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6842
|
+
}) => {
|
|
6843
|
+
const routerURL = resolveRouterURL(baseURL);
|
|
6844
|
+
return new ChatAnthropic({
|
|
6845
|
+
modelName,
|
|
6846
|
+
temperature: defaultTemperature,
|
|
6847
|
+
maxTokens: defaultMaxTokens,
|
|
6848
|
+
anthropicApiKey: apiToken || this.resolveApiKey("anthropic" /* ANTHROPIC */),
|
|
6849
|
+
...routerURL && {
|
|
6850
|
+
anthropicApiUrl: routerURL,
|
|
6851
|
+
clientOptions: { fetch: flutchFetch }
|
|
6852
|
+
}
|
|
6853
|
+
});
|
|
6854
|
+
},
|
|
6675
6855
|
["cohere" /* COHERE */]: ({
|
|
6676
6856
|
modelName,
|
|
6677
6857
|
defaultTemperature,
|
|
@@ -6684,7 +6864,13 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6684
6864
|
return routerURL ? new ChatCohere({
|
|
6685
6865
|
model: modelName,
|
|
6686
6866
|
temperature: defaultTemperature,
|
|
6687
|
-
client: new CohereClient({
|
|
6867
|
+
client: new CohereClient({
|
|
6868
|
+
token,
|
|
6869
|
+
baseUrl: routerURL,
|
|
6870
|
+
// Inject X-Flutch-* headers from the ALS context on every
|
|
6871
|
+
// outbound request via the wrapped default fetcher.
|
|
6872
|
+
fetcher: wrapCohereFetcher(fetcher)
|
|
6873
|
+
})
|
|
6688
6874
|
}) : new ChatCohere({
|
|
6689
6875
|
model: modelName,
|
|
6690
6876
|
temperature: defaultTemperature,
|
|
@@ -6704,7 +6890,13 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6704
6890
|
temperature: defaultTemperature,
|
|
6705
6891
|
maxTokens: defaultMaxTokens,
|
|
6706
6892
|
apiKey: apiToken || this.resolveApiKey("mistral" /* MISTRAL */),
|
|
6707
|
-
...routerURL && {
|
|
6893
|
+
...routerURL && {
|
|
6894
|
+
serverURL: `${routerURL}/v1`,
|
|
6895
|
+
// Mistral SDK doesn't accept a custom fetch directly — its
|
|
6896
|
+
// beforeRequestHooks let us mutate the outgoing Request to add
|
|
6897
|
+
// X-Flutch-* headers from the ALS context.
|
|
6898
|
+
beforeRequestHooks: [flutchMistralHook]
|
|
6899
|
+
}
|
|
6708
6900
|
});
|
|
6709
6901
|
},
|
|
6710
6902
|
["voyageai" /* VOYAGEAI */]: () => {
|
|
@@ -6759,7 +6951,7 @@ var ModelInitializer = class _ModelInitializer {
|
|
|
6759
6951
|
model: modelName,
|
|
6760
6952
|
apiKey: apiToken || this.resolveApiKey("openai" /* OPENAI */),
|
|
6761
6953
|
...routerURL && {
|
|
6762
|
-
configuration: { baseURL: `${routerURL}/v1
|
|
6954
|
+
configuration: { baseURL: `${routerURL}/v1`, fetch: flutchFetch }
|
|
6763
6955
|
}
|
|
6764
6956
|
});
|
|
6765
6957
|
},
|
|
@@ -7705,6 +7897,6 @@ var MongoTokenStore = class {
|
|
|
7705
7897
|
}
|
|
7706
7898
|
};
|
|
7707
7899
|
|
|
7708
|
-
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 };
|
|
7900
|
+
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, isReasoningModel, loadOAuthProviders, normalizeToolConfigs, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, resolveRouterURL, sanitizeTraceData, storeAttachmentData, traceApiCall, withFlutchContext, wrapCohereFetcher };
|
|
7709
7901
|
//# sourceMappingURL=index.js.map
|
|
7710
7902
|
//# sourceMappingURL=index.js.map
|