@axiom-lattice/gateway 2.1.28 → 2.1.30
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 +12 -8
- package/AGENTS.md +50 -0
- package/CHANGELOG.md +20 -0
- package/dist/chunk-FSASG3SB.mjs +94 -0
- package/dist/chunk-FSASG3SB.mjs.map +1 -0
- package/dist/config-F3FCBSPH.mjs +9 -0
- package/dist/config-F3FCBSPH.mjs.map +1 -0
- package/dist/index.js +1996 -209
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1878 -186
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/controllers/auth.ts +443 -0
- package/src/controllers/database-configs.ts +432 -0
- package/src/controllers/metrics-configs.ts +989 -0
- package/src/controllers/run.ts +6 -0
- package/src/controllers/tenants.ts +121 -0
- package/src/controllers/users.ts +135 -0
- package/src/controllers/workspace.ts +598 -0
- package/src/index.ts +2 -10
- package/src/routes/index.ts +21 -0
- package/src/services/agent_service.ts +71 -5
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from "@langchain/core/messages";
|
|
10
10
|
import { Command, CommandParams } from "@langchain/langgraph";
|
|
11
11
|
import { v4 } from "uuid";
|
|
12
|
-
// 修改导入路径,使用 lattice_core 包
|
|
13
12
|
import {
|
|
14
13
|
getAgentClient,
|
|
15
14
|
getAgentLattice,
|
|
@@ -19,6 +18,39 @@ import {
|
|
|
19
18
|
hasChunkBuffer,
|
|
20
19
|
} from "@axiom-lattice/core";
|
|
21
20
|
|
|
21
|
+
interface DatabaseConfigEntry {
|
|
22
|
+
key: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function fetchDatabaseConfigs(baseURL: string, apiKey?: string, tenantId?: string): Promise<DatabaseConfigEntry[]> {
|
|
28
|
+
try {
|
|
29
|
+
const headers: Record<string, string> = {};
|
|
30
|
+
if (apiKey) {
|
|
31
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
32
|
+
}
|
|
33
|
+
if (tenantId) {
|
|
34
|
+
headers["x-tenant-id"] = tenantId;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const response = await fetch(`${baseURL}/api/database-configs`, { headers });
|
|
38
|
+
if (response.ok) {
|
|
39
|
+
const data: any = await response.json();
|
|
40
|
+
if (data.success && data.data && Array.isArray(data.data.records)) {
|
|
41
|
+
return data.data.records.map((record: any) => ({
|
|
42
|
+
key: record.key,
|
|
43
|
+
name: record.name,
|
|
44
|
+
description: record.description,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error("Failed to fetch database configs:", error);
|
|
50
|
+
}
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
|
|
22
54
|
/**
|
|
23
55
|
* Get or create the global ChunkBuffer instance
|
|
24
56
|
*/
|
|
@@ -38,6 +70,8 @@ export async function agent_invoke({
|
|
|
38
70
|
thread_id,
|
|
39
71
|
assistant_id,
|
|
40
72
|
tenant_id,
|
|
73
|
+
workspace_id,
|
|
74
|
+
project_id,
|
|
41
75
|
command,
|
|
42
76
|
run_id,
|
|
43
77
|
}: {
|
|
@@ -45,6 +79,8 @@ export async function agent_invoke({
|
|
|
45
79
|
input: any;
|
|
46
80
|
thread_id: string;
|
|
47
81
|
tenant_id: string;
|
|
82
|
+
workspace_id?: string;
|
|
83
|
+
project_id?: string;
|
|
48
84
|
run_id?: string;
|
|
49
85
|
command?: CommandParams<any>;
|
|
50
86
|
}) {
|
|
@@ -58,11 +94,22 @@ export async function agent_invoke({
|
|
|
58
94
|
throw new Error(`Agent ${assistant_id} not found`);
|
|
59
95
|
}
|
|
60
96
|
|
|
97
|
+
// Fetch database configs and set to global for middleware to access
|
|
98
|
+
const { configService } = await import("../config.js");
|
|
99
|
+
const gatewayConfig = configService.getConfig();
|
|
100
|
+
const databaseConfigs = await fetchDatabaseConfigs(
|
|
101
|
+
gatewayConfig.baseURL || "http://localhost:4001",
|
|
102
|
+
undefined,
|
|
103
|
+
tenant_id
|
|
104
|
+
);
|
|
105
|
+
(global as any).__DATABASE_CONFIGS__ = databaseConfigs;
|
|
106
|
+
|
|
61
107
|
// Get runConfig from agent config and merge into configurable
|
|
62
108
|
const runConfig = {
|
|
63
109
|
...agentLattice?.config?.runConfig || {},
|
|
64
110
|
assistant_id,
|
|
65
|
-
|
|
111
|
+
workspaceId: workspace_id,
|
|
112
|
+
projectId: project_id,
|
|
66
113
|
}
|
|
67
114
|
|
|
68
115
|
const result = await runnable_agent.invoke(
|
|
@@ -74,10 +121,12 @@ export async function agent_invoke({
|
|
|
74
121
|
thread_id: thread_id,
|
|
75
122
|
run_id: run_id || v4(),
|
|
76
123
|
"x-tenant-id": tenant_id,
|
|
124
|
+
"x-workspace-id": workspace_id,
|
|
125
|
+
"x-project-id": project_id,
|
|
77
126
|
"x-request-id": run_id,
|
|
78
127
|
"x-thread-id": thread_id,
|
|
79
128
|
"x-assistant-id": assistant_id,
|
|
80
|
-
runConfig,
|
|
129
|
+
runConfig,
|
|
81
130
|
},
|
|
82
131
|
recursionLimit: 200,
|
|
83
132
|
}
|
|
@@ -98,6 +147,8 @@ export async function agent_stream({
|
|
|
98
147
|
thread_id,
|
|
99
148
|
command,
|
|
100
149
|
tenant_id,
|
|
150
|
+
workspace_id,
|
|
151
|
+
project_id,
|
|
101
152
|
assistant_id,
|
|
102
153
|
run_id,
|
|
103
154
|
}: {
|
|
@@ -106,9 +157,11 @@ export async function agent_stream({
|
|
|
106
157
|
thread_id: string;
|
|
107
158
|
command?: CommandParams<any>;
|
|
108
159
|
tenant_id: string;
|
|
160
|
+
workspace_id?: string;
|
|
161
|
+
project_id?: string;
|
|
109
162
|
run_id?: string;
|
|
110
163
|
}) {
|
|
111
|
-
const runnable_agent = getAgentClient(assistant_id) as any;
|
|
164
|
+
const runnable_agent = getAgentClient(assistant_id) as any;
|
|
112
165
|
const agentLattice = getAgentLattice(assistant_id);
|
|
113
166
|
const { message, ...rest } = input;
|
|
114
167
|
let messages: BaseMessage[] = [];
|
|
@@ -120,11 +173,22 @@ export async function agent_stream({
|
|
|
120
173
|
// Get ChunkBuffer instance
|
|
121
174
|
const chunkBuffer = getOrCreateChunkBuffer();
|
|
122
175
|
|
|
176
|
+
// Fetch database configs and set to global for middleware to access
|
|
177
|
+
const { configService } = await import("../config.js");
|
|
178
|
+
const gatewayConfig = configService.getConfig();
|
|
179
|
+
const databaseConfigs = await fetchDatabaseConfigs(
|
|
180
|
+
gatewayConfig.baseURL || "http://localhost:4001",
|
|
181
|
+
undefined,
|
|
182
|
+
tenant_id
|
|
183
|
+
);
|
|
184
|
+
(global as any).__DATABASE_CONFIGS__ = databaseConfigs;
|
|
185
|
+
|
|
123
186
|
// Get runConfig from agent config and merge into configurable
|
|
124
187
|
const runConfig = {
|
|
125
188
|
...agentLattice?.config?.runConfig || {},
|
|
126
189
|
assistant_id,
|
|
127
|
-
|
|
190
|
+
workspaceId: workspace_id,
|
|
191
|
+
projectId: project_id,
|
|
128
192
|
}
|
|
129
193
|
|
|
130
194
|
try {
|
|
@@ -145,6 +209,8 @@ export async function agent_stream({
|
|
|
145
209
|
thread_id: thread_id,
|
|
146
210
|
run_id: run_id || v4(),
|
|
147
211
|
"x-tenant-id": tenant_id,
|
|
212
|
+
"x-workspace-id": workspace_id,
|
|
213
|
+
"x-project-id": project_id,
|
|
148
214
|
"x-request-id": run_id,
|
|
149
215
|
"x-thread-id": thread_id,
|
|
150
216
|
"x-assistant-id": assistant_id,
|