@flutchai/flutch-sdk 0.2.10 → 0.2.14

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.d.cts CHANGED
@@ -1015,6 +1015,7 @@ interface ModelByIdConfig {
1015
1015
  modelId: string;
1016
1016
  temperature?: number;
1017
1017
  maxTokens?: number;
1018
+ baseURL?: string;
1018
1019
  toolsConfig?: IAgentToolConfig[];
1019
1020
  customTools?: DynamicStructuredTool[];
1020
1021
  }
@@ -1029,6 +1030,7 @@ interface ModelConfigWithToken {
1029
1030
  requiresApiKey: boolean;
1030
1031
  useBedrock?: boolean;
1031
1032
  bedrockModelId?: string;
1033
+ baseURL?: string;
1032
1034
  }
1033
1035
  type ApiKeyResolver = (provider: ModelProvider) => string | undefined;
1034
1036
  type LLModel = BaseChatModel;
@@ -1278,6 +1280,10 @@ interface ExecuteToolWithAttachmentsParams {
1278
1280
  injectIntoArg?: string;
1279
1281
  sourceAttachmentId?: string;
1280
1282
  threadId?: string;
1283
+ toolSchema?: {
1284
+ properties?: Record<string, any>;
1285
+ required?: string[];
1286
+ };
1281
1287
  }
1282
1288
  interface ExecuteToolWithAttachmentsResult {
1283
1289
  toolMessage: ToolMessage;
@@ -1287,7 +1293,10 @@ interface ExecuteToolWithAttachmentsResult {
1287
1293
  };
1288
1294
  }
1289
1295
  declare function executeToolWithAttachments(params: ExecuteToolWithAttachmentsParams): Promise<ExecuteToolWithAttachmentsResult>;
1290
- declare function shouldInjectData(args: Record<string, any>, attachments: Record<string, IGraphAttachment>, dataArgName: string): boolean;
1296
+ declare function shouldInjectData(args: Record<string, any>, attachments: Record<string, IGraphAttachment>, dataArgName: string, toolSchema?: {
1297
+ properties?: Record<string, any>;
1298
+ required?: string[];
1299
+ }): boolean;
1291
1300
  declare const _internals: {
1292
1301
  shouldInjectData: typeof shouldInjectData;
1293
1302
  getLatestAttachment: typeof getLatestAttachment;
@@ -1702,6 +1711,23 @@ declare class OAuthTokenManager {
1702
1711
  declare function encryptTokens(tokens: OAuthTokens, key: string): string;
1703
1712
  declare function decryptTokens(encrypted: string, key: string): OAuthTokens;
1704
1713
 
1714
+ interface OAuthProviderDef {
1715
+ name: string;
1716
+ authorizationUrl: string;
1717
+ tokenUrl: string;
1718
+ scopes: string[];
1719
+ clientIdEnvVar: string;
1720
+ clientSecretEnvVar: string;
1721
+ }
1722
+ declare function loadOAuthProviders(providers: Record<string, OAuthProviderDef>): void;
1723
+ declare function getOAuthProvider(provider: string): OAuthProviderDef;
1724
+ declare function getOAuthProviderNames(): string[];
1725
+ declare function resolveOAuthProviderConfig(provider: string): OAuthProviderConfig;
1726
+ declare function buildOAuthAuthorizationUrl(provider: string, params: {
1727
+ redirectUri: string;
1728
+ state: string;
1729
+ }): string;
1730
+
1705
1731
  declare class FileTokenStore implements IOAuthTokenStore {
1706
1732
  private readonly filePath;
1707
1733
  constructor(filePath: string);
@@ -1723,4 +1749,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
1723
1749
  private ensureIndex;
1724
1750
  }
1725
1751
 
1726
- 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_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 ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, 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 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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, storeAttachmentData, traceApiCall };
1752
+ 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_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 ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, 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 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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, loadOAuthProviders, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, sanitizeTraceData, storeAttachmentData, traceApiCall };
package/dist/index.d.ts CHANGED
@@ -1015,6 +1015,7 @@ interface ModelByIdConfig {
1015
1015
  modelId: string;
1016
1016
  temperature?: number;
1017
1017
  maxTokens?: number;
1018
+ baseURL?: string;
1018
1019
  toolsConfig?: IAgentToolConfig[];
1019
1020
  customTools?: DynamicStructuredTool[];
1020
1021
  }
@@ -1029,6 +1030,7 @@ interface ModelConfigWithToken {
1029
1030
  requiresApiKey: boolean;
1030
1031
  useBedrock?: boolean;
1031
1032
  bedrockModelId?: string;
1033
+ baseURL?: string;
1032
1034
  }
