@axiom-lattice/core 2.1.74 → 2.1.76
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/README.md +93 -110
- package/dist/index.d.mts +40 -24
- package/dist/index.d.ts +40 -24
- package/dist/index.js +186 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +185 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -115,6 +115,7 @@ __export(index_exports, {
|
|
|
115
115
|
checkEmptyContent: () => checkEmptyContent,
|
|
116
116
|
clearEncryptionKeyCache: () => clearEncryptionKeyCache,
|
|
117
117
|
computeSandboxName: () => computeSandboxName,
|
|
118
|
+
configureStores: () => configureStores,
|
|
118
119
|
createAgentTeam: () => createAgentTeam,
|
|
119
120
|
createExecuteSqlQueryTool: () => createExecuteSqlQueryTool,
|
|
120
121
|
createFileData: () => createFileData,
|
|
@@ -2546,24 +2547,6 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
2546
2547
|
}
|
|
2547
2548
|
}
|
|
2548
2549
|
}
|
|
2549
|
-
async markCompleted(messageId) {
|
|
2550
|
-
for (const messages of this.messages.values()) {
|
|
2551
|
-
const message = messages.find((msg) => msg.id === messageId);
|
|
2552
|
-
if (message) {
|
|
2553
|
-
message.status = "completed";
|
|
2554
|
-
return;
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
async clearCompletedMessages(threadId) {
|
|
2559
|
-
const messages = this.messages.get(threadId);
|
|
2560
|
-
if (messages) {
|
|
2561
|
-
const filtered = messages.filter(
|
|
2562
|
-
(msg) => msg.status !== "completed"
|
|
2563
|
-
);
|
|
2564
|
-
this.messages.set(threadId, filtered);
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
2550
|
async resetProcessingToPending(threadId) {
|
|
2568
2551
|
const messages = this.messages.get(threadId);
|
|
2569
2552
|
if (!messages) {
|
|
@@ -3452,7 +3435,6 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
|
|
|
3452
3435
|
constructor() {
|
|
3453
3436
|
this.databases = /* @__PURE__ */ new Map();
|
|
3454
3437
|
this.defaultDatabaseKeys = /* @__PURE__ */ new Map();
|
|
3455
|
-
this.configStore = null;
|
|
3456
3438
|
}
|
|
3457
3439
|
/**
|
|
3458
3440
|
* Get the singleton instance
|
|
@@ -3512,16 +3494,9 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
|
|
|
3512
3494
|
}
|
|
3513
3495
|
this.defaultDatabaseKeys.set(tenantId, key);
|
|
3514
3496
|
}
|
|
3515
|
-
/**
|
|
3516
|
-
* Set the configuration store for on-demand database loading
|
|
3517
|
-
* @param store - The database configuration store
|
|
3518
|
-
*/
|
|
3519
|
-
setConfigStore(store) {
|
|
3520
|
-
this.configStore = store;
|
|
3521
|
-
}
|
|
3522
3497
|
/**
|
|
3523
3498
|
* Get a database by key for a specific tenant
|
|
3524
|
-
* If database is not registered
|
|
3499
|
+
* If database is not registered, tries to load from the store lattice
|
|
3525
3500
|
* @param tenantId - Tenant identifier (required)
|
|
3526
3501
|
* @param key - Database key (optional, uses default if not provided)
|
|
3527
3502
|
* @returns ISqlDatabase instance
|
|
@@ -3539,8 +3514,10 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
|
|
|
3539
3514
|
return database;
|
|
3540
3515
|
}
|
|
3541
3516
|
}
|
|
3542
|
-
|
|
3543
|
-
const
|
|
3517
|
+
try {
|
|
3518
|
+
const { store } = getStoreLattice("default", "database");
|
|
3519
|
+
const configStore = store;
|
|
3520
|
+
const configEntry = await configStore.getConfigByKey(tenantId, dbKey);
|
|
3544
3521
|
if (configEntry) {
|
|
3545
3522
|
this.registerDatabase(tenantId, dbKey, configEntry.config);
|
|
3546
3523
|
if (!this.defaultDatabaseKeys.has(tenantId)) {
|
|
@@ -3554,6 +3531,7 @@ var SqlDatabaseManager = class _SqlDatabaseManager {
|
|
|
3554
3531
|
}
|
|
3555
3532
|
}
|
|
3556
3533
|
}
|
|
3534
|
+
} catch {
|
|
3557
3535
|
}
|
|
3558
3536
|
if (!tenantDbs) {
|
|
3559
3537
|
throw new Error(`No databases registered for tenant '${tenantId}'`);
|
|
@@ -4663,6 +4641,7 @@ var MetricsServerManager = class _MetricsServerManager {
|
|
|
4663
4641
|
this.clients = /* @__PURE__ */ new Map();
|
|
4664
4642
|
this.configs = /* @__PURE__ */ new Map();
|
|
4665
4643
|
this.defaultServerKeys = /* @__PURE__ */ new Map();
|
|
4644
|
+
this._loadingPromise = null;
|
|
4666
4645
|
}
|
|
4667
4646
|
/**
|
|
4668
4647
|
* Get the singleton instance
|
|
@@ -4673,6 +4652,32 @@ var MetricsServerManager = class _MetricsServerManager {
|
|
|
4673
4652
|
}
|
|
4674
4653
|
return _MetricsServerManager.instance;
|
|
4675
4654
|
}
|
|
4655
|
+
/**
|
|
4656
|
+
* Ensure configurations are loaded from the store lattice.
|
|
4657
|
+
* Uses a promise-lock to prevent concurrent loads.
|
|
4658
|
+
*/
|
|
4659
|
+
async _ensureLoaded() {
|
|
4660
|
+
if (this.clients.size > 0) {
|
|
4661
|
+
return;
|
|
4662
|
+
}
|
|
4663
|
+
if (this._loadingPromise) {
|
|
4664
|
+
return this._loadingPromise;
|
|
4665
|
+
}
|
|
4666
|
+
this._loadingPromise = (async () => {
|
|
4667
|
+
try {
|
|
4668
|
+
const { store } = getStoreLattice("default", "metrics");
|
|
4669
|
+
const configStore = store;
|
|
4670
|
+
const configs = await configStore.getAllConfigsWithoutTenant();
|
|
4671
|
+
for (const entry of configs) {
|
|
4672
|
+
const tenantId = entry.tenantId || "default";
|
|
4673
|
+
this.registerServer(tenantId, entry.key, entry.config);
|
|
4674
|
+
}
|
|
4675
|
+
} finally {
|
|
4676
|
+
this._loadingPromise = null;
|
|
4677
|
+
}
|
|
4678
|
+
})();
|
|
4679
|
+
return this._loadingPromise;
|
|
4680
|
+
}
|
|
4676
4681
|
/**
|
|
4677
4682
|
* Get or create tenant clients map
|
|
4678
4683
|
*/
|
|
@@ -4741,7 +4746,8 @@ var MetricsServerManager = class _MetricsServerManager {
|
|
|
4741
4746
|
* @param tenantId - Tenant identifier
|
|
4742
4747
|
* @param key - Server key (optional, uses default if not provided)
|
|
4743
4748
|
*/
|
|
4744
|
-
getClient(tenantId, key) {
|
|
4749
|
+
async getClient(tenantId, key) {
|
|
4750
|
+
await this._ensureLoaded();
|
|
4745
4751
|
const tenantClients = this.clients.get(tenantId);
|
|
4746
4752
|
if (!tenantClients) {
|
|
4747
4753
|
throw new Error(`No metrics servers registered for tenant '${tenantId}'`);
|
|
@@ -4761,7 +4767,8 @@ var MetricsServerManager = class _MetricsServerManager {
|
|
|
4761
4767
|
* @param tenantId - Tenant identifier
|
|
4762
4768
|
* @param key - Server key (optional, uses default if not provided)
|
|
4763
4769
|
*/
|
|
4764
|
-
getConfig(tenantId, key) {
|
|
4770
|
+
async getConfig(tenantId, key) {
|
|
4771
|
+
await this._ensureLoaded();
|
|
4765
4772
|
const tenantConfigs = this.configs.get(tenantId);
|
|
4766
4773
|
if (!tenantConfigs) {
|
|
4767
4774
|
throw new Error(`No metrics servers registered for tenant '${tenantId}'`);
|
|
@@ -4789,7 +4796,8 @@ var MetricsServerManager = class _MetricsServerManager {
|
|
|
4789
4796
|
* Get all registered metrics server keys with their types for a tenant
|
|
4790
4797
|
* @param tenantId - Tenant identifier
|
|
4791
4798
|
*/
|
|
4792
|
-
getServerKeys(tenantId) {
|
|
4799
|
+
async getServerKeys(tenantId) {
|
|
4800
|
+
await this._ensureLoaded();
|
|
4793
4801
|
const tenantConfigs = this.configs.get(tenantId);
|
|
4794
4802
|
if (!tenantConfigs) {
|
|
4795
4803
|
return [];
|
|
@@ -4856,20 +4864,6 @@ var MetricsServerManager = class _MetricsServerManager {
|
|
|
4856
4864
|
this.registerServer(tenantId, entry.key, entry.config);
|
|
4857
4865
|
}
|
|
4858
4866
|
}
|
|
4859
|
-
/**
|
|
4860
|
-
* Load all metrics server configurations from a store
|
|
4861
|
-
* across all tenants and register them with this manager
|
|
4862
|
-
*
|
|
4863
|
-
* @param store - The metrics server configuration store
|
|
4864
|
-
* @deprecated Use loadConfigsFromStore with specific tenant instead
|
|
4865
|
-
*/
|
|
4866
|
-
async loadAllConfigsFromStore(store) {
|
|
4867
|
-
const configs = await store.getAllConfigsWithoutTenant();
|
|
4868
|
-
for (const entry of configs) {
|
|
4869
|
-
const tenantId = entry.tenantId || "default";
|
|
4870
|
-
this.registerServer(tenantId, entry.key, entry.config);
|
|
4871
|
-
}
|
|
4872
|
-
}
|
|
4873
4867
|
};
|
|
4874
4868
|
var metricsServerManager = MetricsServerManager.getInstance();
|
|
4875
4869
|
|
|
@@ -4888,7 +4882,7 @@ ${serverKeys.map(
|
|
|
4888
4882
|
async (_input, _exeConfig) => {
|
|
4889
4883
|
try {
|
|
4890
4884
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
4891
|
-
const servers = metricsServerManager.getServerKeys(tenantId);
|
|
4885
|
+
const servers = await metricsServerManager.getServerKeys(tenantId);
|
|
4892
4886
|
if (servers.length === 0) {
|
|
4893
4887
|
return "No metrics servers registered.";
|
|
4894
4888
|
}
|
|
@@ -4927,7 +4921,7 @@ ${serverKeys.map(
|
|
|
4927
4921
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
4928
4922
|
let effectiveServerKeys = serverKeys;
|
|
4929
4923
|
if (connectAll) {
|
|
4930
|
-
effectiveServerKeys = metricsServerManager.getServerKeys(tenantId).map((s) => s.key);
|
|
4924
|
+
effectiveServerKeys = (await metricsServerManager.getServerKeys(tenantId)).map((s) => s.key);
|
|
4931
4925
|
}
|
|
4932
4926
|
const filteredServerKeys = filterServerKeysByTenant(effectiveServerKeys, tenantId);
|
|
4933
4927
|
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
@@ -4950,12 +4944,12 @@ To view all available data sources, please clear the current selection or reopen
|
|
|
4950
4944
|
const allDataSources = [];
|
|
4951
4945
|
for (const serverKey of filteredServerKeys) {
|
|
4952
4946
|
try {
|
|
4953
|
-
const config = metricsServerManager.getConfig(tenantId, serverKey);
|
|
4947
|
+
const config = await metricsServerManager.getConfig(tenantId, serverKey);
|
|
4954
4948
|
if (config.type !== "semantic") {
|
|
4955
4949
|
console.warn(`Server "${serverKey}" is not a semantic metrics server, skipping.`);
|
|
4956
4950
|
continue;
|
|
4957
4951
|
}
|
|
4958
|
-
const client = metricsServerManager.getClient(tenantId, serverKey);
|
|
4952
|
+
const client = await metricsServerManager.getClient(tenantId, serverKey);
|
|
4959
4953
|
const dataSources = await client.getDataSources();
|
|
4960
4954
|
const selectedIds = config.selectedDataSources || [];
|
|
4961
4955
|
const filteredDataSources = selectedIds.length > 0 ? dataSources.filter((ds) => selectedIds.includes(String(ds.id))) : dataSources;
|
|
@@ -5046,7 +5040,7 @@ ${serverKeys.map(
|
|
|
5046
5040
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
5047
5041
|
let effectiveServerKeys = serverKeys;
|
|
5048
5042
|
if (connectAll) {
|
|
5049
|
-
effectiveServerKeys = metricsServerManager.getServerKeys(tenantId).map((s) => s.key);
|
|
5043
|
+
effectiveServerKeys = (await metricsServerManager.getServerKeys(tenantId)).map((s) => s.key);
|
|
5050
5044
|
}
|
|
5051
5045
|
const filteredServerKeys = filterServerKeysByTenant(effectiveServerKeys, tenantId);
|
|
5052
5046
|
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
@@ -5058,11 +5052,11 @@ ${serverKeys.map(
|
|
|
5058
5052
|
if (!filteredServerKeys.includes(serverKey)) {
|
|
5059
5053
|
return `Error: serverKey "${serverKey}" is not available for tenant "${tenantId}". Available servers: [${filteredServerKeys.join(", ")}]`;
|
|
5060
5054
|
}
|
|
5061
|
-
const config = metricsServerManager.getConfig(tenantId, serverKey);
|
|
5055
|
+
const config = await metricsServerManager.getConfig(tenantId, serverKey);
|
|
5062
5056
|
if (config.type !== "semantic") {
|
|
5063
5057
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
5064
5058
|
}
|
|
5065
|
-
const client = metricsServerManager.getClient(tenantId, serverKey);
|
|
5059
|
+
const client = await metricsServerManager.getClient(tenantId, serverKey);
|
|
5066
5060
|
const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
|
|
5067
5061
|
if (targetDatasourceIds.length === 0) {
|
|
5068
5062
|
return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
|
|
@@ -5204,7 +5198,7 @@ ${serverKeys.map(
|
|
|
5204
5198
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
5205
5199
|
let effectiveServerKeys = serverKeys;
|
|
5206
5200
|
if (connectAll) {
|
|
5207
|
-
effectiveServerKeys = metricsServerManager.getServerKeys(tenantId).map((s) => s.key);
|
|
5201
|
+
effectiveServerKeys = (await metricsServerManager.getServerKeys(tenantId)).map((s) => s.key);
|
|
5208
5202
|
}
|
|
5209
5203
|
const filteredServerKeys = filterServerKeysByTenant(effectiveServerKeys, tenantId);
|
|
5210
5204
|
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
@@ -5220,11 +5214,11 @@ ${serverKeys.map(
|
|
|
5220
5214
|
if (!metricName) {
|
|
5221
5215
|
return "Error: metricName parameter is required.";
|
|
5222
5216
|
}
|
|
5223
|
-
const config = metricsServerManager.getConfig(tenantId, serverKey);
|
|
5217
|
+
const config = await metricsServerManager.getConfig(tenantId, serverKey);
|
|
5224
5218
|
if (config.type !== "semantic") {
|
|
5225
5219
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
5226
5220
|
}
|
|
5227
|
-
const client = metricsServerManager.getClient(tenantId, serverKey);
|
|
5221
|
+
const client = await metricsServerManager.getClient(tenantId, serverKey);
|
|
5228
5222
|
const targetDatasourceIds = datasourceId ? [datasourceId] : client.getSelectedDataSources();
|
|
5229
5223
|
if (targetDatasourceIds.length === 0) {
|
|
5230
5224
|
return `Error: No datasourceId specified and no default data sources configured for server "${serverKey}".`;
|
|
@@ -5440,7 +5434,7 @@ ${serverKeys.map(
|
|
|
5440
5434
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
5441
5435
|
let effectiveServerKeys = serverKeys;
|
|
5442
5436
|
if (connectAll) {
|
|
5443
|
-
effectiveServerKeys = metricsServerManager.getServerKeys(tenantId).map((s) => s.key);
|
|
5437
|
+
effectiveServerKeys = (await metricsServerManager.getServerKeys(tenantId)).map((s) => s.key);
|
|
5444
5438
|
}
|
|
5445
5439
|
const filteredServerKeys = filterServerKeysByTenant(effectiveServerKeys, tenantId);
|
|
5446
5440
|
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
@@ -5459,11 +5453,11 @@ ${serverKeys.map(
|
|
|
5459
5453
|
if (!metrics || metrics.length === 0) {
|
|
5460
5454
|
return "Error: metrics parameter is required (at least one metric name).";
|
|
5461
5455
|
}
|
|
5462
|
-
const config = metricsServerManager.getConfig(tenantId, serverKey);
|
|
5456
|
+
const config = await metricsServerManager.getConfig(tenantId, serverKey);
|
|
5463
5457
|
if (config.type !== "semantic") {
|
|
5464
5458
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
5465
5459
|
}
|
|
5466
|
-
const client = metricsServerManager.getClient(tenantId, serverKey);
|
|
5460
|
+
const client = await metricsServerManager.getClient(tenantId, serverKey);
|
|
5467
5461
|
const semanticFilters = (filters || []).map((f) => ({
|
|
5468
5462
|
dimension: f.dimension,
|
|
5469
5463
|
operator: f.operator,
|
|
@@ -5521,7 +5515,7 @@ ${serverKeys.map(
|
|
|
5521
5515
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
5522
5516
|
let effectiveServerKeys = serverKeys;
|
|
5523
5517
|
if (connectAll) {
|
|
5524
|
-
effectiveServerKeys = metricsServerManager.getServerKeys(tenantId).map((s) => s.key);
|
|
5518
|
+
effectiveServerKeys = (await metricsServerManager.getServerKeys(tenantId)).map((s) => s.key);
|
|
5525
5519
|
}
|
|
5526
5520
|
const filteredServerKeys = filterServerKeysByTenant(effectiveServerKeys, tenantId);
|
|
5527
5521
|
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
@@ -5533,11 +5527,11 @@ ${serverKeys.map(
|
|
|
5533
5527
|
if (!filteredServerKeys.includes(serverKey)) {
|
|
5534
5528
|
return `Error: serverKey "${serverKey}" is not available for tenant "${tenantId}". Available servers: [${filteredServerKeys.join(", ")}]`;
|
|
5535
5529
|
}
|
|
5536
|
-
const config = metricsServerManager.getConfig(tenantId, serverKey);
|
|
5530
|
+
const config = await metricsServerManager.getConfig(tenantId, serverKey);
|
|
5537
5531
|
if (config.type !== "semantic") {
|
|
5538
5532
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
5539
5533
|
}
|
|
5540
|
-
const client = metricsServerManager.getClient(tenantId, serverKey);
|
|
5534
|
+
const client = await metricsServerManager.getClient(tenantId, serverKey);
|
|
5541
5535
|
const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
|
|
5542
5536
|
if (targetDatasourceIds.length === 0) {
|
|
5543
5537
|
return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
|
|
@@ -5626,7 +5620,7 @@ ${serverKeys.map(
|
|
|
5626
5620
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
5627
5621
|
let effectiveServerKeys = serverKeys;
|
|
5628
5622
|
if (connectAll) {
|
|
5629
|
-
effectiveServerKeys = metricsServerManager.getServerKeys(tenantId).map((s) => s.key);
|
|
5623
|
+
effectiveServerKeys = (await metricsServerManager.getServerKeys(tenantId)).map((s) => s.key);
|
|
5630
5624
|
}
|
|
5631
5625
|
const filteredServerKeys = filterServerKeysByTenant(effectiveServerKeys, tenantId);
|
|
5632
5626
|
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
@@ -5642,11 +5636,11 @@ ${serverKeys.map(
|
|
|
5642
5636
|
if (!tableName) {
|
|
5643
5637
|
return "Error: tableName parameter is required.";
|
|
5644
5638
|
}
|
|
5645
|
-
const config = metricsServerManager.getConfig(tenantId, serverKey);
|
|
5639
|
+
const config = await metricsServerManager.getConfig(tenantId, serverKey);
|
|
5646
5640
|
if (config.type !== "semantic") {
|
|
5647
5641
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
5648
5642
|
}
|
|
5649
|
-
const client = metricsServerManager.getClient(tenantId, serverKey);
|
|
5643
|
+
const client = await metricsServerManager.getClient(tenantId, serverKey);
|
|
5650
5644
|
const targetDatasourceIds = datasourceId ? [datasourceId] : client.getSelectedDataSources();
|
|
5651
5645
|
if (targetDatasourceIds.length === 0) {
|
|
5652
5646
|
return `Error: No datasourceId specified and no default data sources configured for server "${serverKey}".`;
|
|
@@ -5766,7 +5760,7 @@ ${serverKeys.map(
|
|
|
5766
5760
|
const tenantId = getTenantIdFromConfig2(_exeConfig, getTenantId2);
|
|
5767
5761
|
let effectiveServerKeys = serverKeys;
|
|
5768
5762
|
if (connectAll) {
|
|
5769
|
-
effectiveServerKeys = metricsServerManager.getServerKeys(tenantId).map((s) => s.key);
|
|
5763
|
+
effectiveServerKeys = (await metricsServerManager.getServerKeys(tenantId)).map((s) => s.key);
|
|
5770
5764
|
}
|
|
5771
5765
|
const filteredServerKeys = filterServerKeysByTenant(effectiveServerKeys, tenantId);
|
|
5772
5766
|
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
@@ -5785,11 +5779,11 @@ ${serverKeys.map(
|
|
|
5785
5779
|
if (!customSql || customSql.trim().length === 0) {
|
|
5786
5780
|
return "Error: customSql parameter is required and cannot be empty.";
|
|
5787
5781
|
}
|
|
5788
|
-
const config = metricsServerManager.getConfig(tenantId, serverKey);
|
|
5782
|
+
const config = await metricsServerManager.getConfig(tenantId, serverKey);
|
|
5789
5783
|
if (config.type !== "semantic") {
|
|
5790
5784
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
5791
5785
|
}
|
|
5792
|
-
const client = metricsServerManager.getClient(tenantId, serverKey);
|
|
5786
|
+
const client = await metricsServerManager.getClient(tenantId, serverKey);
|
|
5793
5787
|
const result = await client.executeSqlQuery({
|
|
5794
5788
|
datasourceId,
|
|
5795
5789
|
customSql,
|
|
@@ -12328,7 +12322,7 @@ var Agent = class {
|
|
|
12328
12322
|
command: p.command,
|
|
12329
12323
|
custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
|
|
12330
12324
|
}, signal);
|
|
12331
|
-
await this.queueStore?.
|
|
12325
|
+
await this.queueStore?.removeMessage(p.id);
|
|
12332
12326
|
const runStatus = await this.getRunStatus();
|
|
12333
12327
|
const state = await this.getCurrentState();
|
|
12334
12328
|
if (runStatus === "interrupted" /* INTERRUPTED */) {
|
|
@@ -12370,7 +12364,8 @@ var Agent = class {
|
|
|
12370
12364
|
error: error instanceof Error ? error.message : String(error),
|
|
12371
12365
|
timestamp: /* @__PURE__ */ new Date()
|
|
12372
12366
|
});
|
|
12373
|
-
|
|
12367
|
+
await this.queueStore?.removeMessage(p.id);
|
|
12368
|
+
continue;
|
|
12374
12369
|
}
|
|
12375
12370
|
}
|
|
12376
12371
|
}
|
|
@@ -12406,7 +12401,7 @@ var Agent = class {
|
|
|
12406
12401
|
const runStatus = await this.getRunStatus();
|
|
12407
12402
|
const state = await this.getCurrentState();
|
|
12408
12403
|
for (const p of remainingPendings) {
|
|
12409
|
-
await this.queueStore?.
|
|
12404
|
+
await this.queueStore?.removeMessage(p.id);
|
|
12410
12405
|
if (runStatus === "interrupted" /* INTERRUPTED */) {
|
|
12411
12406
|
this.publish("message:interrupted", {
|
|
12412
12407
|
type: "message:interrupted",
|
|
@@ -12448,8 +12443,8 @@ var Agent = class {
|
|
|
12448
12443
|
error: error instanceof Error ? error.message : String(error),
|
|
12449
12444
|
timestamp: /* @__PURE__ */ new Date()
|
|
12450
12445
|
});
|
|
12446
|
+
await this.queueStore?.removeMessage(p.id);
|
|
12451
12447
|
}
|
|
12452
|
-
throw error;
|
|
12453
12448
|
}
|
|
12454
12449
|
} else if (this.queueMode.mode === "followup" /* FOLLOWUP */) {
|
|
12455
12450
|
for (const p of remainingPendings) {
|
|
@@ -12477,7 +12472,7 @@ var Agent = class {
|
|
|
12477
12472
|
input,
|
|
12478
12473
|
custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
|
|
12479
12474
|
}, signal);
|
|
12480
|
-
await this.queueStore?.
|
|
12475
|
+
await this.queueStore?.removeMessage(p.id);
|
|
12481
12476
|
const runStatus = await this.getRunStatus();
|
|
12482
12477
|
const state = await this.getCurrentState();
|
|
12483
12478
|
if (runStatus === "interrupted" /* INTERRUPTED */) {
|
|
@@ -12519,7 +12514,8 @@ var Agent = class {
|
|
|
12519
12514
|
error: error instanceof Error ? error.message : String(error),
|
|
12520
12515
|
timestamp: /* @__PURE__ */ new Date()
|
|
12521
12516
|
});
|
|
12522
|
-
|
|
12517
|
+
await this.queueStore?.removeMessage(p.id);
|
|
12518
|
+
continue;
|
|
12523
12519
|
}
|
|
12524
12520
|
}
|
|
12525
12521
|
}
|
|
@@ -18110,6 +18106,75 @@ function mergeAgentConfig(parent, child) {
|
|
|
18110
18106
|
return merged;
|
|
18111
18107
|
}
|
|
18112
18108
|
|
|
18109
|
+
// src/store_lattice/configureStores.ts
|
|
18110
|
+
var _disposables = [];
|
|
18111
|
+
var _cleanupRegistered = false;
|
|
18112
|
+
function registerSignalCleanup() {
|
|
18113
|
+
if (_cleanupRegistered) return;
|
|
18114
|
+
_cleanupRegistered = true;
|
|
18115
|
+
for (const sig of ["SIGINT", "SIGTERM"]) {
|
|
18116
|
+
process.once(sig, async () => {
|
|
18117
|
+
for (const s of _disposables) {
|
|
18118
|
+
if (s.dispose) await s.dispose();
|
|
18119
|
+
}
|
|
18120
|
+
});
|
|
18121
|
+
}
|
|
18122
|
+
}
|
|
18123
|
+
async function initAndRegister(store, localDisposables) {
|
|
18124
|
+
const initStore = store;
|
|
18125
|
+
if (typeof initStore.initialize === "function" && initStore.initialize.length === 0) {
|
|
18126
|
+
await initStore.initialize();
|
|
18127
|
+
}
|
|
18128
|
+
const dispStore = store;
|
|
18129
|
+
if (typeof dispStore.dispose === "function") {
|
|
18130
|
+
localDisposables.push(dispStore);
|
|
18131
|
+
}
|
|
18132
|
+
}
|
|
18133
|
+
async function configureStores(stores, options = {}) {
|
|
18134
|
+
const localDisposables = [];
|
|
18135
|
+
const { schedule, checkpoint, ...regularStores } = stores;
|
|
18136
|
+
for (const [type, store] of Object.entries(regularStores)) {
|
|
18137
|
+
await initAndRegister(store, localDisposables);
|
|
18138
|
+
if (storeLatticeManager.hasLattice("default", type)) {
|
|
18139
|
+
storeLatticeManager.removeLattice("default", type);
|
|
18140
|
+
}
|
|
18141
|
+
storeLatticeManager.registerLattice("default", type, store);
|
|
18142
|
+
}
|
|
18143
|
+
if (schedule !== void 0) {
|
|
18144
|
+
await initAndRegister(schedule, localDisposables);
|
|
18145
|
+
const scheduleConfig = {
|
|
18146
|
+
name: "Default Scheduler",
|
|
18147
|
+
description: "Auto-configured schedule storage",
|
|
18148
|
+
type: "postgres",
|
|
18149
|
+
storage: schedule
|
|
18150
|
+
};
|
|
18151
|
+
registerScheduleLattice("default", scheduleConfig);
|
|
18152
|
+
}
|
|
18153
|
+
if (checkpoint !== void 0) {
|
|
18154
|
+
MemoryLatticeManager.getInstance().removeCheckpointSaver("default");
|
|
18155
|
+
registerCheckpointSaver("default", checkpoint);
|
|
18156
|
+
}
|
|
18157
|
+
if (options.customStores) {
|
|
18158
|
+
for (const [type, store] of Object.entries(options.customStores)) {
|
|
18159
|
+
await initAndRegister(store, localDisposables);
|
|
18160
|
+
const t = type;
|
|
18161
|
+
if (storeLatticeManager.hasLattice("default", t)) {
|
|
18162
|
+
storeLatticeManager.removeLattice("default", t);
|
|
18163
|
+
}
|
|
18164
|
+
storeLatticeManager.registerLattice("default", t, store);
|
|
18165
|
+
}
|
|
18166
|
+
}
|
|
18167
|
+
if (options.autoDisposeStores) {
|
|
18168
|
+
registerSignalCleanup();
|
|
18169
|
+
_disposables.push(...localDisposables);
|
|
18170
|
+
}
|
|
18171
|
+
return async () => {
|
|
18172
|
+
for (const s of localDisposables.reverse()) {
|
|
18173
|
+
if (s.dispose) await s.dispose();
|
|
18174
|
+
}
|
|
18175
|
+
};
|
|
18176
|
+
}
|
|
18177
|
+
|
|
18113
18178
|
// src/store_lattice/SandboxSkillStore.ts
|
|
18114
18179
|
function parseFrontmatter2(content) {
|
|
18115
18180
|
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
|
|
@@ -18398,9 +18463,7 @@ ${body}` : `${frontmatter}
|
|
|
18398
18463
|
} catch (listError) {
|
|
18399
18464
|
console.log(`[SandboxSkillStore] Skills directory not found, creating: ${skillsDir}`);
|
|
18400
18465
|
try {
|
|
18401
|
-
await sandbox.
|
|
18402
|
-
command: `mkdir -p /root/.agents/skills`
|
|
18403
|
-
});
|
|
18466
|
+
await sandbox.file.createDirectory(skillsDir);
|
|
18404
18467
|
} catch (mkdirError) {
|
|
18405
18468
|
console.error(`[SandboxSkillStore] Failed to create skills directory: ${mkdirError.message}`);
|
|
18406
18469
|
return [];
|
|
@@ -18541,12 +18604,7 @@ ${body}` : `${frontmatter}
|
|
|
18541
18604
|
try {
|
|
18542
18605
|
const sandbox = await this.getSandbox(tenantId, context);
|
|
18543
18606
|
const dirPath = this.getSkillDirectoryPath(tenantId, id);
|
|
18544
|
-
|
|
18545
|
-
command: `rm -rf ${dirPath}`
|
|
18546
|
-
});
|
|
18547
|
-
if (deleteResult.exit_code !== 0) {
|
|
18548
|
-
return false;
|
|
18549
|
-
}
|
|
18607
|
+
await sandbox.file.deletePath(dirPath);
|
|
18550
18608
|
return true;
|
|
18551
18609
|
} catch (error) {
|
|
18552
18610
|
console.error(`Error deleting skill ${id}:`, error);
|
|
@@ -21357,6 +21415,20 @@ var MicrosandboxRemoteInstance = class {
|
|
|
21357
21415
|
return Buffer.from(result.contentBase64, "base64");
|
|
21358
21416
|
}
|
|
21359
21417
|
return Buffer.from(result.content ?? "");
|
|
21418
|
+
},
|
|
21419
|
+
deletePath: async (path3) => {
|
|
21420
|
+
const resolved = normalizeExternalSandboxPath(path3);
|
|
21421
|
+
await this.client.execCommand({
|
|
21422
|
+
sandboxName: this.name,
|
|
21423
|
+
command: `rm -rf "${resolved}"`
|
|
21424
|
+
});
|
|
21425
|
+
},
|
|
21426
|
+
createDirectory: async (path3) => {
|
|
21427
|
+
const resolved = normalizeExternalSandboxPath(path3);
|
|
21428
|
+
await this.client.execCommand({
|
|
21429
|
+
sandboxName: this.name,
|
|
21430
|
+
command: `mkdir -p "${resolved}"`
|
|
21431
|
+
});
|
|
21360
21432
|
}
|
|
21361
21433
|
};
|
|
21362
21434
|
this.shell = {
|
|
@@ -21808,6 +21880,24 @@ var RemoteSandboxInstance = class {
|
|
|
21808
21880
|
}
|
|
21809
21881
|
const buffer2 = await result.body.arrayBuffer();
|
|
21810
21882
|
return Buffer.from(buffer2);
|
|
21883
|
+
},
|
|
21884
|
+
deletePath: async (path3) => {
|
|
21885
|
+
const resolved = this.resolvePath(path3);
|
|
21886
|
+
const result = await this.client.shell.execCommand({
|
|
21887
|
+
command: `rm -rf "${resolved}"`
|
|
21888
|
+
});
|
|
21889
|
+
if (!result.ok) {
|
|
21890
|
+
throw new Error(`deletePath failed: ${extractFetcherError(result.error)}`);
|
|
21891
|
+
}
|
|
21892
|
+
},
|
|
21893
|
+
createDirectory: async (path3) => {
|
|
21894
|
+
const resolved = this.resolvePath(path3);
|
|
21895
|
+
const result = await this.client.shell.execCommand({
|
|
21896
|
+
command: `mkdir -p "${resolved}"`
|
|
21897
|
+
});
|
|
21898
|
+
if (!result.ok) {
|
|
21899
|
+
throw new Error(`createDirectory failed: ${extractFetcherError(result.error)}`);
|
|
21900
|
+
}
|
|
21811
21901
|
}
|
|
21812
21902
|
};
|
|
21813
21903
|
this.shell = {
|
|
@@ -22071,6 +22161,12 @@ var E2BInstance = class {
|
|
|
22071
22161
|
downloadFile: async (params) => {
|
|
22072
22162
|
const data = await this.native.files.read(params.file, { format: "bytes" });
|
|
22073
22163
|
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
22164
|
+
},
|
|
22165
|
+
deletePath: async (path3) => {
|
|
22166
|
+
await this.native.commands.run(`rm -rf "${path3}"`);
|
|
22167
|
+
},
|
|
22168
|
+
createDirectory: async (path3) => {
|
|
22169
|
+
await this.native.commands.run(`mkdir -p "${path3}"`);
|
|
22074
22170
|
}
|
|
22075
22171
|
};
|
|
22076
22172
|
this.shell = {
|
|
@@ -22237,6 +22333,12 @@ var DaytonaInstance = class {
|
|
|
22237
22333
|
downloadFile: async (params) => {
|
|
22238
22334
|
const buffer2 = await this.native.fs.downloadFile(toRelativePath(params.file));
|
|
22239
22335
|
return Buffer.isBuffer(buffer2) ? buffer2 : Buffer.from(buffer2);
|
|
22336
|
+
},
|
|
22337
|
+
deletePath: async (path3) => {
|
|
22338
|
+
await this.native.process.executeCommand(`rm -rf "${toRelativePath(path3)}"`, void 0, void 0);
|
|
22339
|
+
},
|
|
22340
|
+
createDirectory: async (path3) => {
|
|
22341
|
+
await this.native.process.executeCommand(`mkdir -p "${toRelativePath(path3)}"`, void 0, void 0);
|
|
22240
22342
|
}
|
|
22241
22343
|
};
|
|
22242
22344
|
this.shell = {
|
|
@@ -22679,6 +22781,7 @@ function clearEncryptionKeyCache() {
|
|
|
22679
22781
|
checkEmptyContent,
|
|
22680
22782
|
clearEncryptionKeyCache,
|
|
22681
22783
|
computeSandboxName,
|
|
22784
|
+
configureStores,
|
|
22682
22785
|
createAgentTeam,
|
|
22683
22786
|
createExecuteSqlQueryTool,
|
|
22684
22787
|
createFileData,
|