@axiom-lattice/core 2.1.11 → 2.1.13

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.ts 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, ScheduleLatticeProtocol, ScheduleConfig, ScheduleClient, ScheduledTaskInfo, 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,480 @@ declare class MemoryQueueClient implements QueueClient {
749
751
  }>;
750
752
  }
751
753
 
754
+ /**
755
+ * ScheduleLatticeManager
756
+ *
757
+ * Schedule Lattice manager for registering and managing schedule services
758
+ */
759
+
760
+ /**
761
+ * Schedule Lattice interface
762
+ */
763
+ interface ScheduleLattice extends ScheduleLatticeProtocol {
764
+ key: string;
765
+ config: ScheduleConfig;
766
+ client: ScheduleLatticeProtocol["client"];
767
+ }
768
+ /**
769
+ * ScheduleLatticeManager - Singleton schedule Lattice manager
770
+ * Responsible for registering and managing various schedule service Lattices
771
+ */
772
+ declare class ScheduleLatticeManager extends BaseLatticeManager<ScheduleLattice> {
773
+ private static _instance;
774
+ /**
775
+ * Get ScheduleLatticeManager singleton instance
776
+ */
777
+ static getInstance(): ScheduleLatticeManager;
778
+ /**
779
+ * Get Lattice type prefix
780
+ */
781
+ protected getLatticeType(): string;
782
+ /**
783
+ * Register schedule Lattice
784
+ * @param key Lattice key name
785
+ * @param config Schedule configuration
786
+ * @param client Optional schedule client. If not provided, will create based on config type.
787
+ */
788
+ registerLattice(key: string, config: ScheduleConfig, client?: ScheduleClient): void;
789
+ /**
790
+ * Get ScheduleLattice
791
+ * @param key Lattice key name
792
+ */
793
+ getScheduleLattice(key: string): ScheduleLattice;
794
+ /**
795
+ * Get all Lattices
796
+ */
797
+ getAllLattices(): ScheduleLattice[];
798
+ /**
799
+ * Check if Lattice exists
800
+ * @param key Lattice key name
801
+ */
802
+ hasLattice(key: string): boolean;
803
+ /**
804
+ * Remove Lattice
805
+ * @param key Lattice key name
806
+ */
807
+ removeLattice(key: string): boolean;
808
+ /**
809
+ * Clear all Lattices
810
+ */
811
+ clearLattices(): void;
812
+ /**
813
+ * Get Lattice count
814
+ */
815
+ getLatticeCount(): number;
816
+ /**
817
+ * Get Lattice key list
818
+ */
819
+ getLatticeKeys(): string[];
820
+ }
821
+ declare const scheduleLatticeManager: ScheduleLatticeManager;
822
+ declare const registerScheduleLattice: (key: string, config: ScheduleConfig, client?: ScheduleClient) => void;
823
+ declare const getScheduleLattice: (key: string) => ScheduleLattice;
824
+
825
+ /**
826
+ * MemoryScheduleClient
827
+ *
828
+ * In-memory schedule service implementation (default)
829
+ * A singleton class for managing delayed function execution
830
+ * Registers functions with timeout and automatically executes and cleans up when time expires
831
+ */
832
+
833
+ /**
834
+ * Memory-based schedule client implementation
835
+ */
836
+ declare class MemoryScheduleClient implements ScheduleClient {
837
+ private static instance;
838
+ private tasks;
839
+ constructor();
840
+ /**
841
+ * Get the singleton instance of MemoryScheduleClient
842
+ */
843
+ static getInstance(): MemoryScheduleClient;
844
+ /**
845
+ * Register a function to be executed after the specified timeout
846
+ * @param taskId - Unique identifier for the task
847
+ * @param callback - Function to execute when timeout expires
848
+ * @param timeoutMs - Delay in milliseconds before execution
849
+ * @returns true if registered successfully
850
+ */
851
+ register(taskId: string, callback: () => void | Promise<void>, timeoutMs: number): boolean;
852
+ /**
853
+ * Cancel a scheduled task by its ID
854
+ * @param taskId - The task identifier to cancel
855
+ * @returns true if task was found and cancelled, false otherwise
856
+ */
857
+ cancel(taskId: string): boolean;
858
+ /**
859
+ * Check if a task is currently scheduled
860
+ * @param taskId - The task identifier to check
861
+ */
862
+ has(taskId: string): boolean;
863
+ /**
864
+ * Get the remaining time in milliseconds for a scheduled task
865
+ * @param taskId - The task identifier
866
+ * @returns Remaining time in ms, or -1 if task not found
867
+ */
868
+ getRemainingTime(taskId: string): number;
869
+ /**
870
+ * Get the count of currently scheduled tasks
871
+ */
872
+ getTaskCount(): number;
873
+ /**
874
+ * Get all scheduled task IDs
875
+ */
876
+ getTaskIds(): string[];
877
+ /**
878
+ * Cancel all scheduled tasks
879
+ */
880
+ cancelAll(): void;
881
+ /**
882
+ * Get task information
883
+ * @param taskId - The task identifier
884
+ * @returns Task info or null if not found
885
+ */
886
+ getTaskInfo(taskId: string): ScheduledTaskInfo | null;
887
+ /**
888
+ * Reset the singleton instance (useful for testing)
889
+ */
890
+ static resetInstance(): void;
891
+ }
892
+
893
+ /**
894
+ * StoreLatticeManager
895
+ *
896
+ * Store Lattice manager for registering and managing store services
897
+ */
898
+
899
+ /**
900
+ * Store type to store interface mapping
901
+ * Maps store type strings to their corresponding interface types
902
+ */
903
+ type StoreTypeMap = {
904
+ thread: ThreadStore;
905
+ assistant: AssistantStore;
906
+ };
907
+ /**
908
+ * Store type keys
909
+ */
910
+ type StoreType = keyof StoreTypeMap;
911
+ /**
912
+ * Store Lattice interface with type safety
913
+ * @template TStoreType - The type of store (e.g., "thread")
914
+ */
915
+ interface StoreLattice<TStoreType extends StoreType = StoreType> {
916
+ type: TStoreType;
917
+ key: string;
918
+ store: StoreTypeMap[TStoreType];
919
+ }
920
+ /**
921
+ * StoreLatticeManager - Singleton store Lattice manager
922
+ * Responsible for registering and managing various store service Lattices
923
+ */
924
+ declare class StoreLatticeManager extends BaseLatticeManager<StoreLattice<StoreType>> {
925
+ private static _instance;
926
+ /**
927
+ * Get StoreLatticeManager singleton instance
928
+ */
929
+ static getInstance(): StoreLatticeManager;
930
+ /**
931
+ * Get Lattice type prefix
932
+ */
933
+ protected getLatticeType(): string;
934
+ /**
935
+ * Generate composite key from key and type
936
+ * @param key Lattice key name
937
+ * @param type Store type
938
+ * @returns Composite key string
939
+ */
940
+ private getCompositeKey;
941
+ /**
942
+ * Register store Lattice with type safety
943
+ * Uses composite key (key + type) as unique identifier
944
+ * @param key Lattice key name
945
+ * @param type Store type (e.g., "thread")
946
+ * @param store Store implementation instance matching the type
947
+ */
948
+ registerLattice<TStoreType extends StoreType>(key: string, type: TStoreType, store: StoreTypeMap[TStoreType]): void;
949
+ /**
950
+ * Get StoreLattice with type safety
951
+ * Uses composite key (key + type) to retrieve the store
952
+ * @param key Lattice key name
953
+ * @param type Expected store type for type checking
954
+ * @returns StoreLattice with typed store
955
+ */
956
+ getStoreLattice<TStoreType extends StoreType>(key: string, type: TStoreType): StoreLattice<TStoreType>;
957
+ /**
958
+ * Get StoreLattice without type checking (for backward compatibility)
959
+ * @param key Lattice key name
960
+ * @param type Store type
961
+ * @returns StoreLattice (type may be unknown)
962
+ */
963
+ getStoreLatticeUnsafe(key: string, type: StoreType): StoreLattice<StoreType>;
964
+ /**
965
+ * Get all Lattices
966
+ */
967
+ getAllLattices(): StoreLattice<StoreType>[];
968
+ /**
969
+ * Check if Lattice exists
970
+ * Uses composite key (key + type) to check existence
971
+ * @param key Lattice key name
972
+ * @param type Store type
973
+ */
974
+ hasLattice(key: string, type: StoreType): boolean;
975
+ /**
976
+ * Remove Lattice
977
+ * Uses composite key (key + type) to remove the store
978
+ * @param key Lattice key name
979
+ * @param type Store type
980
+ */
981
+ removeLattice(key: string, type: StoreType): boolean;
982
+ /**
983
+ * Clear all Lattices
984
+ */
985
+ clearLattices(): void;
986
+ /**
987
+ * Get Lattice count
988
+ */
989
+ getLatticeCount(): number;
990
+ /**
991
+ * Get Lattice key list
992
+ */
993
+ getLatticeKeys(): string[];
994
+ }
995
+ declare const storeLatticeManager: StoreLatticeManager;
996
+ declare const registerStoreLattice: <TStoreType extends StoreType>(key: string, type: TStoreType, store: StoreTypeMap[TStoreType]) => void;
997
+ declare const getStoreLattice: <TStoreType extends StoreType>(key: string, type: TStoreType) => StoreLattice<TStoreType>;
998
+
999
+ /**
1000
+ * InMemoryThreadStore
1001
+ *
1002
+ * In-memory implementation of ThreadStore
1003
+ * Provides CRUD operations for thread data stored in memory
1004
+ * Threads are organized by assistant ID
1005
+ */
1006
+
1007
+ /**
1008
+ * In-memory implementation of ThreadStore
1009
+ */
1010
+ declare class InMemoryThreadStore implements ThreadStore {
1011
+ private threads;
1012
+ /**
1013
+ * Get all threads for a specific assistant
1014
+ */
1015
+ getThreadsByAssistantId(assistantId: string): Promise<Thread[]>;
1016
+ /**
1017
+ * Get a thread by ID for a specific assistant
1018
+ */
1019
+ getThreadById(assistantId: string, threadId: string): Promise<Thread | undefined>;
1020
+ /**
1021
+ * Create a new thread for an assistant
1022
+ */
1023
+ createThread(assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
1024
+ /**
1025
+ * Update an existing thread
1026
+ */
1027
+ updateThread(assistantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
1028
+ /**
1029
+ * Delete a thread by ID
1030
+ */
1031
+ deleteThread(assistantId: string, threadId: string): Promise<boolean>;
1032
+ /**
1033
+ * Check if thread exists
1034
+ */
1035
+ hasThread(assistantId: string, threadId: string): Promise<boolean>;
1036
+ /**
1037
+ * Clear all threads (useful for testing)
1038
+ */
1039
+ clear(): void;
1040
+ /**
1041
+ * Get all threads for all assistants (useful for debugging)
1042
+ */
1043
+ getAllThreads(): Thread[];
1044
+ }
1045
+
1046
+ /**
1047
+ * InMemoryAssistantStore
1048
+ *
1049
+ * In-memory implementation of AssistantStore
1050
+ * Provides CRUD operations for assistant data stored in memory
1051
+ */
1052
+
1053
+ /**
1054
+ * In-memory implementation of AssistantStore
1055
+ */
1056
+ declare class InMemoryAssistantStore implements AssistantStore {
1057
+ private assistants;
1058
+ /**
1059
+ * Get all assistants
1060
+ */
1061
+ getAllAssistants(): Promise<Assistant[]>;
1062
+ /**
1063
+ * Get assistant by ID
1064
+ */
1065
+ getAssistantById(id: string): Promise<Assistant | null>;
1066
+ /**
1067
+ * Create a new assistant
1068
+ */
1069
+ createAssistant(id: string, data: CreateAssistantRequest): Promise<Assistant>;
1070
+ /**
1071
+ * Update an existing assistant
1072
+ */
1073
+ updateAssistant(id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
1074
+ /**
1075
+ * Delete an assistant by ID
1076
+ */
1077
+ deleteAssistant(id: string): Promise<boolean>;
1078
+ /**
1079
+ * Check if assistant exists
1080
+ */
1081
+ hasAssistant(id: string): Promise<boolean>;
1082
+ /**
1083
+ * Clear all assistants (useful for testing)
1084
+ */
1085
+ clear(): void;
1086
+ }
1087
+
1088
+ /**
1089
+ * Embeddings Lattice Interface
1090
+ * Defines the structure of an embeddings lattice entry
1091
+ */
1092
+ interface EmbeddingsLatticeInterface {
1093
+ key: string;
1094
+ client: Embeddings;
1095
+ }
1096
+ /**
1097
+ * EmbeddingsLatticeManager - Singleton embeddings Lattice manager
1098
+ * Responsible for registering and managing various embeddings model Lattices
1099
+ */
1100
+ declare class EmbeddingsLatticeManager extends BaseLatticeManager<EmbeddingsLatticeInterface> {
1101
+ private static _instance;
1102
+ /**
1103
+ * Get EmbeddingsLatticeManager singleton instance
1104
+ */
1105
+ static getInstance(): EmbeddingsLatticeManager;
1106
+ /**
1107
+ * Get Lattice type prefix
1108
+ */
1109
+ protected getLatticeType(): string;
1110
+ /**
1111
+ * Register embeddings Lattice
1112
+ * @param key Lattice key name
1113
+ * @param embeddings Embeddings instance
1114
+ */
1115
+ registerLattice(key: string, embeddings: Embeddings): void;
1116
+ /**
1117
+ * Get EmbeddingsLattice
1118
+ * @param key Lattice key name
1119
+ */
1120
+ getEmbeddingsLattice(key: string): EmbeddingsLatticeInterface;
1121
+ /**
1122
+ * Get all Lattices
1123
+ */
1124
+ getAllLattices(): EmbeddingsLatticeInterface[];
1125
+ /**
1126
+ * Check if Lattice exists
1127
+ * @param key Lattice key name
1128
+ */
1129
+ hasLattice(key: string): boolean;
1130
+ /**
1131
+ * Remove Lattice
1132
+ * @param key Lattice key name
1133
+ */
1134
+ removeLattice(key: string): boolean;
1135
+ /**
1136
+ * Clear all Lattices
1137
+ */
1138
+ clearLattices(): void;
1139
+ /**
1140
+ * Get Lattice count
1141
+ */
1142
+ getLatticeCount(): number;
1143
+ /**
1144
+ * Get Lattice key list
1145
+ */
1146
+ getLatticeKeys(): string[];
1147
+ /**
1148
+ * Get embeddings client
1149
+ * @param key Lattice key name
1150
+ */
1151
+ getEmbeddingsClient(key: string): Embeddings;
1152
+ }
1153
+ declare const embeddingsLatticeManager: EmbeddingsLatticeManager;
1154
+ declare const registerEmbeddingsLattice: (key: string, embeddings: Embeddings) => void;
1155
+ declare const getEmbeddingsLattice: (key: string) => EmbeddingsLatticeInterface;
1156
+ declare const getEmbeddingsClient: (key: string) => Embeddings<number[]>;
1157
+
1158
+ /**
1159
+ * VectorStore Lattice Interface
1160
+ * Defines the structure of a vector store lattice entry
1161
+ */
1162
+ interface VectorStoreLatticeInterface {
1163
+ key: string;
1164
+ client: VectorStore;
1165
+ }
1166
+ /**
1167
+ * VectorStoreLatticeManager - Singleton vector store Lattice manager
1168
+ * Responsible for registering and managing various vector store Lattices
1169
+ */
1170
+ declare class VectorStoreLatticeManager extends BaseLatticeManager<VectorStoreLatticeInterface> {
1171
+ private static _instance;
1172
+ /**
1173
+ * Get VectorStoreLatticeManager singleton instance
1174
+ */
1175
+ static getInstance(): VectorStoreLatticeManager;
1176
+ /**
1177
+ * Get Lattice type prefix
1178
+ */
1179
+ protected getLatticeType(): string;
1180
+ /**
1181
+ * Register vector store Lattice
1182
+ * @param key Lattice key name
1183
+ * @param vectorStore VectorStore instance
1184
+ */
1185
+ registerLattice(key: string, vectorStore: VectorStore): void;
1186
+ /**
1187
+ * Get VectorStoreLattice
1188
+ * @param key Lattice key name
1189
+ */
1190
+ getVectorStoreLattice(key: string): VectorStoreLatticeInterface;
1191
+ /**
1192
+ * Get all Lattices
1193
+ */
1194
+ getAllLattices(): VectorStoreLatticeInterface[];
1195
+ /**
1196
+ * Check if Lattice exists
1197
+ * @param key Lattice key name
1198
+ */
1199
+ hasLattice(key: string): boolean;
1200
+ /**
1201
+ * Remove Lattice
1202
+ * @param key Lattice key name
1203
+ */
1204
+ removeLattice(key: string): boolean;
1205
+ /**
1206
+ * Clear all Lattices
1207
+ */
1208
+ clearLattices(): void;
1209
+ /**
1210
+ * Get Lattice count
1211
+ */
1212
+ getLatticeCount(): number;
1213
+ /**
1214
+ * Get Lattice key list
1215
+ */
1216
+ getLatticeKeys(): string[];
1217
+ /**
1218
+ * Get vector store client
1219
+ * @param key Lattice key name
1220
+ */
1221
+ getVectorStoreClient(key: string): VectorStore;
1222
+ }
1223
+ declare const vectorStoreLatticeManager: VectorStoreLatticeManager;
1224
+ declare const registerVectorStoreLattice: (key: string, vectorStore: VectorStore) => void;
1225
+ declare const getVectorStoreLattice: (key: string) => VectorStoreLatticeInterface;
1226
+ declare const getVectorStoreClient: (key: string) => VectorStore;
1227
+
752
1228
  /**
753
1229
  * Event bus service
754
1230
  * Used for event publishing and subscription between internal system components
@@ -806,4 +1282,4 @@ declare class AgentManager {
806
1282
 
807
1283
  declare const AGENT_TASK_EVENT = "agent:execute";
808
1284
 
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 };
1285
+ export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryThreadStore, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleClient, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type QueueLattice, QueueLatticeManager, type ScheduleLattice, ScheduleLatticeManager, 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, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, hasChunkBuffer, modelLatticeManager, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerToolLattice, registerVectorStoreLattice, scheduleLatticeManager, storeLatticeManager, toolLatticeManager, validateAgentInput, validateToolInput, vectorStoreLatticeManager };