1033
1035
  type ApiKeyResolver = (provider: ModelProvider) => string | undefined;
1034
1036
  type LLModel = BaseChatModel;
@@ -1278,6 +1280,10 @@ interface ExecuteToolWithAttachmentsParams {
1278
1280
  injectIntoArg?: string;
1279
1281
  sourceAttachmentId?: string;
1280
1282
  threadId?: string;
1283
+ toolSchema?: {
1284
+ properties?: Record<string, any>;
1285
+ required?: string[];
1286
+ };
1281
1287
  }
1282
1288
  interface ExecuteToolWithAttachmentsResult {
1283
1289
  toolMessage: ToolMessage;
@@ -1287,7 +1293,10 @@ interface ExecuteToolWithAttachmentsResult {
1287
1293
  };
1288
1294
  }
1289
1295
  declare function executeToolWithAttachments(params: ExecuteToolWithAttachmentsParams): Promise<ExecuteToolWithAttachmentsResult>;
1290
- declare function shouldInjectData(args: Record<string, any>, attachments: Record<string, IGraphAttachment>, dataArgName: string): boolean;
1296
+ declare function shouldInjectData(args: Record<string, any>, attachments: Record<string, IGraphAttachment>, dataArgName: string, toolSchema?: {
1297
+ properties?: Record<string, any>;
1298
+ required?: string[];
1299
+ }): boolean;
1291
1300
  declare const _internals: {
1292
1301
  shouldInjectData: typeof shouldInjectData;
1293
1302
  getLatestAttachment: typeof getLatestAttachment;
@@ -1702,6 +1711,23 @@ declare class OAuthTokenManager {
1702
1711
  declare function encryptTokens(tokens: OAuthTokens, key: string): string;
1703
1712
  declare function decryptTokens(encrypted: string, key: string): OAuthTokens;
1704
1713
 
1714
+ interface OAuthProviderDef {
1715
+ name: string;
1716
+ authorizationUrl: string;
1717
+ tokenUrl: string;
1718
+ scopes: string[];
1719
+ clientIdEnvVar: string;
1720
+ clientSecretEnvVar: string;
1721
+ }
1722
+ declare function loadOAuthProviders(providers: Record<string, OAuthProviderDef>): void;
1723
+ declare function getOAuthProvider(provider: string): OAuthProviderDef;
1724
+ declare function getOAuthProviderNames(): string[];
1725
+ declare function resolveOAuthProviderConfig(provider: string): OAuthProviderConfig;
1726
+ declare function buildOAuthAuthorizationUrl(provider: string, params: {
1727
+ redirectUri: string;
1728
+ state: string;
1729
+ }): string;
1730
+
1705
1731
  declare class FileTokenStore implements IOAuthTokenStore {
1706
1732
  private readonly filePath;
1707
1733
  constructor(filePath: string);
@@ -1723,4 +1749,4 @@ declare class MongoTokenStore implements IOAuthTokenStore {
1723
1749
  private ensureIndex;
1724
1750
  }
1725
1751
 
1726
- 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_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 ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, 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 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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, storeAttachmentData, traceApiCall };
1752
+ 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_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 ModelConfigFetcher, type ModelConfigWithToken, type ModelConfigWithTokenAndType, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, MongoTokenStore, type OAuthProviderConfig, type OAuthProviderDef, OAuthTokenManager, type OAuthTokenManagerOptions, type OAuthTokens, 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 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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, loadOAuthProviders, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, sanitizeTraceData, storeAttachmentData, traceApiCall };
package/dist/index.js CHANGED
@@ -2818,8 +2818,8 @@ IdempotencyManager = __decorateClass([
2818
2818
 
2819
2819
  // src/callbacks/smart-callback.router.ts
2820
2820
  var SmartCallbackRouter = class {
2821
- constructor(registry, store, acl, auditor, metrics, rateLimiter, idempotencyManager, patchService) {
2822
- this.registry = registry;
2821
+ constructor(registry2, store, acl, auditor, metrics, rateLimiter, idempotencyManager, patchService) {
2822
+ this.registry = registry2;
2823
2823
  this.store = store;
2824
2824
  this.acl = acl;
2825
2825
  this.auditor = auditor;
@@ -3098,8 +3098,8 @@ var UniversalCallbackService = class {
3098
3098
  };
3099
3099
 
3100
3100
  // src/callbacks/example.callback.ts
3101
- function registerFinanceExampleCallback(registry) {
3102
- registry.register(
3101
+ function registerFinanceExampleCallback(registry2) {
3102
+ registry2.register(
3103
3103
  "example",
3104
3104
  async () => ({
3105
3105
  success: true,
@@ -3624,8 +3624,8 @@ var CallbackMetrics = class {
3624
3624
  activeCallbacks;
3625
3625
  pendingCallbacks;
3626
3626
  queueSize;
3627
- constructor(registry) {
3628
- this.registry = registry ?? new Registry();
3627
+ constructor(registry2) {
3628
+ this.registry = registry2 ?? new Registry();
3629
3629
  collectDefaultMetrics({ register: this.registry });
3630
3630
  this.callbacksTotal = new Counter({
3631
3631
  name: "graph_callbacks_total",
@@ -4447,11 +4447,17 @@ async function executeToolWithAttachments(params) {
4447
4447
  threshold = DEFAULT_ATTACHMENT_THRESHOLD,
4448
4448
  injectIntoArg = "data",
4449
4449
  sourceAttachmentId,
4450
- threadId
4450
+ threadId,
4451
+ toolSchema
4451
4452
  } = params;
4452
4453
  const argsWithInjection = { ...enrichedArgs };
4453
4454
  try {
4454
- if (shouldInjectData(argsWithInjection, attachments, injectIntoArg)) {
4455
+ if (shouldInjectData(
4456
+ argsWithInjection,
4457
+ attachments,
4458
+ injectIntoArg,
4459
+ toolSchema
4460
+ )) {
4455
4461
  const attachment = sourceAttachmentId ? attachments[sourceAttachmentId] : getLatestAttachment(attachments);
4456
4462
  if (attachment) {
4457
4463
  const attachmentKey = sourceAttachmentId || attachment.toolCallId;
@@ -4513,9 +4519,17 @@ async function executeToolWithAttachments(params) {
4513
4519
  });
4514
4520
  return { toolMessage };
4515
4521
  }
4516
- function shouldInjectData(args, attachments, dataArgName) {
4522
+ function shouldInjectData(args, attachments, dataArgName, toolSchema) {
4517
4523
  if (Object.keys(attachments).length === 0) return false;
4518
- return args[dataArgName] === void 0;
4524
+ if (args[dataArgName] !== void 0) return false;
4525
+ if (toolSchema) {
4526
+ const hasProperty = toolSchema.properties && dataArgName in toolSchema.properties;
4527
+ const isRequired = toolSchema.required?.includes(dataArgName);
4528
+ if (!hasProperty && !isRequired) {
4529
+ return false;
4530
+ }
4531
+ }
4532
+ return true;
4519
4533
  }
4520
4534
  var _internals = {
4521
4535
  shouldInjectData,
@@ -5628,7 +5642,7 @@ var UniversalGraphModule = class {
5628
5642
  },
5629
5643
  {
5630
5644
  provide: CallbackMetrics,
5631
- useFactory: (registry) => new CallbackMetrics(registry),
5645
+ useFactory: (registry2) => new CallbackMetrics(registry2),
5632
5646
  inject: ["PROMETHEUS_REGISTRY"]
5633
5647
  },
5634
5648
  {
@@ -5656,8 +5670,8 @@ var UniversalGraphModule = class {
5656
5670
  },
5657
5671
  {
5658
5672
  provide: SmartCallbackRouter,
5659
- useFactory: (registry, store, acl, auditor, metrics, rateLimiter, idempotencyManager, patchService) => new SmartCallbackRouter(
5660
- registry,
5673
+ useFactory: (registry2, store, acl, auditor, metrics, rateLimiter, idempotencyManager, patchService) => new SmartCallbackRouter(
5674
+ registry2,
5661
5675
  store,
5662
5676
  acl,
5663
5677
  auditor,
@@ -5689,8 +5703,8 @@ var UniversalGraphModule = class {
5689
5703
  },
5690
5704
  {
5691
5705
  provide: "CALLBACK_EXAMPLE_REGISTRATION",
5692
- useFactory: (registry) => {
5693
- registerFinanceExampleCallback(registry);
5706
+ useFactory: (registry2) => {
5707
+ registerFinanceExampleCallback(registry2);
5694
5708
  },
5695
5709
  inject: [CallbackRegistry]
5696
5710
  },
@@ -5753,8 +5767,8 @@ var UniversalGraphModule = class {
5753
5767
  },
5754
5768
  {
5755
5769
  provide: "GRAPH_BUILDERS",
5756
- useFactory: (registry) => {
5757
- return registry.getBuilders();
5770
+ useFactory: (registry2) => {
5771
+ return registry2.getBuilders();
5758
5772
  },
5759
5773
  inject: [BuilderRegistryService]
5760
5774
  },
@@ -6422,12 +6436,19 @@ function hashToolsConfig(toolsConfig) {
6422
6436
  const sorted = toolsConfig.map((t) => `${t.toolName}:${t.enabled}:${JSON.stringify(t.config || {})}`).sort().join("|");
6423
6437
  return createHash("md5").update(sorted).digest("hex").slice(0, 16);
6424
6438
  }
6425
- function generateModelCacheKey(modelId, temperature, maxTokens, toolsConfig) {
6439
+ var DEFAULT_ROUTER_URL = "https://router.flutch.ai";
6440
+ function resolveRouterURL(baseURL) {
6441
+ return baseURL ?? process.env.FLUTCH_ROUTER_URL ?? DEFAULT_ROUTER_URL;
6442
+ }
6443
+ function generateModelCacheKey(modelId, temperature, maxTokens, toolsConfig, baseURL) {
6426
6444
  const parts = [
6427
6445
  modelId,
6428
6446
  temperature ?? "default",
6429
6447
  maxTokens ?? "default"
6430
6448
  ];
6449
+ if (baseURL) {
6450
+ parts.push(baseURL);
6451
+ }
6431
6452
  if (toolsConfig && toolsConfig.length > 0) {
6432
6453
  parts.push(hashToolsConfig(toolsConfig));
6433
6454
  }
@@ -6555,7 +6576,8 @@ var ModelInitializer = class _ModelInitializer {
6555
6576
  config.modelId,
6556
6577
  config.temperature,
6557
6578
  config.maxTokens,
6558
- config.toolsConfig
6579
+ config.toolsConfig,
6580
+ config.baseURL
6559
6581
  );
6560
6582
  }
6561
6583
  // Chat model creators
@@ -6564,7 +6586,8 @@ var ModelInitializer = class _ModelInitializer {
6564
6586
  modelName,
6565
6587
  defaultTemperature,
6566
6588
  defaultMaxTokens,
6567
- apiToken
6589
+ apiToken,
6590
+ baseURL
6568
6591
  }) => {
6569
6592
  const config = buildOpenAIModelConfig(
6570
6593
  modelName,
@@ -6572,18 +6595,21 @@ var ModelInitializer = class _ModelInitializer {
6572
6595
  defaultMaxTokens,
6573
6596
  apiToken || this.resolveApiKey("openai" /* OPENAI */) || ""
6574
6597
  );
6598
+ config.configuration = { baseURL: `${resolveRouterURL(baseURL)}/v1` };
6575
6599
  return new ChatOpenAI(config);
6576
6600
  },
6577
6601
  ["anthropic" /* ANTHROPIC */]: ({
6578
6602
  modelName,
6579
6603
  defaultTemperature,
6580
6604
  defaultMaxTokens,
6581
- apiToken
6605
+ apiToken,
6606
+ baseURL
6582
6607
  }) => new ChatAnthropic({
6583
6608
  modelName,
6584
6609
  temperature: defaultTemperature,
6585
6610
  maxTokens: defaultMaxTokens,
6586
- anthropicApiKey: apiToken || this.resolveApiKey("anthropic" /* ANTHROPIC */)
6611
+ anthropicApiKey: apiToken || this.resolveApiKey("anthropic" /* ANTHROPIC */),
6612
+ anthropicApiUrl: resolveRouterURL(baseURL)
6587
6613
  }),
6588
6614
  ["cohere" /* COHERE */]: ({
6589
6615
  modelName,
@@ -6665,7 +6691,8 @@ var ModelInitializer = class _ModelInitializer {
6665
6691
  ),
6666
6692
  defaultMaxTokens: Number(
6667
6693
  config.maxTokens ?? modelConfig.defaultMaxTokens
6668
- )
6694
+ ),
6695
+ baseURL: config.baseURL ?? modelConfig.baseURL
6669
6696
  };
6670
6697
  this.logger.debug(`Creating new chat model instance: ${cacheKey}`);
6671
6698
  let model;
@@ -7300,11 +7327,7 @@ var ALGORITHM = "aes-256-cbc";
7300
7327
  var IV_LENGTH = 16;
7301
7328
  function encryptTokens(tokens, key) {
7302
7329
  const iv = crypto.randomBytes(IV_LENGTH);
7303
- const cipher = crypto.createCipheriv(
7304
- ALGORITHM,
7305
- Buffer.from(key),
7306
- iv
7307
- );
7330
+ const cipher = crypto.createCipheriv(ALGORITHM, Buffer.from(key), iv);
7308
7331
  const json = JSON.stringify(tokens);
7309
7332
  let encrypted = cipher.update(json, "utf8", "hex");
7310
7333
  encrypted += cipher.final("hex");
@@ -7318,11 +7341,7 @@ function decryptTokens(encrypted, key) {
7318
7341
  const ivHex = encrypted.substring(0, separatorIndex);
7319
7342
  const encryptedData = encrypted.substring(separatorIndex + 1);
7320
7343
  const iv = Buffer.from(ivHex, "hex");
7321
- const decipher = crypto.createDecipheriv(
7322
- ALGORITHM,
7323
- Buffer.from(key),
7324
- iv
7325
- );
7344
+ const decipher = crypto.createDecipheriv(ALGORITHM, Buffer.from(key), iv);
7326
7345
  let decrypted = decipher.update(encryptedData, "hex", "utf8");
7327
7346
  decrypted += decipher.final("utf8");
7328
7347
  return JSON.parse(decrypted);
@@ -7363,7 +7382,10 @@ var OAuthTokenManager = class {
7363
7382
  this.setCache(config.provider, tokens.accessToken, tokens.expiresAt);
7364
7383
  return tokens.accessToken;
7365
7384
  }
7366
- const refreshed = await this.refreshAccessToken(config, tokens.refreshToken);
7385
+ const refreshed = await this.refreshAccessToken(
7386
+ config,
7387
+ tokens.refreshToken
7388
+ );
7367
7389
  await this.persistTokens(config.provider, refreshed);
7368
7390
  return refreshed.accessToken;
7369
7391
  }
@@ -7427,6 +7449,56 @@ var OAuthTokenManager = class {
7427
7449
  this.cache.set(provider, { token, expiresAt });
7428
7450
  }
7429
7451
  };
7452
+
7453
+ // src/oauth/oauth-provider.registry.ts
7454
+ var registry = {};
7455
+ function loadOAuthProviders(providers) {
7456
+ registry = { ...providers };
7457
+ }
7458
+ function getOAuthProvider(provider) {
7459
+ const def = registry[provider];
7460
+ if (!def) {
7461
+ throw new Error(`Unknown OAuth provider: ${provider}`);
7462
+ }
7463
+ return def;
7464
+ }
7465
+ function getOAuthProviderNames() {
7466
+ return Object.keys(registry);
7467
+ }
7468
+ function resolveOAuthProviderConfig(provider) {
7469
+ const def = getOAuthProvider(provider);
7470
+ const clientId = process.env[def.clientIdEnvVar];
7471
+ const clientSecret = process.env[def.clientSecretEnvVar];
7472
+ if (!clientId) {
7473
+ throw new Error(`Missing env var: ${def.clientIdEnvVar}`);
7474
+ }
7475
+ if (!clientSecret) {
7476
+ throw new Error(`Missing env var: ${def.clientSecretEnvVar}`);
7477
+ }
7478
+ return {
7479
+ provider: def.name,
7480
+ tokenUrl: def.tokenUrl,
7481
+ clientId,
7482
+ clientSecret
7483
+ };
7484
+ }
7485
+ function buildOAuthAuthorizationUrl(provider, params) {
7486
+ const def = getOAuthProvider(provider);
7487
+ const clientId = process.env[def.clientIdEnvVar];
7488
+ if (!clientId) {
7489
+ throw new Error(`Missing env var: ${def.clientIdEnvVar}`);
7490
+ }
7491
+ const query = new URLSearchParams({
7492
+ client_id: clientId,
7493
+ redirect_uri: params.redirectUri,
7494
+ response_type: "code",
7495
+ state: params.state
7496
+ });
7497
+ if (def.scopes.length > 0) {
7498
+ query.set("scope", def.scopes.join(" "));
7499
+ }
7500
+ return `${def.authorizationUrl}?${query.toString()}`;
7501
+ }
7430
7502
  var FileTokenStore = class {
7431
7503
  constructor(filePath) {
7432
7504
  this.filePath = filePath;
@@ -7496,6 +7568,6 @@ var MongoTokenStore = class {
7496
7568
  }
7497
7569
  };
7498
7570
 
7499
- 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_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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, storeAttachmentData, traceApiCall };
7571
+ 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_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, clearAttachmentDataStore, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, decryptTokens, dispatchAttachments, encryptTokens, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getOAuthProvider, getOAuthProviderNames, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, loadOAuthProviders, registerFinanceExampleCallback, registerUIEndpointsFromClass, resolveOAuthProviderConfig, sanitizeTraceData, storeAttachmentData, traceApiCall };
7500
7572
  //# sourceMappingURL=index.js.map
7501
7573
  //# sourceMappingURL=index.js.map