@axiom-lattice/core 2.1.32 → 2.1.33

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
@@ -25,6 +25,7 @@ import { Connection, MultiServerMCPClient } from '@langchain/mcp-adapters';
25
25
  /**
26
26
  * BaseLatticeManager - 抽象基类,为各种Lattice管理器提供通用功能
27
27
  * 使用统一的Lattice注册表,不同类型的Lattice通过前缀区分
28
+ * 支持租户隔离,键格式: {type}:{tenantId}:{key}
28
29
  * @template TItem - 管理的项目类型
29
30
  */
30
31
  declare abstract class BaseLatticeManager<TItem = any> {
@@ -43,47 +44,118 @@ declare abstract class BaseLatticeManager<TItem = any> {
43
44
  */
44
45
  protected abstract getLatticeType(): string;
45
46
  /**
46
- * 构造完整的键名,包含类型前缀
47
+ * 从store异步加载单个项目(可选实现)
48
+ * 子类可以重写此方法以支持从持久化存储加载单个项目
49
+ * 方法名使用 loadItemFromStore 以避免与子类可能已有的 loadFromStore 冲突
50
+ * @param tenantId 租户ID
51
+ * @param key 项目键名
52
+ * @returns 加载的项目,如果未找到则返回undefined
53
+ */
54
+ protected loadItemFromStore?(tenantId: string, key: string): Promise<TItem | undefined>;
55
+ /**
56
+ * 构造完整的键名,包含类型前缀和租户ID
57
+ * @param tenantId 租户ID,全局共享使用 "default"
47
58
  * @param key 原始键名
48
59
  */
49
- protected getFullKey(key: string): string;
60
+ protected getFullKey(tenantId: string, key: string): string;
50
61
  /**
51
- * 注册项目
62
+ * 带租户的注册项目
63
+ * @param tenantId 租户ID
64
+ * @param key 项目键名(不含前缀)
65
+ * @param item 项目实例
66
+ */
67
+ registerWithTenant(tenantId: string, key: string, item: TItem): void;
68
+ /**
69
+ * 带租户的获取指定项目(同步)
70
+ * @param tenantId 租户ID
71
+ * @param key 项目键名(不含前缀)
72
+ */
73
+ getWithTenant(tenantId: string, key: string): TItem | undefined;
74
+ /**
75
+ * 带租户的获取指定项目(异步,支持从store回退加载)
76
+ * 如果内存中不存在且子类实现了loadItemFromStore,则尝试从store加载
77
+ * @param tenantId 租户ID
78
+ * @param key 项目键名(不含前缀)
79
+ * @returns 项目实例,如果未找到则返回undefined
80
+ */
81
+ getOrLoadWithTenant(tenantId: string, key: string): Promise<TItem | undefined>;
82
+ /**
83
+ * 带租户的检查项目是否存在(同步)
84
+ * @param tenantId 租户ID
85
+ * @param key 项目键名(不含前缀)
86
+ */
87
+ hasWithTenant(tenantId: string, key: string): boolean;
88
+ /**
89
+ * 带租户的检查项目是否存在(异步,支持从store回退加载)
90
+ * 如果内存中不存在且子类实现了loadItemFromStore,则尝试从store加载
91
+ * @param tenantId 租户ID
92
+ * @param key 项目键名(不含前缀)
93
+ * @returns 如果存在或能从store加载则返回true
94
+ */
95
+ hasOrLoadWithTenant(tenantId: string, key: string): Promise<boolean>;
96
+ /**
97
+ * 带租户的移除项目
98
+ * @param tenantId 租户ID
99
+ * @param key 项目键名(不含前缀)
100
+ */
101
+ removeWithTenant(tenantId: string, key: string): boolean;
102
+ /**
103
+ * 获取指定租户的所有项目
104
+ * @param tenantId 租户ID
105
+ */
106
+ getAllByTenant(tenantId: string): TItem[];
107
+ /**
108
+ * 清空指定租户的所有项目
109
+ * @param tenantId 租户ID
110
+ */
111
+ clearByTenant(tenantId: string): void;
112
+ /**
113
+ * 注册项目(向后兼容,使用 "default" 租户)
114
+ * @deprecated Use registerWithTenant(tenantId, key, item) instead
52
115
  * @param key 项目键名(不含前缀)
53
116
  * @param item 项目实例
54
117
  */
55
118
  register(key: string, item: TItem): void;
56
119
  /**
57
- * 获取指定项目
120
+ * 获取指定项目(向后兼容,使用 "default" 租户)
121
+ * @deprecated Use getWithTenant(tenantId, key) instead
58
122
  * @param key 项目键名(不含前缀)
59
123
  */
60
124
  get(key: string): TItem | undefined;
61
125
  /**
62
- * 获取所有当前类型的项目
126
+ * 获取所有当前类型的项目(向后兼容,包含所有租户)
63
127
  */
64
128
  getAll(): TItem[];
65
129
  /**
66
- * 检查项目是否存在
130
+ * 检查项目是否存在(向后兼容,使用 "default" 租户)
131
+ * @deprecated Use hasWithTenant(tenantId, key) instead
67
132
  * @param key 项目键名(不含前缀)
68
133
  */
69
134
  has(key: string): boolean;
70
135
  /**
71
- * 移除项目
136
+ * 移除项目(向后兼容,使用 "default" 租户)
137
+ * @deprecated Use removeWithTenant(tenantId, key) instead
72
138
  * @param key 项目键名(不含前缀)
73
139
  */
74
140
  remove(key: string): boolean;
75
141
  /**
76
- * 清空当前类型的所有项目
142
+ * 清空当前类型的所有项目(向后兼容,包含所有租户)
77
143
  */
78
144
  clear(): void;
79
145
  /**
80
- * 获取当前类型的项目数量
146
+ * 获取当前类型的项目数量(向后兼容,包含所有租户)
81
147
  */
82
148
  count(): number;
83
149
  /**
84
- * 获取当前类型的项目键名列表(不含前缀)
150
+ * 获取当前类型的项目键名列表(向后兼容,包含所有租户)
151
+ * 返回格式: {tenantId}:{key}
85
152
  */
86
153
  keys(): string[];
154
+ /**
155
+ * 获取当前类型的项目键名列表(仅指定租户,不含租户前缀)
156
+ * @param tenantId 租户ID
157
+ */
158
+ keysByTenant(tenantId: string): string[];
87
159
  }
88
160
 
89
161
  /**
@@ -319,54 +391,72 @@ declare class PostgresDatabase implements ISqlDatabase {
319
391
  }
320
392
  /**
321
393
  * SQL Database Manager
322
- * Manages database connections and provides a unified interface
394
+ * Manages database connections with tenant isolation
395
+ *
396
+ * Structure: Map<tenantId, Map<key, ISqlDatabase>>
397
+ * Each tenant has its own isolated set of database connections
323
398
  */
324
399
  declare class SqlDatabaseManager {
325
400
  private static instance;
326
401
  private databases;
327
- private defaultDatabaseKey;
402
+ private defaultDatabaseKeys;
328
403
  private constructor();
329
404
  /**
330
405
  * Get the singleton instance
331
406
  */
332
407
  static getInstance(): SqlDatabaseManager;
333
408
  /**
334
- * Register a database connection
335
- * @param key - Unique identifier for the database
409
+ * Get or create tenant database map
410
+ */
411
+ private getTenantDatabases;
412
+ /**
413
+ * Register a database connection for a tenant
414
+ * @param tenantId - Tenant identifier
415
+ * @param key - Unique identifier for the database within the tenant
336
416
  * @param config - Database configuration
337
417
  */
338
- registerDatabase(key: string, config: DatabaseConfig): void;
418
+ registerDatabase(tenantId: string, key: string, config: DatabaseConfig): void;
339
419
  /**
340
- * Set the default database
420
+ * Set the default database for a tenant
421
+ * @param tenantId - Tenant identifier
341
422
  * @param key - Database key to set as default
342
423
  */
343
- setDefaultDatabase(key: string): void;
424
+ setDefaultDatabase(tenantId: string, key: string): void;
344
425
  /**
345
- * Get a database by key
426
+ * Get a database by key for a specific tenant
427
+ * @param tenantId - Tenant identifier (required)
346
428
  * @param key - Database key (optional, uses default if not provided)
429
+ * @returns ISqlDatabase instance
430
+ * @throws Error if tenant or database not found
347
431
  */
348
- getDatabase(key?: string): ISqlDatabase;
432
+ getDatabase(tenantId: string, key?: string): ISqlDatabase;
349
433
  /**
350
- * Check if a database is registered
434
+ * Check if a database is registered for a tenant
435
+ * @param tenantId - Tenant identifier
351
436
  * @param key - Database key
437
+ * @returns true if database exists for the tenant
352
438
  */
353
- hasDatabase(key: string): boolean;
439
+ hasDatabase(tenantId: string, key: string): boolean;
354
440
  /**
355
- * Get all registered database keys
441
+ * Get all registered database keys for a tenant
442
+ * @param tenantId - Tenant identifier
443
+ * @returns Array of database keys for the tenant
356
444
  */
357
- getDatabaseKeys(): string[];
445
+ getDatabaseKeys(tenantId: string): string[];
358
446
  /**
359
- * Remove a database connection
447
+ * Remove a database connection for a tenant
448
+ * @param tenantId - Tenant identifier
360
449
  * @param key - Database key
361
450
  */
362
- removeDatabase(key: string): Promise<void>;
451
+ removeDatabase(tenantId: string, key: string): Promise<void>;
363
452
  /**
364
- * Disconnect all databases
453
+ * Disconnect all databases for a tenant
454
+ * @param tenantId - Tenant identifier (optional, disconnects all if not provided)
365
455
  */
366
- disconnectAll(): Promise<void>;
456
+ disconnectAll(tenantId?: string): Promise<void>;
367
457
  /**
368
458
  * Load database configurations from a DatabaseConfigStore
369
- * and register them with this manager
459
+ * and register them with this manager for a specific tenant
370
460
  *
371
461
  * @param store - The database configuration store
372
462
  * @param tenantId - Tenant identifier
@@ -379,14 +469,24 @@ declare class SqlDatabaseManager {
379
469
  * @param store - The database configuration store
380
470
  */
381
471
  loadAllConfigsFromStore(store: _axiom_lattice_protocols.DatabaseConfigStore): Promise<void>;
472
+ /**
473
+ * Clear all databases for a tenant (useful for testing)
474
+ * @param tenantId - Tenant identifier (optional, clears all if not provided)
475
+ */
476
+ clear(tenantId?: string): void;
382
477
  }
383
478
  declare const sqlDatabaseManager: SqlDatabaseManager;
384
479
 
385
480
  interface CreateSqlToolParams$3 {
386
481
  databaseKeys: string[];
387
482
  databaseDescriptions?: Record<string, string>;
483
+ /**
484
+ * Function to get tenant ID dynamically from runConfig
485
+ * This allows tenant isolation based on the execution context
486
+ */
487
+ getTenantId?: () => string;
388
488
  }
389
- declare const createListTablesSqlTool: ({ databaseKeys, databaseDescriptions }: CreateSqlToolParams$3) => langchain.DynamicStructuredTool<z.ZodObject<{
489
+ declare const createListTablesSqlTool: ({ databaseKeys, databaseDescriptions, getTenantId }: CreateSqlToolParams$3) => langchain.DynamicStructuredTool<z.ZodObject<{
390
490
  databaseKey: z.ZodString;
391
491
  }, "strip", z.ZodTypeAny, {
392
492
  databaseKey: string;
@@ -401,8 +501,13 @@ declare const createListTablesSqlTool: ({ databaseKeys, databaseDescriptions }:
401
501
  interface CreateSqlToolParams$2 {
402
502
  databaseKeys: string[];
403
503
  databaseDescriptions?: Record<string, string>;
504
+ /**
505
+ * Function to get tenant ID dynamically from runConfig
506
+ * This allows tenant isolation based on the execution context
507
+ */
508
+ getTenantId?: () => string;
404
509
  }
405
- declare const createInfoSqlTool: ({ databaseKeys, databaseDescriptions }: CreateSqlToolParams$2) => langchain.DynamicStructuredTool<z.ZodObject<{
510
+ declare const createInfoSqlTool: ({ databaseKeys, databaseDescriptions, getTenantId }: CreateSqlToolParams$2) => langchain.DynamicStructuredTool<z.ZodObject<{
406
511
  tables: z.ZodString;
407
512
  databaseKey: z.ZodString;
408
513
  }, "strip", z.ZodTypeAny, {
@@ -422,8 +527,13 @@ declare const createInfoSqlTool: ({ databaseKeys, databaseDescriptions }: Create
422
527
  interface CreateSqlToolParams$1 {
423
528
  databaseKeys: string[];
424
529
  databaseDescriptions?: Record<string, string>;
530
+ /**
531
+ * Function to get tenant ID dynamically from runConfig
532
+ * This allows tenant isolation based on the execution context
533
+ */
534
+ getTenantId?: () => string;
425
535
  }
426
- declare const createQueryCheckerSqlTool: ({ databaseKeys, databaseDescriptions }: CreateSqlToolParams$1) => langchain.DynamicStructuredTool<z.ZodObject<{
536
+ declare const createQueryCheckerSqlTool: ({ databaseKeys, databaseDescriptions, getTenantId }: CreateSqlToolParams$1) => langchain.DynamicStructuredTool<z.ZodObject<{
427
537
  query: z.ZodString;
428
538
  databaseKey: z.ZodString;
429
539
  }, "strip", z.ZodTypeAny, {
@@ -443,8 +553,13 @@ declare const createQueryCheckerSqlTool: ({ databaseKeys, databaseDescriptions }
443
553
  interface CreateSqlToolParams {
444
554
  databaseKeys: string[];
445
555
  databaseDescriptions?: Record<string, string>;
556
+ /**
557
+ * Function to get tenant ID dynamically from runConfig
558
+ * This allows tenant isolation based on the execution context
559
+ */
560
+ getTenantId?: () => string;
446
561
  }
447
- declare const createQuerySqlTool: ({ databaseKeys, databaseDescriptions }: CreateSqlToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
562
+ declare const createQuerySqlTool: ({ databaseKeys, databaseDescriptions, getTenantId }: CreateSqlToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
448
563
  query: z.ZodString;
449
564
  databaseKey: z.ZodString;
450
565
  }, "strip", z.ZodTypeAny, {
@@ -744,60 +859,83 @@ declare class CustomMetricsClient implements IMetricsServerClient {
744
859
  }
745
860
  /**
746
861
  * Metrics Server Manager
747
- * Manages metrics server connections and provides a unified interface
862
+ * Manages metrics server connections with tenant isolation
863
+ *
864
+ * Structure: Map<tenantId, Map<key, IMetricsServerClient>>
865
+ * Each tenant has its own isolated set of metrics server connections
748
866
  */
749
867
  declare class MetricsServerManager {
750
868
  private static instance;
751
869
  private clients;
752
870
  private configs;
753
- private defaultServerKey;
871
+ private defaultServerKeys;
754
872
  private constructor();
755
873
  /**
756
874
  * Get the singleton instance
757
875
  */
758
876
  static getInstance(): MetricsServerManager;
759
877
  /**
760
- * Register a metrics server
878
+ * Get or create tenant clients map
879
+ */
880
+ private getTenantClients;
881
+ /**
882
+ * Get or create tenant configs map
883
+ */
884
+ private getTenantConfigs;
885
+ /**
886
+ * Register a metrics server for a tenant
887
+ * @param tenantId - Tenant identifier
761
888
  * @param key - Unique identifier for the server
762
889
  * @param config - Metrics server configuration
763
890
  */
764
- registerServer(key: string, config: MetricsServerConfig): void;
891
+ registerServer(tenantId: string, key: string, config: MetricsServerConfig): void;
765
892
  /**
766
- * Set the default metrics server
893
+ * Set the default metrics server for a tenant
894
+ * @param tenantId - Tenant identifier
767
895
  * @param key - Server key to set as default
768
896
  */
769
- setDefaultServer(key: string): void;
897
+ setDefaultServer(tenantId: string, key: string): void;
770
898
  /**
771
- * Get a metrics server client by key
899
+ * Get a metrics server client by key for a specific tenant
900
+ * @param tenantId - Tenant identifier
772
901
  * @param key - Server key (optional, uses default if not provided)
773
902
  */
774
- getClient(key?: string): IMetricsServerClient;
903
+ getClient(tenantId: string, key?: string): IMetricsServerClient;
775
904
  /**
776
- * Get metrics server configuration by key
905
+ * Get metrics server configuration by key for a specific tenant
906
+ * @param tenantId - Tenant identifier
777
907
  * @param key - Server key (optional, uses default if not provided)
778
908
  */
779
- getConfig(key?: string): MetricsServerConfig;
909
+ getConfig(tenantId: string, key?: string): MetricsServerConfig;
780
910
  /**
781
- * Check if a metrics server is registered
911
+ * Check if a metrics server is registered for a tenant
912
+ * @param tenantId - Tenant identifier
782
913
  * @param key - Server key
783
914
  */
784
- hasServer(key: string): boolean;
915
+ hasServer(tenantId: string, key: string): boolean;
785
916
  /**
786
- * Get all registered metrics server keys with their types
917
+ * Get all registered metrics server keys with their types for a tenant
918
+ * @param tenantId - Tenant identifier
787
919
  */
788
- getServerKeys(): {
920
+ getServerKeys(tenantId: string): {
789
921
  key: string;
790
922
  type: MetricsServerType;
791
923
  name?: string;
792
924
  }[];
793
925
  /**
794
- * Remove a metrics server
926
+ * Remove a metrics server for a tenant
927
+ * @param tenantId - Tenant identifier
795
928
  * @param key - Server key
796
929
  */
797
- removeServer(key: string): void;
930
+ removeServer(tenantId: string, key: string): void;
931
+ /**
932
+ * Clear all metrics servers for a tenant
933
+ * @param tenantId - Tenant identifier (optional, clears all if not provided)
934
+ */
935
+ clear(tenantId?: string): void;
798
936
  /**
799
937
  * Load metrics server configurations from a store
800
- * and register them with this manager
938
+ * and register them with this manager for a specific tenant
801
939
  *
802
940
  * @param store - The metrics server configuration store
803
941
  * @param tenantId - Tenant identifier
@@ -808,6 +946,7 @@ declare class MetricsServerManager {
808
946
  * across all tenants and register them with this manager
809
947
  *
810
948
  * @param store - The metrics server configuration store
949
+ * @deprecated Use loadConfigsFromStore with specific tenant instead
811
950
  */
812
951
  loadAllConfigsFromStore(store: _axiom_lattice_protocols.MetricsServerConfigStore): Promise<void>;
813
952
  }
@@ -816,20 +955,45 @@ declare const metricsServerManager: MetricsServerManager;
816
955
  interface CreateMetricsToolParams$5 {
817
956
  serverKeys: string[];
818
957
  serverDescriptions?: Record<string, string>;
958
+ /**
959
+ * Function to get tenant ID dynamically from runConfig
960
+ * This allows tenant isolation based on the execution context
961
+ */
962
+ getTenantId?: () => string;
819
963
  }
820
- declare const createListMetricsServersTool: ({ serverKeys, serverDescriptions }: CreateMetricsToolParams$5) => langchain.DynamicStructuredTool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {}, {}, string, "list_metrics_servers">;
964
+ declare const createListMetricsServersTool: ({ serverKeys, serverDescriptions, getTenantId }: CreateMetricsToolParams$5) => langchain.DynamicStructuredTool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {}, {}, string, "list_metrics_servers">;
821
965
 
822
966
  interface CreateMetricsToolParams$4 {
823
967
  serverKeys: string[];
824
968
  serverDescriptions?: Record<string, string>;
969
+ /**
970
+ * Function to get tenant ID dynamically from runConfig
971
+ * This allows tenant isolation based on the execution context
972
+ */
973
+ getTenantId?: () => string;
974
+ /**
975
+ * When true, connect to all available metrics servers automatically at runtime
976
+ * When false or undefined, only the servers in serverKeys will be used
977
+ */
978
+ connectAll?: boolean;
825
979
  }
826
- declare const createListMetricsDataSourcesTool: ({ serverKeys, serverDescriptions }: CreateMetricsToolParams$4) => langchain.DynamicStructuredTool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {}, {}, string, "list_datasources">;
980
+ declare const createListMetricsDataSourcesTool: ({ serverKeys, serverDescriptions, getTenantId, connectAll }: CreateMetricsToolParams$4) => langchain.DynamicStructuredTool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {}, {}, string, "list_datasources">;
827
981
 
828
982
  interface CreateMetricsToolParams$3 {
829
983
  serverKeys: string[];
830
984
  serverDescriptions?: Record<string, string>;
985
+ /**
986
+ * Function to get tenant ID dynamically from runConfig
987
+ * This allows tenant isolation based on the execution context
988
+ */
989
+ getTenantId?: () => string;
990
+ /**
991
+ * When true, connect to all available metrics servers automatically at runtime
992
+ * When false or undefined, only the servers in serverKeys will be used
993
+ */
994
+ connectAll?: boolean;
831
995
  }
832
- declare const createQueryMetricsListTool: ({ serverKeys, serverDescriptions }: CreateMetricsToolParams$3) => langchain.DynamicStructuredTool<z.ZodObject<{
996
+ declare const createQueryMetricsListTool: ({ serverKeys, serverDescriptions, getTenantId, connectAll }: CreateMetricsToolParams$3) => langchain.DynamicStructuredTool<z.ZodObject<{
833
997
  serverKey: z.ZodOptional<z.ZodString>;
834
998
  datasourceIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
835
999
  }, "strip", z.ZodTypeAny, {
@@ -849,8 +1013,18 @@ declare const createQueryMetricsListTool: ({ serverKeys, serverDescriptions }: C
849
1013
  interface CreateMetricsToolParams$2 {
850
1014
  serverKeys: string[];
851
1015
  serverDescriptions?: Record<string, string>;
1016
+ /**
1017
+ * Function to get tenant ID dynamically from runConfig
1018
+ * This allows tenant isolation based on the execution context
1019
+ */
1020
+ getTenantId?: () => string;
1021
+ /**
1022
+ * When true, connect to all available metrics servers automatically at runtime
1023
+ * When false or undefined, only the servers in serverKeys will be used
1024
+ */
1025
+ connectAll?: boolean;
852
1026
  }
853
- declare const createQueryMetricDefinitionTool: ({ serverKeys, serverDescriptions }: CreateMetricsToolParams$2) => langchain.DynamicStructuredTool<z.ZodObject<{
1027
+ declare const createQueryMetricDefinitionTool: ({ serverKeys, serverDescriptions, getTenantId, connectAll }: CreateMetricsToolParams$2) => langchain.DynamicStructuredTool<z.ZodObject<{
854
1028
  serverKey: z.ZodOptional<z.ZodString>;
855
1029
  metricName: z.ZodString;
856
1030
  datasourceId: z.ZodOptional<z.ZodString>;
@@ -875,8 +1049,18 @@ declare const createQueryMetricDefinitionTool: ({ serverKeys, serverDescriptions
875
1049
  interface CreateMetricsToolParams$1 {
876
1050
  serverKeys: string[];
877
1051
  serverDescriptions?: Record<string, string>;
1052
+ /**
1053
+ * Function to get tenant ID dynamically from runConfig
1054
+ * This allows tenant isolation based on the execution context
1055
+ */
1056
+ getTenantId?: () => string;
1057
+ /**
1058
+ * When true, connect to all available metrics servers automatically at runtime
1059
+ * When false or undefined, only the servers in serverKeys will be used
1060
+ */
1061
+ connectAll?: boolean;
878
1062
  }
879
- declare const createQuerySemanticMetricDataTool: ({ serverKeys, serverDescriptions }: CreateMetricsToolParams$1) => langchain.DynamicStructuredTool<z.ZodObject<{
1063
+ declare const createQuerySemanticMetricDataTool: ({ serverKeys, serverDescriptions, getTenantId, connectAll }: CreateMetricsToolParams$1) => langchain.DynamicStructuredTool<z.ZodObject<{
880
1064
  serverKey: z.ZodOptional<z.ZodString>;
881
1065
  datasourceId: z.ZodOptional<z.ZodString>;
882
1066
  metrics: z.ZodArray<z.ZodString, "many">;
@@ -944,8 +1128,18 @@ declare const createQuerySemanticMetricDataTool: ({ serverKeys, serverDescriptio
944
1128
  interface CreateTablesToolParams {
945
1129
  serverKeys: string[];
946
1130
  serverDescriptions?: Record<string, string>;
1131
+ /**
1132
+ * Function to get tenant ID dynamically from runConfig
1133
+ * This allows tenant isolation based on the execution context
1134
+ */
1135
+ getTenantId?: () => string;
1136
+ /**
1137
+ * When true, connect to all available metrics servers automatically at runtime
1138
+ * When false or undefined, only the servers in serverKeys will be used
1139
+ */
1140
+ connectAll?: boolean;
947
1141
  }
948
- declare const createQueryTablesListTool: ({ serverKeys, serverDescriptions }: CreateTablesToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
1142
+ declare const createQueryTablesListTool: ({ serverKeys, serverDescriptions, getTenantId, connectAll }: CreateTablesToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
949
1143
  serverKey: z.ZodOptional<z.ZodString>;
950
1144
  datasourceIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
951
1145
  }, "strip", z.ZodTypeAny, {
@@ -965,8 +1159,18 @@ declare const createQueryTablesListTool: ({ serverKeys, serverDescriptions }: Cr
965
1159
  interface CreateTableToolParams {
966
1160
  serverKeys: string[];
967
1161
  serverDescriptions?: Record<string, string>;
1162
+ /**
1163
+ * Function to get tenant ID dynamically from runConfig
1164
+ * This allows tenant isolation based on the execution context
1165
+ */
1166
+ getTenantId?: () => string;
1167
+ /**
1168
+ * When true, connect to all available metrics servers automatically at runtime
1169
+ * When false or undefined, only the servers in serverKeys will be used
1170
+ */
1171
+ connectAll?: boolean;
968
1172
  }
969
- declare const createQueryTableDefinitionTool: ({ serverKeys, serverDescriptions }: CreateTableToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
1173
+ declare const createQueryTableDefinitionTool: ({ serverKeys, serverDescriptions, getTenantId, connectAll }: CreateTableToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
970
1174
  serverKey: z.ZodOptional<z.ZodString>;
971
1175
  tableName: z.ZodString;
972
1176
  datasourceId: z.ZodOptional<z.ZodString>;
@@ -991,8 +1195,18 @@ declare const createQueryTableDefinitionTool: ({ serverKeys, serverDescriptions
991
1195
  interface CreateMetricsToolParams {
992
1196
  serverKeys: string[];
993
1197
  serverDescriptions?: Record<string, string>;
1198
+ /**
1199
+ * Function to get tenant ID dynamically from runConfig
1200
+ * This allows tenant isolation based on the execution context
1201
+ */
1202
+ getTenantId?: () => string;
1203
+ /**
1204
+ * When true, connect to all available metrics servers automatically at runtime
1205
+ * When false or undefined, only the servers in serverKeys will be used
1206
+ */
1207
+ connectAll?: boolean;
994
1208
  }
995
- declare const createExecuteSqlQueryTool: ({ serverKeys, serverDescriptions }: CreateMetricsToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
1209
+ declare const createExecuteSqlQueryTool: ({ serverKeys, serverDescriptions, getTenantId, connectAll }: CreateMetricsToolParams) => langchain.DynamicStructuredTool<z.ZodObject<{
996
1210
  serverKey: z.ZodOptional<z.ZodString>;
997
1211
  datasourceId: z.ZodOptional<z.ZodString>;
998
1212
  customSql: z.ZodString;
@@ -1141,8 +1355,11 @@ declare const validateToolInput: (key: string, input: any) => boolean;
1141
1355
  */
1142
1356
 
1143
1357
  type AgentClient = CompiledStateGraph<any, any, any, any, any> | ReactAgent<any, any, any, any>;
1358
+ type AgentConfigWithTenant = AgentConfig & {
1359
+ tenantId?: string;
1360
+ };
1144
1361
  interface AgentLattice {
1145
- config: AgentConfig;
1362
+ config: AgentConfigWithTenant;
1146
1363
  client?: AgentClient | undefined;
1147
1364
  }
1148
1365
  interface MiddlewareConfig {
@@ -1178,11 +1395,23 @@ interface AgentBuildParams {
1178
1395
  declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
1179
1396
  private static _instance;
1180
1397
  private initialized;
1398
+ /**
1399
+ * 从store异步加载单个AgentLattice
1400
+ * 实现BaseLatticeManager的可选方法,支持从assistant store加载单个agent
1401
+ * @param tenantId 租户ID
1402
+ * @param key Agent键名
1403
+ * @returns AgentLattice或undefined
1404
+ */
1405
+ protected loadItemFromStore(tenantId: string, key: string): Promise<AgentLattice | undefined>;
1181
1406
  /**
1182
1407
  * 获取AgentLatticeManager单例实例
1183
1408
  */
1184
1409
  static getInstance(): AgentLatticeManager;
1185
1410
  private constructor();
1411
+ /**
1412
+ * @deprecated This method loads assistants only for the "default" tenant.
1413
+ * Use initializeStoredAssistantsForTenant(tenantId) for proper tenant isolation.
1414
+ */
1186
1415
  private initializeStoredAssistants;
1187
1416
  private subscribeToAssistantEvents;
1188
1417
  private handleAssistantChange;
@@ -1192,7 +1421,59 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
1192
1421
  */
1193
1422
  protected getLatticeType(): string;
1194
1423
  /**
1195
- * 注册Agent Lattice
1424
+ * 带租户注册Agent Lattice
1425
+ * @param tenantId 租户ID
1426
+ * @param config Agent配置
1427
+ */
1428
+ registerLatticeWithTenant(tenantId: string, config: AgentConfig): void;
1429
+ /**
1430
+ * 带租户获取AgentLattice
1431
+ * @param tenantId 租户ID
1432
+ * @param key Lattice键名
1433
+ */
1434
+ getAgentLatticeWithTenant(tenantId: string, key: string): AgentLattice | undefined;
1435
+ /**
1436
+ * 带租户检查Lattice是否存在
1437
+ * @param tenantId 租户ID
1438
+ * @param key Lattice键名
1439
+ */
1440
+ hasAgentLatticeWithTenant(tenantId: string, key: string): boolean;
1441
+ /**
1442
+ * 带租户移除Lattice
1443
+ * @param tenantId 租户ID
1444
+ * @param key Lattice键名
1445
+ */
1446
+ removeAgentLatticeWithTenant(tenantId: string, key: string): boolean;
1447
+ /**
1448
+ * 获取指定租户的所有Agent Lattice
1449
+ * @param tenantId 租户ID
1450
+ */
1451
+ getAllAgentLatticesByTenant(tenantId: string): AgentLattice[];
1452
+ /**
1453
+ * 清空指定租户的所有Agent Lattice
1454
+ * @param tenantId 租户ID
1455
+ */
1456
+ clearAgentLatticesByTenant(tenantId: string): void;
1457
+ /**
1458
+ * 带租户获取Agent配置
1459
+ * @param tenantId 租户ID
1460
+ * @param key Lattice键名
1461
+ */
1462
+ getAgentConfigWithTenant(tenantId: string, key: string): AgentConfig | undefined;
1463
+ /**
1464
+ * 获取指定租户的所有Agent配置
1465
+ * 先从数据库加载该租户的 assistants,然后返回所有配置
1466
+ * @param tenantId 租户ID
1467
+ */
1468
+ getAllAgentConfigsByTenant(tenantId: string): Promise<AgentConfig[]>;
1469
+ /**
1470
+ * 从数据库加载指定租户的存储助手
1471
+ * @param tenantId 租户ID
1472
+ */
1473
+ initializeStoredAssistantsForTenant(tenantId: string): Promise<void>;
1474
+ /**
1475
+ * 注册Agent Lattice(向后兼容,使用 "default" 租户)
1476
+ * @deprecated Use registerLatticeWithTenant(tenantId, config) instead
1196
1477
  * @param config Agent配置
1197
1478
  */
1198
1479
  registerLattice(config: AgentConfig): void;
@@ -1210,7 +1491,8 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
1210
1491
  */
1211
1492
  unregisterTeammateAgent(key: string): boolean;
1212
1493
  /**
1213
- * 获取AgentLattice
1494
+ * 获取AgentLattice(向后兼容,使用 "default" 租户)
1495
+ * @deprecated Use getAgentLatticeWithTenant(tenantId, key) instead
1214
1496
  * @param key Lattice键名
1215
1497
  */
1216
1498
  getAgentLattice(key: string): AgentLattice | undefined;
@@ -1219,17 +1501,20 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
1219
1501
  */
1220
1502
  getAllLattices(): AgentLattice[];
1221
1503
  /**
1222
- * 检查Lattice是否存在
1504
+ * 检查Lattice是否存在(向后兼容,使用 "default" 租户)
1505
+ * @deprecated Use hasAgentLatticeWithTenant(tenantId, key) instead
1223
1506
  * @param key Lattice键名
1224
1507
  */
1225
1508
  hasLattice(key: string): boolean;
1226
1509
  /**
1227
- * 移除Lattice
1510
+ * 移除Lattice(向后兼容,使用 "default" 租户)
1511
+ * @deprecated Use removeAgentLatticeWithTenant(tenantId, key) instead
1228
1512
  * @param key Lattice键名
1229
1513
  */
1230
1514
  removeLattice(key: string): boolean;
1231
1515
  /**
1232
- * 获取Agent配置
1516
+ * 获取Agent配置(向后兼容,使用 "default" 租户)
1517
+ * @deprecated Use getAgentConfigWithTenant(tenantId, key) instead
1233
1518
  * @param key Lattice键名
1234
1519
  */
1235
1520
  getAgentConfig(key: string): AgentConfig | undefined;
@@ -1271,35 +1556,49 @@ declare class AgentLatticeManager extends BaseLatticeManager<AgentLattice> {
1271
1556
  * @param options Build options
1272
1557
  * @returns AgentClient instance
1273
1558
  */
1274
- createAgentClientFromConfig(agentLattice: AgentLattice, options?: GraphBuildOptions): AgentClient;
1559
+ createAgentClientFromConfig(agentLattice: AgentLattice, options?: GraphBuildOptions): Promise<AgentClient>;
1275
1560
  /**
1276
1561
  * 初始化Agent客户端
1277
1562
  *
1278
1563
  * 使用AgentGraphBuilderFactory构建Graph并设置为客户端
1279
1564
  *
1565
+ * @param tenantId 租户ID
1280
1566
  * @param key Lattice键名
1281
1567
  * @param options 构建选项
1282
1568
  * @returns 返回CompiledGraph对象
1283
1569
  */
1284
- initializeClient(key: string, options?: GraphBuildOptions): AgentClient;
1570
+ initializeClient(tenantId: string, key: string, options?: GraphBuildOptions): Promise<AgentClient>;
1571
+ /**
1572
+ * 异步初始化Agent客户端(支持从store加载)
1573
+ *
1574
+ * 如果内存中不存在,会尝试从store加载
1575
+ * 使用AgentGraphBuilderFactory构建Graph并设置为客户端
1576
+ *
1577
+ * @param tenantId 租户ID
1578
+ * @param key Lattice键名
1579
+ * @param options 构建选项
1580
+ * @returns 返回CompiledGraph对象
1581
+ */
1582
+ initializeClientAsync(tenantId: string, key: string, options?: GraphBuildOptions): Promise<AgentClient>;
1285
1583
  }
1286
1584
  declare const agentLatticeManager: AgentLatticeManager;
1287
1585
  declare const registerAgentLattice: (config: AgentConfig) => void;
1288
- declare const registerAgentLattices: (configs: AgentConfig[]) => void;
1289
- declare const getAgentLattice: (key: string) => AgentLattice | undefined;
1586
+ declare const registerAgentLatticeWithTenant: (tenantId: string, config: AgentConfig) => void;
1587
+ declare const registerAgentLattices: (tenantId: string, configs: AgentConfig[]) => void;
1290
1588
  declare const getAgentConfig: (key: string) => AgentConfig | undefined;
1291
1589
  declare const getAllAgentConfigs: () => Promise<AgentConfig[]>;
1292
1590
  declare const validateAgentInput: (key: string, input: any) => boolean;
1293
1591
  declare const registerTeammateAgent: (key: string, client: AgentClient) => void;
1294
1592
  declare const unregisterTeammateAgent: (key: string) => boolean;
1295
1593
  /**
1296
- * 获取或初始化Agent客户端
1594
+ * 获取或初始化Agent客户端(同步)
1297
1595
  *
1596
+ * @param tenantId 租户ID
1298
1597
  * @param key Agent Lattice键名
1299
1598
  * @param options 构建选项
1300
1599
  * @returns 返回CompiledGraph对象
1301
1600
  */
1302
- declare const getAgentClient: (key: string, options?: GraphBuildOptions) => AgentClient;
1601
+ declare const getAgentClient: (tenantId: string, key: string, options?: GraphBuildOptions) => Promise<AgentClient>;
1303
1602
 
1304
1603
  /**
1305
1604
  * MemoryLatticeManager
@@ -1389,6 +1688,7 @@ interface ThreadBufferConfig {
1389
1688
  interface ThreadBuffer {
1390
1689
  threadId: string;
1391
1690
  chunks$: ReplaySubject<MessageChunk>;
1691
+ chunks: MessageChunk[];
1392
1692
  status: ThreadStatus;
1393
1693
  createdAt: number;
1394
1694
  updatedAt: number;
@@ -1402,6 +1702,7 @@ interface BufferStats {
1402
1702
  activeThreads: number;
1403
1703
  completedThreads: number;
1404
1704
  abortedThreads: number;
1705
+ totalChunks: number;
1405
1706
  config: Required<ThreadBufferConfig>;
1406
1707
  }
1407
1708
 
@@ -1500,12 +1801,16 @@ declare class InMemoryChunkBuffer extends ChunkBuffer {
1500
1801
  * Create or get thread buffer
1501
1802
  */
1502
1803
  private getOrCreateBuffer;
1804
+ addChunk(threadId: string, messageId: string, content: string): Promise<void>;
1503
1805
  addChunk(threadId: string, content: MessageChunk): Promise<void>;
1504
1806
  completeThread(threadId: string): Promise<void>;
1505
1807
  abortThread(threadId: string): Promise<void>;
1506
1808
  isThreadActive(threadId: string): Promise<boolean>;
1507
1809
  getThreadStatus(threadId: string): Promise<ThreadStatus | undefined>;
1508
1810
  getThreadBuffer(threadId: string): Promise<ThreadBuffer | undefined>;
1811
+ getChunks(threadId: string): Promise<MessageChunk[]>;
1812
+ getAccumulatedContent(threadId: string): Promise<string>;
1813
+ getChunksByMessageId(threadId: string, messageId: string): Promise<MessageChunk[]>;
1509
1814
  clearThread(threadId: string): Promise<void>;
1510
1815
  getActiveThreads(): Promise<string[]>;
1511
1816
  getAllThreads(): Promise<string[]>;
@@ -1829,6 +2134,7 @@ declare class MemoryScheduleStorage implements ScheduleStorage {
1829
2134
  * Get all tasks with optional filters
1830
2135
  */
1831
2136
  getAllTasks(filters?: {
2137
+ tenantId?: string;
1832
2138
  status?: ScheduledTaskStatus;
1833
2139
  executionType?: ScheduleExecutionType;
1834
2140
  taskType?: string;
@@ -1841,6 +2147,7 @@ declare class MemoryScheduleStorage implements ScheduleStorage {
1841
2147
  * Count tasks with optional filters
1842
2148
  */
1843
2149
  countTasks(filters?: {
2150
+ tenantId?: string;
1844
2151
  status?: ScheduledTaskStatus;
1845
2152
  executionType?: ScheduleExecutionType;
1846
2153
  taskType?: string;
@@ -2024,7 +2331,7 @@ declare const getStoreLattice: <TStoreType extends StoreType>(key: string, type:
2024
2331
  *
2025
2332
  * In-memory implementation of ThreadStore
2026
2333
  * Provides CRUD operations for thread data stored in memory
2027
- * Threads are organized by assistant ID
2334
+ * Threads are organized by tenant ID and assistant ID
2028
2335
  */
2029
2336
 
2030
2337
  /**
@@ -2033,33 +2340,33 @@ declare const getStoreLattice: <TStoreType extends StoreType>(key: string, type:
2033
2340
  declare class InMemoryThreadStore implements ThreadStore {
2034
2341
  private threads;
2035
2342
  /**
2036
- * Get all threads for a specific assistant
2343
+ * Get all threads for a specific tenant and assistant
2037
2344
  */
2038
- getThreadsByAssistantId(assistantId: string): Promise<Thread[]>;
2345
+ getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
2039
2346
  /**
2040
- * Get a thread by ID for a specific assistant
2347
+ * Get a thread by ID for a specific tenant
2041
2348
  */
2042
- getThreadById(assistantId: string, threadId: string): Promise<Thread | undefined>;
2349
+ getThreadById(tenantId: string, threadId: string): Promise<Thread | undefined>;
2043
2350
  /**
2044
- * Create a new thread for an assistant
2351
+ * Create a new thread for a tenant and assistant
2045
2352
  */
2046
- createThread(assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
2353
+ createThread(tenantId: string, assistantId: string, threadId: string, data: CreateThreadRequest): Promise<Thread>;
2047
2354
  /**
2048
2355
  * Update an existing thread
2049
2356
  */
2050
- updateThread(assistantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
2357
+ updateThread(tenantId: string, threadId: string, updates: Partial<CreateThreadRequest>): Promise<Thread | null>;
2051
2358
  /**
2052
2359
  * Delete a thread by ID
2053
2360
  */
2054
- deleteThread(assistantId: string, threadId: string): Promise<boolean>;
2361
+ deleteThread(tenantId: string, threadId: string): Promise<boolean>;
2055
2362
  /**
2056
2363
  * Check if thread exists
2057
2364
  */
2058
- hasThread(assistantId: string, threadId: string): Promise<boolean>;
2365
+ hasThread(tenantId: string, threadId: string): Promise<boolean>;
2059
2366
  /**
2060
- * Clear all threads (useful for testing)
2367
+ * Clear all threads for a tenant (useful for testing)
2061
2368
  */
2062
- clear(): void;
2369
+ clear(tenantId?: string): void;
2063
2370
  /**
2064
2371
  * Get all threads for all assistants (useful for debugging)
2065
2372
  */
@@ -2079,33 +2386,33 @@ declare class InMemoryThreadStore implements ThreadStore {
2079
2386
  declare class InMemoryAssistantStore implements AssistantStore {
2080
2387
  private assistants;
2081
2388
  /**
2082
- * Get all assistants
2389
+ * Get all assistants for a tenant
2083
2390
  */
2084
- getAllAssistants(): Promise<Assistant[]>;
2391
+ getAllAssistants(tenantId: string): Promise<Assistant[]>;
2085
2392
  /**
2086
2393
  * Get assistant by ID
2087
2394
  */
2088
- getAssistantById(id: string): Promise<Assistant | null>;
2395
+ getAssistantById(tenantId: string, id: string): Promise<Assistant | null>;
2089
2396
  /**
2090
2397
  * Create a new assistant
2091
2398
  */
2092
- createAssistant(id: string, data: CreateAssistantRequest): Promise<Assistant>;
2399
+ createAssistant(tenantId: string, id: string, data: CreateAssistantRequest): Promise<Assistant>;
2093
2400
  /**
2094
2401
  * Update an existing assistant
2095
2402
  */
2096
- updateAssistant(id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
2403
+ updateAssistant(tenantId: string, id: string, updates: Partial<CreateAssistantRequest>): Promise<Assistant | null>;
2097
2404
  /**
2098
2405
  * Delete an assistant by ID
2099
2406
  */
2100
- deleteAssistant(id: string): Promise<boolean>;
2407
+ deleteAssistant(tenantId: string, id: string): Promise<boolean>;
2101
2408
  /**
2102
2409
  * Check if assistant exists
2103
2410
  */
2104
- hasAssistant(id: string): Promise<boolean>;
2411
+ hasAssistant(tenantId: string, id: string): Promise<boolean>;
2105
2412
  /**
2106
- * Clear all assistants (useful for testing)
2413
+ * Clear all assistants for a tenant (useful for testing)
2107
2414
  */
2108
- clear(): void;
2415
+ clear(tenantId?: string): void;
2109
2416
  }
2110
2417
 
2111
2418
  /**
@@ -2164,61 +2471,163 @@ declare class FileSystemSkillStore implements SkillStore {
2164
2471
  */
2165
2472
  private writeSkillFile;
2166
2473
  /**
2167
- * Get all skills
2474
+ * Get all skills for a tenant
2475
+ * Note: FileSystemSkillStore uses a flat structure. TenantId is accepted for protocol compliance
2476
+ * but all skills are returned regardless of tenant.
2168
2477
  */
2169
- getAllSkills(): Promise<Skill[]>;
2478
+ getAllSkills(_tenantId: string): Promise<Skill[]>;
2170
2479
  /**
2171
- * Get skill by ID
2480
+ * Get skill by ID for a tenant
2172
2481
  * ID should equal name (name is used for path addressing)
2482
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2173
2483
  */
2174
- getSkillById(id: string): Promise<Skill | null>;
2484
+ getSkillById(_tenantId: string, id: string): Promise<Skill | null>;
2175
2485
  /**
2176
- * Create a new skill
2486
+ * Create a new skill for a tenant
2177
2487
  * id should equal name (name is used for path addressing)
2488
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2178
2489
  */
2179
- createSkill(id: string, data: CreateSkillRequest): Promise<Skill>;
2490
+ createSkill(_tenantId: string, id: string, data: CreateSkillRequest): Promise<Skill>;
2180
2491
  /**
2181
- * Update an existing skill
2492
+ * Update an existing skill for a tenant
2493
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2182
2494
  */
2183
- updateSkill(id: string, updates: Partial<CreateSkillRequest>): Promise<Skill | null>;
2495
+ updateSkill(_tenantId: string, id: string, updates: Partial<CreateSkillRequest>): Promise<Skill | null>;
2184
2496
  /**
2185
- * Delete a skill by ID
2497
+ * Delete a skill by ID for a tenant
2186
2498
  * Deletes the entire directory (name is the directory name)
2499
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2187
2500
  */
2188
- deleteSkill(id: string): Promise<boolean>;
2501
+ deleteSkill(_tenantId: string, id: string): Promise<boolean>;
2189
2502
  /**
2190
- * Check if skill exists
2503
+ * Check if skill exists for a tenant
2504
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2191
2505
  */
2192
- hasSkill(id: string): Promise<boolean>;
2506
+ hasSkill(_tenantId: string, id: string): Promise<boolean>;
2193
2507
  /**
2194
- * Search skills by metadata
2508
+ * Search skills by metadata within a tenant
2509
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2195
2510
  */
2196
- searchByMetadata(metadataKey: string, metadataValue: string): Promise<Skill[]>;
2511
+ searchByMetadata(_tenantId: string, metadataKey: string, metadataValue: string): Promise<Skill[]>;
2197
2512
  /**
2198
- * Filter skills by compatibility
2513
+ * Filter skills by compatibility within a tenant
2514
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2199
2515
  */
2200
- filterByCompatibility(compatibility: string): Promise<Skill[]>;
2516
+ filterByCompatibility(_tenantId: string, compatibility: string): Promise<Skill[]>;
2201
2517
  /**
2202
- * Filter skills by license
2518
+ * Filter skills by license within a tenant
2519
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2203
2520
  */
2204
- filterByLicense(license: string): Promise<Skill[]>;
2521
+ filterByLicense(_tenantId: string, license: string): Promise<Skill[]>;
2205
2522
  /**
2206
- * Get sub-skills of a parent skill
2523
+ * Get sub-skills of a parent skill within a tenant
2524
+ * Note: tenantId is accepted for protocol compliance but FileSystemSkillStore uses flat structure
2207
2525
  */
2208
- getSubSkills(parentSkillName: string): Promise<Skill[]>;
2526
+ getSubSkills(_tenantId: string, parentSkillName: string): Promise<Skill[]>;
2209
2527
  /**
2210
2528
  * List all resources in a skill's resources directory
2529
+ * @param tenantId The tenant identifier (accepted for protocol compliance)
2211
2530
  * @param skillName The skill name
2212
2531
  * @returns Array of resource paths relative to resources/ directory
2213
2532
  */
2214
- listSkillResources(skillName: string): Promise<string[]>;
2533
+ listSkillResources(_tenantId: string, skillName: string): Promise<string[]>;
2215
2534
  /**
2216
2535
  * Load a specific resource from a skill's resources directory
2536
+ * @param tenantId The tenant identifier (accepted for protocol compliance)
2217
2537
  * @param skillName The skill name
2218
2538
  * @param resourcePath Path to the resource relative to resources/ directory
2219
2539
  * @returns The resource content as string
2220
2540
  */
2221
- loadSkillResource(skillName: string, resourcePath: string): Promise<string | null>;
2541
+ loadSkillResource(_tenantId: string, skillName: string, resourcePath: string): Promise<string | null>;
2542
+ }
2543
+
2544
+ /**
2545
+ * SandboxSkillStore
2546
+ *
2547
+ * Sandbox-based implementation of SkillStore
2548
+ * Stores skills in a remote sandbox environment
2549
+ * Path format: /home/gem/tenants/{tenantId}/skills/{skillName}/SKILL.md
2550
+ */
2551
+
2552
+ interface SandboxSkillStoreOptions {
2553
+ /**
2554
+ * Sandbox manager instance
2555
+ * If not provided, will use getSandBoxManager() dynamically
2556
+ */
2557
+ sandboxManager?: SandboxManagerProtocol;
2558
+ /**
2559
+ * Base path for skill storage
2560
+ * @default "/home/gem/tenants"
2561
+ */
2562
+ basePath?: string;
2563
+ }
2564
+ /**
2565
+ * Sandbox-based implementation of SkillStore with tenant isolation
2566
+ */
2567
+ declare class SandboxSkillStore implements SkillStore {
2568
+ private sandboxManager?;
2569
+ private basePath;
2570
+ constructor(options?: SandboxSkillStoreOptions);
2571
+ /**
2572
+ * Get sandbox manager for a tenant
2573
+ */
2574
+ private getSandboxManager;
2575
+ /**
2576
+ * Get skill directory path in sandbox
2577
+ */
2578
+ private getSkillDirectoryPath;
2579
+ /**
2580
+ * Get skill file path in sandbox
2581
+ */
2582
+ private getSkillFilePath;
2583
+ /**
2584
+ * Read skill from sandbox
2585
+ */
2586
+ private readSkillFile;
2587
+ /**
2588
+ * Write skill to sandbox
2589
+ */
2590
+ private writeSkillFile;
2591
+ /**
2592
+ * Get all skills for a tenant
2593
+ */
2594
+ getAllSkills(tenantId: string): Promise<Skill[]>;
2595
+ /**
2596
+ * Get skill by ID
2597
+ */
2598
+ getSkillById(tenantId: string, id: string): Promise<Skill | null>;
2599
+ /**
2600
+ * Create a new skill
2601
+ */
2602
+ createSkill(tenantId: string, id: string, data: CreateSkillRequest): Promise<Skill>;
2603
+ /**
2604
+ * Update an existing skill
2605
+ */
2606
+ updateSkill(tenantId: string, id: string, updates: Partial<CreateSkillRequest>): Promise<Skill | null>;
2607
+ /**
2608
+ * Delete a skill by ID
2609
+ */
2610
+ deleteSkill(tenantId: string, id: string): Promise<boolean>;
2611
+ /**
2612
+ * Check if skill exists
2613
+ */
2614
+ hasSkill(tenantId: string, id: string): Promise<boolean>;
2615
+ /**
2616
+ * Search skills by metadata within a tenant
2617
+ */
2618
+ searchByMetadata(tenantId: string, metadataKey: string, metadataValue: string): Promise<Skill[]>;
2619
+ /**
2620
+ * Filter skills by compatibility within a tenant
2621
+ */
2622
+ filterByCompatibility(tenantId: string, compatibility: string): Promise<Skill[]>;
2623
+ /**
2624
+ * Filter skills by license within a tenant
2625
+ */
2626
+ filterByLicense(tenantId: string, license: string): Promise<Skill[]>;
2627
+ /**
2628
+ * Get sub-skills of a parent skill within a tenant
2629
+ */
2630
+ getSubSkills(tenantId: string, parentSkillName: string): Promise<Skill[]>;
2222
2631
  }
2223
2632
 
2224
2633
  /**
@@ -2624,6 +3033,12 @@ declare class SkillLatticeManager extends BaseLatticeManager<SkillLattice> {
2624
3033
  * Get Lattice type prefix
2625
3034
  */
2626
3035
  protected getLatticeType(): string;
3036
+ /**
3037
+ * Default tenant ID for store operations
3038
+ * Note: SkillLatticeManager operates without explicit tenant context.
3039
+ * Store methods require tenantId for protocol compliance.
3040
+ */
3041
+ private getDefaultTenantId;
2627
3042
  /**
2628
3043
  * Configure store for persistence
2629
3044
  * @param storeKey Store key name registered in StoreLatticeManager
@@ -2641,29 +3056,64 @@ declare class SkillLatticeManager extends BaseLatticeManager<SkillLattice> {
2641
3056
  */
2642
3057
  private injectStoreIntoClient;
2643
3058
  /**
2644
- * Register a skill Lattice
3059
+ * Register a skill Lattice with tenant
3060
+ * @param tenantId Tenant ID
3061
+ * @param key Lattice key name
3062
+ * @param config Skill configuration
3063
+ * @param client Optional skill client implementation
3064
+ */
3065
+ registerLatticeWithTenant(tenantId: string, key: string, config: SkillConfig, client?: SkillClient): Promise<void>;
3066
+ /**
3067
+ * Register a skill Lattice (backward compatible, uses "default" tenant)
3068
+ * @deprecated Use registerLatticeWithTenant(tenantId, key, config, client) instead
2645
3069
  * @param key Lattice key name
2646
3070
  * @param config Skill configuration
2647
3071
  * @param client Optional skill client implementation
2648
3072
  */
2649
3073
  registerLattice(key: string, config: SkillConfig, client?: SkillClient): Promise<void>;
2650
3074
  /**
2651
- * Get skill Lattice by key
3075
+ * Get skill Lattice by key with tenant
3076
+ * @param tenantId Tenant ID
3077
+ * @param key Lattice key name
3078
+ */
3079
+ getSkillLatticeWithTenant(tenantId: string, key: string): SkillLattice | undefined;
3080
+ /**
3081
+ * Get skill Lattice by key (backward compatible, uses "default" tenant)
3082
+ * @deprecated Use getSkillLatticeWithTenant(tenantId, key) instead
2652
3083
  * @param key Lattice key name
2653
3084
  */
2654
3085
  getSkillLattice(key: string): SkillLattice | undefined;
2655
3086
  /**
2656
- * Get all skill Lattices from store
2657
- * Always reads from the configured store and merges with in-memory clients
3087
+ * Get all skill Lattices from store with tenant
3088
+ * @param tenantId Tenant ID
3089
+ */
3090
+ getAllLatticesWithTenant(tenantId: string): Promise<SkillLattice[]>;
3091
+ /**
3092
+ * Get all skill Lattices from store (backward compatible, uses "default" tenant)
3093
+ * @deprecated Use getAllLatticesWithTenant(tenantId) instead
2658
3094
  */
2659
3095
  getAllLattices(): Promise<SkillLattice[]>;
2660
3096
  /**
2661
- * Check if Lattice exists
3097
+ * Check if Lattice exists with tenant
3098
+ * @param tenantId Tenant ID
3099
+ * @param key Lattice key name
3100
+ */
3101
+ hasLatticeWithTenant(tenantId: string, key: string): boolean;
3102
+ /**
3103
+ * Check if Lattice exists (backward compatible, uses "default" tenant)
3104
+ * @deprecated Use hasLatticeWithTenant(tenantId, key) instead
2662
3105
  * @param key Lattice key name
2663
3106
  */
2664
3107
  hasLattice(key: string): boolean;
2665
3108
  /**
2666
- * Remove Lattice
3109
+ * Remove Lattice with tenant
3110
+ * @param tenantId Tenant ID
3111
+ * @param key Lattice key name
3112
+ */
3113
+ removeLatticeWithTenant(tenantId: string, key: string): Promise<boolean>;
3114
+ /**
3115
+ * Remove Lattice (backward compatible, uses "default" tenant)
3116
+ * @deprecated Use removeLatticeWithTenant(tenantId, key) instead
2667
3117
  * @param key Lattice key name
2668
3118
  */
2669
3119
  removeLattice(key: string): Promise<boolean>;
@@ -3389,7 +3839,7 @@ interface AgentGraphBuilder {
3389
3839
  * @param params Agent构建参数
3390
3840
  * @returns 返回CompiledGraph对象
3391
3841
  */
3392
- build(agentLattice: AgentLattice, params: AgentBuildParams): AgentClient;
3842
+ build(agentLattice: AgentLattice, params: AgentBuildParams): Promise<AgentClient>;
3393
3843
  }
3394
3844
 
3395
3845
  /**
@@ -3408,7 +3858,7 @@ declare class TeamAgentGraphBuilder implements AgentGraphBuilder {
3408
3858
  * @param params - Build params with resolved tools and model
3409
3859
  * @returns AgentClient (the TeamLead ReactAgent)
3410
3860
  */
3411
- build(agentLattice: AgentLattice, params: AgentBuildParams): AgentClient;
3861
+ build(agentLattice: AgentLattice, params: AgentBuildParams): Promise<AgentClient>;
3412
3862
  }
3413
3863
 
3414
3864
  /**
@@ -3631,6 +4081,7 @@ interface StateAndStore {
3631
4081
  /** Optional assistant ID for per-assistant isolation in store */
3632
4082
  assistantId?: string;
3633
4083
  threadId?: string;
4084
+ tenantId?: string;
3634
4085
  workspaceId?: string;
3635
4086
  projectId?: string;
3636
4087
  }
@@ -3741,8 +4192,9 @@ declare class StoreBackend implements BackendProtocol {
3741
4192
  /**
3742
4193
  * Get the namespace for store operations.
3743
4194
  *
3744
- * If an assistant_id is available in stateAndStore, return
3745
- * [assistant_id, "filesystem"] to provide per-assistant isolation.
4195
+ * If both tenant_id and assistant_id are available, return
4196
+ * [tenant_id, assistant_id, "filesystem"] for full tenant + assistant isolation.
4197
+ * If only assistant_id is available, return [assistant_id, "filesystem"].
3746
4198
  * Otherwise return ["filesystem"].
3747
4199
  */
3748
4200
  protected getNamespace(): string[];
@@ -4370,4 +4822,4 @@ declare function validateEncryptionKey(): void;
4370
4822
  */
4371
4823
  declare function clearEncryptionKeyCache(): void;
4372
4824
 
4373
- export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DefaultScheduleClient, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, type IsolatedLevel, LINE_NUMBER_WIDTH, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, MessageType, MetricsServerManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, type RunSandboxConfig, SandboxFilesystem, SandboxLatticeManager, type SandboxManagerProtocol, type ScheduleLattice, ScheduleLatticeManager, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, type VectorStoreLatticeInterface, VectorStoreLatticeManager, type WriteResult, agentLatticeManager, buildGrepResultsDict, checkEmptyContent, clearEncryptionKeyCache, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createTeamMiddleware, createTeammateTools, decrypt, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAgentLattice, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };
4825
+ export { AGENT_TASK_EVENT, type AgentClient, type AgentLattice, AgentLatticeManager, AgentManager, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DefaultScheduleClient, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, type IsolatedLevel, LINE_NUMBER_WIDTH, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, MessageType, MetricsServerManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, type RunSandboxConfig, SandboxFilesystem, SandboxLatticeManager, type SandboxManagerProtocol, SandboxSkillStore, type SandboxSkillStoreOptions, type ScheduleLattice, ScheduleLatticeManager, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, ThreadStatus, type ToolDefinition, type ToolLattice, ToolLatticeManager, type VectorStoreLatticeInterface, VectorStoreLatticeManager, type WriteResult, agentLatticeManager, buildGrepResultsDict, checkEmptyContent, clearEncryptionKeyCache, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createTeamMiddleware, createTeammateTools, decrypt, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLatticeWithTenant, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };