@flutchai/flutch-sdk 0.2.4 → 0.2.6
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 +140 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +137 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1267,6 +1267,9 @@ declare function generateAttachmentSummary(data: any, toolCallId: string): strin
|
|
|
1267
1267
|
declare function createGraphAttachment(data: any, toolName: string, toolCallId: string): IGraphAttachment;
|
|
1268
1268
|
|
|
1269
1269
|
declare const DEFAULT_ATTACHMENT_THRESHOLD: number;
|
|
1270
|
+
declare function storeAttachmentData(key: string, data: any, threadId?: string): void;
|
|
1271
|
+
declare function getAttachmentData(key: string, threadId?: string): any | undefined;
|
|
1272
|
+
declare function clearAttachmentDataStore(threadId?: string): void;
|
|
1270
1273
|
interface ExecuteToolWithAttachmentsParams {
|
|
1271
1274
|
toolCall: {
|
|
1272
1275
|
id: string;
|
|
@@ -1286,6 +1289,7 @@ interface ExecuteToolWithAttachmentsParams {
|
|
|
1286
1289
|
threshold?: number;
|
|
1287
1290
|
injectIntoArg?: string;
|
|
1288
1291
|
sourceAttachmentId?: string;
|
|
1292
|
+
threadId?: string;
|
|
1289
1293
|
}
|
|
1290
1294
|
interface ExecuteToolWithAttachmentsResult {
|
|
1291
1295
|
toolMessage: ToolMessage;
|
|
@@ -1490,6 +1494,7 @@ declare class EventProcessor {
|
|
|
1490
1494
|
private readonly logger;
|
|
1491
1495
|
createAccumulator(): StreamAccumulator;
|
|
1492
1496
|
private normalizeContentBlocks;
|
|
1497
|
+
private extractAttachments;
|
|
1493
1498
|
private sendDelta;
|
|
1494
1499
|
private processContentStream;
|
|
1495
1500
|
private mapReasoningSteps;
|
|
@@ -1519,6 +1524,7 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1519
1524
|
private sendTraceFromAccumulator;
|
|
1520
1525
|
private sendMetricsWebhook;
|
|
1521
1526
|
private sendTraceEventsBatch;
|
|
1527
|
+
private extractThreadId;
|
|
1522
1528
|
private processGraphResult;
|
|
1523
1529
|
}
|
|
1524
1530
|
|
|
@@ -1534,6 +1540,7 @@ declare class GraphEngineFactory {
|
|
|
1534
1540
|
}
|
|
1535
1541
|
|
|
1536
1542
|
declare function createStaticMessage(content: string, config: LangGraphRunnableConfig): Promise<AIMessage>;
|
|
1543
|
+
declare function dispatchAttachments(attachments: any[], config: LangGraphRunnableConfig): Promise<void>;
|
|
1537
1544
|
|
|
1538
1545
|
interface MongoDBConfig {
|
|
1539
1546
|
uri?: string;
|
|
@@ -1669,4 +1676,4 @@ declare class StaticDiscovery implements ServiceDiscoveryProvider {
|
|
|
1669
1676
|
}>>;
|
|
1670
1677
|
}
|
|
1671
1678
|
|
|
1672
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, 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 ConcreteModels, 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, 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 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, 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, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, traceApiCall };
|
|
1679
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, 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 ConcreteModels, 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, 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 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, 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, dispatchAttachments, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
package/dist/index.d.ts
CHANGED
|
@@ -1267,6 +1267,9 @@ declare function generateAttachmentSummary(data: any, toolCallId: string): strin
|
|
|
1267
1267
|
declare function createGraphAttachment(data: any, toolName: string, toolCallId: string): IGraphAttachment;
|
|
1268
1268
|
|
|
1269
1269
|
declare const DEFAULT_ATTACHMENT_THRESHOLD: number;
|
|
1270
|
+
declare function storeAttachmentData(key: string, data: any, threadId?: string): void;
|
|
1271
|
+
declare function getAttachmentData(key: string, threadId?: string): any | undefined;
|
|
1272
|
+
declare function clearAttachmentDataStore(threadId?: string): void;
|
|
1270
1273
|
interface ExecuteToolWithAttachmentsParams {
|
|
1271
1274
|
toolCall: {
|
|
1272
1275
|
id: string;
|
|
@@ -1286,6 +1289,7 @@ interface ExecuteToolWithAttachmentsParams {
|
|
|
1286
1289
|
threshold?: number;
|
|
1287
1290
|
injectIntoArg?: string;
|
|
1288
1291
|
sourceAttachmentId?: string;
|
|
1292
|
+
threadId?: string;
|
|
1289
1293
|
}
|
|
1290
1294
|
interface ExecuteToolWithAttachmentsResult {
|
|
1291
1295
|
toolMessage: ToolMessage;
|
|
@@ -1490,6 +1494,7 @@ declare class EventProcessor {
|
|
|
1490
1494
|
private readonly logger;
|
|
1491
1495
|
createAccumulator(): StreamAccumulator;
|
|
1492
1496
|
private normalizeContentBlocks;
|
|
1497
|
+
private extractAttachments;
|
|
1493
1498
|
private sendDelta;
|
|
1494
1499
|
private processContentStream;
|
|
1495
1500
|
private mapReasoningSteps;
|
|
@@ -1519,6 +1524,7 @@ declare class LangGraphEngine implements IGraphEngine {
|
|
|
1519
1524
|
private sendTraceFromAccumulator;
|
|
1520
1525
|
private sendMetricsWebhook;
|
|
1521
1526
|
private sendTraceEventsBatch;
|
|
1527
|
+
private extractThreadId;
|
|
1522
1528
|
private processGraphResult;
|
|
1523
1529
|
}
|
|
1524
1530
|
|
|
@@ -1534,6 +1540,7 @@ declare class GraphEngineFactory {
|
|
|
1534
1540
|
}
|
|
1535
1541
|
|
|
1536
1542
|
declare function createStaticMessage(content: string, config: LangGraphRunnableConfig): Promise<AIMessage>;
|
|
1543
|
+
declare function dispatchAttachments(attachments: any[], config: LangGraphRunnableConfig): Promise<void>;
|
|
1537
1544
|
|
|
1538
1545
|
interface MongoDBConfig {
|
|
1539
1546
|
uri?: string;
|
|
@@ -1669,4 +1676,4 @@ declare class StaticDiscovery implements ServiceDiscoveryProvider {
|
|
|
1669
1676
|
}>>;
|
|
1670
1677
|
}
|
|
1671
1678
|
|
|
1672
|
-
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, 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 ConcreteModels, 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, 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 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, 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, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, traceApiCall };
|
|
1679
|
+
export { type ACLValidationResult, AbstractGraphBuilder, type ApiCallTracerOptions, 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 ConcreteModels, 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, 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 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 ModelCreator, type ModelCreators, ModelInitializer, ModelProvider, ModelType, type MongoDBConfig, 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, dispatchAttachments, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
package/dist/index.js
CHANGED
|
@@ -4392,6 +4392,48 @@ function generateTextSummary(data, toolCallId) {
|
|
|
4392
4392
|
|
|
4393
4393
|
// src/graph/attachment-tool-node.ts
|
|
4394
4394
|
var DEFAULT_ATTACHMENT_THRESHOLD = Number(process.env.ATTACHMENT_THRESHOLD) || 4e3;
|
|
4395
|
+
var attachmentDataStore = /* @__PURE__ */ new Map();
|
|
4396
|
+
var cleanupTimers = /* @__PURE__ */ new Map();
|
|
4397
|
+
var AUTO_CLEANUP_MS = 10 * 60 * 1e3;
|
|
4398
|
+
function storeAttachmentData(key, data, threadId) {
|
|
4399
|
+
const scope = threadId || "__global__";
|
|
4400
|
+
let threadStore = attachmentDataStore.get(scope);
|
|
4401
|
+
if (!threadStore) {
|
|
4402
|
+
threadStore = /* @__PURE__ */ new Map();
|
|
4403
|
+
attachmentDataStore.set(scope, threadStore);
|
|
4404
|
+
}
|
|
4405
|
+
threadStore.set(key, data);
|
|
4406
|
+
const existingTimer = cleanupTimers.get(scope);
|
|
4407
|
+
if (existingTimer) {
|
|
4408
|
+
clearTimeout(existingTimer);
|
|
4409
|
+
}
|
|
4410
|
+
const timer = setTimeout(() => {
|
|
4411
|
+
attachmentDataStore.delete(scope);
|
|
4412
|
+
cleanupTimers.delete(scope);
|
|
4413
|
+
}, AUTO_CLEANUP_MS);
|
|
4414
|
+
if (timer.unref) timer.unref();
|
|
4415
|
+
cleanupTimers.set(scope, timer);
|
|
4416
|
+
}
|
|
4417
|
+
function getAttachmentData(key, threadId) {
|
|
4418
|
+
const scope = threadId || "__global__";
|
|
4419
|
+
return attachmentDataStore.get(scope)?.get(key);
|
|
4420
|
+
}
|
|
4421
|
+
function clearAttachmentDataStore(threadId) {
|
|
4422
|
+
if (threadId) {
|
|
4423
|
+
attachmentDataStore.delete(threadId);
|
|
4424
|
+
const timer = cleanupTimers.get(threadId);
|
|
4425
|
+
if (timer) {
|
|
4426
|
+
clearTimeout(timer);
|
|
4427
|
+
cleanupTimers.delete(threadId);
|
|
4428
|
+
}
|
|
4429
|
+
} else {
|
|
4430
|
+
attachmentDataStore.clear();
|
|
4431
|
+
for (const timer of cleanupTimers.values()) {
|
|
4432
|
+
clearTimeout(timer);
|
|
4433
|
+
}
|
|
4434
|
+
cleanupTimers.clear();
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4395
4437
|
async function executeToolWithAttachments(params) {
|
|
4396
4438
|
const {
|
|
4397
4439
|
toolCall,
|
|
@@ -4403,17 +4445,23 @@ async function executeToolWithAttachments(params) {
|
|
|
4403
4445
|
logger: logger2,
|
|
4404
4446
|
threshold = DEFAULT_ATTACHMENT_THRESHOLD,
|
|
4405
4447
|
injectIntoArg = "data",
|
|
4406
|
-
sourceAttachmentId
|
|
4448
|
+
sourceAttachmentId,
|
|
4449
|
+
threadId
|
|
4407
4450
|
} = params;
|
|
4408
4451
|
const argsWithInjection = { ...enrichedArgs };
|
|
4409
4452
|
try {
|
|
4410
4453
|
if (shouldInjectData(argsWithInjection, attachments, injectIntoArg)) {
|
|
4411
4454
|
const attachment = sourceAttachmentId ? attachments[sourceAttachmentId] : getLatestAttachment(attachments);
|
|
4412
4455
|
if (attachment) {
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
)
|
|
4456
|
+
const attachmentKey = sourceAttachmentId || attachment.toolCallId;
|
|
4457
|
+
const storedData = getAttachmentData(attachmentKey, threadId);
|
|
4458
|
+
const data = storedData !== void 0 ? storedData : attachment.data;
|
|
4459
|
+
if (data != null) {
|
|
4460
|
+
argsWithInjection[injectIntoArg] = typeof data === "string" ? data : JSON.stringify(data);
|
|
4461
|
+
logger2?.debug(
|
|
4462
|
+
`[Attachment] Auto-injected data from attachment "${attachment.toolCallId}" into ${toolCall.name}.${injectIntoArg} (source: ${storedData !== void 0 ? "memory" : "state"})`
|
|
4463
|
+
);
|
|
4464
|
+
}
|
|
4417
4465
|
}
|
|
4418
4466
|
}
|
|
4419
4467
|
} catch (e) {
|
|
@@ -4433,8 +4481,14 @@ async function executeToolWithAttachments(params) {
|
|
|
4433
4481
|
toolCall.name,
|
|
4434
4482
|
toolCall.id
|
|
4435
4483
|
);
|
|
4484
|
+
storeAttachmentData(toolCall.id, attachment.data, threadId);
|
|
4485
|
+
const stateAttachment = {
|
|
4486
|
+
...attachment,
|
|
4487
|
+
data: null
|
|
4488
|
+
// Data stored in memory, not in graph state
|
|
4489
|
+
};
|
|
4436
4490
|
logger2?.debug(
|
|
4437
|
-
`[Attachment] Stored large result (${content.length} chars) as attachment "${toolCall.id}"`
|
|
4491
|
+
`[Attachment] Stored large result (${content.length} chars) as attachment "${toolCall.id}" (data in memory, metadata in state)`
|
|
4438
4492
|
);
|
|
4439
4493
|
const toolMessage2 = new ToolMessage({
|
|
4440
4494
|
content: attachment.summary,
|
|
@@ -4443,7 +4497,7 @@ async function executeToolWithAttachments(params) {
|
|
|
4443
4497
|
});
|
|
4444
4498
|
return {
|
|
4445
4499
|
toolMessage: toolMessage2,
|
|
4446
|
-
attachment: { key: toolCall.id, value:
|
|
4500
|
+
attachment: { key: toolCall.id, value: stateAttachment }
|
|
4447
4501
|
};
|
|
4448
4502
|
}
|
|
4449
4503
|
} catch (e) {
|
|
@@ -4475,7 +4529,8 @@ function getLatestAttachment(attachments) {
|
|
|
4475
4529
|
}
|
|
4476
4530
|
var logger = new Logger("ApiCallTracer");
|
|
4477
4531
|
var DEFAULT_TRACER_OPTIONS = {
|
|
4478
|
-
maxStringLength:
|
|
4532
|
+
maxStringLength: 1e5,
|
|
4533
|
+
// 100KB - enough for most tool outputs, prevents overflow
|
|
4479
4534
|
maxDepth: 15
|
|
4480
4535
|
};
|
|
4481
4536
|
var cachedDispatch;
|
|
@@ -4541,6 +4596,9 @@ function sanitizeTraceData(value, depth = 0, seen = /* @__PURE__ */ new WeakSet(
|
|
|
4541
4596
|
return null;
|
|
4542
4597
|
}
|
|
4543
4598
|
if (typeof value === "string") {
|
|
4599
|
+
if (value.length > opts.maxStringLength) {
|
|
4600
|
+
return `${value.slice(0, opts.maxStringLength)}\u2026 [truncated: ${value.length - opts.maxStringLength} chars]`;
|
|
4601
|
+
}
|
|
4544
4602
|
return value;
|
|
4545
4603
|
}
|
|
4546
4604
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
@@ -4705,6 +4763,19 @@ var EventProcessor = class {
|
|
|
4705
4763
|
}
|
|
4706
4764
|
return [];
|
|
4707
4765
|
}
|
|
4766
|
+
/**
|
|
4767
|
+
* Extract attachments from various input formats
|
|
4768
|
+
* Handles both array format (IAttachment[]) and object format (Record<string, IGraphAttachment>)
|
|
4769
|
+
*/
|
|
4770
|
+
extractAttachments(attachments) {
|
|
4771
|
+
if (!attachments) {
|
|
4772
|
+
return [];
|
|
4773
|
+
}
|
|
4774
|
+
const items = Array.isArray(attachments) ? attachments : typeof attachments === "object" ? Object.values(attachments) : [];
|
|
4775
|
+
return items.filter(
|
|
4776
|
+
(item) => item != null && "type" in item && "value" in item
|
|
4777
|
+
);
|
|
4778
|
+
}
|
|
4708
4779
|
/**
|
|
4709
4780
|
* Send delta to UI (unified format)
|
|
4710
4781
|
*/
|
|
@@ -4842,6 +4913,14 @@ var EventProcessor = class {
|
|
|
4842
4913
|
const blocks = this.normalizeContentBlocks(event.data.content);
|
|
4843
4914
|
this.processContentStream(acc, channel, blocks, onPartial);
|
|
4844
4915
|
}
|
|
4916
|
+
if (event.name === "send_attachments" && event.data.attachments) {
|
|
4917
|
+
const attachments = event.data.attachments || [];
|
|
4918
|
+
acc.attachments = [...acc.attachments, ...attachments];
|
|
4919
|
+
this.logger.debug("[ATTACHMENTS] Extracted from send_attachments event", {
|
|
4920
|
+
extractedCount: attachments.length,
|
|
4921
|
+
totalAccCount: acc.attachments.length
|
|
4922
|
+
});
|
|
4923
|
+
}
|
|
4845
4924
|
return;
|
|
4846
4925
|
}
|
|
4847
4926
|
if (event.event === "on_chat_model_stream" && event.data?.chunk?.content) {
|
|
@@ -4881,7 +4960,21 @@ var EventProcessor = class {
|
|
|
4881
4960
|
}
|
|
4882
4961
|
if (toolBlock && toolBlock.type === "tool_use") {
|
|
4883
4962
|
const output = event.data?.output;
|
|
4884
|
-
|
|
4963
|
+
let outputString;
|
|
4964
|
+
try {
|
|
4965
|
+
outputString = typeof output === "string" ? output : JSON.stringify(output, null, 2);
|
|
4966
|
+
} catch {
|
|
4967
|
+
outputString = typeof output?.content === "string" ? output.content : "[Output too large to display]";
|
|
4968
|
+
}
|
|
4969
|
+
const MAX_TOOL_OUTPUT_LENGTH = 5e4;
|
|
4970
|
+
if (outputString.length > MAX_TOOL_OUTPUT_LENGTH) {
|
|
4971
|
+
let cutAt = outputString.lastIndexOf("\n", MAX_TOOL_OUTPUT_LENGTH);
|
|
4972
|
+
if (cutAt < MAX_TOOL_OUTPUT_LENGTH * 0.8) {
|
|
4973
|
+
cutAt = MAX_TOOL_OUTPUT_LENGTH;
|
|
4974
|
+
}
|
|
4975
|
+
outputString = outputString.slice(0, cutAt) + `
|
|
4976
|
+
... [truncated: ${outputString.length - cutAt} chars]`;
|
|
4977
|
+
}
|
|
4885
4978
|
toolBlock.output = outputString;
|
|
4886
4979
|
this.sendDelta(
|
|
4887
4980
|
channel,
|
|
@@ -4925,32 +5018,6 @@ var EventProcessor = class {
|
|
|
4925
5018
|
});
|
|
4926
5019
|
return;
|
|
4927
5020
|
}
|
|
4928
|
-
if (event.event === "on_chain_end") {
|
|
4929
|
-
const channel = event.metadata?.stream_channel ?? "text" /* TEXT */;
|
|
4930
|
-
if (channel === "text" /* TEXT */) {
|
|
4931
|
-
const output = event.data.output;
|
|
4932
|
-
if (output?.answer) {
|
|
4933
|
-
acc.attachments = [
|
|
4934
|
-
...acc.attachments,
|
|
4935
|
-
...output.answer.attachments || []
|
|
4936
|
-
];
|
|
4937
|
-
acc.metadata = { ...acc.metadata, ...output.answer.metadata || {} };
|
|
4938
|
-
} else if (output?.generation) {
|
|
4939
|
-
acc.attachments = [
|
|
4940
|
-
...acc.attachments,
|
|
4941
|
-
...output.generation.attachments || []
|
|
4942
|
-
];
|
|
4943
|
-
acc.metadata = {
|
|
4944
|
-
...acc.metadata,
|
|
4945
|
-
...output.generation.metadata || {}
|
|
4946
|
-
};
|
|
4947
|
-
} else if (output?.attachments || output?.metadata) {
|
|
4948
|
-
acc.attachments = [...acc.attachments, ...output.attachments || []];
|
|
4949
|
-
acc.metadata = { ...acc.metadata, ...output.metadata || {} };
|
|
4950
|
-
}
|
|
4951
|
-
}
|
|
4952
|
-
return;
|
|
4953
|
-
}
|
|
4954
5021
|
}
|
|
4955
5022
|
/**
|
|
4956
5023
|
* Build final result from accumulator
|
|
@@ -4994,7 +5061,9 @@ var EventProcessor = class {
|
|
|
4994
5061
|
textChains: allChains.filter((c) => c.channel === "text").length,
|
|
4995
5062
|
processingChains: allChains.filter((c) => c.channel === "processing").length,
|
|
4996
5063
|
totalSteps: allChains.reduce((sum, c) => sum + c.steps.length, 0),
|
|
4997
|
-
textLength: text.length
|
|
5064
|
+
textLength: text.length,
|
|
5065
|
+
attachmentsCount: acc.attachments?.length || 0,
|
|
5066
|
+
attachments: acc.attachments
|
|
4998
5067
|
});
|
|
4999
5068
|
return {
|
|
5000
5069
|
content: {
|
|
@@ -5135,11 +5204,21 @@ var LangGraphEngine = class {
|
|
|
5135
5204
|
this.logger.debug("[ENGINE] Signal assigned to preparedPayload.signal");
|
|
5136
5205
|
}
|
|
5137
5206
|
const input = await this.deserializeInput(preparedPayload.input || {});
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5207
|
+
try {
|
|
5208
|
+
const result = await graph.invoke(input, {
|
|
5209
|
+
...preparedPayload.config,
|
|
5210
|
+
signal: preparedPayload.signal
|
|
5211
|
+
});
|
|
5212
|
+
return this.processGraphResult(result);
|
|
5213
|
+
} finally {
|
|
5214
|
+
const threadId = this.extractThreadId(preparedPayload);
|
|
5215
|
+
if (threadId) {
|
|
5216
|
+
clearAttachmentDataStore(threadId);
|
|
5217
|
+
this.logger.debug(
|
|
5218
|
+
`[ENGINE] Cleared attachment data store for thread: ${threadId}`
|
|
5219
|
+
);
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5143
5222
|
}
|
|
5144
5223
|
async streamGraph(graph, preparedPayload, onPartial, signal) {
|
|
5145
5224
|
const acc = this.eventProcessor.createAccumulator();
|
|
@@ -5180,6 +5259,13 @@ var LangGraphEngine = class {
|
|
|
5180
5259
|
this.logger.error(`[STREAM-ERROR] Stack trace: ${streamError.stack}`);
|
|
5181
5260
|
} finally {
|
|
5182
5261
|
await this.sendTraceFromAccumulator(acc, preparedPayload, streamError);
|
|
5262
|
+
const threadId = this.extractThreadId(preparedPayload);
|
|
5263
|
+
if (threadId) {
|
|
5264
|
+
clearAttachmentDataStore(threadId);
|
|
5265
|
+
this.logger.debug(
|
|
5266
|
+
`[ENGINE] Cleared attachment data store for thread: ${threadId}`
|
|
5267
|
+
);
|
|
5268
|
+
}
|
|
5183
5269
|
}
|
|
5184
5270
|
const { content, trace } = this.eventProcessor.getResult(acc);
|
|
5185
5271
|
this.logger.debug("[STREAM-RESULT] Got result from EventProcessor", {
|
|
@@ -5358,6 +5444,12 @@ var LangGraphEngine = class {
|
|
|
5358
5444
|
});
|
|
5359
5445
|
}
|
|
5360
5446
|
}
|
|
5447
|
+
/**
|
|
5448
|
+
* Extract threadId from payload (used for attachment store cleanup)
|
|
5449
|
+
*/
|
|
5450
|
+
extractThreadId(preparedPayload) {
|
|
5451
|
+
return preparedPayload.configurable?.thread_id || preparedPayload.configurable?.context?.threadId || preparedPayload.config?.configurable?.thread_id || preparedPayload.config?.configurable?.context?.threadId || void 0;
|
|
5452
|
+
}
|
|
5361
5453
|
/**
|
|
5362
5454
|
* Process graph execution result
|
|
5363
5455
|
*/
|
|
@@ -5383,6 +5475,9 @@ async function createStaticMessage(content, config) {
|
|
|
5383
5475
|
await dispatchCustomEvent("send_static_message", { content }, config);
|
|
5384
5476
|
return message;
|
|
5385
5477
|
}
|
|
5478
|
+
async function dispatchAttachments(attachments, config) {
|
|
5479
|
+
await dispatchCustomEvent("send_attachments", { attachments }, config);
|
|
5480
|
+
}
|
|
5386
5481
|
|
|
5387
5482
|
// src/core/universal-graph.module.ts
|
|
5388
5483
|
init_builder_registry_service();
|
|
@@ -7489,6 +7584,6 @@ StaticDiscovery = __decorateClass([
|
|
|
7489
7584
|
Injectable()
|
|
7490
7585
|
], StaticDiscovery);
|
|
7491
7586
|
|
|
7492
|
-
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, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, RetrieverSearchType, RetrieverService, SmartCallbackRouter, StaticDiscovery, StreamChannel, TelegramPatchHandler, UIDispatchController, UIEndpoint, UIEndpointsDiscoveryService, UniversalCallbackService, UniversalGraphModule, UniversalGraphService, VersionedGraphService, VoyageAIRerank, WebPatchHandler, WithCallbacks, WithEndpoints, WithUIEndpoints, _internals, bootstrap, createEndpointDescriptors, createGraphAttachment, createMongoClientAdapter, createStaticMessage, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, traceApiCall };
|
|
7587
|
+
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, GraphController, GraphEngineFactory, GraphEngineType, GraphManifestSchema, GraphManifestValidator, GraphServiceTokens, GraphTypeUtils, IdempotencyManager, IdempotencyStatus, LangGraphEngine, McpConverter, McpRuntimeHttpClient, McpToolFilter, ModelInitializer, ModelProvider, ModelType, 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, dispatchAttachments, executeToolWithAttachments, findCallbackMethod, findEndpointMethod, generateAttachmentSummary, getAttachmentData, getCallbackMetadata, getEndpointMetadata, getUIEndpointClassMetadata, getUIEndpointMethodsMetadata, hasCallbacks, hasUIEndpoints, registerFinanceExampleCallback, registerUIEndpointsFromClass, sanitizeTraceData, storeAttachmentData, traceApiCall };
|
|
7493
7588
|
//# sourceMappingURL=index.js.map
|
|
7494
7589
|
//# sourceMappingURL=index.js.map
|