@axiom-lattice/core 2.1.11 → 2.1.12

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.mts CHANGED
@@ -5,7 +5,7 @@ import { BaseChatModel, BaseChatModelCallOptions } from '@langchain/core/languag
5
5
  import { BaseLanguageModelInput } from '@langchain/core/language_models/base';
6
6
  import { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
7
7
  import { ChatResult } from '@langchain/core/outputs';
8
- import { LLMConfig, ToolConfig, ToolExecutor, AgentConfig, GraphBuildOptions, MessageChunk, QueueLatticeProtocol, QueueConfig, QueueClient, QueueResult } from '@axiom-lattice/protocols';
8
+ import { LLMConfig, ToolConfig, ToolExecutor, AgentConfig, GraphBuildOptions, MessageChunk, QueueLatticeProtocol, QueueConfig, QueueClient, QueueResult, ThreadStore, AssistantStore, Thread, CreateThreadRequest, Assistant, CreateAssistantRequest } from '@axiom-lattice/protocols';
9
9
  import * as protocols from '@axiom-lattice/protocols';
10
10
  export { protocols as Protocols };
11
11
  export { AgentConfig, AgentType, GraphBuildOptions, MemoryType } from '@axiom-lattice/protocols';
@@ -15,6 +15,8 @@ import { CompiledStateGraph } from '@langchain/langgraph';
15
15
  import { ReactAgent } from 'langchain';
16
16
  import { BaseCheckpointSaver } from '@langchain/langgraph-checkpoint';
17
17
  import { ReplaySubject } from 'rxjs';
18
+ import { Embeddings } from '@langchain/core/embeddings';
19
+ import { VectorStore } from '@langchain/core/vectorstores';
18
20
 
19
21
  /**
20
22
  * BaseLatticeManager - 抽象基类,为各种Lattice管理器提供通用功能
@@ -749,6 +751,341 @@ declare class MemoryQueueClient implements QueueClient {
749
751
  }>;
750
752
  }
751
753
 
754
+ /**
755
+ * StoreLatticeManager
756
+ *
757
+ * Store Lattice manager for registering and managing store services
758
+ */
759
+
760
+ /**
761
+ * Store type to store interface mapping
762
+ * Maps store type strings to their corresponding interface types
763
+ */
764
+ type StoreTypeMap = {
765
+ thread: ThreadStore;
766
+ assistant: AssistantStore;
767
+ };
768
+ /**
769
+ * Store type keys
770
+ */
771
+ type StoreType = keyof StoreTypeMap;
772
+ /**
773
+ * Store Lattice interface with type safety
774
+ * @template TStoreType - The type of store (e.g., "thread")
775
+ */
776
+ interface StoreLattice<TStoreType extends StoreType = StoreType> {
777
+ type: TStoreType;
778
+ key: string;
779
+ store: StoreTypeMap[TStoreType];
780
+ }
781
+ /**
782
+ * StoreLatticeManager - Singleton store Lattice manager
783
+ * Responsible for registering and managing various store service Lattices
784
+ */
785
+ declare class StoreLatticeManager extends BaseLatticeManager<StoreLattice<StoreType>> {
786
+ private static _instance;
787
+ /**
788
+ * Get StoreLatticeManager singleton instance
789
+ */
790
+ static getInstance(): StoreLatticeManager;
791
+ /**
792
+ * Get Lattice type prefix
793
+ */
794
+ protected getLatticeType(): string;
795
+ /**
796
+ * Generate composite key from key and type
797
+ * @param key Lattice key name
798
+ * @param type Store type
799
+ * @returns Composite key string
800
+ */
801
+ private getCompositeKey;
802
+ /**
803
+ * Register store Lattice with type safety
804
+ * Uses composite key (key + type) as unique identifier
805
+ * @param key Lattice key name
806
+ * @param type Store type (e.g., "thread")
807
+ * @param store Store implementation instance matching the type
808
+ */
809
+ registerLattice<TStoreType extends StoreType>(key: string, type: TStoreType, store: StoreTypeMap[TStoreType]): void;
810
+ /**
811
+ * Get StoreLattice with type safety
812
+ * Uses composite key (key + type) to retrieve the store
813
+ * @param key Lattice key name
814
+ * @param type Expected store type for type checking
815
+ * @returns StoreLattice with typed store
816
+ */
817
+ getStoreLattice<TStoreType extends StoreType>(key: string, type: TStoreType): StoreLattice<TStoreType>;
818
+ /**
819
+ * Get StoreLattice without type checking (for backward compatibility)
820
+ * @param key Lattice key name
821
+ * @param type Store type
822
+ * @returns StoreLattice (type may be unknown)
823
+ */
824
+ getStoreLatticeUnsafe(key: string, type: StoreType): StoreLattice<StoreType>;
825
+ /**
826
+ * Get all Lattices
827
+ */
828
+ getAllLattices(): StoreLattice<StoreType>[];
829
+ /**
830
+ * Check if Lattice exists
831
+ * Uses composite key (key + type) to check existence
832
+ * @param key Lattice key name
833
+ * @param type Store type
834
+ */
835
+ hasLattice(key: string, type: StoreType): boolean;
836
+ /**
837
+ * Remove Lattice
838
+ * Uses composite key (key + type) to remove the store
839
+ * @param key Lattice key name
840
+ * @param type Store type
841
+ */
842
+ removeLattice(key: string, type: StoreType): boolean;
843
+ /**
844
+ * Clear all Lattices
845
+ */
846
+ clearLattices(): void;
847
+ /**
848
+ * Get Lattice count
849
+ */
850
+ getLatticeCount(): number;
851
+ /**
852
+ * Get Lattice key list
853
+ */
854
+ getLatticeKeys(): string[];
855
+ }
856
+ declare const storeLatticeManager: StoreLatticeManager;
857
+ declare const registerStoreLattice: <TStoreType extends StoreType>(key: string, type: TStoreType, store: StoreTypeMap[TStoreType]) => void;
858
+ declare const getStoreLattice: <TStoreType extends StoreType>(key: string, type: TStoreType) => StoreLattice<TStoreType>;
859
+
860
+ /**
861
+ * InMemoryThreadStore
862
+ *
863
+ * In-memory implementation of ThreadStore
864
+ * Provides CRUD operations for thread data stored in memory
865
+ * Threads are organized by assistant ID
866
+ */
867
+
868
+ /**
869
+ * In-memory implementation of ThreadStore
870
+ */
871
+ declare class InMemoryThreadStore implements ThreadStore {
872
+ private threads;
873
+ /**
874
+ * Get all threads for a specific assistant
875
+ */
876
+ getThreadsByAssistantId(assistantId: string): Promise<Thread[]>;
877
+ /**
878
+ * Get a thread by ID for a specific assistant
879
+ */
880
+ getThreadById(assistantId: string, threadId: string): Promise<Thread | undefined>;
881
+ /**
882
+ * Create a new thread for an assistant
883
+ */
884
+ createThread(assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
885
+ /**
886
+ * Update an existing thread
887
+ */
888
+ updateThread(assistantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
889
+ /**
890
+ * Delete a thread by ID
891
+ */
892
+ deleteThread(assistantId: string, threadId: string): Promise<boolean>;
893
+ /**
894
+ * Check if thread exists
895
+ */
896
+ hasThread(assistantId: string, threadId: string): Promise<boolean>;
897
+ /**
898
+ * Clear all threads (useful for testing)
899
+ */
900
+ clear(): void;
901
+ /**
902
+ * Get all threads for all assistants (useful for debugging)
903
+ */
904
+ getAllThreads(): Thread[];
905
+ }
906
+
907
+ /**
908
+ * InMemoryAssistantStore
909
+ *
910
+ * In-memory implementation of AssistantStore
911
+ * Provides CRUD operations for assistant data stored in memory
912
+ */
913
+
914
+ /**
915
+ * In-memory implementation of AssistantStore
916
+ */
917
+ declare class InMemoryAssistantStore implements AssistantStore {
918
+ private assistants;
919
+ /**
920
+ * Get all assistants
921
+ */
922
+ getAllAssistants(): Promise<Assistant[]>;
923
+ /**
924
+ * Get assistant by ID
925
+ */
926
+ getAssistantById(id: string): Promise<Assistant | null>;
927
+ /**
928
+ * Create a new assistant
929
+ */
930
+ createAssistant(id: string, data: CreateAssistantRequest): Promise<Assistant>;
931
+ /**
932
+ * Update an existing assistant
933
+ */
934
+ updateAssistant(id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
935
+ /**
936
+ * Delete an assistant by ID
937
+ */
938
+ deleteAssistant(id: string): Promise<boolean>;
939
+ /**
940
+ * Check if assistant exists
941
+ */
942
+ hasAssistant(id: string): Promise<boolean>;
943
+ /**
944
+ * Clear all assistants (useful for testing)
945
+ */
946
+ clear(): void;
947
+ }
948
+
949
+ /**
950
+ * Embeddings Lattice Interface
951
+ * Defines the structure of an embeddings lattice entry
952
+ */
953
+ interface EmbeddingsLatticeInterface {
954
+ key: string;
955
+ client: Embeddings;
956
+ }
957
+ /**
958
+ * EmbeddingsLatticeManager - Singleton embeddings Lattice manager
959
+ * Responsible for registering and managing various embeddings model Lattices
960
+ */
961
+ declare class EmbeddingsLatticeManager extends BaseLatticeManager<EmbeddingsLatticeInterface> {
962
+ private static _instance;
963
+ /**
964
+ * Get EmbeddingsLatticeManager singleton instance
965
+ */
966
+ static getInstance(): EmbeddingsLatticeManager;
967
+ /**
968
+ * Get Lattice type prefix
969
+ */
970
+ protected getLatticeType(): string;
971
+ /**
972
+ * Register embeddings Lattice
973
+ * @param key Lattice key name
974
+ * @param embeddings Embeddings instance
975
+ */
976
+ registerLattice(key: string, embeddings: Embeddings): void;
977
+ /**
978
+ * Get EmbeddingsLattice
979
+ * @param key Lattice key name
980
+ */
981
+ getEmbeddingsLattice(key: string): EmbeddingsLatticeInterface;
982
+ /**
983
+ * Get all Lattices
984
+ */
985
+ getAllLattices(): EmbeddingsLatticeInterface[];
986
+ /**
987
+ * Check if Lattice exists
988
+ * @param key Lattice key name
989
+ */
990
+ hasLattice(key: string): boolean;
991
+ /**
992
+ * Remove Lattice
993
+ * @param key Lattice key name
994
+ */
995
+ removeLattice(key: string): boolean;
996
+ /**
997
+ * Clear all Lattices
998
+ */
999
+ clearLattices(): void;
1000
+ /**
1001
+ * Get Lattice count
1002
+ */
1003
+ getLatticeCount(): number;
1004
+ /**
1005
+ * Get Lattice key list
1006
+ */
1007
+ getLatticeKeys(): string[];
1008
+ /**
1009
+ * Get embeddings client
1010
+ * @param key Lattice key name
1011
+ */
1012
+ getEmbeddingsClient(key: string): Embeddings;
1013
+ }
1014
+ declare const embeddingsLatticeManager: EmbeddingsLatticeManager;
1015
+ declare const registerEmbeddingsLattice: (key: string, embeddings: Embeddings) => void;
1016
+ declare const getEmbeddingsLattice: (key: string) => EmbeddingsLatticeInterface;
1017
+ declare const getEmbeddingsClient: (key: string) => Embeddings<number[]>;
1018
+
1019
+ /**
1020
+ * VectorStore Lattice Interface
1021
+ * Defines the structure of a vector store lattice entry
1022
+ */
1023
+ interface VectorStoreLatticeInterface {
1024
+ key: string;
1025
+ client: VectorStore;
1026
+ }
1027
+ /**
1028
+ * VectorStoreLatticeManager - Singleton vector store Lattice manager
1029
+ * Responsible for registering and managing various vector store Lattices
1030
+ */
1031
+ declare class VectorStoreLatticeManager extends BaseLatticeManager<VectorStoreLatticeInterface> {
1032
+ private static _instance;
1033
+ /**
1034
+ * Get VectorStoreLatticeManager singleton instance
1035
+ */
1036
+ static getInstance(): VectorStoreLatticeManager;
1037
+ /**
1038
+ * Get Lattice type prefix
1039
+ */
1040
+ protected getLatticeType(): string;
1041
+ /**
1042
+ * Register vector store Lattice
1043
+ * @param key Lattice key name
1044
+ * @param vectorStore VectorStore instance
1045
+ */
1046
+ registerLattice(key: string, vectorStore: VectorStore): void;
1047
+ /**
1048
+ * Get VectorStoreLattice
1049
+ * @param key Lattice key name
1050
+ */
1051
+ getVectorStoreLattice(key: string): VectorStoreLatticeInterface;
1052
+ /**
1053
+ * Get all Lattices
1054
+ */
1055
+ getAllLattices(): VectorStoreLatticeInterface[];
1056
+ /**
1057
+ * Check if Lattice exists
1058
+ * @param key Lattice key name
1059
+ */
1060
+ hasLattice(key: string): boolean;
1061
+ /**
1062
+ * Remove Lattice
1063
+ * @param key Lattice key name
1064
+ */
1065
+ removeLattice(key: string): boolean;
1066
+ /**
1067
+ * Clear all Lattices
1068
+ */
1069
+ clearLattices(): void;
1070
+ /**
1071
+ * Get Lattice count
1072
+ */
1073
+ getLatticeCount(): number;
1074
+ /**
1075
+ * Get Lattice key list
1076
+ */
1077
+ getLatticeKeys(): string[];
1078
+ /**
1079
+ * Get vector store client
1080
+ * @param key Lattice key name
1081
+ */
1082
+ getVectorStoreClient(key: string): VectorStore;
1083
+ }
1084
+ declare const vectorStoreLatticeManager: VectorStoreLatticeManager;
1085
+ declare const registerVectorStoreLattice: (key: string, vectorStore: VectorStore) => void;
1086
+ declare const getVectorStoreLattice: (key: string) => VectorStoreLatticeInterface;
1087
+ declare const getVectorStoreClient: (key: string) => VectorStore;
1088
+
752
1089
  /**
753
1090
  * Event bus service
754
1091
  * Used for event publishing and subscription between internal system components
@@ -806,4 +1143,4 @@ declare class AgentManager {
806
1143
 
807
1144
  declare const AGENT_TASK_EVENT = "agent:execute";
808
1145
 
809
- export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, InMemoryChunkBuffer, MemoryLatticeManager, MemoryQueueClient, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type QueueLattice, QueueLatticeManager, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, agentLatticeManager, eventBus, eventBus as eventBusDefault, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getModelLattice, getQueueLattice, getToolClient, getToolDefinition, getToolLattice, hasChunkBuffer, modelLatticeManager, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerModelLattice, registerQueueLattice, registerToolLattice, toolLatticeManager, validateAgentInput, validateToolInput };
1146
+ export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryThreadStore, MemoryLatticeManager, MemoryQueueClient, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type QueueLattice, QueueLatticeManager, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, type VectorStoreLatticeInterface, VectorStoreLatticeManager, agentLatticeManager, embeddingsLatticeManager, eventBus, eventBus as eventBusDefault, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getModelLattice, getQueueLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, hasChunkBuffer, modelLatticeManager, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerModelLattice, registerQueueLattice, registerStoreLattice, registerToolLattice, registerVectorStoreLattice, storeLatticeManager, toolLatticeManager, validateAgentInput, validateToolInput, vectorStoreLatticeManager };