@axiom-lattice/gateway 2.1.112 → 2.1.114
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 +11 -11
- package/CHANGELOG.md +15 -0
- package/dist/index.js +1956 -273
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1767 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/controllers/export-import.ts +166 -0
- package/src/controllers/run.ts +30 -4
- package/src/controllers/workspace.ts +3 -3
- package/src/export_registrations/a2a-api-key.registration.ts +89 -0
- package/src/export_registrations/agent.registration.ts +80 -0
- package/src/export_registrations/binding.registration.ts +106 -0
- package/src/export_registrations/channel-installation.registration.ts +88 -0
- package/src/export_registrations/collection.registration.ts +85 -0
- package/src/export_registrations/connection.registration.ts +97 -0
- package/src/export_registrations/database-config.registration.ts +94 -0
- package/src/export_registrations/eval.registration.ts +334 -0
- package/src/export_registrations/index.ts +31 -0
- package/src/export_registrations/mcp-config.registration.ts +97 -0
- package/src/export_registrations/menu.registration.ts +91 -0
- package/src/export_registrations/metrics-config.registration.ts +94 -0
- package/src/export_registrations/skill.registration.ts +88 -0
- package/src/export_registrations/task.registration.ts +99 -0
- package/src/index.ts +4 -0
- package/src/routes/index.ts +34 -0
- package/src/services/ExportImportService.ts +296 -0
- package/src/services/__tests__/ExportImportService.test.ts +130 -0
package/dist/index.js
CHANGED
|
@@ -94,7 +94,7 @@ __export(mcp_configs_exports, {
|
|
|
94
94
|
testMcpServerTools: () => testMcpServerTools,
|
|
95
95
|
updateMcpServerConfig: () => updateMcpServerConfig
|
|
96
96
|
});
|
|
97
|
-
function
|
|
97
|
+
function getTenantId13(request) {
|
|
98
98
|
const userTenantId = request.user?.tenantId;
|
|
99
99
|
if (userTenantId) {
|
|
100
100
|
return userTenantId;
|
|
@@ -102,9 +102,9 @@ function getTenantId12(request) {
|
|
|
102
102
|
return request.headers["x-tenant-id"] || "default";
|
|
103
103
|
}
|
|
104
104
|
async function getMcpServerConfigList(request, reply) {
|
|
105
|
-
const tenantId =
|
|
105
|
+
const tenantId = getTenantId13(request);
|
|
106
106
|
try {
|
|
107
|
-
const storeLattice = (0,
|
|
107
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
108
108
|
const store2 = storeLattice.store;
|
|
109
109
|
const configs = await store2.getAllConfigs(tenantId);
|
|
110
110
|
return {
|
|
@@ -128,10 +128,10 @@ async function getMcpServerConfigList(request, reply) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
async function getMcpServerConfig(request, reply) {
|
|
131
|
-
const tenantId =
|
|
131
|
+
const tenantId = getTenantId13(request);
|
|
132
132
|
const { key } = request.params;
|
|
133
133
|
try {
|
|
134
|
-
const storeLattice = (0,
|
|
134
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
135
135
|
const store2 = storeLattice.store;
|
|
136
136
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
137
137
|
if (!config) {
|
|
@@ -154,10 +154,10 @@ async function getMcpServerConfig(request, reply) {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
async function createMcpServerConfig(request, reply) {
|
|
157
|
-
const tenantId =
|
|
157
|
+
const tenantId = getTenantId13(request);
|
|
158
158
|
const body = request.body;
|
|
159
159
|
try {
|
|
160
|
-
const storeLattice = (0,
|
|
160
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
161
161
|
const store2 = storeLattice.store;
|
|
162
162
|
const existing = await store2.getConfigByKey(tenantId, body.key);
|
|
163
163
|
if (existing) {
|
|
@@ -167,7 +167,7 @@ async function createMcpServerConfig(request, reply) {
|
|
|
167
167
|
message: "MCP server configuration with this key already exists"
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
const id = body.id || (0,
|
|
170
|
+
const id = body.id || (0, import_crypto7.randomUUID)();
|
|
171
171
|
const config = await store2.createConfig(tenantId, id, body);
|
|
172
172
|
try {
|
|
173
173
|
await connectAndRegisterTools(config);
|
|
@@ -193,11 +193,11 @@ async function createMcpServerConfig(request, reply) {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
async function updateMcpServerConfig(request, reply) {
|
|
196
|
-
const tenantId =
|
|
196
|
+
const tenantId = getTenantId13(request);
|
|
197
197
|
const { key } = request.params;
|
|
198
198
|
const updates = request.body;
|
|
199
199
|
try {
|
|
200
|
-
const storeLattice = (0,
|
|
200
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
201
201
|
const store2 = storeLattice.store;
|
|
202
202
|
const existing = await store2.getConfigByKey(tenantId, key);
|
|
203
203
|
if (!existing) {
|
|
@@ -217,8 +217,8 @@ async function updateMcpServerConfig(request, reply) {
|
|
|
217
217
|
}
|
|
218
218
|
if (shouldReconnect) {
|
|
219
219
|
try {
|
|
220
|
-
await
|
|
221
|
-
await
|
|
220
|
+
await import_core30.mcpManager.reconnectServer(key);
|
|
221
|
+
await import_core30.mcpManager.registerToolsToToolLattice(key, updated.selectedTools);
|
|
222
222
|
await store2.updateConfig(tenantId, existing.id, { status: "connected" });
|
|
223
223
|
updated.status = "connected";
|
|
224
224
|
} catch (error) {
|
|
@@ -241,10 +241,10 @@ async function updateMcpServerConfig(request, reply) {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
async function deleteMcpServerConfig(request, reply) {
|
|
244
|
-
const tenantId =
|
|
244
|
+
const tenantId = getTenantId13(request);
|
|
245
245
|
const { keyOrId } = request.params;
|
|
246
246
|
try {
|
|
247
|
-
const storeLattice = (0,
|
|
247
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
248
248
|
const store2 = storeLattice.store;
|
|
249
249
|
let config = await store2.getConfigByKey(tenantId, keyOrId);
|
|
250
250
|
let configKey = keyOrId;
|
|
@@ -262,8 +262,8 @@ async function deleteMcpServerConfig(request, reply) {
|
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
try {
|
|
265
|
-
if (
|
|
266
|
-
await
|
|
265
|
+
if (import_core30.mcpManager.hasServer(configKey)) {
|
|
266
|
+
await import_core30.mcpManager.removeServer(configKey);
|
|
267
267
|
}
|
|
268
268
|
} catch (error) {
|
|
269
269
|
console.warn("Failed to remove from MCP manager:", error);
|
|
@@ -288,10 +288,10 @@ async function deleteMcpServerConfig(request, reply) {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
async function testMcpServerConnection(request, reply) {
|
|
291
|
-
const tenantId =
|
|
291
|
+
const tenantId = getTenantId13(request);
|
|
292
292
|
const { key } = request.params;
|
|
293
293
|
try {
|
|
294
|
-
const storeLattice = (0,
|
|
294
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
295
295
|
const store2 = storeLattice.store;
|
|
296
296
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
297
297
|
if (!config) {
|
|
@@ -304,7 +304,7 @@ async function testMcpServerConnection(request, reply) {
|
|
|
304
304
|
try {
|
|
305
305
|
const testKey = `__test_${key}_${Date.now()}`;
|
|
306
306
|
const connection = convertToConnection(config.config);
|
|
307
|
-
const { latency } = await
|
|
307
|
+
const { latency } = await import_core30.McpLatticeManager.testConnection(testKey, connection);
|
|
308
308
|
return {
|
|
309
309
|
success: true,
|
|
310
310
|
message: "Connection test successful",
|
|
@@ -336,10 +336,10 @@ async function testMcpServerConnection(request, reply) {
|
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
async function listMcpServerTools(request, reply) {
|
|
339
|
-
const tenantId =
|
|
339
|
+
const tenantId = getTenantId13(request);
|
|
340
340
|
const { key } = request.params;
|
|
341
341
|
try {
|
|
342
|
-
const storeLattice = (0,
|
|
342
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
343
343
|
const store2 = storeLattice.store;
|
|
344
344
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
345
345
|
if (!config) {
|
|
@@ -349,10 +349,10 @@ async function listMcpServerTools(request, reply) {
|
|
|
349
349
|
message: "MCP server configuration not found"
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
-
if (!
|
|
352
|
+
if (!import_core30.mcpManager.hasServer(key)) {
|
|
353
353
|
await connectAndRegisterTools(config);
|
|
354
354
|
}
|
|
355
|
-
const tools = await
|
|
355
|
+
const tools = await import_core30.mcpManager.getServerTools(key);
|
|
356
356
|
return {
|
|
357
357
|
success: true,
|
|
358
358
|
message: "Tools retrieved successfully",
|
|
@@ -369,10 +369,10 @@ async function listMcpServerTools(request, reply) {
|
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
async function connectMcpServer(request, reply) {
|
|
372
|
-
const tenantId =
|
|
372
|
+
const tenantId = getTenantId13(request);
|
|
373
373
|
const { key } = request.params;
|
|
374
374
|
try {
|
|
375
|
-
const storeLattice = (0,
|
|
375
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
376
376
|
const store2 = storeLattice.store;
|
|
377
377
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
378
378
|
if (!config) {
|
|
@@ -393,7 +393,7 @@ async function connectMcpServer(request, reply) {
|
|
|
393
393
|
};
|
|
394
394
|
} catch (error) {
|
|
395
395
|
console.error("Failed to connect MCP server:", error);
|
|
396
|
-
const storeLattice = (0,
|
|
396
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
397
397
|
const store2 = storeLattice.store;
|
|
398
398
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
399
399
|
if (config) {
|
|
@@ -406,10 +406,10 @@ async function connectMcpServer(request, reply) {
|
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
async function disconnectMcpServer(request, reply) {
|
|
409
|
-
const tenantId =
|
|
409
|
+
const tenantId = getTenantId13(request);
|
|
410
410
|
const { key } = request.params;
|
|
411
411
|
try {
|
|
412
|
-
const storeLattice = (0,
|
|
412
|
+
const storeLattice = (0, import_core30.getStoreLattice)("default", "mcp");
|
|
413
413
|
const store2 = storeLattice.store;
|
|
414
414
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
415
415
|
if (!config) {
|
|
@@ -419,8 +419,8 @@ async function disconnectMcpServer(request, reply) {
|
|
|
419
419
|
message: "MCP server configuration not found"
|
|
420
420
|
};
|
|
421
421
|
}
|
|
422
|
-
if (
|
|
423
|
-
await
|
|
422
|
+
if (import_core30.mcpManager.hasServer(key)) {
|
|
423
|
+
await import_core30.mcpManager.removeServer(key);
|
|
424
424
|
}
|
|
425
425
|
const updated = await store2.updateConfig(tenantId, config.id, {
|
|
426
426
|
status: "disconnected"
|
|
@@ -450,7 +450,7 @@ async function testMcpServerTools(request, reply) {
|
|
|
450
450
|
}
|
|
451
451
|
const testKey = `__test_${Date.now()}`;
|
|
452
452
|
const connection = convertToConnection(body.config);
|
|
453
|
-
const { tools } = await
|
|
453
|
+
const { tools } = await import_core30.McpLatticeManager.testConnection(testKey, connection);
|
|
454
454
|
return {
|
|
455
455
|
success: true,
|
|
456
456
|
message: "Tools retrieved successfully",
|
|
@@ -487,9 +487,9 @@ function convertToConnection(config) {
|
|
|
487
487
|
}
|
|
488
488
|
async function connectAndRegisterTools(config) {
|
|
489
489
|
const connection = convertToConnection(config.config);
|
|
490
|
-
|
|
491
|
-
await
|
|
492
|
-
await
|
|
490
|
+
import_core30.mcpManager.addServer(config.key, connection);
|
|
491
|
+
await import_core30.mcpManager.connect();
|
|
492
|
+
await import_core30.mcpManager.registerToolsToToolLattice(config.key, config.selectedTools);
|
|
493
493
|
}
|
|
494
494
|
function registerMcpServerConfigRoutes(app2) {
|
|
495
495
|
app2.get("/api/mcp-servers", getMcpServerConfigList);
|
|
@@ -503,12 +503,12 @@ function registerMcpServerConfigRoutes(app2) {
|
|
|
503
503
|
app2.post("/api/mcp-servers/:key/disconnect", disconnectMcpServer);
|
|
504
504
|
app2.post("/api/mcp-servers/test-tools", testMcpServerTools);
|
|
505
505
|
}
|
|
506
|
-
var
|
|
506
|
+
var import_core30, import_crypto7;
|
|
507
507
|
var init_mcp_configs = __esm({
|
|
508
508
|
"src/controllers/mcp-configs.ts"() {
|
|
509
509
|
"use strict";
|
|
510
|
-
|
|
511
|
-
|
|
510
|
+
import_core30 = require("@axiom-lattice/core");
|
|
511
|
+
import_crypto7 = require("crypto");
|
|
512
512
|
}
|
|
513
513
|
});
|
|
514
514
|
|
|
@@ -1290,7 +1290,7 @@ async function handleTasksSend(request, reply) {
|
|
|
1290
1290
|
taskStore.set(taskId, record);
|
|
1291
1291
|
let agent;
|
|
1292
1292
|
try {
|
|
1293
|
-
agent =
|
|
1293
|
+
agent = import_core54.agentInstanceManager.getAgent({
|
|
1294
1294
|
assistant_id: assistantId,
|
|
1295
1295
|
thread_id: threadId,
|
|
1296
1296
|
tenant_id: tenantId,
|
|
@@ -1382,7 +1382,7 @@ async function handleTasksCancel(request, reply) {
|
|
|
1382
1382
|
return;
|
|
1383
1383
|
}
|
|
1384
1384
|
try {
|
|
1385
|
-
const agent =
|
|
1385
|
+
const agent = import_core54.agentInstanceManager.getAgent({
|
|
1386
1386
|
assistant_id: record.assistantId,
|
|
1387
1387
|
thread_id: record.threadId,
|
|
1388
1388
|
tenant_id: record.tenantId,
|
|
@@ -1419,7 +1419,7 @@ async function handleTasksStream(request, reply) {
|
|
|
1419
1419
|
}
|
|
1420
1420
|
let agent;
|
|
1421
1421
|
try {
|
|
1422
|
-
agent =
|
|
1422
|
+
agent = import_core54.agentInstanceManager.getAgent({
|
|
1423
1423
|
assistant_id: record.assistantId,
|
|
1424
1424
|
thread_id: record.threadId,
|
|
1425
1425
|
tenant_id: record.tenantId,
|
|
@@ -1614,12 +1614,12 @@ function registerA2ARoutes(app2) {
|
|
|
1614
1614
|
handleApiKeyRotate
|
|
1615
1615
|
);
|
|
1616
1616
|
}
|
|
1617
|
-
var import_uuid10,
|
|
1617
|
+
var import_uuid10, import_core54, import_protocols4, taskStore, _a2aKeyStore, _storeKeyMap;
|
|
1618
1618
|
var init_a2a = __esm({
|
|
1619
1619
|
"src/routes/a2a.ts"() {
|
|
1620
1620
|
"use strict";
|
|
1621
1621
|
import_uuid10 = require("uuid");
|
|
1622
|
-
|
|
1622
|
+
import_core54 = require("@axiom-lattice/core");
|
|
1623
1623
|
import_protocols4 = require("@axiom-lattice/protocols");
|
|
1624
1624
|
taskStore = /* @__PURE__ */ new Map();
|
|
1625
1625
|
_a2aKeyStore = null;
|
|
@@ -1632,12 +1632,12 @@ var resources_exports = {};
|
|
|
1632
1632
|
__export(resources_exports, {
|
|
1633
1633
|
ResourceController: () => ResourceController
|
|
1634
1634
|
});
|
|
1635
|
-
var import_bcryptjs,
|
|
1635
|
+
var import_bcryptjs, import_core55, ResourceController;
|
|
1636
1636
|
var init_resources = __esm({
|
|
1637
1637
|
"src/controllers/resources.ts"() {
|
|
1638
1638
|
"use strict";
|
|
1639
1639
|
import_bcryptjs = __toESM(require("bcryptjs"));
|
|
1640
|
-
|
|
1640
|
+
import_core55 = require("@axiom-lattice/core");
|
|
1641
1641
|
init_mime();
|
|
1642
1642
|
ResourceController = class {
|
|
1643
1643
|
constructor(deps) {
|
|
@@ -1652,14 +1652,14 @@ var init_resources = __esm({
|
|
|
1652
1652
|
if (!workspaceId || !projectId) {
|
|
1653
1653
|
return reply.status(400).send({ error: "x-workspace-id and x-project-id headers required" });
|
|
1654
1654
|
}
|
|
1655
|
-
const payload = (0,
|
|
1655
|
+
const payload = (0, import_core55.createSharePayload)(
|
|
1656
1656
|
tenantId,
|
|
1657
1657
|
workspaceId,
|
|
1658
1658
|
projectId,
|
|
1659
1659
|
userId,
|
|
1660
1660
|
body
|
|
1661
1661
|
);
|
|
1662
|
-
const token = (0,
|
|
1662
|
+
const token = (0, import_core55.generateToken)();
|
|
1663
1663
|
try {
|
|
1664
1664
|
await this.deps.store.create({ ...payload, token });
|
|
1665
1665
|
this.deps.logger.info(
|
|
@@ -1811,7 +1811,7 @@ var init_resources = __esm({
|
|
|
1811
1811
|
resourcePath: subPath
|
|
1812
1812
|
}, subPath, ext, request, reply);
|
|
1813
1813
|
}
|
|
1814
|
-
const volume = (0,
|
|
1814
|
+
const volume = (0, import_core55.buildNamedVolumeName)("p", "project", tenantId, workspaceId, projectId);
|
|
1815
1815
|
return this._resolveAndServe(
|
|
1816
1816
|
volume,
|
|
1817
1817
|
subPath,
|
|
@@ -2261,6 +2261,20 @@ var createRun = async (request, reply) => {
|
|
|
2261
2261
|
project_id,
|
|
2262
2262
|
custom_run_config: mergedConfig
|
|
2263
2263
|
});
|
|
2264
|
+
if (background) {
|
|
2265
|
+
const messageInput = message_id ? { ...input, id: message_id } : input;
|
|
2266
|
+
const result = await agent.addMessage({
|
|
2267
|
+
input: messageInput,
|
|
2268
|
+
command,
|
|
2269
|
+
custom_run_config: mergedConfig
|
|
2270
|
+
}, mode);
|
|
2271
|
+
reply.status(202).send({
|
|
2272
|
+
success: true,
|
|
2273
|
+
messageId: result.messageId,
|
|
2274
|
+
queued: true
|
|
2275
|
+
});
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2264
2278
|
if (streaming) {
|
|
2265
2279
|
reply.hijack();
|
|
2266
2280
|
reply.raw.writeHead(200, {
|
|
@@ -2346,8 +2360,13 @@ var resumeStream = async (request, reply) => {
|
|
|
2346
2360
|
workspace_id,
|
|
2347
2361
|
project_id
|
|
2348
2362
|
});
|
|
2349
|
-
const stream = agent.chunkStream(message_id, [
|
|
2363
|
+
const stream = agent.chunkStream(message_id, []);
|
|
2364
|
+
let closed = false;
|
|
2365
|
+
request.raw.on("close", () => {
|
|
2366
|
+
closed = true;
|
|
2367
|
+
});
|
|
2350
2368
|
for await (const chunk of stream) {
|
|
2369
|
+
if (closed || reply.raw.destroyed) break;
|
|
2351
2370
|
reply.raw.write(`data: ${JSON.stringify(chunk)}
|
|
2352
2371
|
|
|
2353
2372
|
`);
|
|
@@ -4978,11 +4997,339 @@ async function completeTask(request, reply) {
|
|
|
4978
4997
|
}
|
|
4979
4998
|
}
|
|
4980
4999
|
|
|
4981
|
-
// src/
|
|
5000
|
+
// src/services/ExportImportService.ts
|
|
4982
5001
|
var import_core18 = require("@axiom-lattice/core");
|
|
5002
|
+
var import_crypto4 = require("crypto");
|
|
5003
|
+
var exportJobs = /* @__PURE__ */ new Map();
|
|
5004
|
+
var JOB_TTL_MS = 60 * 60 * 1e3;
|
|
5005
|
+
function cleanExpiredJobs() {
|
|
5006
|
+
const now = Date.now();
|
|
5007
|
+
for (const [id, entry] of exportJobs) {
|
|
5008
|
+
if (now - entry.createdAt > JOB_TTL_MS) {
|
|
5009
|
+
exportJobs.delete(id);
|
|
5010
|
+
}
|
|
5011
|
+
}
|
|
5012
|
+
}
|
|
5013
|
+
var ExportImportService = class {
|
|
5014
|
+
constructor() {
|
|
5015
|
+
this.registry = import_core18.ExportableEntityRegistry.getInstance();
|
|
5016
|
+
}
|
|
5017
|
+
/**
|
|
5018
|
+
* Preview an export: check which types would be auto-included, which dependencies are missing.
|
|
5019
|
+
*/
|
|
5020
|
+
async exportPreview(tenantId, selectedTypes) {
|
|
5021
|
+
const allDefs = this.registry.getAll();
|
|
5022
|
+
const expanded = import_core18.DependencyResolver.expandCascade(allDefs, selectedTypes);
|
|
5023
|
+
const cascadeAdditions = expanded.filter((t) => !selectedTypes.includes(t));
|
|
5024
|
+
const deps = import_core18.DependencyResolver.computeDependencies(allDefs, expanded);
|
|
5025
|
+
const registeredTypes = new Set(allDefs.map((d) => d.entityType));
|
|
5026
|
+
const missingDependencies = deps.missing.filter((t) => registeredTypes.has(t));
|
|
5027
|
+
return { missingDependencies, cascadeAdditions };
|
|
5028
|
+
}
|
|
5029
|
+
/**
|
|
5030
|
+
* Generate a full ExportBundle for the given tenant and entity types.
|
|
5031
|
+
* Stores the bundle in-memory and returns a jobId for download.
|
|
5032
|
+
*/
|
|
5033
|
+
async export(tenantId, entityTypes, entityIds) {
|
|
5034
|
+
const allDefs = this.registry.getAll();
|
|
5035
|
+
const expanded = import_core18.DependencyResolver.expandCascade(allDefs, entityTypes);
|
|
5036
|
+
const finalTypes = [.../* @__PURE__ */ new Set([...expanded, ...entityTypes])];
|
|
5037
|
+
const dependencyOrder = import_core18.DependencyResolver.resolveOrder(
|
|
5038
|
+
finalTypes.map((t) => this.registry.get(t))
|
|
5039
|
+
);
|
|
5040
|
+
const entities = {};
|
|
5041
|
+
let exportCounter = 0;
|
|
5042
|
+
for (const type of dependencyOrder) {
|
|
5043
|
+
const def = this.registry.get(type);
|
|
5044
|
+
let raw = await def.listForExport(tenantId);
|
|
5045
|
+
if (entityIds && entityIds[type] && entityIds[type].length > 0) {
|
|
5046
|
+
const idSet = new Set(entityIds[type]);
|
|
5047
|
+
raw = raw.filter((e) => idSet.has(e.data.id));
|
|
5048
|
+
}
|
|
5049
|
+
entities[type] = raw.map((e) => ({
|
|
5050
|
+
...e,
|
|
5051
|
+
_exportId: `exp-${type}-${String(++exportCounter).padStart(3, "0")}`,
|
|
5052
|
+
data: this.sanitizeEntityData(e.data)
|
|
5053
|
+
}));
|
|
5054
|
+
}
|
|
5055
|
+
const rawIdToExportId = /* @__PURE__ */ new Map();
|
|
5056
|
+
for (const [, entityList] of Object.entries(entities)) {
|
|
5057
|
+
for (const entity of entityList) {
|
|
5058
|
+
const rawId = entity.data.id;
|
|
5059
|
+
if (rawId) {
|
|
5060
|
+
rawIdToExportId.set(rawId, entity._exportId);
|
|
5061
|
+
}
|
|
5062
|
+
}
|
|
5063
|
+
}
|
|
5064
|
+
for (const [type, entityList] of Object.entries(entities)) {
|
|
5065
|
+
const def = this.registry.get(type);
|
|
5066
|
+
const refFields = def.referenceFields || {};
|
|
5067
|
+
for (const entity of entityList) {
|
|
5068
|
+
for (const [fieldName, refEntityType] of Object.entries(refFields)) {
|
|
5069
|
+
const rawValue = entity.data[fieldName];
|
|
5070
|
+
if (typeof rawValue === "string" && rawValue) {
|
|
5071
|
+
const exportId = rawIdToExportId.get(rawValue);
|
|
5072
|
+
if (exportId) {
|
|
5073
|
+
entity.data[fieldName] = `@${refEntityType}/${exportId}`;
|
|
5074
|
+
}
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
const bundle = {
|
|
5080
|
+
version: 1,
|
|
5081
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5082
|
+
sourceTenantId: tenantId,
|
|
5083
|
+
entities,
|
|
5084
|
+
dependencyOrder,
|
|
5085
|
+
_warning: "This file contains plaintext secrets (passwords, API keys, tokens). Store it securely and delete after import."
|
|
5086
|
+
};
|
|
5087
|
+
const jobId = (0, import_crypto4.randomUUID)();
|
|
5088
|
+
exportJobs.set(jobId, { bundle, tenantId, createdAt: Date.now() });
|
|
5089
|
+
return { jobId, bundle };
|
|
5090
|
+
}
|
|
5091
|
+
/**
|
|
5092
|
+
* Retrieve a previously generated export bundle by jobId with tenant validation.
|
|
5093
|
+
*/
|
|
5094
|
+
getExportJob(jobId, tenantId) {
|
|
5095
|
+
cleanExpiredJobs();
|
|
5096
|
+
const entry = exportJobs.get(jobId);
|
|
5097
|
+
if (!entry || entry.tenantId !== tenantId) return void 0;
|
|
5098
|
+
return entry.bundle;
|
|
5099
|
+
}
|
|
5100
|
+
/**
|
|
5101
|
+
* Preview import: validate bundle and detect conflicts.
|
|
5102
|
+
*/
|
|
5103
|
+
async previewImport(tenantId, bundle) {
|
|
5104
|
+
this.validateBundle(bundle);
|
|
5105
|
+
const allConflicts = [];
|
|
5106
|
+
const allInsertions = [];
|
|
5107
|
+
const allErrors = [];
|
|
5108
|
+
for (const [entityType, entities] of Object.entries(bundle.entities)) {
|
|
5109
|
+
if (entities.length === 0) continue;
|
|
5110
|
+
try {
|
|
5111
|
+
const def = this.registry.get(entityType);
|
|
5112
|
+
const result = await def.previewImport(tenantId, entities);
|
|
5113
|
+
allConflicts.push(...result.conflicts);
|
|
5114
|
+
allInsertions.push(...result.insertions);
|
|
5115
|
+
allErrors.push(...result.errors);
|
|
5116
|
+
} catch (err) {
|
|
5117
|
+
for (const entity of entities) {
|
|
5118
|
+
allErrors.push({
|
|
5119
|
+
_exportId: entity._exportId,
|
|
5120
|
+
entityType,
|
|
5121
|
+
error: `Preview failed: ${err.message}`
|
|
5122
|
+
});
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
return { conflicts: allConflicts, insertions: allInsertions, errors: allErrors };
|
|
5127
|
+
}
|
|
5128
|
+
/**
|
|
5129
|
+
* Apply import: create entities in dependency order with ID remapping.
|
|
5130
|
+
*/
|
|
5131
|
+
async applyImport(tenantId, bundle, resolutions) {
|
|
5132
|
+
this.validateBundle(bundle);
|
|
5133
|
+
const results = [];
|
|
5134
|
+
const idMap = {};
|
|
5135
|
+
const skillIdRemap = {};
|
|
5136
|
+
for (const entityType of bundle.dependencyOrder) {
|
|
5137
|
+
const entities = bundle.entities[entityType];
|
|
5138
|
+
if (!entities || entities.length === 0) continue;
|
|
5139
|
+
const def = this.registry.get(entityType);
|
|
5140
|
+
const remapper = new import_core18.IdRemapper(idMap);
|
|
5141
|
+
for (const entity of entities) {
|
|
5142
|
+
const resolution = resolutions[entity._exportId];
|
|
5143
|
+
if (resolution?.action === "skip") {
|
|
5144
|
+
results.push({ _exportId: entity._exportId, entityType, status: "skipped" });
|
|
5145
|
+
continue;
|
|
5146
|
+
}
|
|
5147
|
+
try {
|
|
5148
|
+
const remappedData = remapper.remapReferences(entity.data);
|
|
5149
|
+
if (entityType === "agent" && Object.keys(skillIdRemap).length > 0) {
|
|
5150
|
+
const skillRemapper = new import_core18.IdRemapper({});
|
|
5151
|
+
remappedData.graphDefinition = skillRemapper.remapSkillIds(
|
|
5152
|
+
remappedData.graphDefinition || {},
|
|
5153
|
+
skillIdRemap
|
|
5154
|
+
);
|
|
5155
|
+
}
|
|
5156
|
+
if (resolution?.action === "rename" && resolution.newId) {
|
|
5157
|
+
remappedData.id = resolution.newId;
|
|
5158
|
+
}
|
|
5159
|
+
const entityWithRemappedData = { ...entity, data: remappedData };
|
|
5160
|
+
const { newId } = await def.applyImport(
|
|
5161
|
+
tenantId,
|
|
5162
|
+
entityWithRemappedData,
|
|
5163
|
+
resolution ?? { _exportId: entity._exportId, action: "overwrite" }
|
|
5164
|
+
);
|
|
5165
|
+
if (newId) {
|
|
5166
|
+
idMap[entity._exportId] = newId;
|
|
5167
|
+
if (entityType === "skill" && newId) {
|
|
5168
|
+
const oldSkillId = remappedData.id;
|
|
5169
|
+
if (oldSkillId !== newId) {
|
|
5170
|
+
skillIdRemap[oldSkillId] = newId;
|
|
5171
|
+
}
|
|
5172
|
+
}
|
|
5173
|
+
results.push({
|
|
5174
|
+
_exportId: entity._exportId,
|
|
5175
|
+
entityType,
|
|
5176
|
+
status: resolution?.action === "overwrite" ? "updated" : "created",
|
|
5177
|
+
newId
|
|
5178
|
+
});
|
|
5179
|
+
}
|
|
5180
|
+
} catch (err) {
|
|
5181
|
+
results.push({
|
|
5182
|
+
_exportId: entity._exportId,
|
|
5183
|
+
entityType,
|
|
5184
|
+
status: "failed",
|
|
5185
|
+
error: err.message
|
|
5186
|
+
});
|
|
5187
|
+
}
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
return { results, idMap };
|
|
5191
|
+
}
|
|
5192
|
+
/**
|
|
5193
|
+
* List all registered exportable types (for frontend).
|
|
5194
|
+
*/
|
|
5195
|
+
listExportableTypes() {
|
|
5196
|
+
return this.registry.listTypes();
|
|
5197
|
+
}
|
|
5198
|
+
validateBundle(bundle) {
|
|
5199
|
+
if (bundle.version !== 1) {
|
|
5200
|
+
throw new Error(`Unsupported bundle version: ${bundle.version}. Expected: 1`);
|
|
5201
|
+
}
|
|
5202
|
+
if (!bundle.entities || typeof bundle.entities !== "object") {
|
|
5203
|
+
throw new Error("Invalid bundle: missing entities");
|
|
5204
|
+
}
|
|
5205
|
+
if (!Array.isArray(bundle.dependencyOrder)) {
|
|
5206
|
+
throw new Error("Invalid bundle: missing dependencyOrder");
|
|
5207
|
+
}
|
|
5208
|
+
}
|
|
5209
|
+
sanitizeEntityData(data) {
|
|
5210
|
+
const sanitized = { ...data };
|
|
5211
|
+
delete sanitized.tenantId;
|
|
5212
|
+
delete sanitized.createdAt;
|
|
5213
|
+
delete sanitized.updatedAt;
|
|
5214
|
+
return sanitized;
|
|
5215
|
+
}
|
|
5216
|
+
};
|
|
5217
|
+
|
|
5218
|
+
// src/controllers/export-import.ts
|
|
5219
|
+
var import_core19 = require("@axiom-lattice/core");
|
|
5220
|
+
var service = new ExportImportService();
|
|
5221
|
+
function getTenantId10(request) {
|
|
5222
|
+
return request.user?.tenantId || request.headers["x-tenant-id"] || "default";
|
|
5223
|
+
}
|
|
5224
|
+
async function getExportableTypes(_request, reply) {
|
|
5225
|
+
const types = service.listExportableTypes();
|
|
5226
|
+
return reply.send({ success: true, data: types });
|
|
5227
|
+
}
|
|
5228
|
+
async function exportConfig(request, reply) {
|
|
5229
|
+
const tenantId = getTenantId10(request) || request.params.tenantId;
|
|
5230
|
+
const { entityTypes, entityIds } = request.body;
|
|
5231
|
+
if (!Array.isArray(entityTypes) || entityTypes.length === 0) {
|
|
5232
|
+
return reply.status(400).send({ success: false, message: "entityTypes must be a non-empty array" });
|
|
5233
|
+
}
|
|
5234
|
+
const preview = await service.exportPreview(tenantId, entityTypes);
|
|
5235
|
+
if (preview.missingDependencies.length > 0 || preview.cascadeAdditions.length > 0) {
|
|
5236
|
+
return reply.send({
|
|
5237
|
+
success: true,
|
|
5238
|
+
data: {
|
|
5239
|
+
needsConfirmation: true,
|
|
5240
|
+
missingDependencies: preview.missingDependencies,
|
|
5241
|
+
cascadeAdditions: preview.cascadeAdditions
|
|
5242
|
+
}
|
|
5243
|
+
});
|
|
5244
|
+
}
|
|
5245
|
+
const { jobId, bundle } = await service.export(tenantId, entityTypes, entityIds);
|
|
5246
|
+
return reply.send({
|
|
5247
|
+
success: true,
|
|
5248
|
+
data: {
|
|
5249
|
+
jobId,
|
|
5250
|
+
summary: Object.fromEntries(
|
|
5251
|
+
Object.entries(bundle.entities).map(([type, entities]) => [type, entities.length])
|
|
5252
|
+
)
|
|
5253
|
+
}
|
|
5254
|
+
});
|
|
5255
|
+
}
|
|
5256
|
+
async function exportConfigConfirm(request, reply) {
|
|
5257
|
+
const tenantId = getTenantId10(request) || request.params.tenantId;
|
|
5258
|
+
const { entityTypes, entityIds } = request.body;
|
|
5259
|
+
const { jobId, bundle } = await service.export(tenantId, entityTypes, entityIds);
|
|
5260
|
+
return reply.send({
|
|
5261
|
+
success: true,
|
|
5262
|
+
data: {
|
|
5263
|
+
jobId,
|
|
5264
|
+
summary: Object.fromEntries(
|
|
5265
|
+
Object.entries(bundle.entities).map(([type, entities]) => [type, entities.length])
|
|
5266
|
+
)
|
|
5267
|
+
}
|
|
5268
|
+
});
|
|
5269
|
+
}
|
|
5270
|
+
async function previewEntities(request, reply) {
|
|
5271
|
+
const tenantId = getTenantId10(request) || request.params.tenantId;
|
|
5272
|
+
const { entityTypes } = request.body;
|
|
5273
|
+
try {
|
|
5274
|
+
const registry = import_core19.ExportableEntityRegistry.getInstance();
|
|
5275
|
+
const result = {};
|
|
5276
|
+
for (const type of entityTypes) {
|
|
5277
|
+
const def = registry.get(type);
|
|
5278
|
+
const entities = await def.listForExport(tenantId);
|
|
5279
|
+
result[type] = entities.map((e) => ({
|
|
5280
|
+
id: e.data.id,
|
|
5281
|
+
name: e.data.name || e.data.id,
|
|
5282
|
+
description: e.data.description
|
|
5283
|
+
}));
|
|
5284
|
+
}
|
|
5285
|
+
return reply.send({ success: true, data: result });
|
|
5286
|
+
} catch (err) {
|
|
5287
|
+
return reply.status(400).send({ success: false, message: err.message });
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
async function downloadExport(request, reply) {
|
|
5291
|
+
const tenantId = getTenantId10(request) || request.params.tenantId;
|
|
5292
|
+
const bundle = service.getExportJob(request.params.jobId, tenantId);
|
|
5293
|
+
if (!bundle) {
|
|
5294
|
+
return reply.status(404).send({ success: false, message: "Export job not found or expired" });
|
|
5295
|
+
}
|
|
5296
|
+
return reply.header("Content-Type", "application/json").header("Content-Disposition", `attachment; filename="tenant-export-${bundle.sourceTenantId}.json"`).send({ success: true, data: bundle });
|
|
5297
|
+
}
|
|
5298
|
+
async function importPreview(request, reply) {
|
|
5299
|
+
const tenantId = getTenantId10(request) || request.params.tenantId;
|
|
5300
|
+
const { bundle } = request.body;
|
|
5301
|
+
if (!bundle) {
|
|
5302
|
+
return reply.status(400).send({ success: false, message: "No bundle provided in request body" });
|
|
5303
|
+
}
|
|
5304
|
+
try {
|
|
5305
|
+
const preview = await service.previewImport(tenantId, bundle);
|
|
5306
|
+
return reply.send({ success: true, data: preview });
|
|
5307
|
+
} catch (err) {
|
|
5308
|
+
return reply.status(400).send({
|
|
5309
|
+
success: false,
|
|
5310
|
+
message: `Invalid export file: ${err.message}`
|
|
5311
|
+
});
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
5314
|
+
async function importApply(request, reply) {
|
|
5315
|
+
const tenantId = getTenantId10(request) || request.params.tenantId;
|
|
5316
|
+
try {
|
|
5317
|
+
const { bundle, resolutions } = request.body;
|
|
5318
|
+
const result = await service.applyImport(tenantId, bundle, resolutions);
|
|
5319
|
+
return reply.send({ success: true, data: result });
|
|
5320
|
+
} catch (err) {
|
|
5321
|
+
return reply.status(400).send({
|
|
5322
|
+
success: false,
|
|
5323
|
+
message: `Import failed: ${err.message}`
|
|
5324
|
+
});
|
|
5325
|
+
}
|
|
5326
|
+
}
|
|
5327
|
+
|
|
5328
|
+
// src/controllers/middleware-types.ts
|
|
5329
|
+
var import_core20 = require("@axiom-lattice/core");
|
|
4983
5330
|
function middlewareTypesRoutes(fastify2) {
|
|
4984
5331
|
fastify2.get("/api/middleware-types", async (_request, reply) => {
|
|
4985
|
-
const metas =
|
|
5332
|
+
const metas = import_core20.PluginRegistry.listMeta();
|
|
4986
5333
|
return reply.send(metas);
|
|
4987
5334
|
});
|
|
4988
5335
|
}
|
|
@@ -5328,7 +5675,7 @@ var getHealthSchema = {
|
|
|
5328
5675
|
};
|
|
5329
5676
|
|
|
5330
5677
|
// src/controllers/thread_status.ts
|
|
5331
|
-
var
|
|
5678
|
+
var import_core21 = require("@axiom-lattice/core");
|
|
5332
5679
|
async function removePendingMessageHandler(request, reply) {
|
|
5333
5680
|
try {
|
|
5334
5681
|
const { assistant_id, thread_id, message_id } = request.params;
|
|
@@ -5341,7 +5688,7 @@ async function removePendingMessageHandler(request, reply) {
|
|
|
5341
5688
|
if (!assistant_id) {
|
|
5342
5689
|
return reply.code(400).send({ error: "Missing assistant_id parameter" });
|
|
5343
5690
|
}
|
|
5344
|
-
const agent =
|
|
5691
|
+
const agent = import_core21.agentInstanceManager.getAgent({
|
|
5345
5692
|
assistant_id,
|
|
5346
5693
|
thread_id,
|
|
5347
5694
|
tenant_id,
|
|
@@ -5375,7 +5722,7 @@ async function removePendingMessageHandler(request, reply) {
|
|
|
5375
5722
|
}
|
|
5376
5723
|
|
|
5377
5724
|
// src/services/sandbox_service.ts
|
|
5378
|
-
var
|
|
5725
|
+
var import_core22 = require("@axiom-lattice/core");
|
|
5379
5726
|
var ERROR_HTML = `<!DOCTYPE html>
|
|
5380
5727
|
<html lang="zh-CN">
|
|
5381
5728
|
<head>
|
|
@@ -5487,7 +5834,7 @@ var ERROR_HTML = `<!DOCTYPE html>
|
|
|
5487
5834
|
</html>`;
|
|
5488
5835
|
var SandboxService = class {
|
|
5489
5836
|
getFilesystemVmIsolation(tenantId, assistantId) {
|
|
5490
|
-
const agentLattice =
|
|
5837
|
+
const agentLattice = import_core22.agentLatticeManager.getAgentLatticeWithTenant(tenantId, assistantId);
|
|
5491
5838
|
if (!agentLattice) {
|
|
5492
5839
|
return null;
|
|
5493
5840
|
}
|
|
@@ -5501,9 +5848,9 @@ var SandboxService = class {
|
|
|
5501
5848
|
computeSandboxName(assistantId, threadId, vmIsolation, tenantId, workspaceId, projectId) {
|
|
5502
5849
|
switch (vmIsolation) {
|
|
5503
5850
|
case "agent":
|
|
5504
|
-
return (0,
|
|
5851
|
+
return (0, import_core22.normalizeSandboxName)(`${tenantId ?? "default"}-${assistantId}`);
|
|
5505
5852
|
case "project":
|
|
5506
|
-
return (0,
|
|
5853
|
+
return (0, import_core22.normalizeSandboxName)(
|
|
5507
5854
|
`${tenantId ?? "default"}-${workspaceId ?? "default"}-${projectId ?? "default"}`
|
|
5508
5855
|
);
|
|
5509
5856
|
case "global":
|
|
@@ -5559,7 +5906,7 @@ var SandboxService = class {
|
|
|
5559
5906
|
var sandboxService = new SandboxService();
|
|
5560
5907
|
|
|
5561
5908
|
// src/controllers/sandbox.ts
|
|
5562
|
-
var
|
|
5909
|
+
var import_core23 = require("@axiom-lattice/core");
|
|
5563
5910
|
init_mime();
|
|
5564
5911
|
function registerSandboxProxyRoutes(app2) {
|
|
5565
5912
|
app2.post(
|
|
@@ -5574,7 +5921,7 @@ function registerSandboxProxyRoutes(app2) {
|
|
|
5574
5921
|
}
|
|
5575
5922
|
const workspaceId = request.headers["x-workspace-id"];
|
|
5576
5923
|
const projectId = request.headers["x-project-id"];
|
|
5577
|
-
const sandboxManager = (0,
|
|
5924
|
+
const sandboxManager = (0, import_core23.getSandBoxManager)();
|
|
5578
5925
|
const sandbox = await sandboxManager.getSandboxFromConfig({
|
|
5579
5926
|
assistant_id: assistantId,
|
|
5580
5927
|
thread_id: threadId,
|
|
@@ -5622,7 +5969,7 @@ function registerSandboxProxyRoutes(app2) {
|
|
|
5622
5969
|
}
|
|
5623
5970
|
const workspaceId = request.headers["x-workspace-id"];
|
|
5624
5971
|
const projectId = request.headers["x-project-id"];
|
|
5625
|
-
const sandboxManager = (0,
|
|
5972
|
+
const sandboxManager = (0, import_core23.getSandBoxManager)();
|
|
5626
5973
|
const sandbox = await sandboxManager.getSandboxFromConfig({
|
|
5627
5974
|
assistant_id: assistantId,
|
|
5628
5975
|
thread_id: threadId,
|
|
@@ -5655,15 +6002,15 @@ function registerSandboxProxyRoutes(app2) {
|
|
|
5655
6002
|
// src/controllers/workspace.ts
|
|
5656
6003
|
var fs = __toESM(require("fs/promises"));
|
|
5657
6004
|
var path = __toESM(require("path"));
|
|
5658
|
-
var import_core22 = require("@axiom-lattice/core");
|
|
5659
|
-
var import_core23 = require("@axiom-lattice/core");
|
|
5660
6005
|
var import_core24 = require("@axiom-lattice/core");
|
|
6006
|
+
var import_core25 = require("@axiom-lattice/core");
|
|
6007
|
+
var import_core26 = require("@axiom-lattice/core");
|
|
5661
6008
|
var import_uuid3 = require("uuid");
|
|
5662
6009
|
init_mime();
|
|
5663
6010
|
var WorkspaceController = class {
|
|
5664
6011
|
constructor() {
|
|
5665
|
-
this.workspaceStore = (0,
|
|
5666
|
-
this.projectStore = (0,
|
|
6012
|
+
this.workspaceStore = (0, import_core24.getStoreLattice)("default", "workspace").store;
|
|
6013
|
+
this.projectStore = (0, import_core24.getStoreLattice)("default", "project").store;
|
|
5667
6014
|
}
|
|
5668
6015
|
getTenantId(request) {
|
|
5669
6016
|
const userTenantId = request.user?.tenantId;
|
|
@@ -5797,7 +6144,7 @@ var WorkspaceController = class {
|
|
|
5797
6144
|
}
|
|
5798
6145
|
console.log(`[getBackend] storageType=${workspace.storageType} filePath=${filePath}`);
|
|
5799
6146
|
if (workspace.storageType === "sandbox") {
|
|
5800
|
-
const sandboxManager = (0,
|
|
6147
|
+
const sandboxManager = (0, import_core26.getSandBoxManager)();
|
|
5801
6148
|
const volumeConfig = {
|
|
5802
6149
|
assistant_id: assistantId || "",
|
|
5803
6150
|
thread_id: "",
|
|
@@ -5815,7 +6162,7 @@ var WorkspaceController = class {
|
|
|
5815
6162
|
const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
|
|
5816
6163
|
console.log(`[getBackend] sandbox acquired, name=${sandbox.name || "unknown"}`);
|
|
5817
6164
|
return {
|
|
5818
|
-
backend: new
|
|
6165
|
+
backend: new import_core25.SandboxFilesystem({
|
|
5819
6166
|
sandboxInstance: sandbox
|
|
5820
6167
|
}),
|
|
5821
6168
|
workspace
|
|
@@ -5823,7 +6170,7 @@ var WorkspaceController = class {
|
|
|
5823
6170
|
} else {
|
|
5824
6171
|
console.log(`[getBackend] using FilesystemBackend rootDir=/lattice_store/tenants/${tenantId}/workspaces/${workspaceId}/${projectId}`);
|
|
5825
6172
|
return {
|
|
5826
|
-
backend: new
|
|
6173
|
+
backend: new import_core25.FilesystemBackend({
|
|
5827
6174
|
rootDir: `/lattice_store/tenants/${tenantId}/workspaces/${workspaceId}/${projectId}`,
|
|
5828
6175
|
virtualMode: true
|
|
5829
6176
|
}),
|
|
@@ -5875,7 +6222,7 @@ var WorkspaceController = class {
|
|
|
5875
6222
|
const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
5876
6223
|
const resolvedPath = filePath;
|
|
5877
6224
|
if (workspace.storageType === "sandbox") {
|
|
5878
|
-
const sandboxManager = (0,
|
|
6225
|
+
const sandboxManager = (0, import_core26.getSandBoxManager)();
|
|
5879
6226
|
const volumeConfig = {
|
|
5880
6227
|
assistant_id: assistantId || "",
|
|
5881
6228
|
thread_id: "",
|
|
@@ -5929,7 +6276,7 @@ var WorkspaceController = class {
|
|
|
5929
6276
|
const { workspace } = await this.getBackend(tenantId, workspaceId, projectId, assistantId);
|
|
5930
6277
|
const resolvedPath = filePath;
|
|
5931
6278
|
if (workspace.storageType === "sandbox") {
|
|
5932
|
-
const sandboxManager = (0,
|
|
6279
|
+
const sandboxManager = (0, import_core26.getSandBoxManager)();
|
|
5933
6280
|
const volumeConfig = {
|
|
5934
6281
|
assistant_id: assistantId || "",
|
|
5935
6282
|
thread_id: "",
|
|
@@ -6049,7 +6396,7 @@ var WorkspaceController = class {
|
|
|
6049
6396
|
async uploadFile(request, reply) {
|
|
6050
6397
|
const tenantId = this.getTenantId(request);
|
|
6051
6398
|
const { workspaceId, projectId } = request.params;
|
|
6052
|
-
const assistantId = request.query.assistantId;
|
|
6399
|
+
const assistantId = request.query.assistantId || request.headers["x-assistant-id"];
|
|
6053
6400
|
const workspace = await this.workspaceStore.getWorkspaceById(
|
|
6054
6401
|
tenantId,
|
|
6055
6402
|
workspaceId
|
|
@@ -6070,7 +6417,7 @@ var WorkspaceController = class {
|
|
|
6070
6417
|
return reply.status(400).send({ success: false, error: "Invalid path parameter" });
|
|
6071
6418
|
}
|
|
6072
6419
|
if (workspace.storageType === "sandbox") {
|
|
6073
|
-
const sandboxManager = (0,
|
|
6420
|
+
const sandboxManager = (0, import_core26.getSandBoxManager)();
|
|
6074
6421
|
const volumeConfig = {
|
|
6075
6422
|
assistant_id: assistantId || "",
|
|
6076
6423
|
thread_id: "",
|
|
@@ -6083,6 +6430,8 @@ var WorkspaceController = class {
|
|
|
6083
6430
|
const volumeBackend = await sandboxManager.getVolumeBackendForPath(volumeConfig, realPath);
|
|
6084
6431
|
if (volumeBackend && !isBinary) {
|
|
6085
6432
|
await volumeBackend.write(realPath, buffer.toString("utf-8"));
|
|
6433
|
+
} else if (volumeBackend && volumeBackend.writeBinary) {
|
|
6434
|
+
await volumeBackend.writeBinary(realPath, buffer);
|
|
6086
6435
|
} else {
|
|
6087
6436
|
const sandbox = await sandboxManager.getSandboxFromConfig(volumeConfig);
|
|
6088
6437
|
await sandbox.file.uploadFile({ file: realPath, data: buffer });
|
|
@@ -6178,9 +6527,9 @@ function registerWorkspaceRoutes(app2) {
|
|
|
6178
6527
|
}
|
|
6179
6528
|
|
|
6180
6529
|
// src/controllers/database-configs.ts
|
|
6181
|
-
var
|
|
6182
|
-
var
|
|
6183
|
-
function
|
|
6530
|
+
var import_core27 = require("@axiom-lattice/core");
|
|
6531
|
+
var import_crypto5 = require("crypto");
|
|
6532
|
+
function getTenantId11(request) {
|
|
6184
6533
|
const userTenantId = request.user?.tenantId;
|
|
6185
6534
|
if (userTenantId) {
|
|
6186
6535
|
return userTenantId;
|
|
@@ -6188,9 +6537,9 @@ function getTenantId10(request) {
|
|
|
6188
6537
|
return request.headers["x-tenant-id"] || "default";
|
|
6189
6538
|
}
|
|
6190
6539
|
async function getDatabaseConfigList(request, reply) {
|
|
6191
|
-
const tenantId =
|
|
6540
|
+
const tenantId = getTenantId11(request);
|
|
6192
6541
|
try {
|
|
6193
|
-
const storeLattice = (0,
|
|
6542
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6194
6543
|
const store2 = storeLattice.store;
|
|
6195
6544
|
const configs = await store2.getAllConfigs(tenantId);
|
|
6196
6545
|
console.log("Backend: getAllConfigs returned:", configs);
|
|
@@ -6218,10 +6567,10 @@ async function getDatabaseConfigList(request, reply) {
|
|
|
6218
6567
|
}
|
|
6219
6568
|
}
|
|
6220
6569
|
async function getDatabaseConfig(request, reply) {
|
|
6221
|
-
const tenantId =
|
|
6570
|
+
const tenantId = getTenantId11(request);
|
|
6222
6571
|
const { key } = request.params;
|
|
6223
6572
|
try {
|
|
6224
|
-
const storeLattice = (0,
|
|
6573
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6225
6574
|
const store2 = storeLattice.store;
|
|
6226
6575
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6227
6576
|
if (!config) {
|
|
@@ -6244,10 +6593,10 @@ async function getDatabaseConfig(request, reply) {
|
|
|
6244
6593
|
}
|
|
6245
6594
|
}
|
|
6246
6595
|
async function createDatabaseConfig(request, reply) {
|
|
6247
|
-
const tenantId =
|
|
6596
|
+
const tenantId = getTenantId11(request);
|
|
6248
6597
|
const body = request.body;
|
|
6249
6598
|
try {
|
|
6250
|
-
const storeLattice = (0,
|
|
6599
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6251
6600
|
const store2 = storeLattice.store;
|
|
6252
6601
|
const existing = await store2.getConfigByKey(tenantId, body.key);
|
|
6253
6602
|
if (existing) {
|
|
@@ -6257,10 +6606,10 @@ async function createDatabaseConfig(request, reply) {
|
|
|
6257
6606
|
message: "Database configuration with this key already exists"
|
|
6258
6607
|
};
|
|
6259
6608
|
}
|
|
6260
|
-
const id = body.id || (0,
|
|
6609
|
+
const id = body.id || (0, import_crypto5.randomUUID)();
|
|
6261
6610
|
const config = await store2.createConfig(tenantId, id, body);
|
|
6262
6611
|
try {
|
|
6263
|
-
|
|
6612
|
+
import_core27.sqlDatabaseManager.registerDatabase(tenantId, config.key, config.config);
|
|
6264
6613
|
} catch (error) {
|
|
6265
6614
|
console.warn("Failed to auto-register database:", error);
|
|
6266
6615
|
}
|
|
@@ -6279,11 +6628,11 @@ async function createDatabaseConfig(request, reply) {
|
|
|
6279
6628
|
}
|
|
6280
6629
|
}
|
|
6281
6630
|
async function updateDatabaseConfig(request, reply) {
|
|
6282
|
-
const tenantId =
|
|
6631
|
+
const tenantId = getTenantId11(request);
|
|
6283
6632
|
const { key } = request.params;
|
|
6284
6633
|
const updates = request.body;
|
|
6285
6634
|
try {
|
|
6286
|
-
const storeLattice = (0,
|
|
6635
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6287
6636
|
const store2 = storeLattice.store;
|
|
6288
6637
|
const existing = await store2.getConfigByKey(tenantId, key);
|
|
6289
6638
|
if (!existing) {
|
|
@@ -6302,7 +6651,7 @@ async function updateDatabaseConfig(request, reply) {
|
|
|
6302
6651
|
}
|
|
6303
6652
|
if (updates.config) {
|
|
6304
6653
|
try {
|
|
6305
|
-
|
|
6654
|
+
import_core27.sqlDatabaseManager.registerDatabase(tenantId, updated.key, updated.config);
|
|
6306
6655
|
} catch (error) {
|
|
6307
6656
|
console.warn("Failed to re-register database:", error);
|
|
6308
6657
|
}
|
|
@@ -6321,10 +6670,10 @@ async function updateDatabaseConfig(request, reply) {
|
|
|
6321
6670
|
}
|
|
6322
6671
|
}
|
|
6323
6672
|
async function deleteDatabaseConfig(request, reply) {
|
|
6324
|
-
const tenantId =
|
|
6673
|
+
const tenantId = getTenantId11(request);
|
|
6325
6674
|
const { keyOrId } = request.params;
|
|
6326
6675
|
try {
|
|
6327
|
-
const storeLattice = (0,
|
|
6676
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6328
6677
|
const store2 = storeLattice.store;
|
|
6329
6678
|
console.log("Delete request - keyOrId:", keyOrId);
|
|
6330
6679
|
let config = await store2.getConfigByKey(tenantId, keyOrId);
|
|
@@ -6351,8 +6700,8 @@ async function deleteDatabaseConfig(request, reply) {
|
|
|
6351
6700
|
};
|
|
6352
6701
|
}
|
|
6353
6702
|
try {
|
|
6354
|
-
if (
|
|
6355
|
-
await
|
|
6703
|
+
if (import_core27.sqlDatabaseManager.hasDatabase(tenantId, configKey)) {
|
|
6704
|
+
await import_core27.sqlDatabaseManager.removeDatabase(tenantId, configKey);
|
|
6356
6705
|
}
|
|
6357
6706
|
} catch (error) {
|
|
6358
6707
|
console.warn("Failed to remove from SqlDatabaseManager:", error);
|
|
@@ -6370,10 +6719,10 @@ async function deleteDatabaseConfig(request, reply) {
|
|
|
6370
6719
|
}
|
|
6371
6720
|
}
|
|
6372
6721
|
async function testDatabaseConnection(request, reply) {
|
|
6373
|
-
const tenantId =
|
|
6722
|
+
const tenantId = getTenantId11(request);
|
|
6374
6723
|
const { key } = request.params;
|
|
6375
6724
|
try {
|
|
6376
|
-
const storeLattice = (0,
|
|
6725
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6377
6726
|
const store2 = storeLattice.store;
|
|
6378
6727
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6379
6728
|
if (!config) {
|
|
@@ -6384,16 +6733,16 @@ async function testDatabaseConnection(request, reply) {
|
|
|
6384
6733
|
};
|
|
6385
6734
|
}
|
|
6386
6735
|
const testKey = `__test_${key}_${Date.now()}`;
|
|
6387
|
-
|
|
6736
|
+
import_core27.sqlDatabaseManager.registerDatabase(tenantId, testKey, config.config);
|
|
6388
6737
|
const startTime = Date.now();
|
|
6389
|
-
const db = await
|
|
6738
|
+
const db = await import_core27.sqlDatabaseManager.getDatabase(tenantId, testKey);
|
|
6390
6739
|
try {
|
|
6391
6740
|
await db.connect();
|
|
6392
6741
|
await db.listTables();
|
|
6393
6742
|
const latency = Date.now() - startTime;
|
|
6394
6743
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
6395
6744
|
await db.disconnect();
|
|
6396
|
-
await
|
|
6745
|
+
await import_core27.sqlDatabaseManager.removeDatabase(tenantId, testKey);
|
|
6397
6746
|
return {
|
|
6398
6747
|
success: true,
|
|
6399
6748
|
message: "Connection test successful",
|
|
@@ -6405,7 +6754,7 @@ async function testDatabaseConnection(request, reply) {
|
|
|
6405
6754
|
} catch (error) {
|
|
6406
6755
|
try {
|
|
6407
6756
|
await db.disconnect();
|
|
6408
|
-
await
|
|
6757
|
+
await import_core27.sqlDatabaseManager.removeDatabase(tenantId, testKey);
|
|
6409
6758
|
} catch {
|
|
6410
6759
|
}
|
|
6411
6760
|
return {
|
|
@@ -6457,9 +6806,9 @@ function registerDatabaseConfigRoutes(app2) {
|
|
|
6457
6806
|
}
|
|
6458
6807
|
|
|
6459
6808
|
// src/controllers/metrics-configs.ts
|
|
6460
|
-
var
|
|
6461
|
-
var
|
|
6462
|
-
function
|
|
6809
|
+
var import_core28 = require("@axiom-lattice/core");
|
|
6810
|
+
var import_crypto6 = require("crypto");
|
|
6811
|
+
function getTenantId12(request) {
|
|
6463
6812
|
const userTenantId = request.user?.tenantId;
|
|
6464
6813
|
if (userTenantId) {
|
|
6465
6814
|
return userTenantId;
|
|
@@ -6467,9 +6816,9 @@ function getTenantId11(request) {
|
|
|
6467
6816
|
return request.headers["x-tenant-id"] || "default";
|
|
6468
6817
|
}
|
|
6469
6818
|
async function getMetricsServerConfigList(request, reply) {
|
|
6470
|
-
const tenantId =
|
|
6819
|
+
const tenantId = getTenantId12(request);
|
|
6471
6820
|
try {
|
|
6472
|
-
const storeLattice = (0,
|
|
6821
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6473
6822
|
const store2 = storeLattice.store;
|
|
6474
6823
|
const configs = await store2.getAllConfigs(tenantId);
|
|
6475
6824
|
return {
|
|
@@ -6493,10 +6842,10 @@ async function getMetricsServerConfigList(request, reply) {
|
|
|
6493
6842
|
}
|
|
6494
6843
|
}
|
|
6495
6844
|
async function getMetricsServerConfig(request, reply) {
|
|
6496
|
-
const tenantId =
|
|
6845
|
+
const tenantId = getTenantId12(request);
|
|
6497
6846
|
const { key } = request.params;
|
|
6498
6847
|
try {
|
|
6499
|
-
const storeLattice = (0,
|
|
6848
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6500
6849
|
const store2 = storeLattice.store;
|
|
6501
6850
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6502
6851
|
if (!config) {
|
|
@@ -6519,10 +6868,10 @@ async function getMetricsServerConfig(request, reply) {
|
|
|
6519
6868
|
}
|
|
6520
6869
|
}
|
|
6521
6870
|
async function createMetricsServerConfig(request, reply) {
|
|
6522
|
-
const tenantId =
|
|
6871
|
+
const tenantId = getTenantId12(request);
|
|
6523
6872
|
const body = request.body;
|
|
6524
6873
|
try {
|
|
6525
|
-
const storeLattice = (0,
|
|
6874
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6526
6875
|
const store2 = storeLattice.store;
|
|
6527
6876
|
const existing = await store2.getConfigByKey(tenantId, body.key);
|
|
6528
6877
|
if (existing) {
|
|
@@ -6539,7 +6888,7 @@ async function createMetricsServerConfig(request, reply) {
|
|
|
6539
6888
|
message: "selectedDataSources is required for semantic metrics servers"
|
|
6540
6889
|
};
|
|
6541
6890
|
}
|
|
6542
|
-
const id = body.id || (0,
|
|
6891
|
+
const id = body.id || (0, import_crypto6.randomUUID)();
|
|
6543
6892
|
const configData = {
|
|
6544
6893
|
key: body.key,
|
|
6545
6894
|
name: body.name,
|
|
@@ -6551,7 +6900,7 @@ async function createMetricsServerConfig(request, reply) {
|
|
|
6551
6900
|
};
|
|
6552
6901
|
const config = await store2.createConfig(tenantId, id, configData);
|
|
6553
6902
|
try {
|
|
6554
|
-
|
|
6903
|
+
import_core28.metricsServerManager.registerServer(tenantId, config.key, config.config);
|
|
6555
6904
|
} catch (error) {
|
|
6556
6905
|
console.warn("Failed to auto-register metrics server:", error);
|
|
6557
6906
|
}
|
|
@@ -6570,11 +6919,11 @@ async function createMetricsServerConfig(request, reply) {
|
|
|
6570
6919
|
}
|
|
6571
6920
|
}
|
|
6572
6921
|
async function updateMetricsServerConfig(request, reply) {
|
|
6573
|
-
const tenantId =
|
|
6922
|
+
const tenantId = getTenantId12(request);
|
|
6574
6923
|
const { key } = request.params;
|
|
6575
6924
|
const updates = request.body;
|
|
6576
6925
|
try {
|
|
6577
|
-
const storeLattice = (0,
|
|
6926
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6578
6927
|
const store2 = storeLattice.store;
|
|
6579
6928
|
const existing = await store2.getConfigByKey(tenantId, key);
|
|
6580
6929
|
if (!existing) {
|
|
@@ -6602,7 +6951,7 @@ async function updateMetricsServerConfig(request, reply) {
|
|
|
6602
6951
|
}
|
|
6603
6952
|
if (updates.config) {
|
|
6604
6953
|
try {
|
|
6605
|
-
|
|
6954
|
+
import_core28.metricsServerManager.registerServer(tenantId, updated.key, updated.config);
|
|
6606
6955
|
} catch (error) {
|
|
6607
6956
|
console.warn("Failed to re-register metrics server:", error);
|
|
6608
6957
|
}
|
|
@@ -6621,10 +6970,10 @@ async function updateMetricsServerConfig(request, reply) {
|
|
|
6621
6970
|
}
|
|
6622
6971
|
}
|
|
6623
6972
|
async function deleteMetricsServerConfig(request, reply) {
|
|
6624
|
-
const tenantId =
|
|
6973
|
+
const tenantId = getTenantId12(request);
|
|
6625
6974
|
const { keyOrId } = request.params;
|
|
6626
6975
|
try {
|
|
6627
|
-
const storeLattice = (0,
|
|
6976
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6628
6977
|
const store2 = storeLattice.store;
|
|
6629
6978
|
let config = await store2.getConfigByKey(tenantId, keyOrId);
|
|
6630
6979
|
let configKey = keyOrId;
|
|
@@ -6649,8 +6998,8 @@ async function deleteMetricsServerConfig(request, reply) {
|
|
|
6649
6998
|
};
|
|
6650
6999
|
}
|
|
6651
7000
|
try {
|
|
6652
|
-
if (
|
|
6653
|
-
|
|
7001
|
+
if (import_core28.metricsServerManager.hasServer(tenantId, configKey)) {
|
|
7002
|
+
import_core28.metricsServerManager.removeServer(tenantId, configKey);
|
|
6654
7003
|
}
|
|
6655
7004
|
} catch (error) {
|
|
6656
7005
|
console.warn("Failed to remove from MetricsServerManager:", error);
|
|
@@ -6668,10 +7017,10 @@ async function deleteMetricsServerConfig(request, reply) {
|
|
|
6668
7017
|
}
|
|
6669
7018
|
}
|
|
6670
7019
|
async function testMetricsServerConnection(request, reply) {
|
|
6671
|
-
const tenantId =
|
|
7020
|
+
const tenantId = getTenantId12(request);
|
|
6672
7021
|
const { key } = request.params;
|
|
6673
7022
|
try {
|
|
6674
|
-
const storeLattice = (0,
|
|
7023
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6675
7024
|
const store2 = storeLattice.store;
|
|
6676
7025
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6677
7026
|
if (!config) {
|
|
@@ -6682,11 +7031,11 @@ async function testMetricsServerConnection(request, reply) {
|
|
|
6682
7031
|
};
|
|
6683
7032
|
}
|
|
6684
7033
|
const testKey = `__test_${key}_${Date.now()}`;
|
|
6685
|
-
|
|
7034
|
+
import_core28.metricsServerManager.registerServer(tenantId, testKey, config.config);
|
|
6686
7035
|
try {
|
|
6687
|
-
const client = await
|
|
7036
|
+
const client = await import_core28.metricsServerManager.getClient(tenantId, testKey);
|
|
6688
7037
|
const result = await client.testConnection();
|
|
6689
|
-
|
|
7038
|
+
import_core28.metricsServerManager.removeServer(tenantId, testKey);
|
|
6690
7039
|
return {
|
|
6691
7040
|
success: true,
|
|
6692
7041
|
message: result.connected ? "Connection test successful" : "Connection test failed",
|
|
@@ -6694,7 +7043,7 @@ async function testMetricsServerConnection(request, reply) {
|
|
|
6694
7043
|
};
|
|
6695
7044
|
} catch (error) {
|
|
6696
7045
|
try {
|
|
6697
|
-
|
|
7046
|
+
import_core28.metricsServerManager.removeServer(tenantId, testKey);
|
|
6698
7047
|
} catch {
|
|
6699
7048
|
}
|
|
6700
7049
|
return {
|
|
@@ -6719,10 +7068,10 @@ async function testMetricsServerConnection(request, reply) {
|
|
|
6719
7068
|
}
|
|
6720
7069
|
}
|
|
6721
7070
|
async function listAvailableMetrics(request, reply) {
|
|
6722
|
-
const tenantId =
|
|
7071
|
+
const tenantId = getTenantId12(request);
|
|
6723
7072
|
const { key } = request.params;
|
|
6724
7073
|
try {
|
|
6725
|
-
const storeLattice = (0,
|
|
7074
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6726
7075
|
const store2 = storeLattice.store;
|
|
6727
7076
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6728
7077
|
if (!config) {
|
|
@@ -6732,10 +7081,10 @@ async function listAvailableMetrics(request, reply) {
|
|
|
6732
7081
|
message: "Metrics server configuration not found"
|
|
6733
7082
|
};
|
|
6734
7083
|
}
|
|
6735
|
-
if (!
|
|
6736
|
-
|
|
7084
|
+
if (!import_core28.metricsServerManager.hasServer(tenantId, key)) {
|
|
7085
|
+
import_core28.metricsServerManager.registerServer(tenantId, key, config.config);
|
|
6737
7086
|
}
|
|
6738
|
-
const client = await
|
|
7087
|
+
const client = await import_core28.metricsServerManager.getClient(tenantId, key);
|
|
6739
7088
|
const metrics = await client.listMetrics();
|
|
6740
7089
|
return {
|
|
6741
7090
|
success: true,
|
|
@@ -6757,11 +7106,11 @@ async function listAvailableMetrics(request, reply) {
|
|
|
6757
7106
|
}
|
|
6758
7107
|
}
|
|
6759
7108
|
async function queryMetricsData(request, reply) {
|
|
6760
|
-
const tenantId =
|
|
7109
|
+
const tenantId = getTenantId12(request);
|
|
6761
7110
|
const { key } = request.params;
|
|
6762
7111
|
const { metricName, startTime, endTime, step, labels } = request.body;
|
|
6763
7112
|
try {
|
|
6764
|
-
const storeLattice = (0,
|
|
7113
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6765
7114
|
const store2 = storeLattice.store;
|
|
6766
7115
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6767
7116
|
if (!config) {
|
|
@@ -6778,10 +7127,10 @@ async function queryMetricsData(request, reply) {
|
|
|
6778
7127
|
message: "metricName is required"
|
|
6779
7128
|
};
|
|
6780
7129
|
}
|
|
6781
|
-
if (!
|
|
6782
|
-
|
|
7130
|
+
if (!import_core28.metricsServerManager.hasServer(tenantId, key)) {
|
|
7131
|
+
import_core28.metricsServerManager.registerServer(tenantId, key, config.config);
|
|
6783
7132
|
}
|
|
6784
|
-
const client = await
|
|
7133
|
+
const client = await import_core28.metricsServerManager.getClient(tenantId, key);
|
|
6785
7134
|
const result = await client.queryMetricData(metricName, {
|
|
6786
7135
|
startTime,
|
|
6787
7136
|
endTime,
|
|
@@ -6805,10 +7154,10 @@ async function queryMetricsData(request, reply) {
|
|
|
6805
7154
|
}
|
|
6806
7155
|
}
|
|
6807
7156
|
async function getDataSources(request, reply) {
|
|
6808
|
-
const tenantId =
|
|
7157
|
+
const tenantId = getTenantId12(request);
|
|
6809
7158
|
const { key } = request.params;
|
|
6810
7159
|
try {
|
|
6811
|
-
const storeLattice = (0,
|
|
7160
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6812
7161
|
const store2 = storeLattice.store;
|
|
6813
7162
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6814
7163
|
if (!config) {
|
|
@@ -6826,7 +7175,7 @@ async function getDataSources(request, reply) {
|
|
|
6826
7175
|
};
|
|
6827
7176
|
}
|
|
6828
7177
|
const semanticConfig = config.config;
|
|
6829
|
-
const client = new
|
|
7178
|
+
const client = new import_core28.SemanticMetricsClient(semanticConfig);
|
|
6830
7179
|
const allDatasources = await client.getDataSources();
|
|
6831
7180
|
const selectedIds = semanticConfig.selectedDataSources || [];
|
|
6832
7181
|
const filteredDatasources = selectedIds.length > 0 ? allDatasources.filter((ds) => selectedIds.includes(String(ds.id))) : allDatasources;
|
|
@@ -6846,10 +7195,10 @@ async function getDataSources(request, reply) {
|
|
|
6846
7195
|
}
|
|
6847
7196
|
}
|
|
6848
7197
|
async function getDatasourceMetrics(request, reply) {
|
|
6849
|
-
const tenantId =
|
|
7198
|
+
const tenantId = getTenantId12(request);
|
|
6850
7199
|
const { key, datasourceId } = request.params;
|
|
6851
7200
|
try {
|
|
6852
|
-
const storeLattice = (0,
|
|
7201
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6853
7202
|
const store2 = storeLattice.store;
|
|
6854
7203
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6855
7204
|
if (!config) {
|
|
@@ -6867,7 +7216,7 @@ async function getDatasourceMetrics(request, reply) {
|
|
|
6867
7216
|
};
|
|
6868
7217
|
}
|
|
6869
7218
|
const semanticConfig = config.config;
|
|
6870
|
-
const client = new
|
|
7219
|
+
const client = new import_core28.SemanticMetricsClient(semanticConfig);
|
|
6871
7220
|
const metrics = await client.getDatasourceMetrics(datasourceId);
|
|
6872
7221
|
return {
|
|
6873
7222
|
success: true,
|
|
@@ -6883,11 +7232,11 @@ async function getDatasourceMetrics(request, reply) {
|
|
|
6883
7232
|
}
|
|
6884
7233
|
}
|
|
6885
7234
|
async function querySemanticMetrics(request, reply) {
|
|
6886
|
-
const tenantId =
|
|
7235
|
+
const tenantId = getTenantId12(request);
|
|
6887
7236
|
const { key } = request.params;
|
|
6888
7237
|
const body = request.body;
|
|
6889
7238
|
try {
|
|
6890
|
-
const storeLattice = (0,
|
|
7239
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6891
7240
|
const store2 = storeLattice.store;
|
|
6892
7241
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6893
7242
|
if (!config) {
|
|
@@ -6912,7 +7261,7 @@ async function querySemanticMetrics(request, reply) {
|
|
|
6912
7261
|
};
|
|
6913
7262
|
}
|
|
6914
7263
|
const semanticConfig = config.config;
|
|
6915
|
-
const client = new
|
|
7264
|
+
const client = new import_core28.SemanticMetricsClient(semanticConfig);
|
|
6916
7265
|
const result = await client.semanticQuery(body);
|
|
6917
7266
|
const columnNames = result.columns.map((col) => col.name);
|
|
6918
7267
|
const allDataPoints = [];
|
|
@@ -6972,7 +7321,7 @@ async function testSemanticDataSources(request, reply) {
|
|
|
6972
7321
|
password: body.password,
|
|
6973
7322
|
headers: body.headers
|
|
6974
7323
|
};
|
|
6975
|
-
const client = new
|
|
7324
|
+
const client = new import_core28.SemanticMetricsClient(testConfig);
|
|
6976
7325
|
const datasources = await client.getDataSources();
|
|
6977
7326
|
return {
|
|
6978
7327
|
success: true,
|
|
@@ -7008,7 +7357,7 @@ async function testDatasourceMetrics(request, reply) {
|
|
|
7008
7357
|
password: body.password,
|
|
7009
7358
|
headers: body.headers
|
|
7010
7359
|
};
|
|
7011
|
-
const client = new
|
|
7360
|
+
const client = new import_core28.SemanticMetricsClient(testConfig);
|
|
7012
7361
|
const metrics = await client.getDatasourceMetrics(datasourceId);
|
|
7013
7362
|
return {
|
|
7014
7363
|
success: true,
|
|
@@ -7040,7 +7389,7 @@ function registerMetricsServerConfigRoutes(app2) {
|
|
|
7040
7389
|
}
|
|
7041
7390
|
|
|
7042
7391
|
// src/controllers/connections.ts
|
|
7043
|
-
var
|
|
7392
|
+
var import_core29 = require("@axiom-lattice/core");
|
|
7044
7393
|
var import_zod = require("zod");
|
|
7045
7394
|
var createBody = import_zod.z.object({
|
|
7046
7395
|
type: import_zod.z.string().min(1),
|
|
@@ -7081,7 +7430,7 @@ function maskSecrets(config) {
|
|
|
7081
7430
|
}
|
|
7082
7431
|
async function resolveConfig(type, body, tenantId) {
|
|
7083
7432
|
if (body.key) {
|
|
7084
|
-
const entry = await
|
|
7433
|
+
const entry = await import_core29.ConnectionRegistry.get(type, body.key, tenantId);
|
|
7085
7434
|
if (!entry) throw { status: 404, error: `Connection "${body.key}" not found` };
|
|
7086
7435
|
return entry.config;
|
|
7087
7436
|
}
|
|
@@ -7092,7 +7441,7 @@ function connectionRoutes(fastify2) {
|
|
|
7092
7441
|
fastify2.get("/api/connections", async (request, reply) => {
|
|
7093
7442
|
const { type } = request.query;
|
|
7094
7443
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7095
|
-
const entries = await
|
|
7444
|
+
const entries = await import_core29.ConnectionRegistry.list(type, getTenant(request));
|
|
7096
7445
|
return reply.send({
|
|
7097
7446
|
success: true,
|
|
7098
7447
|
data: { records: entries.map((e) => ({ ...e, config: maskSecrets(e.config) })), total: entries.length }
|
|
@@ -7100,7 +7449,7 @@ function connectionRoutes(fastify2) {
|
|
|
7100
7449
|
});
|
|
7101
7450
|
fastify2.post("/api/connections", async (request, reply) => {
|
|
7102
7451
|
const parsed = createBody.parse(request.body);
|
|
7103
|
-
const entry = await
|
|
7452
|
+
const entry = await import_core29.ConnectionRegistry.create({
|
|
7104
7453
|
tenantId: getTenant(request),
|
|
7105
7454
|
type: parsed.type,
|
|
7106
7455
|
key: parsed.key,
|
|
@@ -7119,7 +7468,7 @@ function connectionRoutes(fastify2) {
|
|
|
7119
7468
|
const { key } = request.params;
|
|
7120
7469
|
const body = request.body;
|
|
7121
7470
|
const tenantId = getTenant(request);
|
|
7122
|
-
const existing = await
|
|
7471
|
+
const existing = await import_core29.ConnectionRegistry.get(type, key, tenantId);
|
|
7123
7472
|
if (!existing) return reply.status(404).send({ error: "not found" });
|
|
7124
7473
|
const updates = {};
|
|
7125
7474
|
if (body.name !== void 0) updates.name = body.name;
|
|
@@ -7127,7 +7476,7 @@ function connectionRoutes(fastify2) {
|
|
|
7127
7476
|
if (body.config) {
|
|
7128
7477
|
updates.config = { ...existing.config, ...body.config };
|
|
7129
7478
|
}
|
|
7130
|
-
const entry = await
|
|
7479
|
+
const entry = await import_core29.ConnectionRegistry.update(tenantId, type, key, updates);
|
|
7131
7480
|
return reply.send({
|
|
7132
7481
|
success: true,
|
|
7133
7482
|
data: { ...entry, config: maskSecrets(entry?.config ?? {}) }
|
|
@@ -7137,13 +7486,13 @@ function connectionRoutes(fastify2) {
|
|
|
7137
7486
|
const { type } = request.query;
|
|
7138
7487
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7139
7488
|
const { key } = request.params;
|
|
7140
|
-
const ok = await
|
|
7489
|
+
const ok = await import_core29.ConnectionRegistry.delete(getTenant(request), type, key);
|
|
7141
7490
|
return reply.send({ success: ok });
|
|
7142
7491
|
});
|
|
7143
7492
|
fastify2.post("/api/connections/test", async (request, reply) => {
|
|
7144
7493
|
const { type } = request.query;
|
|
7145
7494
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7146
|
-
const plugin =
|
|
7495
|
+
const plugin = import_core29.PluginRegistry.get(type);
|
|
7147
7496
|
if (!plugin?.connection?.test) {
|
|
7148
7497
|
return reply.status(400).send({ error: "plugin does not support connection testing" });
|
|
7149
7498
|
}
|
|
@@ -7171,7 +7520,7 @@ function connectionRoutes(fastify2) {
|
|
|
7171
7520
|
fastify2.post("/api/connections/discover", async (request, reply) => {
|
|
7172
7521
|
const { type } = request.query;
|
|
7173
7522
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7174
|
-
const plugin =
|
|
7523
|
+
const plugin = import_core29.PluginRegistry.get(type);
|
|
7175
7524
|
if (!plugin?.connection?.discover) {
|
|
7176
7525
|
return reply.status(400).send({ error: "plugin does not support resource discovery" });
|
|
7177
7526
|
}
|
|
@@ -7201,12 +7550,12 @@ function connectionRoutes(fastify2) {
|
|
|
7201
7550
|
init_mcp_configs();
|
|
7202
7551
|
|
|
7203
7552
|
// src/controllers/eval.ts
|
|
7204
|
-
var
|
|
7553
|
+
var import_core32 = require("@axiom-lattice/core");
|
|
7205
7554
|
var import_uuid5 = require("uuid");
|
|
7206
7555
|
|
|
7207
7556
|
// src/services/eval-runner.ts
|
|
7208
7557
|
var import_events = require("events");
|
|
7209
|
-
var
|
|
7558
|
+
var import_core31 = require("@axiom-lattice/core");
|
|
7210
7559
|
var import_uuid4 = require("uuid");
|
|
7211
7560
|
function mapLogs(logs) {
|
|
7212
7561
|
return logs.map((l) => ({
|
|
@@ -7265,12 +7614,12 @@ var EvalRunner = class {
|
|
|
7265
7614
|
const judgeModelKey = judgeCfg.modelKey || "";
|
|
7266
7615
|
let resolvedJudgeModelKey;
|
|
7267
7616
|
if (judgeModelKey) {
|
|
7268
|
-
if (!
|
|
7617
|
+
if (!import_core31.modelLatticeManager.hasLattice(judgeModelKey)) {
|
|
7269
7618
|
throw new Error(`Judge model "${judgeModelKey}" is not registered`);
|
|
7270
7619
|
}
|
|
7271
7620
|
resolvedJudgeModelKey = judgeModelKey;
|
|
7272
7621
|
} else {
|
|
7273
|
-
const firstModel =
|
|
7622
|
+
const firstModel = import_core31.modelLatticeManager.getAllLattices()[0];
|
|
7274
7623
|
if (!firstModel) {
|
|
7275
7624
|
throw new Error("No model registered \u2014 cannot run eval without a judge model");
|
|
7276
7625
|
}
|
|
@@ -7330,7 +7679,7 @@ var EvalRunner = class {
|
|
|
7330
7679
|
};
|
|
7331
7680
|
const runPromise = (async () => {
|
|
7332
7681
|
try {
|
|
7333
|
-
const evalProject = new
|
|
7682
|
+
const evalProject = new import_core31.LatticeEvalProject(projectConfig, onCaseComplete);
|
|
7334
7683
|
const { report } = await evalProject.runAllSuitesBatch(concurrency, abortController.signal);
|
|
7335
7684
|
if (!abortController.signal.aborted) {
|
|
7336
7685
|
const completedCount = stats.passed + stats.failed;
|
|
@@ -7384,13 +7733,13 @@ var EvalRunner = class {
|
|
|
7384
7733
|
return this.runs.has(runId);
|
|
7385
7734
|
}
|
|
7386
7735
|
getEvalStore() {
|
|
7387
|
-
return (0,
|
|
7736
|
+
return (0, import_core31.getStoreLattice)("default", "eval").store;
|
|
7388
7737
|
}
|
|
7389
7738
|
};
|
|
7390
7739
|
var evalRunner = new EvalRunner();
|
|
7391
7740
|
|
|
7392
7741
|
// src/controllers/eval.ts
|
|
7393
|
-
function
|
|
7742
|
+
function getTenantId14(request) {
|
|
7394
7743
|
const userTenantId = request.user?.tenantId;
|
|
7395
7744
|
if (userTenantId) {
|
|
7396
7745
|
return userTenantId;
|
|
@@ -7398,11 +7747,11 @@ function getTenantId13(request) {
|
|
|
7398
7747
|
return request.headers["x-tenant-id"] || "default";
|
|
7399
7748
|
}
|
|
7400
7749
|
function getEvalStore() {
|
|
7401
|
-
return (0,
|
|
7750
|
+
return (0, import_core32.getStoreLattice)("default", "eval").store;
|
|
7402
7751
|
}
|
|
7403
7752
|
async function createProject(request, reply) {
|
|
7404
7753
|
try {
|
|
7405
|
-
const tenantId =
|
|
7754
|
+
const tenantId = getTenantId14(request);
|
|
7406
7755
|
const store2 = getEvalStore();
|
|
7407
7756
|
const id = (0, import_uuid5.v4)();
|
|
7408
7757
|
const data = request.body;
|
|
@@ -7442,7 +7791,7 @@ async function createProject(request, reply) {
|
|
|
7442
7791
|
}
|
|
7443
7792
|
async function listProjects(request, reply) {
|
|
7444
7793
|
try {
|
|
7445
|
-
const tenantId =
|
|
7794
|
+
const tenantId = getTenantId14(request);
|
|
7446
7795
|
const store2 = getEvalStore();
|
|
7447
7796
|
let projects = await store2.getProjectsByTenant(tenantId);
|
|
7448
7797
|
if (projects.length === 0) {
|
|
@@ -7476,7 +7825,7 @@ async function listProjects(request, reply) {
|
|
|
7476
7825
|
}
|
|
7477
7826
|
async function getProject(request, reply) {
|
|
7478
7827
|
try {
|
|
7479
|
-
const tenantId =
|
|
7828
|
+
const tenantId = getTenantId14(request);
|
|
7480
7829
|
const store2 = getEvalStore();
|
|
7481
7830
|
const { pid } = request.params;
|
|
7482
7831
|
const project = await store2.getProjectById(tenantId, pid);
|
|
@@ -7496,7 +7845,7 @@ async function getProject(request, reply) {
|
|
|
7496
7845
|
}
|
|
7497
7846
|
async function updateProject(request, reply) {
|
|
7498
7847
|
try {
|
|
7499
|
-
const tenantId =
|
|
7848
|
+
const tenantId = getTenantId14(request);
|
|
7500
7849
|
const store2 = getEvalStore();
|
|
7501
7850
|
const { pid } = request.params;
|
|
7502
7851
|
const existing = await store2.getProjectById(tenantId, pid);
|
|
@@ -7539,7 +7888,7 @@ async function updateProject(request, reply) {
|
|
|
7539
7888
|
}
|
|
7540
7889
|
async function deleteProject(request, reply) {
|
|
7541
7890
|
try {
|
|
7542
|
-
const tenantId =
|
|
7891
|
+
const tenantId = getTenantId14(request);
|
|
7543
7892
|
const store2 = getEvalStore();
|
|
7544
7893
|
const { pid } = request.params;
|
|
7545
7894
|
const existing = await store2.getProjectById(tenantId, pid);
|
|
@@ -7558,7 +7907,7 @@ async function deleteProject(request, reply) {
|
|
|
7558
7907
|
}
|
|
7559
7908
|
async function createSuite(request, reply) {
|
|
7560
7909
|
try {
|
|
7561
|
-
const tenantId =
|
|
7910
|
+
const tenantId = getTenantId14(request);
|
|
7562
7911
|
const store2 = getEvalStore();
|
|
7563
7912
|
const { pid } = request.params;
|
|
7564
7913
|
const project = await store2.getProjectById(tenantId, pid);
|
|
@@ -7580,7 +7929,7 @@ async function createSuite(request, reply) {
|
|
|
7580
7929
|
}
|
|
7581
7930
|
async function updateSuite(request, reply) {
|
|
7582
7931
|
try {
|
|
7583
|
-
const tenantId =
|
|
7932
|
+
const tenantId = getTenantId14(request);
|
|
7584
7933
|
const store2 = getEvalStore();
|
|
7585
7934
|
const { sid } = request.params;
|
|
7586
7935
|
const existing = await store2.getSuiteById(tenantId, sid);
|
|
@@ -7600,7 +7949,7 @@ async function updateSuite(request, reply) {
|
|
|
7600
7949
|
}
|
|
7601
7950
|
async function deleteSuite(request, reply) {
|
|
7602
7951
|
try {
|
|
7603
|
-
const tenantId =
|
|
7952
|
+
const tenantId = getTenantId14(request);
|
|
7604
7953
|
const store2 = getEvalStore();
|
|
7605
7954
|
const { sid } = request.params;
|
|
7606
7955
|
const existing = await store2.getSuiteById(tenantId, sid);
|
|
@@ -7619,7 +7968,7 @@ async function deleteSuite(request, reply) {
|
|
|
7619
7968
|
}
|
|
7620
7969
|
async function createCase(request, reply) {
|
|
7621
7970
|
try {
|
|
7622
|
-
const tenantId =
|
|
7971
|
+
const tenantId = getTenantId14(request);
|
|
7623
7972
|
const store2 = getEvalStore();
|
|
7624
7973
|
const { sid } = request.params;
|
|
7625
7974
|
const suite = await store2.getSuiteById(tenantId, sid);
|
|
@@ -7648,7 +7997,7 @@ async function createCase(request, reply) {
|
|
|
7648
7997
|
}
|
|
7649
7998
|
async function listCasesForSuite(request, reply) {
|
|
7650
7999
|
try {
|
|
7651
|
-
const tenantId =
|
|
8000
|
+
const tenantId = getTenantId14(request);
|
|
7652
8001
|
const store2 = getEvalStore();
|
|
7653
8002
|
const { sid } = request.params;
|
|
7654
8003
|
const cases = await store2.getCasesBySuite(tenantId, sid);
|
|
@@ -7664,7 +8013,7 @@ async function listCasesForSuite(request, reply) {
|
|
|
7664
8013
|
}
|
|
7665
8014
|
async function updateCase(request, reply) {
|
|
7666
8015
|
try {
|
|
7667
|
-
const tenantId =
|
|
8016
|
+
const tenantId = getTenantId14(request);
|
|
7668
8017
|
const store2 = getEvalStore();
|
|
7669
8018
|
const { cid } = request.params;
|
|
7670
8019
|
const existing = await store2.getCaseById(tenantId, cid);
|
|
@@ -7684,7 +8033,7 @@ async function updateCase(request, reply) {
|
|
|
7684
8033
|
}
|
|
7685
8034
|
async function deleteCase(request, reply) {
|
|
7686
8035
|
try {
|
|
7687
|
-
const tenantId =
|
|
8036
|
+
const tenantId = getTenantId14(request);
|
|
7688
8037
|
const store2 = getEvalStore();
|
|
7689
8038
|
const { cid } = request.params;
|
|
7690
8039
|
const existing = await store2.getCaseById(tenantId, cid);
|
|
@@ -7716,7 +8065,7 @@ function registerEvalRoutes(app2) {
|
|
|
7716
8065
|
app2.delete("/api/eval/projects/:pid/suites/:sid/cases/:cid", deleteCase);
|
|
7717
8066
|
app2.post("/api/eval/projects/:pid/runs", async (request, reply) => {
|
|
7718
8067
|
try {
|
|
7719
|
-
const tenantId =
|
|
8068
|
+
const tenantId = getTenantId14(request);
|
|
7720
8069
|
const { pid } = request.params;
|
|
7721
8070
|
const runId = await evalRunner.startRun(tenantId, pid);
|
|
7722
8071
|
reply.status(202).send({ success: true, message: "Run started", data: { run_id: runId } });
|
|
@@ -7728,7 +8077,7 @@ function registerEvalRoutes(app2) {
|
|
|
7728
8077
|
});
|
|
7729
8078
|
app2.get("/api/eval/runs", async (request, reply) => {
|
|
7730
8079
|
try {
|
|
7731
|
-
const tenantId =
|
|
8080
|
+
const tenantId = getTenantId14(request);
|
|
7732
8081
|
const query = request.query;
|
|
7733
8082
|
const runs = await getEvalStore().getRunsByTenant(tenantId, { projectId: query.project_id, status: query.status });
|
|
7734
8083
|
reply.send({ success: true, message: "Ok", data: { records: runs, total: runs.length } });
|
|
@@ -7738,7 +8087,7 @@ function registerEvalRoutes(app2) {
|
|
|
7738
8087
|
});
|
|
7739
8088
|
app2.get("/api/eval/runs/:rid", async (request, reply) => {
|
|
7740
8089
|
try {
|
|
7741
|
-
const tenantId =
|
|
8090
|
+
const tenantId = getTenantId14(request);
|
|
7742
8091
|
const { rid } = request.params;
|
|
7743
8092
|
const run = await getEvalStore().getRunById(tenantId, rid);
|
|
7744
8093
|
if (!run) return reply.status(404).send({ success: false, message: "Run not found" });
|
|
@@ -7760,7 +8109,7 @@ function registerEvalRoutes(app2) {
|
|
|
7760
8109
|
const emitter = evalRunner.getEventEmitter();
|
|
7761
8110
|
const eventKey = `run:${rid}`;
|
|
7762
8111
|
if (!evalRunner.isRunning(rid)) {
|
|
7763
|
-
const tenantId =
|
|
8112
|
+
const tenantId = getTenantId14(request);
|
|
7764
8113
|
const run = await getEvalStore().getRunById(tenantId, rid);
|
|
7765
8114
|
if (run) {
|
|
7766
8115
|
const eventType = run.status === "completed" ? "completed" : "error";
|
|
@@ -7799,7 +8148,7 @@ data: ${JSON.stringify(event.data)}
|
|
|
7799
8148
|
});
|
|
7800
8149
|
app2.delete("/api/eval/runs/:rid", async (request, reply) => {
|
|
7801
8150
|
try {
|
|
7802
|
-
const tenantId =
|
|
8151
|
+
const tenantId = getTenantId14(request);
|
|
7803
8152
|
const { rid } = request.params;
|
|
7804
8153
|
const deleted = await getEvalStore().deleteRun(tenantId, rid);
|
|
7805
8154
|
if (!deleted) return reply.status(404).send({ success: false, message: "Run not found" });
|
|
@@ -7810,7 +8159,7 @@ data: ${JSON.stringify(event.data)}
|
|
|
7810
8159
|
});
|
|
7811
8160
|
app2.get("/api/eval/reports/projects/:pid", async (request, reply) => {
|
|
7812
8161
|
try {
|
|
7813
|
-
const tenantId =
|
|
8162
|
+
const tenantId = getTenantId14(request);
|
|
7814
8163
|
const { pid } = request.params;
|
|
7815
8164
|
const report = await getEvalStore().getProjectReport(tenantId, pid);
|
|
7816
8165
|
if (!report) return reply.status(404).send({ success: false, message: "Project not found" });
|
|
@@ -7822,11 +8171,11 @@ data: ${JSON.stringify(event.data)}
|
|
|
7822
8171
|
}
|
|
7823
8172
|
|
|
7824
8173
|
// src/controllers/users.ts
|
|
7825
|
-
var
|
|
8174
|
+
var import_core33 = require("@axiom-lattice/core");
|
|
7826
8175
|
var import_uuid6 = require("uuid");
|
|
7827
8176
|
var UsersController = class {
|
|
7828
8177
|
constructor() {
|
|
7829
|
-
this.userStore = (0,
|
|
8178
|
+
this.userStore = (0, import_core33.getStoreLattice)("default", "user").store;
|
|
7830
8179
|
}
|
|
7831
8180
|
async listUsers(request, reply) {
|
|
7832
8181
|
const { email } = request.query;
|
|
@@ -7904,11 +8253,11 @@ function registerUserRoutes(app2) {
|
|
|
7904
8253
|
}
|
|
7905
8254
|
|
|
7906
8255
|
// src/controllers/tenants.ts
|
|
7907
|
-
var
|
|
8256
|
+
var import_core34 = require("@axiom-lattice/core");
|
|
7908
8257
|
var import_uuid7 = require("uuid");
|
|
7909
8258
|
var TenantsController = class {
|
|
7910
8259
|
constructor() {
|
|
7911
|
-
this.tenantStore = (0,
|
|
8260
|
+
this.tenantStore = (0, import_core34.getStoreLattice)("default", "tenant").store;
|
|
7912
8261
|
}
|
|
7913
8262
|
// ==================== Tenant CRUD ====================
|
|
7914
8263
|
async listTenants(request, reply) {
|
|
@@ -7972,7 +8321,7 @@ function registerTenantRoutes(app2) {
|
|
|
7972
8321
|
}
|
|
7973
8322
|
|
|
7974
8323
|
// src/controllers/auth.ts
|
|
7975
|
-
var
|
|
8324
|
+
var import_core35 = require("@axiom-lattice/core");
|
|
7976
8325
|
var import_uuid8 = require("uuid");
|
|
7977
8326
|
var defaultAuthConfig = {
|
|
7978
8327
|
autoApproveUsers: true,
|
|
@@ -7981,9 +8330,9 @@ var defaultAuthConfig = {
|
|
|
7981
8330
|
};
|
|
7982
8331
|
var AuthController = class {
|
|
7983
8332
|
constructor(config = {}) {
|
|
7984
|
-
this.userStore = (0,
|
|
7985
|
-
this.tenantStore = (0,
|
|
7986
|
-
this.userTenantLinkStore = (0,
|
|
8333
|
+
this.userStore = (0, import_core35.getStoreLattice)("default", "user").store;
|
|
8334
|
+
this.tenantStore = (0, import_core35.getStoreLattice)("default", "tenant").store;
|
|
8335
|
+
this.userTenantLinkStore = (0, import_core35.getStoreLattice)("default", "userTenantLink").store;
|
|
7987
8336
|
this.config = { ...defaultAuthConfig, ...config };
|
|
7988
8337
|
}
|
|
7989
8338
|
async register(request, reply) {
|
|
@@ -8141,7 +8490,7 @@ var AuthController = class {
|
|
|
8141
8490
|
const linkMeta = link?.metadata || {};
|
|
8142
8491
|
let personalAssistant = null;
|
|
8143
8492
|
if (linkMeta.personalAssistantId) {
|
|
8144
|
-
const assistantStore = (0,
|
|
8493
|
+
const assistantStore = (0, import_core35.getStoreLattice)("default", "assistant").store;
|
|
8145
8494
|
const exists = await assistantStore.hasAssistant(tenantId, linkMeta.personalAssistantId);
|
|
8146
8495
|
if (exists) {
|
|
8147
8496
|
personalAssistant = {
|
|
@@ -8561,7 +8910,7 @@ var larkChannelAdapter = {
|
|
|
8561
8910
|
};
|
|
8562
8911
|
|
|
8563
8912
|
// src/channels/lark/verification.ts
|
|
8564
|
-
var
|
|
8913
|
+
var import_crypto8 = __toESM(require("crypto"));
|
|
8565
8914
|
function parseLarkRequestBody(body, encryptKey) {
|
|
8566
8915
|
const parsed = body || {};
|
|
8567
8916
|
if (encryptKey && typeof parsed.encrypt === "string") {
|
|
@@ -8570,11 +8919,11 @@ function parseLarkRequestBody(body, encryptKey) {
|
|
|
8570
8919
|
return parsed;
|
|
8571
8920
|
}
|
|
8572
8921
|
function decryptLarkPayload(encryptKey, encryptedPayload) {
|
|
8573
|
-
const key =
|
|
8922
|
+
const key = import_crypto8.default.createHash("sha256").update(encryptKey).digest();
|
|
8574
8923
|
const buffer = Buffer.from(encryptedPayload, "base64");
|
|
8575
8924
|
const iv = buffer.subarray(0, 16);
|
|
8576
8925
|
const ciphertext = buffer.subarray(16);
|
|
8577
|
-
const decipher =
|
|
8926
|
+
const decipher = import_crypto8.default.createDecipheriv("aes-256-cbc", key, iv);
|
|
8578
8927
|
const plaintext = Buffer.concat([
|
|
8579
8928
|
decipher.update(ciphertext),
|
|
8580
8929
|
decipher.final()
|
|
@@ -8691,14 +9040,14 @@ function registerChannelRoutes(app2, dependencies) {
|
|
|
8691
9040
|
}
|
|
8692
9041
|
|
|
8693
9042
|
// src/controllers/channel-installations.ts
|
|
8694
|
-
var
|
|
9043
|
+
var import_crypto9 = require("crypto");
|
|
8695
9044
|
var _adapterRegistry;
|
|
8696
9045
|
var _router;
|
|
8697
9046
|
function setChannelControllerDeps(deps) {
|
|
8698
9047
|
_adapterRegistry = deps.adapterRegistry;
|
|
8699
9048
|
_router = deps.router;
|
|
8700
9049
|
}
|
|
8701
|
-
function
|
|
9050
|
+
function getTenantId15(request) {
|
|
8702
9051
|
const userTenantId = request.user?.tenantId;
|
|
8703
9052
|
if (userTenantId) {
|
|
8704
9053
|
return userTenantId;
|
|
@@ -8706,8 +9055,8 @@ function getTenantId14(request) {
|
|
|
8706
9055
|
return request.headers["x-tenant-id"] || "default";
|
|
8707
9056
|
}
|
|
8708
9057
|
async function getInstallationStore() {
|
|
8709
|
-
const { getStoreLattice:
|
|
8710
|
-
const store2 =
|
|
9058
|
+
const { getStoreLattice: getStoreLattice31 } = await import("@axiom-lattice/core");
|
|
9059
|
+
const store2 = getStoreLattice31("default", "channelInstallation").store;
|
|
8711
9060
|
if (store2) return store2;
|
|
8712
9061
|
const { PostgreSQLChannelInstallationStore } = await import("@axiom-lattice/pg-stores");
|
|
8713
9062
|
const databaseUrl = process.env.DATABASE_URL;
|
|
@@ -8719,7 +9068,7 @@ async function getInstallationStore() {
|
|
|
8719
9068
|
});
|
|
8720
9069
|
}
|
|
8721
9070
|
async function getChannelInstallationList(request, reply) {
|
|
8722
|
-
const tenantId =
|
|
9071
|
+
const tenantId = getTenantId15(request);
|
|
8723
9072
|
const { channel } = request.query;
|
|
8724
9073
|
try {
|
|
8725
9074
|
const store2 = await getInstallationStore();
|
|
@@ -8745,7 +9094,7 @@ async function getChannelInstallationList(request, reply) {
|
|
|
8745
9094
|
}
|
|
8746
9095
|
}
|
|
8747
9096
|
async function getChannelInstallation(request, reply) {
|
|
8748
|
-
const tenantId =
|
|
9097
|
+
const tenantId = getTenantId15(request);
|
|
8749
9098
|
const { installationId } = request.params;
|
|
8750
9099
|
try {
|
|
8751
9100
|
const store2 = await getInstallationStore();
|
|
@@ -8778,7 +9127,7 @@ async function getChannelInstallation(request, reply) {
|
|
|
8778
9127
|
}
|
|
8779
9128
|
}
|
|
8780
9129
|
async function createChannelInstallation(request, reply) {
|
|
8781
|
-
const tenantId =
|
|
9130
|
+
const tenantId = getTenantId15(request);
|
|
8782
9131
|
const body = request.body;
|
|
8783
9132
|
try {
|
|
8784
9133
|
if (!body.channel) {
|
|
@@ -8813,7 +9162,7 @@ async function createChannelInstallation(request, reply) {
|
|
|
8813
9162
|
}
|
|
8814
9163
|
}
|
|
8815
9164
|
const store2 = await getInstallationStore();
|
|
8816
|
-
const installationId = body.id || (0,
|
|
9165
|
+
const installationId = body.id || (0, import_crypto9.randomUUID)();
|
|
8817
9166
|
const installation = await store2.createInstallation(
|
|
8818
9167
|
tenantId,
|
|
8819
9168
|
installationId,
|
|
@@ -8851,7 +9200,7 @@ async function createChannelInstallation(request, reply) {
|
|
|
8851
9200
|
}
|
|
8852
9201
|
}
|
|
8853
9202
|
async function updateChannelInstallation(request, reply) {
|
|
8854
|
-
const tenantId =
|
|
9203
|
+
const tenantId = getTenantId15(request);
|
|
8855
9204
|
const { installationId } = request.params;
|
|
8856
9205
|
const body = request.body;
|
|
8857
9206
|
try {
|
|
@@ -8905,7 +9254,7 @@ async function updateChannelInstallation(request, reply) {
|
|
|
8905
9254
|
}
|
|
8906
9255
|
}
|
|
8907
9256
|
async function deleteChannelInstallation(request, reply) {
|
|
8908
|
-
const tenantId =
|
|
9257
|
+
const tenantId = getTenantId15(request);
|
|
8909
9258
|
const { installationId } = request.params;
|
|
8910
9259
|
try {
|
|
8911
9260
|
const store2 = await getInstallationStore();
|
|
@@ -8965,17 +9314,17 @@ function registerChannelInstallationRoutes(app2) {
|
|
|
8965
9314
|
}
|
|
8966
9315
|
|
|
8967
9316
|
// src/controllers/channel-bindings.ts
|
|
8968
|
-
var
|
|
8969
|
-
function
|
|
9317
|
+
var import_core36 = require("@axiom-lattice/core");
|
|
9318
|
+
function getTenantId16(request) {
|
|
8970
9319
|
const userTenantId = request.user?.tenantId;
|
|
8971
9320
|
if (userTenantId) return userTenantId;
|
|
8972
9321
|
return request.headers["x-tenant-id"] || "default";
|
|
8973
9322
|
}
|
|
8974
9323
|
async function getBindingList(request, _reply) {
|
|
8975
|
-
const tenantId =
|
|
9324
|
+
const tenantId = getTenantId16(request);
|
|
8976
9325
|
const { channel, agentId, channelInstallationId, limit, offset } = request.query;
|
|
8977
9326
|
try {
|
|
8978
|
-
const registry = (0,
|
|
9327
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
8979
9328
|
const bindings = await registry.list({ channel, agentId, tenantId, channelInstallationId, limit, offset });
|
|
8980
9329
|
return { success: true, message: "Bindings retrieved", data: { records: bindings, total: bindings.length } };
|
|
8981
9330
|
} catch (error) {
|
|
@@ -8984,9 +9333,9 @@ async function getBindingList(request, _reply) {
|
|
|
8984
9333
|
}
|
|
8985
9334
|
}
|
|
8986
9335
|
async function getBinding(request, reply) {
|
|
8987
|
-
const tenantId =
|
|
9336
|
+
const tenantId = getTenantId16(request);
|
|
8988
9337
|
try {
|
|
8989
|
-
const registry = (0,
|
|
9338
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
8990
9339
|
const bindings = await registry.list({ tenantId });
|
|
8991
9340
|
const binding = bindings.find((b) => b.id === request.params.id);
|
|
8992
9341
|
if (!binding || binding.tenantId !== tenantId) {
|
|
@@ -9000,9 +9349,9 @@ async function getBinding(request, reply) {
|
|
|
9000
9349
|
}
|
|
9001
9350
|
}
|
|
9002
9351
|
async function createBinding(request, reply) {
|
|
9003
|
-
const tenantId =
|
|
9352
|
+
const tenantId = getTenantId16(request);
|
|
9004
9353
|
try {
|
|
9005
|
-
const registry = (0,
|
|
9354
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9006
9355
|
const binding = await registry.create({ ...request.body, tenantId });
|
|
9007
9356
|
reply.status(201);
|
|
9008
9357
|
return { success: true, message: "Binding created", data: binding };
|
|
@@ -9014,8 +9363,8 @@ async function createBinding(request, reply) {
|
|
|
9014
9363
|
}
|
|
9015
9364
|
async function updateBinding(request, reply) {
|
|
9016
9365
|
try {
|
|
9017
|
-
const tenantId =
|
|
9018
|
-
const registry = (0,
|
|
9366
|
+
const tenantId = getTenantId16(request);
|
|
9367
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9019
9368
|
const bindings = await registry.list({ tenantId });
|
|
9020
9369
|
const existing = bindings.find((b) => b.id === request.params.id);
|
|
9021
9370
|
if (!existing || existing.tenantId !== tenantId) {
|
|
@@ -9032,8 +9381,8 @@ async function updateBinding(request, reply) {
|
|
|
9032
9381
|
}
|
|
9033
9382
|
async function deleteBinding(request, reply) {
|
|
9034
9383
|
try {
|
|
9035
|
-
const tenantId =
|
|
9036
|
-
const registry = (0,
|
|
9384
|
+
const tenantId = getTenantId16(request);
|
|
9385
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9037
9386
|
const bindings = await registry.list({ tenantId });
|
|
9038
9387
|
const existing = bindings.find((b) => b.id === request.params.id);
|
|
9039
9388
|
if (!existing || existing.tenantId !== tenantId) {
|
|
@@ -9049,10 +9398,10 @@ async function deleteBinding(request, reply) {
|
|
|
9049
9398
|
}
|
|
9050
9399
|
}
|
|
9051
9400
|
async function resolveBinding(request, _reply) {
|
|
9052
|
-
const tenantId =
|
|
9401
|
+
const tenantId = getTenantId16(request);
|
|
9053
9402
|
const { channel, senderId, channelInstallationId } = request.query;
|
|
9054
9403
|
try {
|
|
9055
|
-
const registry = (0,
|
|
9404
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9056
9405
|
const binding = await registry.resolve({ channel, senderId, channelInstallationId, tenantId });
|
|
9057
9406
|
if (!binding) {
|
|
9058
9407
|
return { success: false, message: "No binding found", data: null };
|
|
@@ -9075,8 +9424,8 @@ function registerChannelBindingRoutes(app2) {
|
|
|
9075
9424
|
}
|
|
9076
9425
|
|
|
9077
9426
|
// src/controllers/menu-items.ts
|
|
9078
|
-
var
|
|
9079
|
-
function
|
|
9427
|
+
var import_core37 = require("@axiom-lattice/core");
|
|
9428
|
+
function getTenantId17(request) {
|
|
9080
9429
|
const userTenantId = request.user?.tenantId;
|
|
9081
9430
|
if (userTenantId) return userTenantId;
|
|
9082
9431
|
return request.headers["x-tenant-id"] || "default";
|
|
@@ -9085,9 +9434,9 @@ function errorMessage(err) {
|
|
|
9085
9434
|
return err instanceof Error ? err.message : "Unexpected error";
|
|
9086
9435
|
}
|
|
9087
9436
|
async function getMenuItemList(request, _reply) {
|
|
9088
|
-
const tenantId =
|
|
9437
|
+
const tenantId = getTenantId17(request);
|
|
9089
9438
|
try {
|
|
9090
|
-
const registry = (0,
|
|
9439
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9091
9440
|
const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget });
|
|
9092
9441
|
return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
|
|
9093
9442
|
} catch (error) {
|
|
@@ -9097,9 +9446,9 @@ async function getMenuItemList(request, _reply) {
|
|
|
9097
9446
|
}
|
|
9098
9447
|
}
|
|
9099
9448
|
async function getMenuItem(request, reply) {
|
|
9100
|
-
const tenantId =
|
|
9449
|
+
const tenantId = getTenantId17(request);
|
|
9101
9450
|
try {
|
|
9102
|
-
const registry = (0,
|
|
9451
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9103
9452
|
const item = await registry.getById(request.params.id);
|
|
9104
9453
|
if (!item || item.tenantId !== tenantId) {
|
|
9105
9454
|
reply.status(404);
|
|
@@ -9114,9 +9463,9 @@ async function getMenuItem(request, reply) {
|
|
|
9114
9463
|
}
|
|
9115
9464
|
}
|
|
9116
9465
|
async function createMenuItem(request, reply) {
|
|
9117
|
-
const tenantId =
|
|
9466
|
+
const tenantId = getTenantId17(request);
|
|
9118
9467
|
try {
|
|
9119
|
-
const registry = (0,
|
|
9468
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9120
9469
|
const item = await registry.create({ ...request.body, tenantId });
|
|
9121
9470
|
reply.status(201);
|
|
9122
9471
|
return { success: true, message: "Menu item created", data: item };
|
|
@@ -9129,8 +9478,8 @@ async function createMenuItem(request, reply) {
|
|
|
9129
9478
|
}
|
|
9130
9479
|
async function updateMenuItem(request, reply) {
|
|
9131
9480
|
try {
|
|
9132
|
-
const tenantId =
|
|
9133
|
-
const registry = (0,
|
|
9481
|
+
const tenantId = getTenantId17(request);
|
|
9482
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9134
9483
|
const existing = await registry.getById(request.params.id);
|
|
9135
9484
|
if (!existing || existing.tenantId !== tenantId) {
|
|
9136
9485
|
reply.status(404);
|
|
@@ -9147,8 +9496,8 @@ async function updateMenuItem(request, reply) {
|
|
|
9147
9496
|
}
|
|
9148
9497
|
async function deleteMenuItem(request, reply) {
|
|
9149
9498
|
try {
|
|
9150
|
-
const tenantId =
|
|
9151
|
-
const registry = (0,
|
|
9499
|
+
const tenantId = getTenantId17(request);
|
|
9500
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9152
9501
|
const existing = await registry.getById(request.params.id);
|
|
9153
9502
|
if (!existing || existing.tenantId !== tenantId) {
|
|
9154
9503
|
reply.status(404);
|
|
@@ -9586,6 +9935,31 @@ var registerLatticeRoutes = (app2, channelDeps) => {
|
|
|
9586
9935
|
"/api/assistants/:assistant_id/threads/:thread_id/pending-messages/:message_id",
|
|
9587
9936
|
removePendingMessageHandler
|
|
9588
9937
|
);
|
|
9938
|
+
app2.get("/api/tenants/exportable-types", getExportableTypes);
|
|
9939
|
+
app2.post(
|
|
9940
|
+
"/api/tenants/:tenantId/export",
|
|
9941
|
+
exportConfig
|
|
9942
|
+
);
|
|
9943
|
+
app2.post(
|
|
9944
|
+
"/api/tenants/:tenantId/export/confirm",
|
|
9945
|
+
exportConfigConfirm
|
|
9946
|
+
);
|
|
9947
|
+
app2.post(
|
|
9948
|
+
"/api/tenants/:tenantId/export/entities",
|
|
9949
|
+
previewEntities
|
|
9950
|
+
);
|
|
9951
|
+
app2.get(
|
|
9952
|
+
"/api/tenants/:tenantId/export/:jobId/download",
|
|
9953
|
+
downloadExport
|
|
9954
|
+
);
|
|
9955
|
+
app2.post(
|
|
9956
|
+
"/api/tenants/:tenantId/import/preview",
|
|
9957
|
+
importPreview
|
|
9958
|
+
);
|
|
9959
|
+
app2.post(
|
|
9960
|
+
"/api/tenants/:tenantId/import/apply",
|
|
9961
|
+
importApply
|
|
9962
|
+
);
|
|
9589
9963
|
};
|
|
9590
9964
|
|
|
9591
9965
|
// src/routes/resource-routes.ts
|
|
@@ -9614,19 +9988,1327 @@ function registerResourceRoutes(app2, controller) {
|
|
|
9614
9988
|
app2.delete("/api/resources/share/:token", controller.revokeShare.bind(controller));
|
|
9615
9989
|
}
|
|
9616
9990
|
|
|
9617
|
-
// src/
|
|
9618
|
-
var
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9991
|
+
// src/export_registrations/index.ts
|
|
9992
|
+
var import_core51 = require("@axiom-lattice/core");
|
|
9993
|
+
|
|
9994
|
+
// src/export_registrations/skill.registration.ts
|
|
9995
|
+
var import_core38 = require("@axiom-lattice/core");
|
|
9996
|
+
function getStore2() {
|
|
9997
|
+
return (0, import_core38.getStoreLattice)("default", "skill").store;
|
|
9998
|
+
}
|
|
9999
|
+
var skillRegistration = {
|
|
10000
|
+
entityType: "skill",
|
|
10001
|
+
label: "Skill(\u6280\u80FD)",
|
|
10002
|
+
category: "core",
|
|
10003
|
+
dependsOn: [],
|
|
10004
|
+
cascadeParents: [],
|
|
10005
|
+
async listForExport(tenantId) {
|
|
10006
|
+
const store2 = getStore2();
|
|
10007
|
+
const skills = await store2.getAllSkills(tenantId);
|
|
10008
|
+
return skills.map((s) => ({
|
|
10009
|
+
_exportId: "",
|
|
10010
|
+
data: {
|
|
10011
|
+
id: s.id,
|
|
10012
|
+
name: s.name,
|
|
10013
|
+
description: s.description,
|
|
10014
|
+
license: s.license,
|
|
10015
|
+
compatibility: s.compatibility,
|
|
10016
|
+
metadata: s.metadata,
|
|
10017
|
+
content: s.content,
|
|
10018
|
+
subSkills: s.subSkills
|
|
10019
|
+
}
|
|
10020
|
+
}));
|
|
10021
|
+
},
|
|
10022
|
+
async previewImport(tenantId, entities) {
|
|
10023
|
+
const store2 = getStore2();
|
|
10024
|
+
const existing = await store2.getAllSkills(tenantId);
|
|
10025
|
+
const existingIds = new Set(existing.map((s) => s.id));
|
|
10026
|
+
const conflicts = [];
|
|
10027
|
+
const insertions = [];
|
|
10028
|
+
for (const entity of entities) {
|
|
10029
|
+
const id = entity.data.id;
|
|
10030
|
+
if (existingIds.has(id)) {
|
|
10031
|
+
conflicts.push({
|
|
10032
|
+
_exportId: entity._exportId,
|
|
10033
|
+
entityType: "skill",
|
|
10034
|
+
conflictType: "id_exists",
|
|
10035
|
+
existingId: id,
|
|
10036
|
+
existingName: entity.data.name || id
|
|
10037
|
+
});
|
|
10038
|
+
} else {
|
|
10039
|
+
insertions.push({
|
|
10040
|
+
_exportId: entity._exportId,
|
|
10041
|
+
entityType: "skill",
|
|
10042
|
+
name: entity.data.name || id
|
|
10043
|
+
});
|
|
10044
|
+
}
|
|
10045
|
+
}
|
|
10046
|
+
return { conflicts, insertions, errors: [] };
|
|
10047
|
+
},
|
|
10048
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10049
|
+
const store2 = getStore2();
|
|
10050
|
+
const data = entity.data;
|
|
10051
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10052
|
+
if (resolution.action === "overwrite") {
|
|
10053
|
+
try {
|
|
10054
|
+
await store2.deleteSkill(tenantId, id);
|
|
10055
|
+
} catch {
|
|
10056
|
+
}
|
|
10057
|
+
}
|
|
10058
|
+
await store2.createSkill(tenantId, id, {
|
|
10059
|
+
name: data.name,
|
|
10060
|
+
description: data.description,
|
|
10061
|
+
license: data.license,
|
|
10062
|
+
compatibility: data.compatibility,
|
|
10063
|
+
metadata: data.metadata,
|
|
10064
|
+
content: data.content,
|
|
10065
|
+
subSkills: data.subSkills
|
|
10066
|
+
});
|
|
10067
|
+
return { newId: id };
|
|
10068
|
+
}
|
|
10069
|
+
};
|
|
10070
|
+
|
|
10071
|
+
// src/export_registrations/agent.registration.ts
|
|
10072
|
+
var import_core39 = require("@axiom-lattice/core");
|
|
10073
|
+
function getStore3() {
|
|
10074
|
+
return (0, import_core39.getStoreLattice)("default", "assistant").store;
|
|
10075
|
+
}
|
|
10076
|
+
var agentRegistration = {
|
|
10077
|
+
entityType: "agent",
|
|
10078
|
+
label: "Agent(\u667A\u80FD\u4F53)",
|
|
10079
|
+
category: "core",
|
|
10080
|
+
dependsOn: ["skill"],
|
|
10081
|
+
cascadeParents: [],
|
|
10082
|
+
async listForExport(tenantId) {
|
|
10083
|
+
const store2 = getStore3();
|
|
10084
|
+
const agents = await store2.getAllAssistants(tenantId);
|
|
10085
|
+
return agents.map((a) => ({
|
|
10086
|
+
_exportId: "",
|
|
10087
|
+
data: {
|
|
10088
|
+
id: a.id,
|
|
10089
|
+
name: a.name,
|
|
10090
|
+
description: a.description,
|
|
10091
|
+
graphDefinition: a.graphDefinition
|
|
10092
|
+
}
|
|
10093
|
+
}));
|
|
10094
|
+
},
|
|
10095
|
+
async previewImport(tenantId, entities) {
|
|
10096
|
+
const store2 = getStore3();
|
|
10097
|
+
const existing = await store2.getAllAssistants(tenantId);
|
|
10098
|
+
const existingIds = new Set(existing.map((a) => a.id));
|
|
10099
|
+
const conflicts = [];
|
|
10100
|
+
const insertions = [];
|
|
10101
|
+
for (const entity of entities) {
|
|
10102
|
+
const id = entity.data.id;
|
|
10103
|
+
if (existingIds.has(id)) {
|
|
10104
|
+
conflicts.push({
|
|
10105
|
+
_exportId: entity._exportId,
|
|
10106
|
+
entityType: "agent",
|
|
10107
|
+
conflictType: "id_exists",
|
|
10108
|
+
existingId: id,
|
|
10109
|
+
existingName: entity.data.name || id
|
|
10110
|
+
});
|
|
10111
|
+
} else {
|
|
10112
|
+
insertions.push({
|
|
10113
|
+
_exportId: entity._exportId,
|
|
10114
|
+
entityType: "agent",
|
|
10115
|
+
name: entity.data.name || id
|
|
10116
|
+
});
|
|
10117
|
+
}
|
|
10118
|
+
}
|
|
10119
|
+
return { conflicts, insertions, errors: [] };
|
|
10120
|
+
},
|
|
10121
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10122
|
+
const store2 = getStore3();
|
|
10123
|
+
const data = entity.data;
|
|
10124
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10125
|
+
if (resolution.action === "overwrite") {
|
|
10126
|
+
try {
|
|
10127
|
+
await store2.deleteAssistant(tenantId, id);
|
|
10128
|
+
} catch {
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10131
|
+
await store2.createAssistant(tenantId, id, {
|
|
10132
|
+
name: data.name,
|
|
10133
|
+
description: data.description || "",
|
|
10134
|
+
graphDefinition: data.graphDefinition
|
|
10135
|
+
});
|
|
10136
|
+
return { newId: id };
|
|
10137
|
+
}
|
|
10138
|
+
};
|
|
10139
|
+
|
|
10140
|
+
// src/export_registrations/binding.registration.ts
|
|
10141
|
+
var import_core40 = require("@axiom-lattice/core");
|
|
10142
|
+
function getStore4() {
|
|
10143
|
+
return (0, import_core40.getStoreLattice)("default", "channelBinding").store;
|
|
10144
|
+
}
|
|
10145
|
+
var bindingRegistration = {
|
|
10146
|
+
entityType: "binding",
|
|
10147
|
+
label: "Binding(\u6E20\u9053\u7ED1\u5B9A)",
|
|
10148
|
+
category: "core",
|
|
10149
|
+
dependsOn: ["agent", "channel_installation"],
|
|
10150
|
+
cascadeParents: [],
|
|
10151
|
+
referenceFields: { agentId: "agent", channelInstallationId: "channel_installation" },
|
|
10152
|
+
async listForExport(tenantId) {
|
|
10153
|
+
const store2 = getStore4();
|
|
10154
|
+
const bindings = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10155
|
+
return bindings.map((b) => ({
|
|
10156
|
+
_exportId: "",
|
|
10157
|
+
data: {
|
|
10158
|
+
channel: b.channel,
|
|
10159
|
+
channelInstallationId: b.channelInstallationId,
|
|
10160
|
+
senderId: b.senderId,
|
|
10161
|
+
agentId: b.agentId,
|
|
10162
|
+
threadId: b.threadId,
|
|
10163
|
+
workspaceId: b.workspaceId,
|
|
10164
|
+
projectId: b.projectId,
|
|
10165
|
+
threadMode: b.threadMode,
|
|
10166
|
+
senderDisplayName: b.senderDisplayName,
|
|
10167
|
+
senderMetadata: b.senderMetadata,
|
|
10168
|
+
enabled: b.enabled
|
|
10169
|
+
}
|
|
10170
|
+
}));
|
|
10171
|
+
},
|
|
10172
|
+
async previewImport(tenantId, entities) {
|
|
10173
|
+
const store2 = getStore4();
|
|
10174
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10175
|
+
const existingKeys = new Set(
|
|
10176
|
+
existing.map((b) => `${b.channel}:${b.channelInstallationId}:${b.senderId}`)
|
|
10177
|
+
);
|
|
10178
|
+
const conflicts = [];
|
|
10179
|
+
const insertions = [];
|
|
10180
|
+
for (const entity of entities) {
|
|
10181
|
+
const d = entity.data;
|
|
10182
|
+
const key = `${d.channel}:${d.channelInstallationId}:${d.senderId}`;
|
|
10183
|
+
if (existingKeys.has(key)) {
|
|
10184
|
+
conflicts.push({
|
|
10185
|
+
_exportId: entity._exportId,
|
|
10186
|
+
entityType: "binding",
|
|
10187
|
+
conflictType: "unique_constraint",
|
|
10188
|
+
existingName: `${d.channel}:${d.senderId}`,
|
|
10189
|
+
field: "channel+channelInstallationId+senderId"
|
|
10190
|
+
});
|
|
10191
|
+
} else {
|
|
10192
|
+
insertions.push({
|
|
10193
|
+
_exportId: entity._exportId,
|
|
10194
|
+
entityType: "binding",
|
|
10195
|
+
name: `${d.channel}:${d.senderId}`
|
|
10196
|
+
});
|
|
10197
|
+
}
|
|
10198
|
+
}
|
|
10199
|
+
return { conflicts, insertions, errors: [] };
|
|
10200
|
+
},
|
|
10201
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10202
|
+
if (resolution.action === "skip") return {};
|
|
10203
|
+
const store2 = getStore4();
|
|
10204
|
+
const d = entity.data;
|
|
10205
|
+
if (resolution.action === "overwrite") {
|
|
10206
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10207
|
+
const match = existing.find(
|
|
10208
|
+
(b) => b.channel === d.channel && b.channelInstallationId === d.channelInstallationId && b.senderId === d.senderId
|
|
10209
|
+
);
|
|
10210
|
+
if (match) {
|
|
10211
|
+
await store2.delete(match.id);
|
|
10212
|
+
}
|
|
10213
|
+
}
|
|
10214
|
+
await store2.create({
|
|
10215
|
+
channel: d.channel,
|
|
10216
|
+
channelInstallationId: d.channelInstallationId,
|
|
10217
|
+
tenantId,
|
|
10218
|
+
senderId: d.senderId,
|
|
10219
|
+
agentId: d.agentId,
|
|
10220
|
+
threadMode: d.threadMode || "fixed",
|
|
10221
|
+
senderDisplayName: d.senderDisplayName,
|
|
10222
|
+
senderMetadata: d.senderMetadata,
|
|
10223
|
+
workspaceId: d.workspaceId,
|
|
10224
|
+
projectId: d.projectId
|
|
10225
|
+
});
|
|
10226
|
+
return { newId: void 0 };
|
|
10227
|
+
}
|
|
10228
|
+
};
|
|
10229
|
+
|
|
10230
|
+
// src/export_registrations/database-config.registration.ts
|
|
10231
|
+
var import_core41 = require("@axiom-lattice/core");
|
|
10232
|
+
function getStore5() {
|
|
10233
|
+
return (0, import_core41.getStoreLattice)("default", "database").store;
|
|
10234
|
+
}
|
|
10235
|
+
var databaseConfigRegistration = {
|
|
10236
|
+
entityType: "database_config",
|
|
10237
|
+
label: "Database Config(\u6570\u636E\u5E93\u914D\u7F6E)",
|
|
10238
|
+
category: "core",
|
|
10239
|
+
dependsOn: [],
|
|
10240
|
+
cascadeParents: [],
|
|
10241
|
+
async listForExport(tenantId) {
|
|
10242
|
+
const store2 = getStore5();
|
|
10243
|
+
const configs = await store2.getAllConfigs(tenantId);
|
|
10244
|
+
return configs.map((c) => ({
|
|
10245
|
+
_exportId: "",
|
|
10246
|
+
data: {
|
|
10247
|
+
id: c.id,
|
|
10248
|
+
key: c.key,
|
|
10249
|
+
name: c.name,
|
|
10250
|
+
description: c.description,
|
|
10251
|
+
config: c.config
|
|
10252
|
+
}
|
|
10253
|
+
}));
|
|
10254
|
+
},
|
|
10255
|
+
async previewImport(tenantId, entities) {
|
|
10256
|
+
const store2 = getStore5();
|
|
10257
|
+
const existing = await store2.getAllConfigs(tenantId);
|
|
10258
|
+
const existingIds = new Set(existing.map((c) => c.id));
|
|
10259
|
+
const existingKeys = new Set(existing.map((c) => c.key));
|
|
10260
|
+
const conflicts = [];
|
|
10261
|
+
const insertions = [];
|
|
10262
|
+
for (const entity of entities) {
|
|
10263
|
+
const d = entity.data;
|
|
10264
|
+
const id = d.id;
|
|
10265
|
+
const key = d.key;
|
|
10266
|
+
if (existingIds.has(id)) {
|
|
10267
|
+
conflicts.push({
|
|
10268
|
+
_exportId: entity._exportId,
|
|
10269
|
+
entityType: "database_config",
|
|
10270
|
+
conflictType: "id_exists",
|
|
10271
|
+
existingId: id,
|
|
10272
|
+
existingName: d.name || key
|
|
10273
|
+
});
|
|
10274
|
+
} else if (key && existingKeys.has(key)) {
|
|
10275
|
+
conflicts.push({
|
|
10276
|
+
_exportId: entity._exportId,
|
|
10277
|
+
entityType: "database_config",
|
|
10278
|
+
conflictType: "unique_constraint",
|
|
10279
|
+
existingName: d.name || key,
|
|
10280
|
+
field: "key"
|
|
10281
|
+
});
|
|
10282
|
+
} else {
|
|
10283
|
+
insertions.push({
|
|
10284
|
+
_exportId: entity._exportId,
|
|
10285
|
+
entityType: "database_config",
|
|
10286
|
+
name: d.name || key
|
|
10287
|
+
});
|
|
10288
|
+
}
|
|
10289
|
+
}
|
|
10290
|
+
return { conflicts, insertions, errors: [] };
|
|
10291
|
+
},
|
|
10292
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10293
|
+
const store2 = getStore5();
|
|
10294
|
+
const data = entity.data;
|
|
10295
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10296
|
+
if (resolution.action === "overwrite") {
|
|
10297
|
+
try {
|
|
10298
|
+
await store2.deleteConfig(tenantId, id);
|
|
10299
|
+
} catch {
|
|
10300
|
+
}
|
|
10301
|
+
}
|
|
10302
|
+
await store2.createConfig(tenantId, id, {
|
|
10303
|
+
key: data.key,
|
|
10304
|
+
name: data.name,
|
|
10305
|
+
description: data.description,
|
|
10306
|
+
config: data.config
|
|
10307
|
+
});
|
|
10308
|
+
return { newId: id };
|
|
10309
|
+
}
|
|
10310
|
+
};
|
|
10311
|
+
|
|
10312
|
+
// src/export_registrations/metrics-config.registration.ts
|
|
10313
|
+
var import_core42 = require("@axiom-lattice/core");
|
|
10314
|
+
function getStore6() {
|
|
10315
|
+
return (0, import_core42.getStoreLattice)("default", "metrics").store;
|
|
10316
|
+
}
|
|
10317
|
+
var metricsConfigRegistration = {
|
|
10318
|
+
entityType: "metrics_config",
|
|
10319
|
+
label: "Metrics Config(\u6307\u6807\u914D\u7F6E)",
|
|
10320
|
+
category: "core",
|
|
10321
|
+
dependsOn: [],
|
|
10322
|
+
cascadeParents: [],
|
|
10323
|
+
async listForExport(tenantId) {
|
|
10324
|
+
const store2 = getStore6();
|
|
10325
|
+
const configs = await store2.getAllConfigs(tenantId);
|
|
10326
|
+
return configs.map((c) => ({
|
|
10327
|
+
_exportId: "",
|
|
10328
|
+
data: {
|
|
10329
|
+
id: c.id,
|
|
10330
|
+
key: c.key,
|
|
10331
|
+
name: c.name,
|
|
10332
|
+
description: c.description,
|
|
10333
|
+
config: c.config
|
|
10334
|
+
}
|
|
10335
|
+
}));
|
|
10336
|
+
},
|
|
10337
|
+
async previewImport(tenantId, entities) {
|
|
10338
|
+
const store2 = getStore6();
|
|
10339
|
+
const existing = await store2.getAllConfigs(tenantId);
|
|
10340
|
+
const existingIds = new Set(existing.map((c) => c.id));
|
|
10341
|
+
const existingKeys = new Set(existing.map((c) => c.key));
|
|
10342
|
+
const conflicts = [];
|
|
10343
|
+
const insertions = [];
|
|
10344
|
+
for (const entity of entities) {
|
|
10345
|
+
const d = entity.data;
|
|
10346
|
+
const id = d.id;
|
|
10347
|
+
const key = d.key;
|
|
10348
|
+
if (existingIds.has(id)) {
|
|
10349
|
+
conflicts.push({
|
|
10350
|
+
_exportId: entity._exportId,
|
|
10351
|
+
entityType: "metrics_config",
|
|
10352
|
+
conflictType: "id_exists",
|
|
10353
|
+
existingId: id,
|
|
10354
|
+
existingName: d.name || key
|
|
10355
|
+
});
|
|
10356
|
+
} else if (key && existingKeys.has(key)) {
|
|
10357
|
+
conflicts.push({
|
|
10358
|
+
_exportId: entity._exportId,
|
|
10359
|
+
entityType: "metrics_config",
|
|
10360
|
+
conflictType: "unique_constraint",
|
|
10361
|
+
existingName: d.name || key,
|
|
10362
|
+
field: "key"
|
|
10363
|
+
});
|
|
10364
|
+
} else {
|
|
10365
|
+
insertions.push({
|
|
10366
|
+
_exportId: entity._exportId,
|
|
10367
|
+
entityType: "metrics_config",
|
|
10368
|
+
name: d.name || key
|
|
10369
|
+
});
|
|
10370
|
+
}
|
|
10371
|
+
}
|
|
10372
|
+
return { conflicts, insertions, errors: [] };
|
|
10373
|
+
},
|
|
10374
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10375
|
+
const store2 = getStore6();
|
|
10376
|
+
const data = entity.data;
|
|
10377
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10378
|
+
if (resolution.action === "overwrite") {
|
|
10379
|
+
try {
|
|
10380
|
+
await store2.deleteConfig(tenantId, id);
|
|
10381
|
+
} catch {
|
|
10382
|
+
}
|
|
10383
|
+
}
|
|
10384
|
+
await store2.createConfig(tenantId, id, {
|
|
10385
|
+
key: data.key,
|
|
10386
|
+
name: data.name,
|
|
10387
|
+
description: data.description,
|
|
10388
|
+
config: data.config
|
|
10389
|
+
});
|
|
10390
|
+
return { newId: id };
|
|
10391
|
+
}
|
|
10392
|
+
};
|
|
10393
|
+
|
|
10394
|
+
// src/export_registrations/mcp-config.registration.ts
|
|
10395
|
+
var import_core43 = require("@axiom-lattice/core");
|
|
10396
|
+
function getStore7() {
|
|
10397
|
+
return (0, import_core43.getStoreLattice)("default", "mcp").store;
|
|
10398
|
+
}
|
|
10399
|
+
var mcpConfigRegistration = {
|
|
10400
|
+
entityType: "mcp_config",
|
|
10401
|
+
label: "MCP Config(MCP\u914D\u7F6E)",
|
|
10402
|
+
category: "core",
|
|
10403
|
+
dependsOn: [],
|
|
10404
|
+
cascadeParents: [],
|
|
10405
|
+
async listForExport(tenantId) {
|
|
10406
|
+
const store2 = getStore7();
|
|
10407
|
+
const configs = await store2.getAllConfigs(tenantId);
|
|
10408
|
+
return configs.map((c) => ({
|
|
10409
|
+
_exportId: "",
|
|
10410
|
+
data: {
|
|
10411
|
+
id: c.id,
|
|
10412
|
+
key: c.key,
|
|
10413
|
+
name: c.name,
|
|
10414
|
+
description: c.description,
|
|
10415
|
+
config: c.config,
|
|
10416
|
+
selectedTools: c.selectedTools,
|
|
10417
|
+
status: c.status
|
|
10418
|
+
}
|
|
10419
|
+
}));
|
|
10420
|
+
},
|
|
10421
|
+
async previewImport(tenantId, entities) {
|
|
10422
|
+
const store2 = getStore7();
|
|
10423
|
+
const existing = await store2.getAllConfigs(tenantId);
|
|
10424
|
+
const existingIds = new Set(existing.map((c) => c.id));
|
|
10425
|
+
const existingKeys = new Set(existing.map((c) => c.key));
|
|
10426
|
+
const conflicts = [];
|
|
10427
|
+
const insertions = [];
|
|
10428
|
+
for (const entity of entities) {
|
|
10429
|
+
const d = entity.data;
|
|
10430
|
+
const id = d.id;
|
|
10431
|
+
const key = d.key;
|
|
10432
|
+
if (existingIds.has(id)) {
|
|
10433
|
+
conflicts.push({
|
|
10434
|
+
_exportId: entity._exportId,
|
|
10435
|
+
entityType: "mcp_config",
|
|
10436
|
+
conflictType: "id_exists",
|
|
10437
|
+
existingId: id,
|
|
10438
|
+
existingName: d.name || key
|
|
10439
|
+
});
|
|
10440
|
+
} else if (key && existingKeys.has(key)) {
|
|
10441
|
+
conflicts.push({
|
|
10442
|
+
_exportId: entity._exportId,
|
|
10443
|
+
entityType: "mcp_config",
|
|
10444
|
+
conflictType: "unique_constraint",
|
|
10445
|
+
existingName: d.name || key,
|
|
10446
|
+
field: "key"
|
|
10447
|
+
});
|
|
10448
|
+
} else {
|
|
10449
|
+
insertions.push({
|
|
10450
|
+
_exportId: entity._exportId,
|
|
10451
|
+
entityType: "mcp_config",
|
|
10452
|
+
name: d.name || key
|
|
10453
|
+
});
|
|
10454
|
+
}
|
|
10455
|
+
}
|
|
10456
|
+
return { conflicts, insertions, errors: [] };
|
|
10457
|
+
},
|
|
10458
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10459
|
+
const store2 = getStore7();
|
|
10460
|
+
const data = entity.data;
|
|
10461
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10462
|
+
if (resolution.action === "overwrite") {
|
|
10463
|
+
try {
|
|
10464
|
+
await store2.deleteConfig(tenantId, id);
|
|
10465
|
+
} catch {
|
|
10466
|
+
}
|
|
10467
|
+
}
|
|
10468
|
+
await store2.createConfig(tenantId, id, {
|
|
10469
|
+
key: data.key,
|
|
10470
|
+
name: data.name,
|
|
10471
|
+
description: data.description,
|
|
10472
|
+
config: data.config,
|
|
10473
|
+
selectedTools: data.selectedTools
|
|
10474
|
+
});
|
|
10475
|
+
return { newId: id };
|
|
10476
|
+
}
|
|
10477
|
+
};
|
|
10478
|
+
|
|
10479
|
+
// src/export_registrations/connection.registration.ts
|
|
10480
|
+
var import_core44 = require("@axiom-lattice/core");
|
|
10481
|
+
function getStore8() {
|
|
10482
|
+
return (0, import_core44.getStoreLattice)("default", "connection").store;
|
|
10483
|
+
}
|
|
10484
|
+
async function listAllConnections(tenantId) {
|
|
10485
|
+
const store2 = getStore8();
|
|
10486
|
+
if (typeof store2.listByTenant !== "function") {
|
|
10487
|
+
throw new Error("ConnectionStore.listByTenant is not implemented. SQL bypass removed \u2014 upgrade your store adapter.");
|
|
10488
|
+
}
|
|
10489
|
+
return store2.listByTenant(tenantId);
|
|
10490
|
+
}
|
|
10491
|
+
var connectionRegistration = {
|
|
10492
|
+
entityType: "connection",
|
|
10493
|
+
label: "Connection(\u8FDE\u63A5)",
|
|
10494
|
+
category: "core",
|
|
10495
|
+
dependsOn: [],
|
|
10496
|
+
cascadeParents: [],
|
|
10497
|
+
async listForExport(tenantId) {
|
|
10498
|
+
const connections2 = await listAllConnections(tenantId);
|
|
10499
|
+
return connections2.map((c) => ({
|
|
10500
|
+
_exportId: "",
|
|
10501
|
+
data: {
|
|
10502
|
+
id: c.id,
|
|
10503
|
+
type: c.type,
|
|
10504
|
+
key: c.key,
|
|
10505
|
+
name: c.name,
|
|
10506
|
+
description: c.description,
|
|
10507
|
+
config: c.config
|
|
10508
|
+
}
|
|
10509
|
+
}));
|
|
10510
|
+
},
|
|
10511
|
+
async previewImport(tenantId, entities) {
|
|
10512
|
+
const existing = await listAllConnections(tenantId);
|
|
10513
|
+
const existingCompositeKeys = new Set(
|
|
10514
|
+
existing.map((c) => `${c.type}:${c.key}`)
|
|
10515
|
+
);
|
|
10516
|
+
const conflicts = [];
|
|
10517
|
+
const insertions = [];
|
|
10518
|
+
for (const entity of entities) {
|
|
10519
|
+
const d = entity.data;
|
|
10520
|
+
const compositeKey = `${d.type}:${d.key}`;
|
|
10521
|
+
if (existingCompositeKeys.has(compositeKey)) {
|
|
10522
|
+
conflicts.push({
|
|
10523
|
+
_exportId: entity._exportId,
|
|
10524
|
+
entityType: "connection",
|
|
10525
|
+
conflictType: "unique_constraint",
|
|
10526
|
+
existingName: `${d.type}:${d.key}`,
|
|
10527
|
+
field: "type+key"
|
|
10528
|
+
});
|
|
10529
|
+
} else {
|
|
10530
|
+
insertions.push({
|
|
10531
|
+
_exportId: entity._exportId,
|
|
10532
|
+
entityType: "connection",
|
|
10533
|
+
name: `${d.type}:${d.key}`
|
|
10534
|
+
});
|
|
10535
|
+
}
|
|
10536
|
+
}
|
|
10537
|
+
return { conflicts, insertions, errors: [] };
|
|
10538
|
+
},
|
|
10539
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10540
|
+
if (resolution.action === "skip") return {};
|
|
10541
|
+
const store2 = getStore8();
|
|
10542
|
+
const d = entity.data;
|
|
10543
|
+
const type = d.type;
|
|
10544
|
+
const key = d.key;
|
|
10545
|
+
if (resolution.action === "overwrite") {
|
|
10546
|
+
try {
|
|
10547
|
+
await store2.delete(tenantId, type, key);
|
|
10548
|
+
} catch {
|
|
10549
|
+
}
|
|
10550
|
+
}
|
|
10551
|
+
await store2.create({
|
|
10552
|
+
tenantId,
|
|
10553
|
+
type,
|
|
10554
|
+
key,
|
|
10555
|
+
name: d.name,
|
|
10556
|
+
description: d.description,
|
|
10557
|
+
config: d.config
|
|
10558
|
+
});
|
|
10559
|
+
return { newId: void 0 };
|
|
10560
|
+
}
|
|
10561
|
+
};
|
|
10562
|
+
|
|
10563
|
+
// src/export_registrations/collection.registration.ts
|
|
10564
|
+
var import_core45 = require("@axiom-lattice/core");
|
|
10565
|
+
function getStore9() {
|
|
10566
|
+
return (0, import_core45.getStoreLattice)("default", "collection").store;
|
|
10567
|
+
}
|
|
10568
|
+
var collectionRegistration = {
|
|
10569
|
+
entityType: "collection",
|
|
10570
|
+
label: "Collection(\u77E5\u8BC6\u5E93)",
|
|
10571
|
+
category: "core",
|
|
10572
|
+
dependsOn: [],
|
|
10573
|
+
cascadeParents: [],
|
|
10574
|
+
async listForExport(tenantId) {
|
|
10575
|
+
const store2 = getStore9();
|
|
10576
|
+
const collections = await store2.getAllCollections(tenantId);
|
|
10577
|
+
return collections.map((c) => ({
|
|
10578
|
+
_exportId: "",
|
|
10579
|
+
data: {
|
|
10580
|
+
id: c.id,
|
|
10581
|
+
name: c.name,
|
|
10582
|
+
label: c.label,
|
|
10583
|
+
embeddingKey: c.embeddingKey,
|
|
10584
|
+
schema: c.schema
|
|
10585
|
+
}
|
|
10586
|
+
}));
|
|
10587
|
+
},
|
|
10588
|
+
async previewImport(tenantId, entities) {
|
|
10589
|
+
const store2 = getStore9();
|
|
10590
|
+
const existing = await store2.getAllCollections(tenantId);
|
|
10591
|
+
const existingNames = new Set(existing.map((c) => c.name));
|
|
10592
|
+
const conflicts = [];
|
|
10593
|
+
const insertions = [];
|
|
10594
|
+
for (const entity of entities) {
|
|
10595
|
+
const d = entity.data;
|
|
10596
|
+
const name = d.name;
|
|
10597
|
+
if (existingNames.has(name)) {
|
|
10598
|
+
conflicts.push({
|
|
10599
|
+
_exportId: entity._exportId,
|
|
10600
|
+
entityType: "collection",
|
|
10601
|
+
conflictType: "unique_constraint",
|
|
10602
|
+
existingName: name,
|
|
10603
|
+
field: "name"
|
|
10604
|
+
});
|
|
10605
|
+
} else {
|
|
10606
|
+
insertions.push({
|
|
10607
|
+
_exportId: entity._exportId,
|
|
10608
|
+
entityType: "collection",
|
|
10609
|
+
name
|
|
10610
|
+
});
|
|
10611
|
+
}
|
|
10612
|
+
}
|
|
10613
|
+
return { conflicts, insertions, errors: [] };
|
|
10614
|
+
},
|
|
10615
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10616
|
+
if (resolution.action === "skip") return {};
|
|
10617
|
+
const store2 = getStore9();
|
|
10618
|
+
const d = entity.data;
|
|
10619
|
+
const name = d.name;
|
|
10620
|
+
if (resolution.action === "overwrite") {
|
|
10621
|
+
try {
|
|
10622
|
+
await store2.deleteCollection(tenantId, name);
|
|
10623
|
+
} catch {
|
|
10624
|
+
}
|
|
10625
|
+
}
|
|
10626
|
+
await store2.createCollection(tenantId, {
|
|
10627
|
+
name,
|
|
10628
|
+
label: d.label,
|
|
10629
|
+
embeddingKey: d.embeddingKey,
|
|
10630
|
+
schema: d.schema
|
|
10631
|
+
});
|
|
10632
|
+
return { newId: void 0 };
|
|
10633
|
+
}
|
|
10634
|
+
};
|
|
10635
|
+
|
|
10636
|
+
// src/export_registrations/channel-installation.registration.ts
|
|
10637
|
+
var import_core46 = require("@axiom-lattice/core");
|
|
10638
|
+
function getStore10() {
|
|
10639
|
+
return (0, import_core46.getStoreLattice)("default", "channelInstallation").store;
|
|
10640
|
+
}
|
|
10641
|
+
var channelInstallationRegistration = {
|
|
10642
|
+
entityType: "channel_installation",
|
|
10643
|
+
label: "Channel Installation(\u6E20\u9053\u5B89\u88C5)",
|
|
10644
|
+
category: "core",
|
|
10645
|
+
dependsOn: ["agent"],
|
|
10646
|
+
cascadeParents: [],
|
|
10647
|
+
referenceFields: { fallbackAgentId: "agent" },
|
|
10648
|
+
async listForExport(tenantId) {
|
|
10649
|
+
const store2 = getStore10();
|
|
10650
|
+
const installations = await store2.getInstallationsByTenant(tenantId);
|
|
10651
|
+
return installations.map((i) => ({
|
|
10652
|
+
_exportId: "",
|
|
10653
|
+
data: {
|
|
10654
|
+
id: i.id,
|
|
10655
|
+
channel: i.channel,
|
|
10656
|
+
name: i.name,
|
|
10657
|
+
config: i.config,
|
|
10658
|
+
enabled: i.enabled,
|
|
10659
|
+
fallbackAgentId: i.fallbackAgentId,
|
|
10660
|
+
rejectWhenNoBinding: i.rejectWhenNoBinding
|
|
10661
|
+
}
|
|
10662
|
+
}));
|
|
10663
|
+
},
|
|
10664
|
+
async previewImport(tenantId, entities) {
|
|
10665
|
+
const store2 = getStore10();
|
|
10666
|
+
const existing = await store2.getInstallationsByTenant(tenantId);
|
|
10667
|
+
const existingIds = new Set(existing.map((i) => i.id));
|
|
10668
|
+
const conflicts = [];
|
|
10669
|
+
const insertions = [];
|
|
10670
|
+
for (const entity of entities) {
|
|
10671
|
+
const d = entity.data;
|
|
10672
|
+
const id = d.id;
|
|
10673
|
+
if (existingIds.has(id)) {
|
|
10674
|
+
conflicts.push({
|
|
10675
|
+
_exportId: entity._exportId,
|
|
10676
|
+
entityType: "channel_installation",
|
|
10677
|
+
conflictType: "id_exists",
|
|
10678
|
+
existingId: id,
|
|
10679
|
+
existingName: d.name || id
|
|
10680
|
+
});
|
|
10681
|
+
} else {
|
|
10682
|
+
insertions.push({
|
|
10683
|
+
_exportId: entity._exportId,
|
|
10684
|
+
entityType: "channel_installation",
|
|
10685
|
+
name: d.name || id
|
|
10686
|
+
});
|
|
10687
|
+
}
|
|
10688
|
+
}
|
|
10689
|
+
return { conflicts, insertions, errors: [] };
|
|
10690
|
+
},
|
|
10691
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10692
|
+
const store2 = getStore10();
|
|
10693
|
+
const data = entity.data;
|
|
10694
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10695
|
+
if (resolution.action === "overwrite") {
|
|
10696
|
+
try {
|
|
10697
|
+
await store2.deleteInstallation(tenantId, id);
|
|
10698
|
+
} catch {
|
|
10699
|
+
}
|
|
10700
|
+
}
|
|
10701
|
+
await store2.createInstallation(tenantId, id, {
|
|
10702
|
+
channel: data.channel,
|
|
10703
|
+
name: data.name,
|
|
10704
|
+
config: data.config,
|
|
10705
|
+
enabled: data.enabled,
|
|
10706
|
+
fallbackAgentId: data.fallbackAgentId,
|
|
10707
|
+
rejectWhenNoBinding: data.rejectWhenNoBinding
|
|
10708
|
+
});
|
|
10709
|
+
return { newId: id };
|
|
10710
|
+
}
|
|
10711
|
+
};
|
|
10712
|
+
|
|
10713
|
+
// src/export_registrations/menu.registration.ts
|
|
10714
|
+
var import_core47 = require("@axiom-lattice/core");
|
|
10715
|
+
function getStore11() {
|
|
10716
|
+
return (0, import_core47.getStoreLattice)("default", "menu").store;
|
|
10717
|
+
}
|
|
10718
|
+
var menuRegistration = {
|
|
10719
|
+
entityType: "menu",
|
|
10720
|
+
label: "Menu(\u83DC\u5355)",
|
|
10721
|
+
category: "core",
|
|
10722
|
+
dependsOn: ["agent"],
|
|
10723
|
+
cascadeParents: [],
|
|
10724
|
+
async listForExport(tenantId) {
|
|
10725
|
+
const store2 = getStore11();
|
|
10726
|
+
const menus = await store2.list({ tenantId });
|
|
10727
|
+
return menus.map((m) => ({
|
|
10728
|
+
_exportId: "",
|
|
10729
|
+
data: {
|
|
10730
|
+
id: m.id,
|
|
10731
|
+
menuTarget: m.menuTarget,
|
|
10732
|
+
group: m.group,
|
|
10733
|
+
name: m.name,
|
|
10734
|
+
icon: m.icon,
|
|
10735
|
+
sortOrder: m.sortOrder,
|
|
10736
|
+
contentType: m.contentType,
|
|
10737
|
+
contentConfig: m.contentConfig,
|
|
10738
|
+
enabled: m.enabled
|
|
10739
|
+
}
|
|
10740
|
+
}));
|
|
10741
|
+
},
|
|
10742
|
+
async previewImport(tenantId, entities) {
|
|
10743
|
+
const store2 = getStore11();
|
|
10744
|
+
const existing = await store2.list({ tenantId });
|
|
10745
|
+
const existingIds = new Set(existing.map((m) => m.id));
|
|
10746
|
+
const conflicts = [];
|
|
10747
|
+
const insertions = [];
|
|
10748
|
+
for (const entity of entities) {
|
|
10749
|
+
const d = entity.data;
|
|
10750
|
+
const id = d.id;
|
|
10751
|
+
if (existingIds.has(id)) {
|
|
10752
|
+
conflicts.push({
|
|
10753
|
+
_exportId: entity._exportId,
|
|
10754
|
+
entityType: "menu",
|
|
10755
|
+
conflictType: "id_exists",
|
|
10756
|
+
existingId: id,
|
|
10757
|
+
existingName: d.name || id
|
|
10758
|
+
});
|
|
10759
|
+
} else {
|
|
10760
|
+
insertions.push({
|
|
10761
|
+
_exportId: entity._exportId,
|
|
10762
|
+
entityType: "menu",
|
|
10763
|
+
name: d.name || id
|
|
10764
|
+
});
|
|
10765
|
+
}
|
|
10766
|
+
}
|
|
10767
|
+
return { conflicts, insertions, errors: [] };
|
|
10768
|
+
},
|
|
10769
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10770
|
+
const store2 = getStore11();
|
|
10771
|
+
const d = entity.data;
|
|
10772
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : d.id;
|
|
10773
|
+
if (resolution.action === "overwrite") {
|
|
10774
|
+
try {
|
|
10775
|
+
await store2.delete(id);
|
|
10776
|
+
} catch {
|
|
10777
|
+
}
|
|
10778
|
+
}
|
|
10779
|
+
await store2.create({
|
|
10780
|
+
tenantId,
|
|
10781
|
+
menuTarget: d.menuTarget,
|
|
10782
|
+
group: d.group,
|
|
10783
|
+
name: d.name,
|
|
10784
|
+
icon: d.icon,
|
|
10785
|
+
sortOrder: d.sortOrder,
|
|
10786
|
+
contentType: d.contentType,
|
|
10787
|
+
contentConfig: d.contentConfig
|
|
10788
|
+
});
|
|
10789
|
+
return { newId: void 0 };
|
|
10790
|
+
}
|
|
10791
|
+
};
|
|
10792
|
+
|
|
10793
|
+
// src/export_registrations/task.registration.ts
|
|
10794
|
+
var import_core48 = require("@axiom-lattice/core");
|
|
10795
|
+
function getStore12() {
|
|
10796
|
+
return (0, import_core48.getStoreLattice)("default", "task").store;
|
|
10797
|
+
}
|
|
10798
|
+
var taskRegistration = {
|
|
10799
|
+
entityType: "task",
|
|
10800
|
+
label: "Task(\u4EFB\u52A1)",
|
|
10801
|
+
category: "core",
|
|
10802
|
+
dependsOn: ["agent"],
|
|
10803
|
+
cascadeParents: [],
|
|
10804
|
+
referenceFields: { ownerId: "agent", parentId: "task" },
|
|
10805
|
+
async listForExport(tenantId) {
|
|
10806
|
+
const store2 = getStore12();
|
|
10807
|
+
const tasks = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10808
|
+
return tasks.map((t) => ({
|
|
10809
|
+
_exportId: "",
|
|
10810
|
+
data: {
|
|
10811
|
+
id: t.id,
|
|
10812
|
+
title: t.title,
|
|
10813
|
+
description: t.description,
|
|
10814
|
+
status: t.status,
|
|
10815
|
+
priority: t.priority,
|
|
10816
|
+
dueDate: t.dueDate,
|
|
10817
|
+
ownerType: t.ownerType,
|
|
10818
|
+
ownerId: t.ownerId,
|
|
10819
|
+
metadata: t.metadata,
|
|
10820
|
+
parentId: t.parentId,
|
|
10821
|
+
sourceId: t.sourceId,
|
|
10822
|
+
context: t.context
|
|
10823
|
+
}
|
|
10824
|
+
}));
|
|
10825
|
+
},
|
|
10826
|
+
async previewImport(tenantId, entities) {
|
|
10827
|
+
const store2 = getStore12();
|
|
10828
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10829
|
+
const existingIds = new Set(existing.map((t) => t.id));
|
|
10830
|
+
const conflicts = [];
|
|
10831
|
+
const insertions = [];
|
|
10832
|
+
for (const entity of entities) {
|
|
10833
|
+
const d = entity.data;
|
|
10834
|
+
const id = d.id;
|
|
10835
|
+
if (existingIds.has(id)) {
|
|
10836
|
+
conflicts.push({
|
|
10837
|
+
_exportId: entity._exportId,
|
|
10838
|
+
entityType: "task",
|
|
10839
|
+
conflictType: "id_exists",
|
|
10840
|
+
existingId: id,
|
|
10841
|
+
existingName: d.title || id
|
|
10842
|
+
});
|
|
10843
|
+
} else {
|
|
10844
|
+
insertions.push({
|
|
10845
|
+
_exportId: entity._exportId,
|
|
10846
|
+
entityType: "task",
|
|
10847
|
+
name: d.title || id
|
|
10848
|
+
});
|
|
10849
|
+
}
|
|
10850
|
+
}
|
|
10851
|
+
return { conflicts, insertions, errors: [] };
|
|
10852
|
+
},
|
|
10853
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10854
|
+
const store2 = getStore12();
|
|
10855
|
+
const data = entity.data;
|
|
10856
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10857
|
+
if (resolution.action === "overwrite") {
|
|
10858
|
+
try {
|
|
10859
|
+
await store2.delete(tenantId, id);
|
|
10860
|
+
} catch {
|
|
10861
|
+
}
|
|
10862
|
+
}
|
|
10863
|
+
await store2.create({
|
|
10864
|
+
tenantId,
|
|
10865
|
+
ownerType: data.ownerType || "user",
|
|
10866
|
+
ownerId: data.ownerId || "",
|
|
10867
|
+
title: data.title,
|
|
10868
|
+
description: data.description,
|
|
10869
|
+
status: data.status,
|
|
10870
|
+
priority: data.priority,
|
|
10871
|
+
dueDate: data.dueDate,
|
|
10872
|
+
metadata: data.metadata,
|
|
10873
|
+
parentId: data.parentId,
|
|
10874
|
+
sourceId: data.sourceId,
|
|
10875
|
+
context: data.context
|
|
10876
|
+
});
|
|
10877
|
+
return { newId: id };
|
|
10878
|
+
}
|
|
10879
|
+
};
|
|
10880
|
+
|
|
10881
|
+
// src/export_registrations/a2a-api-key.registration.ts
|
|
10882
|
+
var import_core49 = require("@axiom-lattice/core");
|
|
10883
|
+
function getStore13() {
|
|
10884
|
+
return (0, import_core49.getStoreLattice)("default", "a2aApiKey").store;
|
|
10885
|
+
}
|
|
10886
|
+
var a2aApiKeyRegistration = {
|
|
10887
|
+
entityType: "a2a_api_key",
|
|
10888
|
+
label: "A2A API Key(API\u5BC6\u94A5)",
|
|
10889
|
+
category: "core",
|
|
10890
|
+
dependsOn: [],
|
|
10891
|
+
cascadeParents: [],
|
|
10892
|
+
async listForExport(tenantId) {
|
|
10893
|
+
const store2 = getStore13();
|
|
10894
|
+
const keys = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10895
|
+
return keys.map((k) => ({
|
|
10896
|
+
_exportId: "",
|
|
10897
|
+
data: {
|
|
10898
|
+
id: k.id,
|
|
10899
|
+
tenantId: k.tenantId,
|
|
10900
|
+
projectId: k.projectId,
|
|
10901
|
+
workspaceId: k.workspaceId,
|
|
10902
|
+
label: k.label,
|
|
10903
|
+
enabled: k.enabled
|
|
10904
|
+
}
|
|
10905
|
+
}));
|
|
10906
|
+
},
|
|
10907
|
+
async previewImport(tenantId, entities) {
|
|
10908
|
+
const store2 = getStore13();
|
|
10909
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10910
|
+
const existingIds = new Set(existing.map((k) => k.id));
|
|
10911
|
+
const conflicts = [];
|
|
10912
|
+
const insertions = [];
|
|
10913
|
+
for (const entity of entities) {
|
|
10914
|
+
const d = entity.data;
|
|
10915
|
+
const id = d.id;
|
|
10916
|
+
if (existingIds.has(id)) {
|
|
10917
|
+
conflicts.push({
|
|
10918
|
+
_exportId: entity._exportId,
|
|
10919
|
+
entityType: "a2a_api_key",
|
|
10920
|
+
conflictType: "id_exists",
|
|
10921
|
+
existingId: id,
|
|
10922
|
+
existingName: d.label || id
|
|
10923
|
+
});
|
|
10924
|
+
} else {
|
|
10925
|
+
insertions.push({
|
|
10926
|
+
_exportId: entity._exportId,
|
|
10927
|
+
entityType: "a2a_api_key",
|
|
10928
|
+
name: d.label || id
|
|
10929
|
+
});
|
|
10930
|
+
}
|
|
10931
|
+
}
|
|
10932
|
+
return { conflicts, insertions, errors: [] };
|
|
10933
|
+
},
|
|
10934
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10935
|
+
if (resolution.action === "skip") return {};
|
|
10936
|
+
const store2 = getStore13();
|
|
10937
|
+
const d = entity.data;
|
|
10938
|
+
if (resolution.action === "overwrite") {
|
|
10939
|
+
try {
|
|
10940
|
+
await store2.delete(d.id);
|
|
10941
|
+
} catch {
|
|
10942
|
+
}
|
|
10943
|
+
}
|
|
10944
|
+
await store2.create({
|
|
10945
|
+
tenantId,
|
|
10946
|
+
projectId: d.projectId,
|
|
10947
|
+
workspaceId: d.workspaceId,
|
|
10948
|
+
label: d.label
|
|
10949
|
+
});
|
|
10950
|
+
return { newId: void 0 };
|
|
10951
|
+
}
|
|
10952
|
+
};
|
|
10953
|
+
|
|
10954
|
+
// src/export_registrations/eval.registration.ts
|
|
10955
|
+
var import_core50 = require("@axiom-lattice/core");
|
|
10956
|
+
function getStore14() {
|
|
10957
|
+
return (0, import_core50.getStoreLattice)("default", "eval").store;
|
|
10958
|
+
}
|
|
10959
|
+
var evalRegistration = {
|
|
10960
|
+
entityType: "eval",
|
|
10961
|
+
label: "Eval(\u8BC4\u4F30)",
|
|
10962
|
+
category: "core",
|
|
10963
|
+
dependsOn: [],
|
|
10964
|
+
cascadeParents: [],
|
|
10965
|
+
referenceFields: { suiteId: "eval_suite", projectId: "eval_project", runId: "eval_run", caseId: "eval_case" },
|
|
10966
|
+
async listForExport(tenantId) {
|
|
10967
|
+
const store2 = getStore14();
|
|
10968
|
+
const projects = await store2.getProjectsByTenant(tenantId);
|
|
10969
|
+
const entities = [];
|
|
10970
|
+
for (const project of projects) {
|
|
10971
|
+
entities.push({
|
|
10972
|
+
_exportId: "",
|
|
10973
|
+
data: {
|
|
10974
|
+
_subType: "eval_project",
|
|
10975
|
+
id: project.id,
|
|
10976
|
+
name: project.name,
|
|
10977
|
+
description: project.description,
|
|
10978
|
+
version: project.version,
|
|
10979
|
+
judgeModelConfig: project.judgeModelConfig,
|
|
10980
|
+
targetServerConfig: project.targetServerConfig,
|
|
10981
|
+
concurrency: project.concurrency,
|
|
10982
|
+
reportConfig: project.reportConfig
|
|
10983
|
+
}
|
|
10984
|
+
});
|
|
10985
|
+
const suites = await store2.getSuitesByProject(tenantId, project.id);
|
|
10986
|
+
for (const suite of suites) {
|
|
10987
|
+
entities.push({
|
|
10988
|
+
_exportId: "",
|
|
10989
|
+
data: {
|
|
10990
|
+
_subType: "eval_suite",
|
|
10991
|
+
id: suite.id,
|
|
10992
|
+
projectId: suite.projectId,
|
|
10993
|
+
name: suite.name
|
|
10994
|
+
}
|
|
10995
|
+
});
|
|
10996
|
+
const cases = await store2.getCasesBySuite(tenantId, suite.id);
|
|
10997
|
+
for (const c of cases) {
|
|
10998
|
+
entities.push({
|
|
10999
|
+
_exportId: "",
|
|
11000
|
+
data: {
|
|
11001
|
+
_subType: "eval_case",
|
|
11002
|
+
id: c.id,
|
|
11003
|
+
suiteId: c.suiteId,
|
|
11004
|
+
inputMessage: c.inputMessage,
|
|
11005
|
+
inputFiles: c.inputFiles,
|
|
11006
|
+
steps: c.steps,
|
|
11007
|
+
outputType: c.outputType,
|
|
11008
|
+
contentAssertion: c.contentAssertion,
|
|
11009
|
+
rubrics: c.rubrics
|
|
11010
|
+
}
|
|
11011
|
+
});
|
|
11012
|
+
}
|
|
11013
|
+
}
|
|
11014
|
+
const runs = await store2.getRunsByTenant(tenantId, { projectId: project.id });
|
|
11015
|
+
for (const run of runs) {
|
|
11016
|
+
entities.push({
|
|
11017
|
+
_exportId: "",
|
|
11018
|
+
data: {
|
|
11019
|
+
_subType: "eval_run",
|
|
11020
|
+
id: run.id,
|
|
11021
|
+
projectId: run.projectId,
|
|
11022
|
+
status: run.status,
|
|
11023
|
+
concurrency: run.concurrency,
|
|
11024
|
+
totalCases: run.totalCases,
|
|
11025
|
+
passedCases: run.passedCases,
|
|
11026
|
+
failedCases: run.failedCases,
|
|
11027
|
+
avgScore: run.avgScore,
|
|
11028
|
+
error: run.error
|
|
11029
|
+
}
|
|
11030
|
+
});
|
|
11031
|
+
const results = await store2.getResultsByRun(tenantId, run.id);
|
|
11032
|
+
for (const result of results) {
|
|
11033
|
+
entities.push({
|
|
11034
|
+
_exportId: "",
|
|
11035
|
+
data: {
|
|
11036
|
+
_subType: "eval_run_result",
|
|
11037
|
+
id: result.id,
|
|
11038
|
+
runId: result.runId,
|
|
11039
|
+
suiteName: result.suiteName,
|
|
11040
|
+
caseId: result.caseId,
|
|
11041
|
+
pass: result.pass,
|
|
11042
|
+
score: result.score,
|
|
11043
|
+
summary: result.summary,
|
|
11044
|
+
dimensionResults: result.dimensionResults,
|
|
11045
|
+
durationMs: result.durationMs,
|
|
11046
|
+
messages: result.messages,
|
|
11047
|
+
logs: result.logs,
|
|
11048
|
+
error: result.error
|
|
11049
|
+
}
|
|
11050
|
+
});
|
|
11051
|
+
}
|
|
11052
|
+
}
|
|
11053
|
+
}
|
|
11054
|
+
return entities;
|
|
11055
|
+
},
|
|
11056
|
+
async previewImport(tenantId, entities) {
|
|
11057
|
+
const store2 = getStore14();
|
|
11058
|
+
const existingProjects = await store2.getProjectsByTenant(tenantId);
|
|
11059
|
+
const existingProjectIds = new Set(existingProjects.map((p) => p.id));
|
|
11060
|
+
const existingProjectNames = new Set(existingProjects.map((p) => p.name));
|
|
11061
|
+
const existingSuites = /* @__PURE__ */ new Map();
|
|
11062
|
+
const existingSuiteIds = /* @__PURE__ */ new Set();
|
|
11063
|
+
const existingCaseIds = /* @__PURE__ */ new Set();
|
|
11064
|
+
const existingRunIds = /* @__PURE__ */ new Set();
|
|
11065
|
+
const existingResultIds = /* @__PURE__ */ new Set();
|
|
11066
|
+
for (const project of existingProjects) {
|
|
11067
|
+
const suites = await store2.getSuitesByProject(tenantId, project.id);
|
|
11068
|
+
existingSuites.set(project.id, new Set(suites.map((s) => `${s.projectId}:${s.name}`)));
|
|
11069
|
+
for (const s of suites) {
|
|
11070
|
+
existingSuiteIds.add(s.id);
|
|
11071
|
+
try {
|
|
11072
|
+
const cases = await store2.getCasesBySuite(tenantId, s.id);
|
|
11073
|
+
for (const c of cases) existingCaseIds.add(c.id);
|
|
11074
|
+
} catch {
|
|
11075
|
+
}
|
|
11076
|
+
}
|
|
11077
|
+
}
|
|
11078
|
+
for (const project of existingProjects) {
|
|
11079
|
+
const runs = await store2.getRunsByTenant(tenantId, { projectId: project.id });
|
|
11080
|
+
for (const run of runs) {
|
|
11081
|
+
existingRunIds.add(run.id);
|
|
11082
|
+
try {
|
|
11083
|
+
const results = await store2.getResultsByRun(tenantId, run.id);
|
|
11084
|
+
for (const r of results) existingResultIds.add(r.id);
|
|
11085
|
+
} catch {
|
|
11086
|
+
}
|
|
11087
|
+
}
|
|
11088
|
+
}
|
|
11089
|
+
const conflicts = [];
|
|
11090
|
+
const insertions = [];
|
|
11091
|
+
for (const entity of entities) {
|
|
11092
|
+
const d = entity.data;
|
|
11093
|
+
const subType = d._subType;
|
|
11094
|
+
const id = d.id;
|
|
11095
|
+
switch (subType) {
|
|
11096
|
+
case "eval_project": {
|
|
11097
|
+
const name = d.name;
|
|
11098
|
+
if (existingProjectIds.has(id)) {
|
|
11099
|
+
conflicts.push({
|
|
11100
|
+
_exportId: entity._exportId,
|
|
11101
|
+
entityType: "eval_project",
|
|
11102
|
+
conflictType: "id_exists",
|
|
11103
|
+
existingId: id,
|
|
11104
|
+
existingName: name
|
|
11105
|
+
});
|
|
11106
|
+
} else if (name && existingProjectNames.has(name)) {
|
|
11107
|
+
conflicts.push({
|
|
11108
|
+
_exportId: entity._exportId,
|
|
11109
|
+
entityType: "eval_project",
|
|
11110
|
+
conflictType: "unique_constraint",
|
|
11111
|
+
existingName: name,
|
|
11112
|
+
field: "name"
|
|
11113
|
+
});
|
|
11114
|
+
} else {
|
|
11115
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_project", name });
|
|
11116
|
+
}
|
|
11117
|
+
break;
|
|
11118
|
+
}
|
|
11119
|
+
case "eval_suite": {
|
|
11120
|
+
const projectId = d.projectId;
|
|
11121
|
+
const name = d.name;
|
|
11122
|
+
const suiteKey = `${projectId}:${name}`;
|
|
11123
|
+
const projectSuites = existingSuites.get(projectId);
|
|
11124
|
+
if (existingSuiteIds.has(id)) {
|
|
11125
|
+
conflicts.push({
|
|
11126
|
+
_exportId: entity._exportId,
|
|
11127
|
+
entityType: "eval_suite",
|
|
11128
|
+
conflictType: "id_exists",
|
|
11129
|
+
existingId: id,
|
|
11130
|
+
existingName: name
|
|
11131
|
+
});
|
|
11132
|
+
} else if (projectSuites?.has(suiteKey)) {
|
|
11133
|
+
conflicts.push({
|
|
11134
|
+
_exportId: entity._exportId,
|
|
11135
|
+
entityType: "eval_suite",
|
|
11136
|
+
conflictType: "unique_constraint",
|
|
11137
|
+
existingName: name,
|
|
11138
|
+
field: "projectId+name"
|
|
11139
|
+
});
|
|
11140
|
+
} else {
|
|
11141
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_suite", name });
|
|
11142
|
+
}
|
|
11143
|
+
break;
|
|
11144
|
+
}
|
|
11145
|
+
case "eval_case": {
|
|
11146
|
+
if (existingCaseIds.has(id)) {
|
|
11147
|
+
conflicts.push({
|
|
11148
|
+
_exportId: entity._exportId,
|
|
11149
|
+
entityType: "eval_case",
|
|
11150
|
+
conflictType: "id_exists",
|
|
11151
|
+
existingId: id
|
|
11152
|
+
});
|
|
11153
|
+
} else {
|
|
11154
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_case", name: id });
|
|
11155
|
+
}
|
|
11156
|
+
break;
|
|
11157
|
+
}
|
|
11158
|
+
case "eval_run": {
|
|
11159
|
+
if (existingRunIds.has(id)) {
|
|
11160
|
+
conflicts.push({
|
|
11161
|
+
_exportId: entity._exportId,
|
|
11162
|
+
entityType: "eval_run",
|
|
11163
|
+
conflictType: "id_exists",
|
|
11164
|
+
existingId: id
|
|
11165
|
+
});
|
|
11166
|
+
} else {
|
|
11167
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_run", name: id });
|
|
11168
|
+
}
|
|
11169
|
+
break;
|
|
11170
|
+
}
|
|
11171
|
+
case "eval_run_result": {
|
|
11172
|
+
if (existingResultIds.has(id)) {
|
|
11173
|
+
conflicts.push({
|
|
11174
|
+
_exportId: entity._exportId,
|
|
11175
|
+
entityType: "eval_run_result",
|
|
11176
|
+
conflictType: "id_exists",
|
|
11177
|
+
existingId: id
|
|
11178
|
+
});
|
|
11179
|
+
} else {
|
|
11180
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_run_result", name: id });
|
|
11181
|
+
}
|
|
11182
|
+
break;
|
|
11183
|
+
}
|
|
11184
|
+
}
|
|
11185
|
+
}
|
|
11186
|
+
return { conflicts, insertions, errors: [] };
|
|
11187
|
+
},
|
|
11188
|
+
async applyImport(tenantId, entity, resolution) {
|
|
11189
|
+
if (resolution.action === "skip") return {};
|
|
11190
|
+
const store2 = getStore14();
|
|
11191
|
+
const d = entity.data;
|
|
11192
|
+
const subType = d._subType;
|
|
11193
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : d.id;
|
|
11194
|
+
switch (subType) {
|
|
11195
|
+
case "eval_project": {
|
|
11196
|
+
if (resolution.action === "overwrite") {
|
|
11197
|
+
try {
|
|
11198
|
+
await store2.deleteProject(tenantId, id);
|
|
11199
|
+
} catch {
|
|
11200
|
+
}
|
|
11201
|
+
}
|
|
11202
|
+
await store2.createProject(tenantId, id, {
|
|
11203
|
+
name: d.name,
|
|
11204
|
+
description: d.description,
|
|
11205
|
+
version: d.version,
|
|
11206
|
+
judgeModelConfig: d.judgeModelConfig,
|
|
11207
|
+
targetServerConfig: d.targetServerConfig,
|
|
11208
|
+
concurrency: d.concurrency,
|
|
11209
|
+
reportConfig: d.reportConfig
|
|
11210
|
+
});
|
|
11211
|
+
break;
|
|
11212
|
+
}
|
|
11213
|
+
case "eval_suite": {
|
|
11214
|
+
if (resolution.action === "overwrite") {
|
|
11215
|
+
try {
|
|
11216
|
+
await store2.deleteSuite(tenantId, id);
|
|
11217
|
+
} catch {
|
|
11218
|
+
}
|
|
11219
|
+
}
|
|
11220
|
+
await store2.createSuite(tenantId, d.projectId, id, {
|
|
11221
|
+
name: d.name
|
|
11222
|
+
});
|
|
11223
|
+
break;
|
|
11224
|
+
}
|
|
11225
|
+
case "eval_case": {
|
|
11226
|
+
if (resolution.action === "overwrite") {
|
|
11227
|
+
try {
|
|
11228
|
+
await store2.deleteCase(tenantId, id);
|
|
11229
|
+
} catch {
|
|
11230
|
+
}
|
|
11231
|
+
}
|
|
11232
|
+
await store2.createCase(tenantId, d.suiteId, id, {
|
|
11233
|
+
inputMessage: d.inputMessage,
|
|
11234
|
+
inputFiles: d.inputFiles,
|
|
11235
|
+
steps: d.steps,
|
|
11236
|
+
outputType: d.outputType,
|
|
11237
|
+
contentAssertion: d.contentAssertion,
|
|
11238
|
+
rubrics: d.rubrics
|
|
11239
|
+
});
|
|
11240
|
+
break;
|
|
11241
|
+
}
|
|
11242
|
+
case "eval_run": {
|
|
11243
|
+
if (resolution.action === "overwrite") {
|
|
11244
|
+
try {
|
|
11245
|
+
await store2.deleteRun(tenantId, id);
|
|
11246
|
+
} catch {
|
|
11247
|
+
}
|
|
11248
|
+
}
|
|
11249
|
+
await store2.createRun(tenantId, d.projectId, id, {
|
|
11250
|
+
totalCases: d.totalCases,
|
|
11251
|
+
concurrency: d.concurrency
|
|
11252
|
+
});
|
|
11253
|
+
break;
|
|
11254
|
+
}
|
|
11255
|
+
case "eval_run_result": {
|
|
11256
|
+
if (resolution.action === "overwrite") {
|
|
11257
|
+
try {
|
|
11258
|
+
await store2.deleteRunResult(tenantId, entity.data.id);
|
|
11259
|
+
} catch {
|
|
11260
|
+
}
|
|
11261
|
+
}
|
|
11262
|
+
await store2.createRunResult(tenantId, d.runId, id, {
|
|
11263
|
+
suiteName: d.suiteName,
|
|
11264
|
+
caseId: d.caseId,
|
|
11265
|
+
pass: d.pass,
|
|
11266
|
+
score: d.score,
|
|
11267
|
+
summary: d.summary,
|
|
11268
|
+
dimensionResults: d.dimensionResults,
|
|
11269
|
+
durationMs: d.durationMs,
|
|
11270
|
+
messages: d.messages,
|
|
11271
|
+
logs: d.logs,
|
|
11272
|
+
error: d.error
|
|
11273
|
+
});
|
|
11274
|
+
break;
|
|
11275
|
+
}
|
|
11276
|
+
}
|
|
11277
|
+
return { newId: id };
|
|
11278
|
+
}
|
|
11279
|
+
};
|
|
11280
|
+
|
|
11281
|
+
// src/export_registrations/index.ts
|
|
11282
|
+
function registerAllBuiltinEntities() {
|
|
11283
|
+
const registry = import_core51.ExportableEntityRegistry.getInstance();
|
|
11284
|
+
registry.register(skillRegistration);
|
|
11285
|
+
registry.register(agentRegistration);
|
|
11286
|
+
registry.register(bindingRegistration);
|
|
11287
|
+
registry.register(databaseConfigRegistration);
|
|
11288
|
+
registry.register(metricsConfigRegistration);
|
|
11289
|
+
registry.register(mcpConfigRegistration);
|
|
11290
|
+
registry.register(connectionRegistration);
|
|
11291
|
+
registry.register(collectionRegistration);
|
|
11292
|
+
registry.register(channelInstallationRegistration);
|
|
11293
|
+
registry.register(menuRegistration);
|
|
11294
|
+
registry.register(taskRegistration);
|
|
11295
|
+
registry.register(a2aApiKeyRegistration);
|
|
11296
|
+
registry.register(evalRegistration);
|
|
11297
|
+
}
|
|
11298
|
+
|
|
11299
|
+
// src/router/MessageRouter.ts
|
|
11300
|
+
var import_core52 = require("@axiom-lattice/core");
|
|
11301
|
+
var import_crypto10 = require("crypto");
|
|
11302
|
+
var BindingNotFoundError = class extends Error {
|
|
11303
|
+
constructor(message) {
|
|
11304
|
+
super(message);
|
|
11305
|
+
this.name = "BindingNotFoundError";
|
|
11306
|
+
}
|
|
11307
|
+
};
|
|
11308
|
+
var MessageRouter = class {
|
|
11309
|
+
constructor(config) {
|
|
11310
|
+
/**
|
|
11311
|
+
* Tracks reply subscriptions per thread+channel to avoid duplicate
|
|
9630
11312
|
* `subscribeOnce` registrations and ensure proper cleanup.
|
|
9631
11313
|
*
|
|
9632
11314
|
* Key format: `{threadId}:{adapterChannel}:reply`
|
|
@@ -9776,7 +11458,7 @@ var MessageRouter = class {
|
|
|
9776
11458
|
channel: message.channel,
|
|
9777
11459
|
adapterChannel: adapter.channel
|
|
9778
11460
|
}, "Thread resolved by adapter strategy");
|
|
9779
|
-
const threadStore = (0,
|
|
11461
|
+
const threadStore = (0, import_core52.getStoreLattice)("default", "thread").store;
|
|
9780
11462
|
try {
|
|
9781
11463
|
await threadStore.createThread(
|
|
9782
11464
|
tenantId,
|
|
@@ -9813,8 +11495,8 @@ var MessageRouter = class {
|
|
|
9813
11495
|
}
|
|
9814
11496
|
}
|
|
9815
11497
|
if (!threadId) {
|
|
9816
|
-
const threadStore = (0,
|
|
9817
|
-
const newThreadId = (0,
|
|
11498
|
+
const threadStore = (0, import_core52.getStoreLattice)("default", "thread").store;
|
|
11499
|
+
const newThreadId = (0, import_crypto10.randomUUID)();
|
|
9818
11500
|
console.log({
|
|
9819
11501
|
event: "dispatch:thread:create",
|
|
9820
11502
|
agentId,
|
|
@@ -9853,7 +11535,7 @@ var MessageRouter = class {
|
|
|
9853
11535
|
senderId: message.sender.id,
|
|
9854
11536
|
contentLength: message.content.text.length
|
|
9855
11537
|
}, "Dispatching to agent");
|
|
9856
|
-
const agent =
|
|
11538
|
+
const agent = import_core52.agentInstanceManager.getAgent({
|
|
9857
11539
|
tenant_id: tenantId,
|
|
9858
11540
|
assistant_id: agentId,
|
|
9859
11541
|
thread_id: threadId,
|
|
@@ -10098,7 +11780,7 @@ function createAuditLoggerMiddleware() {
|
|
|
10098
11780
|
}
|
|
10099
11781
|
|
|
10100
11782
|
// src/index.ts
|
|
10101
|
-
var
|
|
11783
|
+
var import_core56 = require("@axiom-lattice/core");
|
|
10102
11784
|
|
|
10103
11785
|
// src/swagger.ts
|
|
10104
11786
|
var import_swagger = __toESM(require("@fastify/swagger"));
|
|
@@ -10163,7 +11845,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
10163
11845
|
};
|
|
10164
11846
|
|
|
10165
11847
|
// src/services/agent_task_consumer.ts
|
|
10166
|
-
var
|
|
11848
|
+
var import_core53 = require("@axiom-lattice/core");
|
|
10167
11849
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
10168
11850
|
const {
|
|
10169
11851
|
assistant_id,
|
|
@@ -10181,17 +11863,17 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
10181
11863
|
console.log(
|
|
10182
11864
|
`\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
10183
11865
|
);
|
|
10184
|
-
const agent =
|
|
10185
|
-
await agent.addMessage({ input, command, custom_run_config: runConfig },
|
|
11866
|
+
const agent = import_core53.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: runConfig?.workspaceId, project_id: runConfig?.projectId, custom_run_config: runConfig });
|
|
11867
|
+
await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core53.QueueMode.STEER);
|
|
10186
11868
|
if (callback_event) {
|
|
10187
11869
|
agent.subscribeOnce("message:completed", (evt) => {
|
|
10188
|
-
|
|
11870
|
+
import_core53.eventBus.publish(callback_event, {
|
|
10189
11871
|
success: true,
|
|
10190
11872
|
state: evt.state
|
|
10191
11873
|
});
|
|
10192
11874
|
if (main_thread_id && main_tenant_id) {
|
|
10193
11875
|
try {
|
|
10194
|
-
const mainAgent =
|
|
11876
|
+
const mainAgent = import_core53.agentInstanceManager.getAgent({
|
|
10195
11877
|
assistant_id: main_assistant_id ?? assistant_id,
|
|
10196
11878
|
thread_id: main_thread_id,
|
|
10197
11879
|
tenant_id: main_tenant_id,
|
|
@@ -10221,7 +11903,7 @@ ${summary}`
|
|
|
10221
11903
|
}
|
|
10222
11904
|
});
|
|
10223
11905
|
agent.subscribeOnce("message:interrupted", (evt) => {
|
|
10224
|
-
|
|
11906
|
+
import_core53.eventBus.publish(callback_event, {
|
|
10225
11907
|
success: true,
|
|
10226
11908
|
state: evt.state
|
|
10227
11909
|
});
|
|
@@ -10244,7 +11926,7 @@ ${summary}`
|
|
|
10244
11926
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
10245
11927
|
}
|
|
10246
11928
|
if (callback_event) {
|
|
10247
|
-
|
|
11929
|
+
import_core53.eventBus.publish(callback_event, {
|
|
10248
11930
|
success: false,
|
|
10249
11931
|
error: error instanceof Error ? error.message : String(error)
|
|
10250
11932
|
});
|
|
@@ -10281,7 +11963,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
10281
11963
|
* 初始化事件监听和队列轮询
|
|
10282
11964
|
*/
|
|
10283
11965
|
initialize() {
|
|
10284
|
-
|
|
11966
|
+
import_core53.eventBus.subscribe(import_core53.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
10285
11967
|
this.startPollingQueue();
|
|
10286
11968
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
10287
11969
|
}
|
|
@@ -10400,7 +12082,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
10400
12082
|
handleAgentTask(taskRequest).catch((error) => {
|
|
10401
12083
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
10402
12084
|
if (taskRequest.callback_event) {
|
|
10403
|
-
|
|
12085
|
+
import_core53.eventBus.publish(taskRequest.callback_event, {
|
|
10404
12086
|
success: false,
|
|
10405
12087
|
error: error instanceof Error ? error.message : String(error)
|
|
10406
12088
|
});
|
|
@@ -10415,7 +12097,7 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
|
|
|
10415
12097
|
var AgentTaskConsumer = _AgentTaskConsumer;
|
|
10416
12098
|
|
|
10417
12099
|
// src/index.ts
|
|
10418
|
-
var
|
|
12100
|
+
var import_core57 = require("@axiom-lattice/core");
|
|
10419
12101
|
var import_protocols5 = require("@axiom-lattice/protocols");
|
|
10420
12102
|
var import_meta = {};
|
|
10421
12103
|
process.on("unhandledRejection", (reason, promise) => {
|
|
@@ -10431,11 +12113,11 @@ var DEFAULT_LOGGER_CONFIG = {
|
|
|
10431
12113
|
var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
|
|
10432
12114
|
var logger5 = loggerLattice.client;
|
|
10433
12115
|
function initializeLogger(config) {
|
|
10434
|
-
if (
|
|
10435
|
-
|
|
12116
|
+
if (import_core57.loggerLatticeManager.hasLattice("default")) {
|
|
12117
|
+
import_core57.loggerLatticeManager.removeLattice("default");
|
|
10436
12118
|
}
|
|
10437
|
-
(0,
|
|
10438
|
-
return (0,
|
|
12119
|
+
(0, import_core57.registerLoggerLattice)("default", config);
|
|
12120
|
+
return (0, import_core57.getLoggerLattice)("default");
|
|
10439
12121
|
}
|
|
10440
12122
|
var app = (0, import_fastify.default)({
|
|
10441
12123
|
logger: false,
|
|
@@ -10546,7 +12228,7 @@ app.setErrorHandler((error, request, reply) => {
|
|
|
10546
12228
|
});
|
|
10547
12229
|
function getConfiguredSandboxProvider() {
|
|
10548
12230
|
const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox-remote";
|
|
10549
|
-
return (0,
|
|
12231
|
+
return (0, import_core57.createSandboxProvider)({
|
|
10550
12232
|
type: sandboxProviderType,
|
|
10551
12233
|
remoteBaseURL: process.env.SANDBOX_BASE_URL,
|
|
10552
12234
|
microsandboxServiceBaseURL: process.env.MICROSANDBOX_SERVICE_BASE_URL,
|
|
@@ -10562,7 +12244,7 @@ function getConfiguredSandboxProvider() {
|
|
|
10562
12244
|
}
|
|
10563
12245
|
async function restoreMcpConnections() {
|
|
10564
12246
|
try {
|
|
10565
|
-
const storeLattice = (0,
|
|
12247
|
+
const storeLattice = (0, import_core57.getStoreLattice)("default", "mcp");
|
|
10566
12248
|
const store2 = storeLattice.store;
|
|
10567
12249
|
if (!store2) {
|
|
10568
12250
|
logger5.info("MCP store not configured, skipping connection restoration");
|
|
@@ -10576,15 +12258,15 @@ async function restoreMcpConnections() {
|
|
|
10576
12258
|
for (const config of connectedConfigs) {
|
|
10577
12259
|
try {
|
|
10578
12260
|
const connection = convertToConnection2(config.config);
|
|
10579
|
-
|
|
12261
|
+
import_core57.mcpManager.addServer(config.key, connection);
|
|
10580
12262
|
} catch (err) {
|
|
10581
12263
|
logger5.warn(`Failed to prepare MCP server "${config.key}" for restoration`, { error: err });
|
|
10582
12264
|
}
|
|
10583
12265
|
}
|
|
10584
|
-
await
|
|
12266
|
+
await import_core57.mcpManager.connect();
|
|
10585
12267
|
for (const config of connectedConfigs) {
|
|
10586
12268
|
try {
|
|
10587
|
-
await
|
|
12269
|
+
await import_core57.mcpManager.registerToolsToToolLattice(config.key, config.selectedTools);
|
|
10588
12270
|
logger5.info(`MCP server "${config.key}" restored with ${config.selectedTools.length} tools`);
|
|
10589
12271
|
} catch (err) {
|
|
10590
12272
|
logger5.warn(`Failed to register tools for MCP server "${config.key}"`, { error: err });
|
|
@@ -10614,10 +12296,10 @@ var start = async (config) => {
|
|
|
10614
12296
|
const { wechatChannelAdapter: wechatChannelAdapter2 } = await Promise.resolve().then(() => (init_WechatChannelAdapter(), WechatChannelAdapter_exports));
|
|
10615
12297
|
adapterRegistry.register(wechatChannelAdapter2);
|
|
10616
12298
|
try {
|
|
10617
|
-
const { getStoreLattice:
|
|
10618
|
-
const bindingStore =
|
|
10619
|
-
const installationStore =
|
|
10620
|
-
(0,
|
|
12299
|
+
const { getStoreLattice: getStore15 } = await import("@axiom-lattice/core");
|
|
12300
|
+
const bindingStore = getStore15("default", "channelBinding").store;
|
|
12301
|
+
const installationStore = getStore15("default", "channelInstallation").store;
|
|
12302
|
+
(0, import_core56.setBindingRegistry)(bindingStore);
|
|
10621
12303
|
const router = new MessageRouter({
|
|
10622
12304
|
middlewares: [
|
|
10623
12305
|
createDeduplicationMiddleware(),
|
|
@@ -10630,7 +12312,7 @@ var start = async (config) => {
|
|
|
10630
12312
|
});
|
|
10631
12313
|
channelDeps = { router, installationStore };
|
|
10632
12314
|
try {
|
|
10633
|
-
const a2aKeyStore =
|
|
12315
|
+
const a2aKeyStore = getStore15("default", "a2aApiKey").store;
|
|
10634
12316
|
const a2a = await Promise.resolve().then(() => (init_a2a(), a2a_exports));
|
|
10635
12317
|
a2a.setA2AKeyStore(a2aKeyStore);
|
|
10636
12318
|
await a2a.refreshStoreKeyMap();
|
|
@@ -10642,28 +12324,29 @@ var start = async (config) => {
|
|
|
10642
12324
|
error: err instanceof Error ? err.message : String(err)
|
|
10643
12325
|
});
|
|
10644
12326
|
}
|
|
10645
|
-
(0,
|
|
12327
|
+
(0, import_core56.setEvalRunService)(evalRunner);
|
|
10646
12328
|
try {
|
|
10647
|
-
const menuStore = (0,
|
|
10648
|
-
(0,
|
|
12329
|
+
const menuStore = (0, import_core57.getStoreLattice)("default", "menu").store;
|
|
12330
|
+
(0, import_core56.setMenuRegistry)(menuStore);
|
|
10649
12331
|
logger5.info("Menu registry initialized");
|
|
10650
12332
|
} catch {
|
|
10651
12333
|
}
|
|
12334
|
+
registerAllBuiltinEntities();
|
|
10652
12335
|
if (channelDeps?.router) {
|
|
10653
12336
|
setChannelControllerDeps({ adapterRegistry, router: channelDeps.router });
|
|
10654
12337
|
}
|
|
10655
12338
|
registerLatticeRoutes(app, channelDeps);
|
|
10656
|
-
if (!
|
|
10657
|
-
|
|
12339
|
+
if (!import_core57.sandboxLatticeManager.hasLattice("default")) {
|
|
12340
|
+
import_core57.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
|
|
10658
12341
|
logger5.info("Registered sandbox manager from env configuration");
|
|
10659
12342
|
}
|
|
10660
12343
|
try {
|
|
10661
12344
|
const { ResourceController: ResourceController2 } = await Promise.resolve().then(() => (init_resources(), resources_exports));
|
|
10662
|
-
const sharedResourceStore = (0,
|
|
10663
|
-
const cache = new
|
|
12345
|
+
const sharedResourceStore = (0, import_core57.getStoreLattice)("default", "sharedResource").store;
|
|
12346
|
+
const cache = new import_core57.TokenCache();
|
|
10664
12347
|
const resourceController = new ResourceController2({
|
|
10665
12348
|
store: sharedResourceStore,
|
|
10666
|
-
sandboxManager:
|
|
12349
|
+
sandboxManager: import_core57.sandboxLatticeManager,
|
|
10667
12350
|
cache,
|
|
10668
12351
|
logger: logger5
|
|
10669
12352
|
});
|
|
@@ -10704,7 +12387,7 @@ var start = async (config) => {
|
|
|
10704
12387
|
}
|
|
10705
12388
|
}
|
|
10706
12389
|
if (process.env.AXIOM_RESTORE_PENDING_ON_STARTUP === "true") {
|
|
10707
|
-
|
|
12390
|
+
import_core57.agentInstanceManager.restore().then((stats) => {
|
|
10708
12391
|
logger5.info(`Agent recovery complete: ${stats.restored} threads restored, ${stats.errors} errors`);
|
|
10709
12392
|
}).catch((error) => {
|
|
10710
12393
|
logger5.error("Agent recovery failed", { error });
|