@axiom-lattice/gateway 2.1.35 → 2.1.37
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/.turbo/turbo-build.log +8 -12
- package/CHANGELOG.md +16 -0
- package/dist/index.js +207 -280
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/controllers/metrics-configs.ts +8 -2
- package/src/services/agent_service.ts +0 -53
- package/dist/chunk-FSASG3SB.mjs +0 -94
- package/dist/chunk-FSASG3SB.mjs.map +0 -1
- package/dist/config-F3FCBSPH.mjs +0 -9
- package/dist/config-F3FCBSPH.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
configService
|
|
3
|
-
} from "./chunk-FSASG3SB.mjs";
|
|
4
|
-
|
|
5
1
|
// src/index.ts
|
|
6
2
|
import fastify from "fastify";
|
|
7
3
|
import cors from "@fastify/cors";
|
|
@@ -24,31 +20,6 @@ import {
|
|
|
24
20
|
getChunkBuffer,
|
|
25
21
|
hasChunkBuffer
|
|
26
22
|
} from "@axiom-lattice/core";
|
|
27
|
-
async function fetchDatabaseConfigs(baseURL, apiKey, tenantId) {
|
|
28
|
-
try {
|
|
29
|
-
const headers = {};
|
|
30
|
-
if (apiKey) {
|
|
31
|
-
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
32
|
-
}
|
|
33
|
-
if (tenantId) {
|
|
34
|
-
headers["x-tenant-id"] = tenantId;
|
|
35
|
-
}
|
|
36
|
-
const response = await fetch(`${baseURL}/api/database-configs`, { headers });
|
|
37
|
-
if (response.ok) {
|
|
38
|
-
const data = await response.json();
|
|
39
|
-
if (data.success && data.data && Array.isArray(data.data.records)) {
|
|
40
|
-
return data.data.records.map((record) => ({
|
|
41
|
-
key: record.key,
|
|
42
|
-
name: record.name,
|
|
43
|
-
description: record.description
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error("Failed to fetch database configs:", error);
|
|
49
|
-
}
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
23
|
function getOrCreateChunkBuffer() {
|
|
53
24
|
if (!hasChunkBuffer("default")) {
|
|
54
25
|
const buffer = new InMemoryChunkBuffer({
|
|
@@ -80,14 +51,6 @@ async function agent_invoke({
|
|
|
80
51
|
if (!runnable_agent) {
|
|
81
52
|
throw new Error(`Agent ${assistant_id} not found`);
|
|
82
53
|
}
|
|
83
|
-
const { configService: configService2 } = await import("./config-F3FCBSPH.mjs");
|
|
84
|
-
const gatewayConfig = configService2.getConfig();
|
|
85
|
-
const databaseConfigs = await fetchDatabaseConfigs(
|
|
86
|
-
gatewayConfig.baseURL || "http://localhost:4001",
|
|
87
|
-
void 0,
|
|
88
|
-
tenant_id
|
|
89
|
-
);
|
|
90
|
-
global.__DATABASE_CONFIGS__ = databaseConfigs;
|
|
91
54
|
const runConfig = {
|
|
92
55
|
...agentLattice?.config?.runConfig || {},
|
|
93
56
|
workspaceId: workspace_id,
|
|
@@ -141,14 +104,6 @@ async function agent_stream({
|
|
|
141
104
|
messages = [humanMessage];
|
|
142
105
|
}
|
|
143
106
|
const chunkBuffer = getOrCreateChunkBuffer();
|
|
144
|
-
const { configService: configService2 } = await import("./config-F3FCBSPH.mjs");
|
|
145
|
-
const gatewayConfig = configService2.getConfig();
|
|
146
|
-
const databaseConfigs = await fetchDatabaseConfigs(
|
|
147
|
-
gatewayConfig.baseURL || "http://localhost:4001",
|
|
148
|
-
void 0,
|
|
149
|
-
tenant_id
|
|
150
|
-
);
|
|
151
|
-
global.__DATABASE_CONFIGS__ = databaseConfigs;
|
|
152
107
|
const runConfig = {
|
|
153
108
|
...agentLattice?.config?.runConfig || {},
|
|
154
109
|
workspaceId: workspace_id,
|
|
@@ -1087,6 +1042,78 @@ async function resumeScheduledTask(request, reply) {
|
|
|
1087
1042
|
}
|
|
1088
1043
|
}
|
|
1089
1044
|
|
|
1045
|
+
// src/config.ts
|
|
1046
|
+
var ConfigService = class {
|
|
1047
|
+
constructor() {
|
|
1048
|
+
this.config = this.loadFromEnv();
|
|
1049
|
+
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Load configuration from environment variables
|
|
1052
|
+
*/
|
|
1053
|
+
loadFromEnv() {
|
|
1054
|
+
return {
|
|
1055
|
+
port: process.env.PORT ? Number(process.env.PORT) : void 0,
|
|
1056
|
+
queueServiceType: process.env.QUEUE_SERVICE_TYPE,
|
|
1057
|
+
redisUrl: process.env.REDIS_URL,
|
|
1058
|
+
redisPassword: process.env.REDIS_PASSWORD,
|
|
1059
|
+
queueName: process.env.QUEUE_NAME
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Update configuration from JSON object
|
|
1064
|
+
* This will update both the internal config and process.env
|
|
1065
|
+
*/
|
|
1066
|
+
updateConfig(jsonConfig) {
|
|
1067
|
+
for (const [key, value] of Object.entries(jsonConfig)) {
|
|
1068
|
+
if (value !== null && value !== void 0) {
|
|
1069
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
1070
|
+
for (const [nestedKey, nestedValue] of Object.entries(value)) {
|
|
1071
|
+
const envKey = `${key.toUpperCase()}_${nestedKey.toUpperCase()}`;
|
|
1072
|
+
process.env[envKey] = String(nestedValue);
|
|
1073
|
+
}
|
|
1074
|
+
} else {
|
|
1075
|
+
process.env[key.toUpperCase()] = String(value);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
this.config = this.loadFromEnv();
|
|
1080
|
+
this.config = this.deepMerge(this.config, jsonConfig);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Deep merge two objects
|
|
1084
|
+
*/
|
|
1085
|
+
deepMerge(target, source) {
|
|
1086
|
+
const output = { ...target };
|
|
1087
|
+
if (this.isObject(target) && this.isObject(source)) {
|
|
1088
|
+
Object.keys(source).forEach((key) => {
|
|
1089
|
+
if (this.isObject(source[key])) {
|
|
1090
|
+
if (!(key in target)) {
|
|
1091
|
+
Object.assign(output, { [key]: source[key] });
|
|
1092
|
+
} else {
|
|
1093
|
+
output[key] = this.deepMerge(target[key], source[key]);
|
|
1094
|
+
}
|
|
1095
|
+
} else {
|
|
1096
|
+
Object.assign(output, { [key]: source[key] });
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
return output;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Check if value is a plain object
|
|
1104
|
+
*/
|
|
1105
|
+
isObject(item) {
|
|
1106
|
+
return item && typeof item === "object" && !Array.isArray(item);
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Get current configuration
|
|
1110
|
+
*/
|
|
1111
|
+
getConfig() {
|
|
1112
|
+
return { ...this.config };
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
var configService = new ConfigService();
|
|
1116
|
+
|
|
1090
1117
|
// src/services/queue_service.ts
|
|
1091
1118
|
import {
|
|
1092
1119
|
queueLatticeManager,
|
|
@@ -3356,12 +3383,14 @@ async function getDataSources(request, reply) {
|
|
|
3356
3383
|
}
|
|
3357
3384
|
const semanticConfig = config.config;
|
|
3358
3385
|
const client = new SemanticMetricsClient(semanticConfig);
|
|
3359
|
-
const
|
|
3386
|
+
const allDatasources = await client.getDataSources();
|
|
3387
|
+
const selectedIds = semanticConfig.selectedDataSources || [];
|
|
3388
|
+
const filteredDatasources = selectedIds.length > 0 ? allDatasources.filter((ds) => selectedIds.includes(String(ds.id))) : allDatasources;
|
|
3360
3389
|
return {
|
|
3361
3390
|
success: true,
|
|
3362
3391
|
message: "Data sources retrieved successfully",
|
|
3363
3392
|
data: {
|
|
3364
|
-
datasources
|
|
3393
|
+
datasources: filteredDatasources
|
|
3365
3394
|
}
|
|
3366
3395
|
};
|
|
3367
3396
|
} catch (error) {
|