@axiom-lattice/gateway 2.1.112 → 2.1.113
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 +9 -0
- package/dist/index.js +1954 -273
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1764 -83
- 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/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: "",
|
|
@@ -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: "",
|
|
@@ -6178,9 +6525,9 @@ function registerWorkspaceRoutes(app2) {
|
|
|
6178
6525
|
}
|
|
6179
6526
|
|
|
6180
6527
|
// src/controllers/database-configs.ts
|
|
6181
|
-
var
|
|
6182
|
-
var
|
|
6183
|
-
function
|
|
6528
|
+
var import_core27 = require("@axiom-lattice/core");
|
|
6529
|
+
var import_crypto5 = require("crypto");
|
|
6530
|
+
function getTenantId11(request) {
|
|
6184
6531
|
const userTenantId = request.user?.tenantId;
|
|
6185
6532
|
if (userTenantId) {
|
|
6186
6533
|
return userTenantId;
|
|
@@ -6188,9 +6535,9 @@ function getTenantId10(request) {
|
|
|
6188
6535
|
return request.headers["x-tenant-id"] || "default";
|
|
6189
6536
|
}
|
|
6190
6537
|
async function getDatabaseConfigList(request, reply) {
|
|
6191
|
-
const tenantId =
|
|
6538
|
+
const tenantId = getTenantId11(request);
|
|
6192
6539
|
try {
|
|
6193
|
-
const storeLattice = (0,
|
|
6540
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6194
6541
|
const store2 = storeLattice.store;
|
|
6195
6542
|
const configs = await store2.getAllConfigs(tenantId);
|
|
6196
6543
|
console.log("Backend: getAllConfigs returned:", configs);
|
|
@@ -6218,10 +6565,10 @@ async function getDatabaseConfigList(request, reply) {
|
|
|
6218
6565
|
}
|
|
6219
6566
|
}
|
|
6220
6567
|
async function getDatabaseConfig(request, reply) {
|
|
6221
|
-
const tenantId =
|
|
6568
|
+
const tenantId = getTenantId11(request);
|
|
6222
6569
|
const { key } = request.params;
|
|
6223
6570
|
try {
|
|
6224
|
-
const storeLattice = (0,
|
|
6571
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6225
6572
|
const store2 = storeLattice.store;
|
|
6226
6573
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6227
6574
|
if (!config) {
|
|
@@ -6244,10 +6591,10 @@ async function getDatabaseConfig(request, reply) {
|
|
|
6244
6591
|
}
|
|
6245
6592
|
}
|
|
6246
6593
|
async function createDatabaseConfig(request, reply) {
|
|
6247
|
-
const tenantId =
|
|
6594
|
+
const tenantId = getTenantId11(request);
|
|
6248
6595
|
const body = request.body;
|
|
6249
6596
|
try {
|
|
6250
|
-
const storeLattice = (0,
|
|
6597
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6251
6598
|
const store2 = storeLattice.store;
|
|
6252
6599
|
const existing = await store2.getConfigByKey(tenantId, body.key);
|
|
6253
6600
|
if (existing) {
|
|
@@ -6257,10 +6604,10 @@ async function createDatabaseConfig(request, reply) {
|
|
|
6257
6604
|
message: "Database configuration with this key already exists"
|
|
6258
6605
|
};
|
|
6259
6606
|
}
|
|
6260
|
-
const id = body.id || (0,
|
|
6607
|
+
const id = body.id || (0, import_crypto5.randomUUID)();
|
|
6261
6608
|
const config = await store2.createConfig(tenantId, id, body);
|
|
6262
6609
|
try {
|
|
6263
|
-
|
|
6610
|
+
import_core27.sqlDatabaseManager.registerDatabase(tenantId, config.key, config.config);
|
|
6264
6611
|
} catch (error) {
|
|
6265
6612
|
console.warn("Failed to auto-register database:", error);
|
|
6266
6613
|
}
|
|
@@ -6279,11 +6626,11 @@ async function createDatabaseConfig(request, reply) {
|
|
|
6279
6626
|
}
|
|
6280
6627
|
}
|
|
6281
6628
|
async function updateDatabaseConfig(request, reply) {
|
|
6282
|
-
const tenantId =
|
|
6629
|
+
const tenantId = getTenantId11(request);
|
|
6283
6630
|
const { key } = request.params;
|
|
6284
6631
|
const updates = request.body;
|
|
6285
6632
|
try {
|
|
6286
|
-
const storeLattice = (0,
|
|
6633
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6287
6634
|
const store2 = storeLattice.store;
|
|
6288
6635
|
const existing = await store2.getConfigByKey(tenantId, key);
|
|
6289
6636
|
if (!existing) {
|
|
@@ -6302,7 +6649,7 @@ async function updateDatabaseConfig(request, reply) {
|
|
|
6302
6649
|
}
|
|
6303
6650
|
if (updates.config) {
|
|
6304
6651
|
try {
|
|
6305
|
-
|
|
6652
|
+
import_core27.sqlDatabaseManager.registerDatabase(tenantId, updated.key, updated.config);
|
|
6306
6653
|
} catch (error) {
|
|
6307
6654
|
console.warn("Failed to re-register database:", error);
|
|
6308
6655
|
}
|
|
@@ -6321,10 +6668,10 @@ async function updateDatabaseConfig(request, reply) {
|
|
|
6321
6668
|
}
|
|
6322
6669
|
}
|
|
6323
6670
|
async function deleteDatabaseConfig(request, reply) {
|
|
6324
|
-
const tenantId =
|
|
6671
|
+
const tenantId = getTenantId11(request);
|
|
6325
6672
|
const { keyOrId } = request.params;
|
|
6326
6673
|
try {
|
|
6327
|
-
const storeLattice = (0,
|
|
6674
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6328
6675
|
const store2 = storeLattice.store;
|
|
6329
6676
|
console.log("Delete request - keyOrId:", keyOrId);
|
|
6330
6677
|
let config = await store2.getConfigByKey(tenantId, keyOrId);
|
|
@@ -6351,8 +6698,8 @@ async function deleteDatabaseConfig(request, reply) {
|
|
|
6351
6698
|
};
|
|
6352
6699
|
}
|
|
6353
6700
|
try {
|
|
6354
|
-
if (
|
|
6355
|
-
await
|
|
6701
|
+
if (import_core27.sqlDatabaseManager.hasDatabase(tenantId, configKey)) {
|
|
6702
|
+
await import_core27.sqlDatabaseManager.removeDatabase(tenantId, configKey);
|
|
6356
6703
|
}
|
|
6357
6704
|
} catch (error) {
|
|
6358
6705
|
console.warn("Failed to remove from SqlDatabaseManager:", error);
|
|
@@ -6370,10 +6717,10 @@ async function deleteDatabaseConfig(request, reply) {
|
|
|
6370
6717
|
}
|
|
6371
6718
|
}
|
|
6372
6719
|
async function testDatabaseConnection(request, reply) {
|
|
6373
|
-
const tenantId =
|
|
6720
|
+
const tenantId = getTenantId11(request);
|
|
6374
6721
|
const { key } = request.params;
|
|
6375
6722
|
try {
|
|
6376
|
-
const storeLattice = (0,
|
|
6723
|
+
const storeLattice = (0, import_core27.getStoreLattice)("default", "database");
|
|
6377
6724
|
const store2 = storeLattice.store;
|
|
6378
6725
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6379
6726
|
if (!config) {
|
|
@@ -6384,16 +6731,16 @@ async function testDatabaseConnection(request, reply) {
|
|
|
6384
6731
|
};
|
|
6385
6732
|
}
|
|
6386
6733
|
const testKey = `__test_${key}_${Date.now()}`;
|
|
6387
|
-
|
|
6734
|
+
import_core27.sqlDatabaseManager.registerDatabase(tenantId, testKey, config.config);
|
|
6388
6735
|
const startTime = Date.now();
|
|
6389
|
-
const db = await
|
|
6736
|
+
const db = await import_core27.sqlDatabaseManager.getDatabase(tenantId, testKey);
|
|
6390
6737
|
try {
|
|
6391
6738
|
await db.connect();
|
|
6392
6739
|
await db.listTables();
|
|
6393
6740
|
const latency = Date.now() - startTime;
|
|
6394
6741
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
6395
6742
|
await db.disconnect();
|
|
6396
|
-
await
|
|
6743
|
+
await import_core27.sqlDatabaseManager.removeDatabase(tenantId, testKey);
|
|
6397
6744
|
return {
|
|
6398
6745
|
success: true,
|
|
6399
6746
|
message: "Connection test successful",
|
|
@@ -6405,7 +6752,7 @@ async function testDatabaseConnection(request, reply) {
|
|
|
6405
6752
|
} catch (error) {
|
|
6406
6753
|
try {
|
|
6407
6754
|
await db.disconnect();
|
|
6408
|
-
await
|
|
6755
|
+
await import_core27.sqlDatabaseManager.removeDatabase(tenantId, testKey);
|
|
6409
6756
|
} catch {
|
|
6410
6757
|
}
|
|
6411
6758
|
return {
|
|
@@ -6457,9 +6804,9 @@ function registerDatabaseConfigRoutes(app2) {
|
|
|
6457
6804
|
}
|
|
6458
6805
|
|
|
6459
6806
|
// src/controllers/metrics-configs.ts
|
|
6460
|
-
var
|
|
6461
|
-
var
|
|
6462
|
-
function
|
|
6807
|
+
var import_core28 = require("@axiom-lattice/core");
|
|
6808
|
+
var import_crypto6 = require("crypto");
|
|
6809
|
+
function getTenantId12(request) {
|
|
6463
6810
|
const userTenantId = request.user?.tenantId;
|
|
6464
6811
|
if (userTenantId) {
|
|
6465
6812
|
return userTenantId;
|
|
@@ -6467,9 +6814,9 @@ function getTenantId11(request) {
|
|
|
6467
6814
|
return request.headers["x-tenant-id"] || "default";
|
|
6468
6815
|
}
|
|
6469
6816
|
async function getMetricsServerConfigList(request, reply) {
|
|
6470
|
-
const tenantId =
|
|
6817
|
+
const tenantId = getTenantId12(request);
|
|
6471
6818
|
try {
|
|
6472
|
-
const storeLattice = (0,
|
|
6819
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6473
6820
|
const store2 = storeLattice.store;
|
|
6474
6821
|
const configs = await store2.getAllConfigs(tenantId);
|
|
6475
6822
|
return {
|
|
@@ -6493,10 +6840,10 @@ async function getMetricsServerConfigList(request, reply) {
|
|
|
6493
6840
|
}
|
|
6494
6841
|
}
|
|
6495
6842
|
async function getMetricsServerConfig(request, reply) {
|
|
6496
|
-
const tenantId =
|
|
6843
|
+
const tenantId = getTenantId12(request);
|
|
6497
6844
|
const { key } = request.params;
|
|
6498
6845
|
try {
|
|
6499
|
-
const storeLattice = (0,
|
|
6846
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6500
6847
|
const store2 = storeLattice.store;
|
|
6501
6848
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6502
6849
|
if (!config) {
|
|
@@ -6519,10 +6866,10 @@ async function getMetricsServerConfig(request, reply) {
|
|
|
6519
6866
|
}
|
|
6520
6867
|
}
|
|
6521
6868
|
async function createMetricsServerConfig(request, reply) {
|
|
6522
|
-
const tenantId =
|
|
6869
|
+
const tenantId = getTenantId12(request);
|
|
6523
6870
|
const body = request.body;
|
|
6524
6871
|
try {
|
|
6525
|
-
const storeLattice = (0,
|
|
6872
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6526
6873
|
const store2 = storeLattice.store;
|
|
6527
6874
|
const existing = await store2.getConfigByKey(tenantId, body.key);
|
|
6528
6875
|
if (existing) {
|
|
@@ -6539,7 +6886,7 @@ async function createMetricsServerConfig(request, reply) {
|
|
|
6539
6886
|
message: "selectedDataSources is required for semantic metrics servers"
|
|
6540
6887
|
};
|
|
6541
6888
|
}
|
|
6542
|
-
const id = body.id || (0,
|
|
6889
|
+
const id = body.id || (0, import_crypto6.randomUUID)();
|
|
6543
6890
|
const configData = {
|
|
6544
6891
|
key: body.key,
|
|
6545
6892
|
name: body.name,
|
|
@@ -6551,7 +6898,7 @@ async function createMetricsServerConfig(request, reply) {
|
|
|
6551
6898
|
};
|
|
6552
6899
|
const config = await store2.createConfig(tenantId, id, configData);
|
|
6553
6900
|
try {
|
|
6554
|
-
|
|
6901
|
+
import_core28.metricsServerManager.registerServer(tenantId, config.key, config.config);
|
|
6555
6902
|
} catch (error) {
|
|
6556
6903
|
console.warn("Failed to auto-register metrics server:", error);
|
|
6557
6904
|
}
|
|
@@ -6570,11 +6917,11 @@ async function createMetricsServerConfig(request, reply) {
|
|
|
6570
6917
|
}
|
|
6571
6918
|
}
|
|
6572
6919
|
async function updateMetricsServerConfig(request, reply) {
|
|
6573
|
-
const tenantId =
|
|
6920
|
+
const tenantId = getTenantId12(request);
|
|
6574
6921
|
const { key } = request.params;
|
|
6575
6922
|
const updates = request.body;
|
|
6576
6923
|
try {
|
|
6577
|
-
const storeLattice = (0,
|
|
6924
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6578
6925
|
const store2 = storeLattice.store;
|
|
6579
6926
|
const existing = await store2.getConfigByKey(tenantId, key);
|
|
6580
6927
|
if (!existing) {
|
|
@@ -6602,7 +6949,7 @@ async function updateMetricsServerConfig(request, reply) {
|
|
|
6602
6949
|
}
|
|
6603
6950
|
if (updates.config) {
|
|
6604
6951
|
try {
|
|
6605
|
-
|
|
6952
|
+
import_core28.metricsServerManager.registerServer(tenantId, updated.key, updated.config);
|
|
6606
6953
|
} catch (error) {
|
|
6607
6954
|
console.warn("Failed to re-register metrics server:", error);
|
|
6608
6955
|
}
|
|
@@ -6621,10 +6968,10 @@ async function updateMetricsServerConfig(request, reply) {
|
|
|
6621
6968
|
}
|
|
6622
6969
|
}
|
|
6623
6970
|
async function deleteMetricsServerConfig(request, reply) {
|
|
6624
|
-
const tenantId =
|
|
6971
|
+
const tenantId = getTenantId12(request);
|
|
6625
6972
|
const { keyOrId } = request.params;
|
|
6626
6973
|
try {
|
|
6627
|
-
const storeLattice = (0,
|
|
6974
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6628
6975
|
const store2 = storeLattice.store;
|
|
6629
6976
|
let config = await store2.getConfigByKey(tenantId, keyOrId);
|
|
6630
6977
|
let configKey = keyOrId;
|
|
@@ -6649,8 +6996,8 @@ async function deleteMetricsServerConfig(request, reply) {
|
|
|
6649
6996
|
};
|
|
6650
6997
|
}
|
|
6651
6998
|
try {
|
|
6652
|
-
if (
|
|
6653
|
-
|
|
6999
|
+
if (import_core28.metricsServerManager.hasServer(tenantId, configKey)) {
|
|
7000
|
+
import_core28.metricsServerManager.removeServer(tenantId, configKey);
|
|
6654
7001
|
}
|
|
6655
7002
|
} catch (error) {
|
|
6656
7003
|
console.warn("Failed to remove from MetricsServerManager:", error);
|
|
@@ -6668,10 +7015,10 @@ async function deleteMetricsServerConfig(request, reply) {
|
|
|
6668
7015
|
}
|
|
6669
7016
|
}
|
|
6670
7017
|
async function testMetricsServerConnection(request, reply) {
|
|
6671
|
-
const tenantId =
|
|
7018
|
+
const tenantId = getTenantId12(request);
|
|
6672
7019
|
const { key } = request.params;
|
|
6673
7020
|
try {
|
|
6674
|
-
const storeLattice = (0,
|
|
7021
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6675
7022
|
const store2 = storeLattice.store;
|
|
6676
7023
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6677
7024
|
if (!config) {
|
|
@@ -6682,11 +7029,11 @@ async function testMetricsServerConnection(request, reply) {
|
|
|
6682
7029
|
};
|
|
6683
7030
|
}
|
|
6684
7031
|
const testKey = `__test_${key}_${Date.now()}`;
|
|
6685
|
-
|
|
7032
|
+
import_core28.metricsServerManager.registerServer(tenantId, testKey, config.config);
|
|
6686
7033
|
try {
|
|
6687
|
-
const client = await
|
|
7034
|
+
const client = await import_core28.metricsServerManager.getClient(tenantId, testKey);
|
|
6688
7035
|
const result = await client.testConnection();
|
|
6689
|
-
|
|
7036
|
+
import_core28.metricsServerManager.removeServer(tenantId, testKey);
|
|
6690
7037
|
return {
|
|
6691
7038
|
success: true,
|
|
6692
7039
|
message: result.connected ? "Connection test successful" : "Connection test failed",
|
|
@@ -6694,7 +7041,7 @@ async function testMetricsServerConnection(request, reply) {
|
|
|
6694
7041
|
};
|
|
6695
7042
|
} catch (error) {
|
|
6696
7043
|
try {
|
|
6697
|
-
|
|
7044
|
+
import_core28.metricsServerManager.removeServer(tenantId, testKey);
|
|
6698
7045
|
} catch {
|
|
6699
7046
|
}
|
|
6700
7047
|
return {
|
|
@@ -6719,10 +7066,10 @@ async function testMetricsServerConnection(request, reply) {
|
|
|
6719
7066
|
}
|
|
6720
7067
|
}
|
|
6721
7068
|
async function listAvailableMetrics(request, reply) {
|
|
6722
|
-
const tenantId =
|
|
7069
|
+
const tenantId = getTenantId12(request);
|
|
6723
7070
|
const { key } = request.params;
|
|
6724
7071
|
try {
|
|
6725
|
-
const storeLattice = (0,
|
|
7072
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6726
7073
|
const store2 = storeLattice.store;
|
|
6727
7074
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6728
7075
|
if (!config) {
|
|
@@ -6732,10 +7079,10 @@ async function listAvailableMetrics(request, reply) {
|
|
|
6732
7079
|
message: "Metrics server configuration not found"
|
|
6733
7080
|
};
|
|
6734
7081
|
}
|
|
6735
|
-
if (!
|
|
6736
|
-
|
|
7082
|
+
if (!import_core28.metricsServerManager.hasServer(tenantId, key)) {
|
|
7083
|
+
import_core28.metricsServerManager.registerServer(tenantId, key, config.config);
|
|
6737
7084
|
}
|
|
6738
|
-
const client = await
|
|
7085
|
+
const client = await import_core28.metricsServerManager.getClient(tenantId, key);
|
|
6739
7086
|
const metrics = await client.listMetrics();
|
|
6740
7087
|
return {
|
|
6741
7088
|
success: true,
|
|
@@ -6757,11 +7104,11 @@ async function listAvailableMetrics(request, reply) {
|
|
|
6757
7104
|
}
|
|
6758
7105
|
}
|
|
6759
7106
|
async function queryMetricsData(request, reply) {
|
|
6760
|
-
const tenantId =
|
|
7107
|
+
const tenantId = getTenantId12(request);
|
|
6761
7108
|
const { key } = request.params;
|
|
6762
7109
|
const { metricName, startTime, endTime, step, labels } = request.body;
|
|
6763
7110
|
try {
|
|
6764
|
-
const storeLattice = (0,
|
|
7111
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6765
7112
|
const store2 = storeLattice.store;
|
|
6766
7113
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6767
7114
|
if (!config) {
|
|
@@ -6778,10 +7125,10 @@ async function queryMetricsData(request, reply) {
|
|
|
6778
7125
|
message: "metricName is required"
|
|
6779
7126
|
};
|
|
6780
7127
|
}
|
|
6781
|
-
if (!
|
|
6782
|
-
|
|
7128
|
+
if (!import_core28.metricsServerManager.hasServer(tenantId, key)) {
|
|
7129
|
+
import_core28.metricsServerManager.registerServer(tenantId, key, config.config);
|
|
6783
7130
|
}
|
|
6784
|
-
const client = await
|
|
7131
|
+
const client = await import_core28.metricsServerManager.getClient(tenantId, key);
|
|
6785
7132
|
const result = await client.queryMetricData(metricName, {
|
|
6786
7133
|
startTime,
|
|
6787
7134
|
endTime,
|
|
@@ -6805,10 +7152,10 @@ async function queryMetricsData(request, reply) {
|
|
|
6805
7152
|
}
|
|
6806
7153
|
}
|
|
6807
7154
|
async function getDataSources(request, reply) {
|
|
6808
|
-
const tenantId =
|
|
7155
|
+
const tenantId = getTenantId12(request);
|
|
6809
7156
|
const { key } = request.params;
|
|
6810
7157
|
try {
|
|
6811
|
-
const storeLattice = (0,
|
|
7158
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6812
7159
|
const store2 = storeLattice.store;
|
|
6813
7160
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6814
7161
|
if (!config) {
|
|
@@ -6826,7 +7173,7 @@ async function getDataSources(request, reply) {
|
|
|
6826
7173
|
};
|
|
6827
7174
|
}
|
|
6828
7175
|
const semanticConfig = config.config;
|
|
6829
|
-
const client = new
|
|
7176
|
+
const client = new import_core28.SemanticMetricsClient(semanticConfig);
|
|
6830
7177
|
const allDatasources = await client.getDataSources();
|
|
6831
7178
|
const selectedIds = semanticConfig.selectedDataSources || [];
|
|
6832
7179
|
const filteredDatasources = selectedIds.length > 0 ? allDatasources.filter((ds) => selectedIds.includes(String(ds.id))) : allDatasources;
|
|
@@ -6846,10 +7193,10 @@ async function getDataSources(request, reply) {
|
|
|
6846
7193
|
}
|
|
6847
7194
|
}
|
|
6848
7195
|
async function getDatasourceMetrics(request, reply) {
|
|
6849
|
-
const tenantId =
|
|
7196
|
+
const tenantId = getTenantId12(request);
|
|
6850
7197
|
const { key, datasourceId } = request.params;
|
|
6851
7198
|
try {
|
|
6852
|
-
const storeLattice = (0,
|
|
7199
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6853
7200
|
const store2 = storeLattice.store;
|
|
6854
7201
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6855
7202
|
if (!config) {
|
|
@@ -6867,7 +7214,7 @@ async function getDatasourceMetrics(request, reply) {
|
|
|
6867
7214
|
};
|
|
6868
7215
|
}
|
|
6869
7216
|
const semanticConfig = config.config;
|
|
6870
|
-
const client = new
|
|
7217
|
+
const client = new import_core28.SemanticMetricsClient(semanticConfig);
|
|
6871
7218
|
const metrics = await client.getDatasourceMetrics(datasourceId);
|
|
6872
7219
|
return {
|
|
6873
7220
|
success: true,
|
|
@@ -6883,11 +7230,11 @@ async function getDatasourceMetrics(request, reply) {
|
|
|
6883
7230
|
}
|
|
6884
7231
|
}
|
|
6885
7232
|
async function querySemanticMetrics(request, reply) {
|
|
6886
|
-
const tenantId =
|
|
7233
|
+
const tenantId = getTenantId12(request);
|
|
6887
7234
|
const { key } = request.params;
|
|
6888
7235
|
const body = request.body;
|
|
6889
7236
|
try {
|
|
6890
|
-
const storeLattice = (0,
|
|
7237
|
+
const storeLattice = (0, import_core28.getStoreLattice)("default", "metrics");
|
|
6891
7238
|
const store2 = storeLattice.store;
|
|
6892
7239
|
const config = await store2.getConfigByKey(tenantId, key);
|
|
6893
7240
|
if (!config) {
|
|
@@ -6912,7 +7259,7 @@ async function querySemanticMetrics(request, reply) {
|
|
|
6912
7259
|
};
|
|
6913
7260
|
}
|
|
6914
7261
|
const semanticConfig = config.config;
|
|
6915
|
-
const client = new
|
|
7262
|
+
const client = new import_core28.SemanticMetricsClient(semanticConfig);
|
|
6916
7263
|
const result = await client.semanticQuery(body);
|
|
6917
7264
|
const columnNames = result.columns.map((col) => col.name);
|
|
6918
7265
|
const allDataPoints = [];
|
|
@@ -6972,7 +7319,7 @@ async function testSemanticDataSources(request, reply) {
|
|
|
6972
7319
|
password: body.password,
|
|
6973
7320
|
headers: body.headers
|
|
6974
7321
|
};
|
|
6975
|
-
const client = new
|
|
7322
|
+
const client = new import_core28.SemanticMetricsClient(testConfig);
|
|
6976
7323
|
const datasources = await client.getDataSources();
|
|
6977
7324
|
return {
|
|
6978
7325
|
success: true,
|
|
@@ -7008,7 +7355,7 @@ async function testDatasourceMetrics(request, reply) {
|
|
|
7008
7355
|
password: body.password,
|
|
7009
7356
|
headers: body.headers
|
|
7010
7357
|
};
|
|
7011
|
-
const client = new
|
|
7358
|
+
const client = new import_core28.SemanticMetricsClient(testConfig);
|
|
7012
7359
|
const metrics = await client.getDatasourceMetrics(datasourceId);
|
|
7013
7360
|
return {
|
|
7014
7361
|
success: true,
|
|
@@ -7040,7 +7387,7 @@ function registerMetricsServerConfigRoutes(app2) {
|
|
|
7040
7387
|
}
|
|
7041
7388
|
|
|
7042
7389
|
// src/controllers/connections.ts
|
|
7043
|
-
var
|
|
7390
|
+
var import_core29 = require("@axiom-lattice/core");
|
|
7044
7391
|
var import_zod = require("zod");
|
|
7045
7392
|
var createBody = import_zod.z.object({
|
|
7046
7393
|
type: import_zod.z.string().min(1),
|
|
@@ -7081,7 +7428,7 @@ function maskSecrets(config) {
|
|
|
7081
7428
|
}
|
|
7082
7429
|
async function resolveConfig(type, body, tenantId) {
|
|
7083
7430
|
if (body.key) {
|
|
7084
|
-
const entry = await
|
|
7431
|
+
const entry = await import_core29.ConnectionRegistry.get(type, body.key, tenantId);
|
|
7085
7432
|
if (!entry) throw { status: 404, error: `Connection "${body.key}" not found` };
|
|
7086
7433
|
return entry.config;
|
|
7087
7434
|
}
|
|
@@ -7092,7 +7439,7 @@ function connectionRoutes(fastify2) {
|
|
|
7092
7439
|
fastify2.get("/api/connections", async (request, reply) => {
|
|
7093
7440
|
const { type } = request.query;
|
|
7094
7441
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7095
|
-
const entries = await
|
|
7442
|
+
const entries = await import_core29.ConnectionRegistry.list(type, getTenant(request));
|
|
7096
7443
|
return reply.send({
|
|
7097
7444
|
success: true,
|
|
7098
7445
|
data: { records: entries.map((e) => ({ ...e, config: maskSecrets(e.config) })), total: entries.length }
|
|
@@ -7100,7 +7447,7 @@ function connectionRoutes(fastify2) {
|
|
|
7100
7447
|
});
|
|
7101
7448
|
fastify2.post("/api/connections", async (request, reply) => {
|
|
7102
7449
|
const parsed = createBody.parse(request.body);
|
|
7103
|
-
const entry = await
|
|
7450
|
+
const entry = await import_core29.ConnectionRegistry.create({
|
|
7104
7451
|
tenantId: getTenant(request),
|
|
7105
7452
|
type: parsed.type,
|
|
7106
7453
|
key: parsed.key,
|
|
@@ -7119,7 +7466,7 @@ function connectionRoutes(fastify2) {
|
|
|
7119
7466
|
const { key } = request.params;
|
|
7120
7467
|
const body = request.body;
|
|
7121
7468
|
const tenantId = getTenant(request);
|
|
7122
|
-
const existing = await
|
|
7469
|
+
const existing = await import_core29.ConnectionRegistry.get(type, key, tenantId);
|
|
7123
7470
|
if (!existing) return reply.status(404).send({ error: "not found" });
|
|
7124
7471
|
const updates = {};
|
|
7125
7472
|
if (body.name !== void 0) updates.name = body.name;
|
|
@@ -7127,7 +7474,7 @@ function connectionRoutes(fastify2) {
|
|
|
7127
7474
|
if (body.config) {
|
|
7128
7475
|
updates.config = { ...existing.config, ...body.config };
|
|
7129
7476
|
}
|
|
7130
|
-
const entry = await
|
|
7477
|
+
const entry = await import_core29.ConnectionRegistry.update(tenantId, type, key, updates);
|
|
7131
7478
|
return reply.send({
|
|
7132
7479
|
success: true,
|
|
7133
7480
|
data: { ...entry, config: maskSecrets(entry?.config ?? {}) }
|
|
@@ -7137,13 +7484,13 @@ function connectionRoutes(fastify2) {
|
|
|
7137
7484
|
const { type } = request.query;
|
|
7138
7485
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7139
7486
|
const { key } = request.params;
|
|
7140
|
-
const ok = await
|
|
7487
|
+
const ok = await import_core29.ConnectionRegistry.delete(getTenant(request), type, key);
|
|
7141
7488
|
return reply.send({ success: ok });
|
|
7142
7489
|
});
|
|
7143
7490
|
fastify2.post("/api/connections/test", async (request, reply) => {
|
|
7144
7491
|
const { type } = request.query;
|
|
7145
7492
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7146
|
-
const plugin =
|
|
7493
|
+
const plugin = import_core29.PluginRegistry.get(type);
|
|
7147
7494
|
if (!plugin?.connection?.test) {
|
|
7148
7495
|
return reply.status(400).send({ error: "plugin does not support connection testing" });
|
|
7149
7496
|
}
|
|
@@ -7171,7 +7518,7 @@ function connectionRoutes(fastify2) {
|
|
|
7171
7518
|
fastify2.post("/api/connections/discover", async (request, reply) => {
|
|
7172
7519
|
const { type } = request.query;
|
|
7173
7520
|
if (!type) return reply.status(400).send({ error: "query 'type' required" });
|
|
7174
|
-
const plugin =
|
|
7521
|
+
const plugin = import_core29.PluginRegistry.get(type);
|
|
7175
7522
|
if (!plugin?.connection?.discover) {
|
|
7176
7523
|
return reply.status(400).send({ error: "plugin does not support resource discovery" });
|
|
7177
7524
|
}
|
|
@@ -7201,12 +7548,12 @@ function connectionRoutes(fastify2) {
|
|
|
7201
7548
|
init_mcp_configs();
|
|
7202
7549
|
|
|
7203
7550
|
// src/controllers/eval.ts
|
|
7204
|
-
var
|
|
7551
|
+
var import_core32 = require("@axiom-lattice/core");
|
|
7205
7552
|
var import_uuid5 = require("uuid");
|
|
7206
7553
|
|
|
7207
7554
|
// src/services/eval-runner.ts
|
|
7208
7555
|
var import_events = require("events");
|
|
7209
|
-
var
|
|
7556
|
+
var import_core31 = require("@axiom-lattice/core");
|
|
7210
7557
|
var import_uuid4 = require("uuid");
|
|
7211
7558
|
function mapLogs(logs) {
|
|
7212
7559
|
return logs.map((l) => ({
|
|
@@ -7265,12 +7612,12 @@ var EvalRunner = class {
|
|
|
7265
7612
|
const judgeModelKey = judgeCfg.modelKey || "";
|
|
7266
7613
|
let resolvedJudgeModelKey;
|
|
7267
7614
|
if (judgeModelKey) {
|
|
7268
|
-
if (!
|
|
7615
|
+
if (!import_core31.modelLatticeManager.hasLattice(judgeModelKey)) {
|
|
7269
7616
|
throw new Error(`Judge model "${judgeModelKey}" is not registered`);
|
|
7270
7617
|
}
|
|
7271
7618
|
resolvedJudgeModelKey = judgeModelKey;
|
|
7272
7619
|
} else {
|
|
7273
|
-
const firstModel =
|
|
7620
|
+
const firstModel = import_core31.modelLatticeManager.getAllLattices()[0];
|
|
7274
7621
|
if (!firstModel) {
|
|
7275
7622
|
throw new Error("No model registered \u2014 cannot run eval without a judge model");
|
|
7276
7623
|
}
|
|
@@ -7330,7 +7677,7 @@ var EvalRunner = class {
|
|
|
7330
7677
|
};
|
|
7331
7678
|
const runPromise = (async () => {
|
|
7332
7679
|
try {
|
|
7333
|
-
const evalProject = new
|
|
7680
|
+
const evalProject = new import_core31.LatticeEvalProject(projectConfig, onCaseComplete);
|
|
7334
7681
|
const { report } = await evalProject.runAllSuitesBatch(concurrency, abortController.signal);
|
|
7335
7682
|
if (!abortController.signal.aborted) {
|
|
7336
7683
|
const completedCount = stats.passed + stats.failed;
|
|
@@ -7384,13 +7731,13 @@ var EvalRunner = class {
|
|
|
7384
7731
|
return this.runs.has(runId);
|
|
7385
7732
|
}
|
|
7386
7733
|
getEvalStore() {
|
|
7387
|
-
return (0,
|
|
7734
|
+
return (0, import_core31.getStoreLattice)("default", "eval").store;
|
|
7388
7735
|
}
|
|
7389
7736
|
};
|
|
7390
7737
|
var evalRunner = new EvalRunner();
|
|
7391
7738
|
|
|
7392
7739
|
// src/controllers/eval.ts
|
|
7393
|
-
function
|
|
7740
|
+
function getTenantId14(request) {
|
|
7394
7741
|
const userTenantId = request.user?.tenantId;
|
|
7395
7742
|
if (userTenantId) {
|
|
7396
7743
|
return userTenantId;
|
|
@@ -7398,11 +7745,11 @@ function getTenantId13(request) {
|
|
|
7398
7745
|
return request.headers["x-tenant-id"] || "default";
|
|
7399
7746
|
}
|
|
7400
7747
|
function getEvalStore() {
|
|
7401
|
-
return (0,
|
|
7748
|
+
return (0, import_core32.getStoreLattice)("default", "eval").store;
|
|
7402
7749
|
}
|
|
7403
7750
|
async function createProject(request, reply) {
|
|
7404
7751
|
try {
|
|
7405
|
-
const tenantId =
|
|
7752
|
+
const tenantId = getTenantId14(request);
|
|
7406
7753
|
const store2 = getEvalStore();
|
|
7407
7754
|
const id = (0, import_uuid5.v4)();
|
|
7408
7755
|
const data = request.body;
|
|
@@ -7442,7 +7789,7 @@ async function createProject(request, reply) {
|
|
|
7442
7789
|
}
|
|
7443
7790
|
async function listProjects(request, reply) {
|
|
7444
7791
|
try {
|
|
7445
|
-
const tenantId =
|
|
7792
|
+
const tenantId = getTenantId14(request);
|
|
7446
7793
|
const store2 = getEvalStore();
|
|
7447
7794
|
let projects = await store2.getProjectsByTenant(tenantId);
|
|
7448
7795
|
if (projects.length === 0) {
|
|
@@ -7476,7 +7823,7 @@ async function listProjects(request, reply) {
|
|
|
7476
7823
|
}
|
|
7477
7824
|
async function getProject(request, reply) {
|
|
7478
7825
|
try {
|
|
7479
|
-
const tenantId =
|
|
7826
|
+
const tenantId = getTenantId14(request);
|
|
7480
7827
|
const store2 = getEvalStore();
|
|
7481
7828
|
const { pid } = request.params;
|
|
7482
7829
|
const project = await store2.getProjectById(tenantId, pid);
|
|
@@ -7496,7 +7843,7 @@ async function getProject(request, reply) {
|
|
|
7496
7843
|
}
|
|
7497
7844
|
async function updateProject(request, reply) {
|
|
7498
7845
|
try {
|
|
7499
|
-
const tenantId =
|
|
7846
|
+
const tenantId = getTenantId14(request);
|
|
7500
7847
|
const store2 = getEvalStore();
|
|
7501
7848
|
const { pid } = request.params;
|
|
7502
7849
|
const existing = await store2.getProjectById(tenantId, pid);
|
|
@@ -7539,7 +7886,7 @@ async function updateProject(request, reply) {
|
|
|
7539
7886
|
}
|
|
7540
7887
|
async function deleteProject(request, reply) {
|
|
7541
7888
|
try {
|
|
7542
|
-
const tenantId =
|
|
7889
|
+
const tenantId = getTenantId14(request);
|
|
7543
7890
|
const store2 = getEvalStore();
|
|
7544
7891
|
const { pid } = request.params;
|
|
7545
7892
|
const existing = await store2.getProjectById(tenantId, pid);
|
|
@@ -7558,7 +7905,7 @@ async function deleteProject(request, reply) {
|
|
|
7558
7905
|
}
|
|
7559
7906
|
async function createSuite(request, reply) {
|
|
7560
7907
|
try {
|
|
7561
|
-
const tenantId =
|
|
7908
|
+
const tenantId = getTenantId14(request);
|
|
7562
7909
|
const store2 = getEvalStore();
|
|
7563
7910
|
const { pid } = request.params;
|
|
7564
7911
|
const project = await store2.getProjectById(tenantId, pid);
|
|
@@ -7580,7 +7927,7 @@ async function createSuite(request, reply) {
|
|
|
7580
7927
|
}
|
|
7581
7928
|
async function updateSuite(request, reply) {
|
|
7582
7929
|
try {
|
|
7583
|
-
const tenantId =
|
|
7930
|
+
const tenantId = getTenantId14(request);
|
|
7584
7931
|
const store2 = getEvalStore();
|
|
7585
7932
|
const { sid } = request.params;
|
|
7586
7933
|
const existing = await store2.getSuiteById(tenantId, sid);
|
|
@@ -7600,7 +7947,7 @@ async function updateSuite(request, reply) {
|
|
|
7600
7947
|
}
|
|
7601
7948
|
async function deleteSuite(request, reply) {
|
|
7602
7949
|
try {
|
|
7603
|
-
const tenantId =
|
|
7950
|
+
const tenantId = getTenantId14(request);
|
|
7604
7951
|
const store2 = getEvalStore();
|
|
7605
7952
|
const { sid } = request.params;
|
|
7606
7953
|
const existing = await store2.getSuiteById(tenantId, sid);
|
|
@@ -7619,7 +7966,7 @@ async function deleteSuite(request, reply) {
|
|
|
7619
7966
|
}
|
|
7620
7967
|
async function createCase(request, reply) {
|
|
7621
7968
|
try {
|
|
7622
|
-
const tenantId =
|
|
7969
|
+
const tenantId = getTenantId14(request);
|
|
7623
7970
|
const store2 = getEvalStore();
|
|
7624
7971
|
const { sid } = request.params;
|
|
7625
7972
|
const suite = await store2.getSuiteById(tenantId, sid);
|
|
@@ -7648,7 +7995,7 @@ async function createCase(request, reply) {
|
|
|
7648
7995
|
}
|
|
7649
7996
|
async function listCasesForSuite(request, reply) {
|
|
7650
7997
|
try {
|
|
7651
|
-
const tenantId =
|
|
7998
|
+
const tenantId = getTenantId14(request);
|
|
7652
7999
|
const store2 = getEvalStore();
|
|
7653
8000
|
const { sid } = request.params;
|
|
7654
8001
|
const cases = await store2.getCasesBySuite(tenantId, sid);
|
|
@@ -7664,7 +8011,7 @@ async function listCasesForSuite(request, reply) {
|
|
|
7664
8011
|
}
|
|
7665
8012
|
async function updateCase(request, reply) {
|
|
7666
8013
|
try {
|
|
7667
|
-
const tenantId =
|
|
8014
|
+
const tenantId = getTenantId14(request);
|
|
7668
8015
|
const store2 = getEvalStore();
|
|
7669
8016
|
const { cid } = request.params;
|
|
7670
8017
|
const existing = await store2.getCaseById(tenantId, cid);
|
|
@@ -7684,7 +8031,7 @@ async function updateCase(request, reply) {
|
|
|
7684
8031
|
}
|
|
7685
8032
|
async function deleteCase(request, reply) {
|
|
7686
8033
|
try {
|
|
7687
|
-
const tenantId =
|
|
8034
|
+
const tenantId = getTenantId14(request);
|
|
7688
8035
|
const store2 = getEvalStore();
|
|
7689
8036
|
const { cid } = request.params;
|
|
7690
8037
|
const existing = await store2.getCaseById(tenantId, cid);
|
|
@@ -7716,7 +8063,7 @@ function registerEvalRoutes(app2) {
|
|
|
7716
8063
|
app2.delete("/api/eval/projects/:pid/suites/:sid/cases/:cid", deleteCase);
|
|
7717
8064
|
app2.post("/api/eval/projects/:pid/runs", async (request, reply) => {
|
|
7718
8065
|
try {
|
|
7719
|
-
const tenantId =
|
|
8066
|
+
const tenantId = getTenantId14(request);
|
|
7720
8067
|
const { pid } = request.params;
|
|
7721
8068
|
const runId = await evalRunner.startRun(tenantId, pid);
|
|
7722
8069
|
reply.status(202).send({ success: true, message: "Run started", data: { run_id: runId } });
|
|
@@ -7728,7 +8075,7 @@ function registerEvalRoutes(app2) {
|
|
|
7728
8075
|
});
|
|
7729
8076
|
app2.get("/api/eval/runs", async (request, reply) => {
|
|
7730
8077
|
try {
|
|
7731
|
-
const tenantId =
|
|
8078
|
+
const tenantId = getTenantId14(request);
|
|
7732
8079
|
const query = request.query;
|
|
7733
8080
|
const runs = await getEvalStore().getRunsByTenant(tenantId, { projectId: query.project_id, status: query.status });
|
|
7734
8081
|
reply.send({ success: true, message: "Ok", data: { records: runs, total: runs.length } });
|
|
@@ -7738,7 +8085,7 @@ function registerEvalRoutes(app2) {
|
|
|
7738
8085
|
});
|
|
7739
8086
|
app2.get("/api/eval/runs/:rid", async (request, reply) => {
|
|
7740
8087
|
try {
|
|
7741
|
-
const tenantId =
|
|
8088
|
+
const tenantId = getTenantId14(request);
|
|
7742
8089
|
const { rid } = request.params;
|
|
7743
8090
|
const run = await getEvalStore().getRunById(tenantId, rid);
|
|
7744
8091
|
if (!run) return reply.status(404).send({ success: false, message: "Run not found" });
|
|
@@ -7760,7 +8107,7 @@ function registerEvalRoutes(app2) {
|
|
|
7760
8107
|
const emitter = evalRunner.getEventEmitter();
|
|
7761
8108
|
const eventKey = `run:${rid}`;
|
|
7762
8109
|
if (!evalRunner.isRunning(rid)) {
|
|
7763
|
-
const tenantId =
|
|
8110
|
+
const tenantId = getTenantId14(request);
|
|
7764
8111
|
const run = await getEvalStore().getRunById(tenantId, rid);
|
|
7765
8112
|
if (run) {
|
|
7766
8113
|
const eventType = run.status === "completed" ? "completed" : "error";
|
|
@@ -7799,7 +8146,7 @@ data: ${JSON.stringify(event.data)}
|
|
|
7799
8146
|
});
|
|
7800
8147
|
app2.delete("/api/eval/runs/:rid", async (request, reply) => {
|
|
7801
8148
|
try {
|
|
7802
|
-
const tenantId =
|
|
8149
|
+
const tenantId = getTenantId14(request);
|
|
7803
8150
|
const { rid } = request.params;
|
|
7804
8151
|
const deleted = await getEvalStore().deleteRun(tenantId, rid);
|
|
7805
8152
|
if (!deleted) return reply.status(404).send({ success: false, message: "Run not found" });
|
|
@@ -7810,7 +8157,7 @@ data: ${JSON.stringify(event.data)}
|
|
|
7810
8157
|
});
|
|
7811
8158
|
app2.get("/api/eval/reports/projects/:pid", async (request, reply) => {
|
|
7812
8159
|
try {
|
|
7813
|
-
const tenantId =
|
|
8160
|
+
const tenantId = getTenantId14(request);
|
|
7814
8161
|
const { pid } = request.params;
|
|
7815
8162
|
const report = await getEvalStore().getProjectReport(tenantId, pid);
|
|
7816
8163
|
if (!report) return reply.status(404).send({ success: false, message: "Project not found" });
|
|
@@ -7822,11 +8169,11 @@ data: ${JSON.stringify(event.data)}
|
|
|
7822
8169
|
}
|
|
7823
8170
|
|
|
7824
8171
|
// src/controllers/users.ts
|
|
7825
|
-
var
|
|
8172
|
+
var import_core33 = require("@axiom-lattice/core");
|
|
7826
8173
|
var import_uuid6 = require("uuid");
|
|
7827
8174
|
var UsersController = class {
|
|
7828
8175
|
constructor() {
|
|
7829
|
-
this.userStore = (0,
|
|
8176
|
+
this.userStore = (0, import_core33.getStoreLattice)("default", "user").store;
|
|
7830
8177
|
}
|
|
7831
8178
|
async listUsers(request, reply) {
|
|
7832
8179
|
const { email } = request.query;
|
|
@@ -7904,11 +8251,11 @@ function registerUserRoutes(app2) {
|
|
|
7904
8251
|
}
|
|
7905
8252
|
|
|
7906
8253
|
// src/controllers/tenants.ts
|
|
7907
|
-
var
|
|
8254
|
+
var import_core34 = require("@axiom-lattice/core");
|
|
7908
8255
|
var import_uuid7 = require("uuid");
|
|
7909
8256
|
var TenantsController = class {
|
|
7910
8257
|
constructor() {
|
|
7911
|
-
this.tenantStore = (0,
|
|
8258
|
+
this.tenantStore = (0, import_core34.getStoreLattice)("default", "tenant").store;
|
|
7912
8259
|
}
|
|
7913
8260
|
// ==================== Tenant CRUD ====================
|
|
7914
8261
|
async listTenants(request, reply) {
|
|
@@ -7972,7 +8319,7 @@ function registerTenantRoutes(app2) {
|
|
|
7972
8319
|
}
|
|
7973
8320
|
|
|
7974
8321
|
// src/controllers/auth.ts
|
|
7975
|
-
var
|
|
8322
|
+
var import_core35 = require("@axiom-lattice/core");
|
|
7976
8323
|
var import_uuid8 = require("uuid");
|
|
7977
8324
|
var defaultAuthConfig = {
|
|
7978
8325
|
autoApproveUsers: true,
|
|
@@ -7981,9 +8328,9 @@ var defaultAuthConfig = {
|
|
|
7981
8328
|
};
|
|
7982
8329
|
var AuthController = class {
|
|
7983
8330
|
constructor(config = {}) {
|
|
7984
|
-
this.userStore = (0,
|
|
7985
|
-
this.tenantStore = (0,
|
|
7986
|
-
this.userTenantLinkStore = (0,
|
|
8331
|
+
this.userStore = (0, import_core35.getStoreLattice)("default", "user").store;
|
|
8332
|
+
this.tenantStore = (0, import_core35.getStoreLattice)("default", "tenant").store;
|
|
8333
|
+
this.userTenantLinkStore = (0, import_core35.getStoreLattice)("default", "userTenantLink").store;
|
|
7987
8334
|
this.config = { ...defaultAuthConfig, ...config };
|
|
7988
8335
|
}
|
|
7989
8336
|
async register(request, reply) {
|
|
@@ -8141,7 +8488,7 @@ var AuthController = class {
|
|
|
8141
8488
|
const linkMeta = link?.metadata || {};
|
|
8142
8489
|
let personalAssistant = null;
|
|
8143
8490
|
if (linkMeta.personalAssistantId) {
|
|
8144
|
-
const assistantStore = (0,
|
|
8491
|
+
const assistantStore = (0, import_core35.getStoreLattice)("default", "assistant").store;
|
|
8145
8492
|
const exists = await assistantStore.hasAssistant(tenantId, linkMeta.personalAssistantId);
|
|
8146
8493
|
if (exists) {
|
|
8147
8494
|
personalAssistant = {
|
|
@@ -8561,7 +8908,7 @@ var larkChannelAdapter = {
|
|
|
8561
8908
|
};
|
|
8562
8909
|
|
|
8563
8910
|
// src/channels/lark/verification.ts
|
|
8564
|
-
var
|
|
8911
|
+
var import_crypto8 = __toESM(require("crypto"));
|
|
8565
8912
|
function parseLarkRequestBody(body, encryptKey) {
|
|
8566
8913
|
const parsed = body || {};
|
|
8567
8914
|
if (encryptKey && typeof parsed.encrypt === "string") {
|
|
@@ -8570,11 +8917,11 @@ function parseLarkRequestBody(body, encryptKey) {
|
|
|
8570
8917
|
return parsed;
|
|
8571
8918
|
}
|
|
8572
8919
|
function decryptLarkPayload(encryptKey, encryptedPayload) {
|
|
8573
|
-
const key =
|
|
8920
|
+
const key = import_crypto8.default.createHash("sha256").update(encryptKey).digest();
|
|
8574
8921
|
const buffer = Buffer.from(encryptedPayload, "base64");
|
|
8575
8922
|
const iv = buffer.subarray(0, 16);
|
|
8576
8923
|
const ciphertext = buffer.subarray(16);
|
|
8577
|
-
const decipher =
|
|
8924
|
+
const decipher = import_crypto8.default.createDecipheriv("aes-256-cbc", key, iv);
|
|
8578
8925
|
const plaintext = Buffer.concat([
|
|
8579
8926
|
decipher.update(ciphertext),
|
|
8580
8927
|
decipher.final()
|
|
@@ -8691,14 +9038,14 @@ function registerChannelRoutes(app2, dependencies) {
|
|
|
8691
9038
|
}
|
|
8692
9039
|
|
|
8693
9040
|
// src/controllers/channel-installations.ts
|
|
8694
|
-
var
|
|
9041
|
+
var import_crypto9 = require("crypto");
|
|
8695
9042
|
var _adapterRegistry;
|
|
8696
9043
|
var _router;
|
|
8697
9044
|
function setChannelControllerDeps(deps) {
|
|
8698
9045
|
_adapterRegistry = deps.adapterRegistry;
|
|
8699
9046
|
_router = deps.router;
|
|
8700
9047
|
}
|
|
8701
|
-
function
|
|
9048
|
+
function getTenantId15(request) {
|
|
8702
9049
|
const userTenantId = request.user?.tenantId;
|
|
8703
9050
|
if (userTenantId) {
|
|
8704
9051
|
return userTenantId;
|
|
@@ -8706,8 +9053,8 @@ function getTenantId14(request) {
|
|
|
8706
9053
|
return request.headers["x-tenant-id"] || "default";
|
|
8707
9054
|
}
|
|
8708
9055
|
async function getInstallationStore() {
|
|
8709
|
-
const { getStoreLattice:
|
|
8710
|
-
const store2 =
|
|
9056
|
+
const { getStoreLattice: getStoreLattice31 } = await import("@axiom-lattice/core");
|
|
9057
|
+
const store2 = getStoreLattice31("default", "channelInstallation").store;
|
|
8711
9058
|
if (store2) return store2;
|
|
8712
9059
|
const { PostgreSQLChannelInstallationStore } = await import("@axiom-lattice/pg-stores");
|
|
8713
9060
|
const databaseUrl = process.env.DATABASE_URL;
|
|
@@ -8719,7 +9066,7 @@ async function getInstallationStore() {
|
|
|
8719
9066
|
});
|
|
8720
9067
|
}
|
|
8721
9068
|
async function getChannelInstallationList(request, reply) {
|
|
8722
|
-
const tenantId =
|
|
9069
|
+
const tenantId = getTenantId15(request);
|
|
8723
9070
|
const { channel } = request.query;
|
|
8724
9071
|
try {
|
|
8725
9072
|
const store2 = await getInstallationStore();
|
|
@@ -8745,7 +9092,7 @@ async function getChannelInstallationList(request, reply) {
|
|
|
8745
9092
|
}
|
|
8746
9093
|
}
|
|
8747
9094
|
async function getChannelInstallation(request, reply) {
|
|
8748
|
-
const tenantId =
|
|
9095
|
+
const tenantId = getTenantId15(request);
|
|
8749
9096
|
const { installationId } = request.params;
|
|
8750
9097
|
try {
|
|
8751
9098
|
const store2 = await getInstallationStore();
|
|
@@ -8778,7 +9125,7 @@ async function getChannelInstallation(request, reply) {
|
|
|
8778
9125
|
}
|
|
8779
9126
|
}
|
|
8780
9127
|
async function createChannelInstallation(request, reply) {
|
|
8781
|
-
const tenantId =
|
|
9128
|
+
const tenantId = getTenantId15(request);
|
|
8782
9129
|
const body = request.body;
|
|
8783
9130
|
try {
|
|
8784
9131
|
if (!body.channel) {
|
|
@@ -8813,7 +9160,7 @@ async function createChannelInstallation(request, reply) {
|
|
|
8813
9160
|
}
|
|
8814
9161
|
}
|
|
8815
9162
|
const store2 = await getInstallationStore();
|
|
8816
|
-
const installationId = body.id || (0,
|
|
9163
|
+
const installationId = body.id || (0, import_crypto9.randomUUID)();
|
|
8817
9164
|
const installation = await store2.createInstallation(
|
|
8818
9165
|
tenantId,
|
|
8819
9166
|
installationId,
|
|
@@ -8851,7 +9198,7 @@ async function createChannelInstallation(request, reply) {
|
|
|
8851
9198
|
}
|
|
8852
9199
|
}
|
|
8853
9200
|
async function updateChannelInstallation(request, reply) {
|
|
8854
|
-
const tenantId =
|
|
9201
|
+
const tenantId = getTenantId15(request);
|
|
8855
9202
|
const { installationId } = request.params;
|
|
8856
9203
|
const body = request.body;
|
|
8857
9204
|
try {
|
|
@@ -8905,7 +9252,7 @@ async function updateChannelInstallation(request, reply) {
|
|
|
8905
9252
|
}
|
|
8906
9253
|
}
|
|
8907
9254
|
async function deleteChannelInstallation(request, reply) {
|
|
8908
|
-
const tenantId =
|
|
9255
|
+
const tenantId = getTenantId15(request);
|
|
8909
9256
|
const { installationId } = request.params;
|
|
8910
9257
|
try {
|
|
8911
9258
|
const store2 = await getInstallationStore();
|
|
@@ -8965,17 +9312,17 @@ function registerChannelInstallationRoutes(app2) {
|
|
|
8965
9312
|
}
|
|
8966
9313
|
|
|
8967
9314
|
// src/controllers/channel-bindings.ts
|
|
8968
|
-
var
|
|
8969
|
-
function
|
|
9315
|
+
var import_core36 = require("@axiom-lattice/core");
|
|
9316
|
+
function getTenantId16(request) {
|
|
8970
9317
|
const userTenantId = request.user?.tenantId;
|
|
8971
9318
|
if (userTenantId) return userTenantId;
|
|
8972
9319
|
return request.headers["x-tenant-id"] || "default";
|
|
8973
9320
|
}
|
|
8974
9321
|
async function getBindingList(request, _reply) {
|
|
8975
|
-
const tenantId =
|
|
9322
|
+
const tenantId = getTenantId16(request);
|
|
8976
9323
|
const { channel, agentId, channelInstallationId, limit, offset } = request.query;
|
|
8977
9324
|
try {
|
|
8978
|
-
const registry = (0,
|
|
9325
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
8979
9326
|
const bindings = await registry.list({ channel, agentId, tenantId, channelInstallationId, limit, offset });
|
|
8980
9327
|
return { success: true, message: "Bindings retrieved", data: { records: bindings, total: bindings.length } };
|
|
8981
9328
|
} catch (error) {
|
|
@@ -8984,9 +9331,9 @@ async function getBindingList(request, _reply) {
|
|
|
8984
9331
|
}
|
|
8985
9332
|
}
|
|
8986
9333
|
async function getBinding(request, reply) {
|
|
8987
|
-
const tenantId =
|
|
9334
|
+
const tenantId = getTenantId16(request);
|
|
8988
9335
|
try {
|
|
8989
|
-
const registry = (0,
|
|
9336
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
8990
9337
|
const bindings = await registry.list({ tenantId });
|
|
8991
9338
|
const binding = bindings.find((b) => b.id === request.params.id);
|
|
8992
9339
|
if (!binding || binding.tenantId !== tenantId) {
|
|
@@ -9000,9 +9347,9 @@ async function getBinding(request, reply) {
|
|
|
9000
9347
|
}
|
|
9001
9348
|
}
|
|
9002
9349
|
async function createBinding(request, reply) {
|
|
9003
|
-
const tenantId =
|
|
9350
|
+
const tenantId = getTenantId16(request);
|
|
9004
9351
|
try {
|
|
9005
|
-
const registry = (0,
|
|
9352
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9006
9353
|
const binding = await registry.create({ ...request.body, tenantId });
|
|
9007
9354
|
reply.status(201);
|
|
9008
9355
|
return { success: true, message: "Binding created", data: binding };
|
|
@@ -9014,8 +9361,8 @@ async function createBinding(request, reply) {
|
|
|
9014
9361
|
}
|
|
9015
9362
|
async function updateBinding(request, reply) {
|
|
9016
9363
|
try {
|
|
9017
|
-
const tenantId =
|
|
9018
|
-
const registry = (0,
|
|
9364
|
+
const tenantId = getTenantId16(request);
|
|
9365
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9019
9366
|
const bindings = await registry.list({ tenantId });
|
|
9020
9367
|
const existing = bindings.find((b) => b.id === request.params.id);
|
|
9021
9368
|
if (!existing || existing.tenantId !== tenantId) {
|
|
@@ -9032,8 +9379,8 @@ async function updateBinding(request, reply) {
|
|
|
9032
9379
|
}
|
|
9033
9380
|
async function deleteBinding(request, reply) {
|
|
9034
9381
|
try {
|
|
9035
|
-
const tenantId =
|
|
9036
|
-
const registry = (0,
|
|
9382
|
+
const tenantId = getTenantId16(request);
|
|
9383
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9037
9384
|
const bindings = await registry.list({ tenantId });
|
|
9038
9385
|
const existing = bindings.find((b) => b.id === request.params.id);
|
|
9039
9386
|
if (!existing || existing.tenantId !== tenantId) {
|
|
@@ -9049,10 +9396,10 @@ async function deleteBinding(request, reply) {
|
|
|
9049
9396
|
}
|
|
9050
9397
|
}
|
|
9051
9398
|
async function resolveBinding(request, _reply) {
|
|
9052
|
-
const tenantId =
|
|
9399
|
+
const tenantId = getTenantId16(request);
|
|
9053
9400
|
const { channel, senderId, channelInstallationId } = request.query;
|
|
9054
9401
|
try {
|
|
9055
|
-
const registry = (0,
|
|
9402
|
+
const registry = (0, import_core36.getBindingRegistry)();
|
|
9056
9403
|
const binding = await registry.resolve({ channel, senderId, channelInstallationId, tenantId });
|
|
9057
9404
|
if (!binding) {
|
|
9058
9405
|
return { success: false, message: "No binding found", data: null };
|
|
@@ -9075,8 +9422,8 @@ function registerChannelBindingRoutes(app2) {
|
|
|
9075
9422
|
}
|
|
9076
9423
|
|
|
9077
9424
|
// src/controllers/menu-items.ts
|
|
9078
|
-
var
|
|
9079
|
-
function
|
|
9425
|
+
var import_core37 = require("@axiom-lattice/core");
|
|
9426
|
+
function getTenantId17(request) {
|
|
9080
9427
|
const userTenantId = request.user?.tenantId;
|
|
9081
9428
|
if (userTenantId) return userTenantId;
|
|
9082
9429
|
return request.headers["x-tenant-id"] || "default";
|
|
@@ -9085,9 +9432,9 @@ function errorMessage(err) {
|
|
|
9085
9432
|
return err instanceof Error ? err.message : "Unexpected error";
|
|
9086
9433
|
}
|
|
9087
9434
|
async function getMenuItemList(request, _reply) {
|
|
9088
|
-
const tenantId =
|
|
9435
|
+
const tenantId = getTenantId17(request);
|
|
9089
9436
|
try {
|
|
9090
|
-
const registry = (0,
|
|
9437
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9091
9438
|
const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget });
|
|
9092
9439
|
return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
|
|
9093
9440
|
} catch (error) {
|
|
@@ -9097,9 +9444,9 @@ async function getMenuItemList(request, _reply) {
|
|
|
9097
9444
|
}
|
|
9098
9445
|
}
|
|
9099
9446
|
async function getMenuItem(request, reply) {
|
|
9100
|
-
const tenantId =
|
|
9447
|
+
const tenantId = getTenantId17(request);
|
|
9101
9448
|
try {
|
|
9102
|
-
const registry = (0,
|
|
9449
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9103
9450
|
const item = await registry.getById(request.params.id);
|
|
9104
9451
|
if (!item || item.tenantId !== tenantId) {
|
|
9105
9452
|
reply.status(404);
|
|
@@ -9114,9 +9461,9 @@ async function getMenuItem(request, reply) {
|
|
|
9114
9461
|
}
|
|
9115
9462
|
}
|
|
9116
9463
|
async function createMenuItem(request, reply) {
|
|
9117
|
-
const tenantId =
|
|
9464
|
+
const tenantId = getTenantId17(request);
|
|
9118
9465
|
try {
|
|
9119
|
-
const registry = (0,
|
|
9466
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9120
9467
|
const item = await registry.create({ ...request.body, tenantId });
|
|
9121
9468
|
reply.status(201);
|
|
9122
9469
|
return { success: true, message: "Menu item created", data: item };
|
|
@@ -9129,8 +9476,8 @@ async function createMenuItem(request, reply) {
|
|
|
9129
9476
|
}
|
|
9130
9477
|
async function updateMenuItem(request, reply) {
|
|
9131
9478
|
try {
|
|
9132
|
-
const tenantId =
|
|
9133
|
-
const registry = (0,
|
|
9479
|
+
const tenantId = getTenantId17(request);
|
|
9480
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9134
9481
|
const existing = await registry.getById(request.params.id);
|
|
9135
9482
|
if (!existing || existing.tenantId !== tenantId) {
|
|
9136
9483
|
reply.status(404);
|
|
@@ -9147,8 +9494,8 @@ async function updateMenuItem(request, reply) {
|
|
|
9147
9494
|
}
|
|
9148
9495
|
async function deleteMenuItem(request, reply) {
|
|
9149
9496
|
try {
|
|
9150
|
-
const tenantId =
|
|
9151
|
-
const registry = (0,
|
|
9497
|
+
const tenantId = getTenantId17(request);
|
|
9498
|
+
const registry = (0, import_core37.getMenuRegistry)();
|
|
9152
9499
|
const existing = await registry.getById(request.params.id);
|
|
9153
9500
|
if (!existing || existing.tenantId !== tenantId) {
|
|
9154
9501
|
reply.status(404);
|
|
@@ -9586,6 +9933,31 @@ var registerLatticeRoutes = (app2, channelDeps) => {
|
|
|
9586
9933
|
"/api/assistants/:assistant_id/threads/:thread_id/pending-messages/:message_id",
|
|
9587
9934
|
removePendingMessageHandler
|
|
9588
9935
|
);
|
|
9936
|
+
app2.get("/api/tenants/exportable-types", getExportableTypes);
|
|
9937
|
+
app2.post(
|
|
9938
|
+
"/api/tenants/:tenantId/export",
|
|
9939
|
+
exportConfig
|
|
9940
|
+
);
|
|
9941
|
+
app2.post(
|
|
9942
|
+
"/api/tenants/:tenantId/export/confirm",
|
|
9943
|
+
exportConfigConfirm
|
|
9944
|
+
);
|
|
9945
|
+
app2.post(
|
|
9946
|
+
"/api/tenants/:tenantId/export/entities",
|
|
9947
|
+
previewEntities
|
|
9948
|
+
);
|
|
9949
|
+
app2.get(
|
|
9950
|
+
"/api/tenants/:tenantId/export/:jobId/download",
|
|
9951
|
+
downloadExport
|
|
9952
|
+
);
|
|
9953
|
+
app2.post(
|
|
9954
|
+
"/api/tenants/:tenantId/import/preview",
|
|
9955
|
+
importPreview
|
|
9956
|
+
);
|
|
9957
|
+
app2.post(
|
|
9958
|
+
"/api/tenants/:tenantId/import/apply",
|
|
9959
|
+
importApply
|
|
9960
|
+
);
|
|
9589
9961
|
};
|
|
9590
9962
|
|
|
9591
9963
|
// src/routes/resource-routes.ts
|
|
@@ -9614,20 +9986,1328 @@ function registerResourceRoutes(app2, controller) {
|
|
|
9614
9986
|
app2.delete("/api/resources/share/:token", controller.revokeShare.bind(controller));
|
|
9615
9987
|
}
|
|
9616
9988
|
|
|
9617
|
-
// src/
|
|
9618
|
-
var
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9989
|
+
// src/export_registrations/index.ts
|
|
9990
|
+
var import_core51 = require("@axiom-lattice/core");
|
|
9991
|
+
|
|
9992
|
+
// src/export_registrations/skill.registration.ts
|
|
9993
|
+
var import_core38 = require("@axiom-lattice/core");
|
|
9994
|
+
function getStore2() {
|
|
9995
|
+
return (0, import_core38.getStoreLattice)("default", "skill").store;
|
|
9996
|
+
}
|
|
9997
|
+
var skillRegistration = {
|
|
9998
|
+
entityType: "skill",
|
|
9999
|
+
label: "Skill(\u6280\u80FD)",
|
|
10000
|
+
category: "core",
|
|
10001
|
+
dependsOn: [],
|
|
10002
|
+
cascadeParents: [],
|
|
10003
|
+
async listForExport(tenantId) {
|
|
10004
|
+
const store2 = getStore2();
|
|
10005
|
+
const skills = await store2.getAllSkills(tenantId);
|
|
10006
|
+
return skills.map((s) => ({
|
|
10007
|
+
_exportId: "",
|
|
10008
|
+
data: {
|
|
10009
|
+
id: s.id,
|
|
10010
|
+
name: s.name,
|
|
10011
|
+
description: s.description,
|
|
10012
|
+
license: s.license,
|
|
10013
|
+
compatibility: s.compatibility,
|
|
10014
|
+
metadata: s.metadata,
|
|
10015
|
+
content: s.content,
|
|
10016
|
+
subSkills: s.subSkills
|
|
10017
|
+
}
|
|
10018
|
+
}));
|
|
10019
|
+
},
|
|
10020
|
+
async previewImport(tenantId, entities) {
|
|
10021
|
+
const store2 = getStore2();
|
|
10022
|
+
const existing = await store2.getAllSkills(tenantId);
|
|
10023
|
+
const existingIds = new Set(existing.map((s) => s.id));
|
|
10024
|
+
const conflicts = [];
|
|
10025
|
+
const insertions = [];
|
|
10026
|
+
for (const entity of entities) {
|
|
10027
|
+
const id = entity.data.id;
|
|
10028
|
+
if (existingIds.has(id)) {
|
|
10029
|
+
conflicts.push({
|
|
10030
|
+
_exportId: entity._exportId,
|
|
10031
|
+
entityType: "skill",
|
|
10032
|
+
conflictType: "id_exists",
|
|
10033
|
+
existingId: id,
|
|
10034
|
+
existingName: entity.data.name || id
|
|
10035
|
+
});
|
|
10036
|
+
} else {
|
|
10037
|
+
insertions.push({
|
|
10038
|
+
_exportId: entity._exportId,
|
|
10039
|
+
entityType: "skill",
|
|
10040
|
+
name: entity.data.name || id
|
|
10041
|
+
});
|
|
10042
|
+
}
|
|
10043
|
+
}
|
|
10044
|
+
return { conflicts, insertions, errors: [] };
|
|
10045
|
+
},
|
|
10046
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10047
|
+
const store2 = getStore2();
|
|
10048
|
+
const data = entity.data;
|
|
10049
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10050
|
+
if (resolution.action === "overwrite") {
|
|
10051
|
+
try {
|
|
10052
|
+
await store2.deleteSkill(tenantId, id);
|
|
10053
|
+
} catch {
|
|
10054
|
+
}
|
|
10055
|
+
}
|
|
10056
|
+
await store2.createSkill(tenantId, id, {
|
|
10057
|
+
name: data.name,
|
|
10058
|
+
description: data.description,
|
|
10059
|
+
license: data.license,
|
|
10060
|
+
compatibility: data.compatibility,
|
|
10061
|
+
metadata: data.metadata,
|
|
10062
|
+
content: data.content,
|
|
10063
|
+
subSkills: data.subSkills
|
|
10064
|
+
});
|
|
10065
|
+
return { newId: id };
|
|
10066
|
+
}
|
|
10067
|
+
};
|
|
10068
|
+
|
|
10069
|
+
// src/export_registrations/agent.registration.ts
|
|
10070
|
+
var import_core39 = require("@axiom-lattice/core");
|
|
10071
|
+
function getStore3() {
|
|
10072
|
+
return (0, import_core39.getStoreLattice)("default", "assistant").store;
|
|
10073
|
+
}
|
|
10074
|
+
var agentRegistration = {
|
|
10075
|
+
entityType: "agent",
|
|
10076
|
+
label: "Agent(\u667A\u80FD\u4F53)",
|
|
10077
|
+
category: "core",
|
|
10078
|
+
dependsOn: ["skill"],
|
|
10079
|
+
cascadeParents: [],
|
|
10080
|
+
async listForExport(tenantId) {
|
|
10081
|
+
const store2 = getStore3();
|
|
10082
|
+
const agents = await store2.getAllAssistants(tenantId);
|
|
10083
|
+
return agents.map((a) => ({
|
|
10084
|
+
_exportId: "",
|
|
10085
|
+
data: {
|
|
10086
|
+
id: a.id,
|
|
10087
|
+
name: a.name,
|
|
10088
|
+
description: a.description,
|
|
10089
|
+
graphDefinition: a.graphDefinition
|
|
10090
|
+
}
|
|
10091
|
+
}));
|
|
10092
|
+
},
|
|
10093
|
+
async previewImport(tenantId, entities) {
|
|
10094
|
+
const store2 = getStore3();
|
|
10095
|
+
const existing = await store2.getAllAssistants(tenantId);
|
|
10096
|
+
const existingIds = new Set(existing.map((a) => a.id));
|
|
10097
|
+
const conflicts = [];
|
|
10098
|
+
const insertions = [];
|
|
10099
|
+
for (const entity of entities) {
|
|
10100
|
+
const id = entity.data.id;
|
|
10101
|
+
if (existingIds.has(id)) {
|
|
10102
|
+
conflicts.push({
|
|
10103
|
+
_exportId: entity._exportId,
|
|
10104
|
+
entityType: "agent",
|
|
10105
|
+
conflictType: "id_exists",
|
|
10106
|
+
existingId: id,
|
|
10107
|
+
existingName: entity.data.name || id
|
|
10108
|
+
});
|
|
10109
|
+
} else {
|
|
10110
|
+
insertions.push({
|
|
10111
|
+
_exportId: entity._exportId,
|
|
10112
|
+
entityType: "agent",
|
|
10113
|
+
name: entity.data.name || id
|
|
10114
|
+
});
|
|
10115
|
+
}
|
|
10116
|
+
}
|
|
10117
|
+
return { conflicts, insertions, errors: [] };
|
|
10118
|
+
},
|
|
10119
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10120
|
+
const store2 = getStore3();
|
|
10121
|
+
const data = entity.data;
|
|
10122
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10123
|
+
if (resolution.action === "overwrite") {
|
|
10124
|
+
try {
|
|
10125
|
+
await store2.deleteAssistant(tenantId, id);
|
|
10126
|
+
} catch {
|
|
10127
|
+
}
|
|
10128
|
+
}
|
|
10129
|
+
await store2.createAssistant(tenantId, id, {
|
|
10130
|
+
name: data.name,
|
|
10131
|
+
description: data.description || "",
|
|
10132
|
+
graphDefinition: data.graphDefinition
|
|
10133
|
+
});
|
|
10134
|
+
return { newId: id };
|
|
10135
|
+
}
|
|
10136
|
+
};
|
|
10137
|
+
|
|
10138
|
+
// src/export_registrations/binding.registration.ts
|
|
10139
|
+
var import_core40 = require("@axiom-lattice/core");
|
|
10140
|
+
function getStore4() {
|
|
10141
|
+
return (0, import_core40.getStoreLattice)("default", "channelBinding").store;
|
|
10142
|
+
}
|
|
10143
|
+
var bindingRegistration = {
|
|
10144
|
+
entityType: "binding",
|
|
10145
|
+
label: "Binding(\u6E20\u9053\u7ED1\u5B9A)",
|
|
10146
|
+
category: "core",
|
|
10147
|
+
dependsOn: ["agent", "channel_installation"],
|
|
10148
|
+
cascadeParents: [],
|
|
10149
|
+
referenceFields: { agentId: "agent", channelInstallationId: "channel_installation" },
|
|
10150
|
+
async listForExport(tenantId) {
|
|
10151
|
+
const store2 = getStore4();
|
|
10152
|
+
const bindings = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10153
|
+
return bindings.map((b) => ({
|
|
10154
|
+
_exportId: "",
|
|
10155
|
+
data: {
|
|
10156
|
+
channel: b.channel,
|
|
10157
|
+
channelInstallationId: b.channelInstallationId,
|
|
10158
|
+
senderId: b.senderId,
|
|
10159
|
+
agentId: b.agentId,
|
|
10160
|
+
threadId: b.threadId,
|
|
10161
|
+
workspaceId: b.workspaceId,
|
|
10162
|
+
projectId: b.projectId,
|
|
10163
|
+
threadMode: b.threadMode,
|
|
10164
|
+
senderDisplayName: b.senderDisplayName,
|
|
10165
|
+
senderMetadata: b.senderMetadata,
|
|
10166
|
+
enabled: b.enabled
|
|
10167
|
+
}
|
|
10168
|
+
}));
|
|
10169
|
+
},
|
|
10170
|
+
async previewImport(tenantId, entities) {
|
|
10171
|
+
const store2 = getStore4();
|
|
10172
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10173
|
+
const existingKeys = new Set(
|
|
10174
|
+
existing.map((b) => `${b.channel}:${b.channelInstallationId}:${b.senderId}`)
|
|
10175
|
+
);
|
|
10176
|
+
const conflicts = [];
|
|
10177
|
+
const insertions = [];
|
|
10178
|
+
for (const entity of entities) {
|
|
10179
|
+
const d = entity.data;
|
|
10180
|
+
const key = `${d.channel}:${d.channelInstallationId}:${d.senderId}`;
|
|
10181
|
+
if (existingKeys.has(key)) {
|
|
10182
|
+
conflicts.push({
|
|
10183
|
+
_exportId: entity._exportId,
|
|
10184
|
+
entityType: "binding",
|
|
10185
|
+
conflictType: "unique_constraint",
|
|
10186
|
+
existingName: `${d.channel}:${d.senderId}`,
|
|
10187
|
+
field: "channel+channelInstallationId+senderId"
|
|
10188
|
+
});
|
|
10189
|
+
} else {
|
|
10190
|
+
insertions.push({
|
|
10191
|
+
_exportId: entity._exportId,
|
|
10192
|
+
entityType: "binding",
|
|
10193
|
+
name: `${d.channel}:${d.senderId}`
|
|
10194
|
+
});
|
|
10195
|
+
}
|
|
10196
|
+
}
|
|
10197
|
+
return { conflicts, insertions, errors: [] };
|
|
10198
|
+
},
|
|
10199
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10200
|
+
if (resolution.action === "skip") return {};
|
|
10201
|
+
const store2 = getStore4();
|
|
10202
|
+
const d = entity.data;
|
|
10203
|
+
if (resolution.action === "overwrite") {
|
|
10204
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10205
|
+
const match = existing.find(
|
|
10206
|
+
(b) => b.channel === d.channel && b.channelInstallationId === d.channelInstallationId && b.senderId === d.senderId
|
|
10207
|
+
);
|
|
10208
|
+
if (match) {
|
|
10209
|
+
await store2.delete(match.id);
|
|
10210
|
+
}
|
|
10211
|
+
}
|
|
10212
|
+
await store2.create({
|
|
10213
|
+
channel: d.channel,
|
|
10214
|
+
channelInstallationId: d.channelInstallationId,
|
|
10215
|
+
tenantId,
|
|
10216
|
+
senderId: d.senderId,
|
|
10217
|
+
agentId: d.agentId,
|
|
10218
|
+
threadMode: d.threadMode || "fixed",
|
|
10219
|
+
senderDisplayName: d.senderDisplayName,
|
|
10220
|
+
senderMetadata: d.senderMetadata,
|
|
10221
|
+
workspaceId: d.workspaceId,
|
|
10222
|
+
projectId: d.projectId
|
|
10223
|
+
});
|
|
10224
|
+
return { newId: void 0 };
|
|
10225
|
+
}
|
|
10226
|
+
};
|
|
10227
|
+
|
|
10228
|
+
// src/export_registrations/database-config.registration.ts
|
|
10229
|
+
var import_core41 = require("@axiom-lattice/core");
|
|
10230
|
+
function getStore5() {
|
|
10231
|
+
return (0, import_core41.getStoreLattice)("default", "database").store;
|
|
10232
|
+
}
|
|
10233
|
+
var databaseConfigRegistration = {
|
|
10234
|
+
entityType: "database_config",
|
|
10235
|
+
label: "Database Config(\u6570\u636E\u5E93\u914D\u7F6E)",
|
|
10236
|
+
category: "core",
|
|
10237
|
+
dependsOn: [],
|
|
10238
|
+
cascadeParents: [],
|
|
10239
|
+
async listForExport(tenantId) {
|
|
10240
|
+
const store2 = getStore5();
|
|
10241
|
+
const configs = await store2.getAllConfigs(tenantId);
|
|
10242
|
+
return configs.map((c) => ({
|
|
10243
|
+
_exportId: "",
|
|
10244
|
+
data: {
|
|
10245
|
+
id: c.id,
|
|
10246
|
+
key: c.key,
|
|
10247
|
+
name: c.name,
|
|
10248
|
+
description: c.description,
|
|
10249
|
+
config: c.config
|
|
10250
|
+
}
|
|
10251
|
+
}));
|
|
10252
|
+
},
|
|
10253
|
+
async previewImport(tenantId, entities) {
|
|
10254
|
+
const store2 = getStore5();
|
|
10255
|
+
const existing = await store2.getAllConfigs(tenantId);
|
|
10256
|
+
const existingIds = new Set(existing.map((c) => c.id));
|
|
10257
|
+
const existingKeys = new Set(existing.map((c) => c.key));
|
|
10258
|
+
const conflicts = [];
|
|
10259
|
+
const insertions = [];
|
|
10260
|
+
for (const entity of entities) {
|
|
10261
|
+
const d = entity.data;
|
|
10262
|
+
const id = d.id;
|
|
10263
|
+
const key = d.key;
|
|
10264
|
+
if (existingIds.has(id)) {
|
|
10265
|
+
conflicts.push({
|
|
10266
|
+
_exportId: entity._exportId,
|
|
10267
|
+
entityType: "database_config",
|
|
10268
|
+
conflictType: "id_exists",
|
|
10269
|
+
existingId: id,
|
|
10270
|
+
existingName: d.name || key
|
|
10271
|
+
});
|
|
10272
|
+
} else if (key && existingKeys.has(key)) {
|
|
10273
|
+
conflicts.push({
|
|
10274
|
+
_exportId: entity._exportId,
|
|
10275
|
+
entityType: "database_config",
|
|
10276
|
+
conflictType: "unique_constraint",
|
|
10277
|
+
existingName: d.name || key,
|
|
10278
|
+
field: "key"
|
|
10279
|
+
});
|
|
10280
|
+
} else {
|
|
10281
|
+
insertions.push({
|
|
10282
|
+
_exportId: entity._exportId,
|
|
10283
|
+
entityType: "database_config",
|
|
10284
|
+
name: d.name || key
|
|
10285
|
+
});
|
|
10286
|
+
}
|
|
10287
|
+
}
|
|
10288
|
+
return { conflicts, insertions, errors: [] };
|
|
10289
|
+
},
|
|
10290
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10291
|
+
const store2 = getStore5();
|
|
10292
|
+
const data = entity.data;
|
|
10293
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10294
|
+
if (resolution.action === "overwrite") {
|
|
10295
|
+
try {
|
|
10296
|
+
await store2.deleteConfig(tenantId, id);
|
|
10297
|
+
} catch {
|
|
10298
|
+
}
|
|
10299
|
+
}
|
|
10300
|
+
await store2.createConfig(tenantId, id, {
|
|
10301
|
+
key: data.key,
|
|
10302
|
+
name: data.name,
|
|
10303
|
+
description: data.description,
|
|
10304
|
+
config: data.config
|
|
10305
|
+
});
|
|
10306
|
+
return { newId: id };
|
|
10307
|
+
}
|
|
10308
|
+
};
|
|
10309
|
+
|
|
10310
|
+
// src/export_registrations/metrics-config.registration.ts
|
|
10311
|
+
var import_core42 = require("@axiom-lattice/core");
|
|
10312
|
+
function getStore6() {
|
|
10313
|
+
return (0, import_core42.getStoreLattice)("default", "metrics").store;
|
|
10314
|
+
}
|
|
10315
|
+
var metricsConfigRegistration = {
|
|
10316
|
+
entityType: "metrics_config",
|
|
10317
|
+
label: "Metrics Config(\u6307\u6807\u914D\u7F6E)",
|
|
10318
|
+
category: "core",
|
|
10319
|
+
dependsOn: [],
|
|
10320
|
+
cascadeParents: [],
|
|
10321
|
+
async listForExport(tenantId) {
|
|
10322
|
+
const store2 = getStore6();
|
|
10323
|
+
const configs = await store2.getAllConfigs(tenantId);
|
|
10324
|
+
return configs.map((c) => ({
|
|
10325
|
+
_exportId: "",
|
|
10326
|
+
data: {
|
|
10327
|
+
id: c.id,
|
|
10328
|
+
key: c.key,
|
|
10329
|
+
name: c.name,
|
|
10330
|
+
description: c.description,
|
|
10331
|
+
config: c.config
|
|
10332
|
+
}
|
|
10333
|
+
}));
|
|
10334
|
+
},
|
|
10335
|
+
async previewImport(tenantId, entities) {
|
|
10336
|
+
const store2 = getStore6();
|
|
10337
|
+
const existing = await store2.getAllConfigs(tenantId);
|
|
10338
|
+
const existingIds = new Set(existing.map((c) => c.id));
|
|
10339
|
+
const existingKeys = new Set(existing.map((c) => c.key));
|
|
10340
|
+
const conflicts = [];
|
|
10341
|
+
const insertions = [];
|
|
10342
|
+
for (const entity of entities) {
|
|
10343
|
+
const d = entity.data;
|
|
10344
|
+
const id = d.id;
|
|
10345
|
+
const key = d.key;
|
|
10346
|
+
if (existingIds.has(id)) {
|
|
10347
|
+
conflicts.push({
|
|
10348
|
+
_exportId: entity._exportId,
|
|
10349
|
+
entityType: "metrics_config",
|
|
10350
|
+
conflictType: "id_exists",
|
|
10351
|
+
existingId: id,
|
|
10352
|
+
existingName: d.name || key
|
|
10353
|
+
});
|
|
10354
|
+
} else if (key && existingKeys.has(key)) {
|
|
10355
|
+
conflicts.push({
|
|
10356
|
+
_exportId: entity._exportId,
|
|
10357
|
+
entityType: "metrics_config",
|
|
10358
|
+
conflictType: "unique_constraint",
|
|
10359
|
+
existingName: d.name || key,
|
|
10360
|
+
field: "key"
|
|
10361
|
+
});
|
|
10362
|
+
} else {
|
|
10363
|
+
insertions.push({
|
|
10364
|
+
_exportId: entity._exportId,
|
|
10365
|
+
entityType: "metrics_config",
|
|
10366
|
+
name: d.name || key
|
|
10367
|
+
});
|
|
10368
|
+
}
|
|
10369
|
+
}
|
|
10370
|
+
return { conflicts, insertions, errors: [] };
|
|
10371
|
+
},
|
|
10372
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10373
|
+
const store2 = getStore6();
|
|
10374
|
+
const data = entity.data;
|
|
10375
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10376
|
+
if (resolution.action === "overwrite") {
|
|
10377
|
+
try {
|
|
10378
|
+
await store2.deleteConfig(tenantId, id);
|
|
10379
|
+
} catch {
|
|
10380
|
+
}
|
|
10381
|
+
}
|
|
10382
|
+
await store2.createConfig(tenantId, id, {
|
|
10383
|
+
key: data.key,
|
|
10384
|
+
name: data.name,
|
|
10385
|
+
description: data.description,
|
|
10386
|
+
config: data.config
|
|
10387
|
+
});
|
|
10388
|
+
return { newId: id };
|
|
10389
|
+
}
|
|
10390
|
+
};
|
|
10391
|
+
|
|
10392
|
+
// src/export_registrations/mcp-config.registration.ts
|
|
10393
|
+
var import_core43 = require("@axiom-lattice/core");
|
|
10394
|
+
function getStore7() {
|
|
10395
|
+
return (0, import_core43.getStoreLattice)("default", "mcp").store;
|
|
10396
|
+
}
|
|
10397
|
+
var mcpConfigRegistration = {
|
|
10398
|
+
entityType: "mcp_config",
|
|
10399
|
+
label: "MCP Config(MCP\u914D\u7F6E)",
|
|
10400
|
+
category: "core",
|
|
10401
|
+
dependsOn: [],
|
|
10402
|
+
cascadeParents: [],
|
|
10403
|
+
async listForExport(tenantId) {
|
|
10404
|
+
const store2 = getStore7();
|
|
10405
|
+
const configs = await store2.getAllConfigs(tenantId);
|
|
10406
|
+
return configs.map((c) => ({
|
|
10407
|
+
_exportId: "",
|
|
10408
|
+
data: {
|
|
10409
|
+
id: c.id,
|
|
10410
|
+
key: c.key,
|
|
10411
|
+
name: c.name,
|
|
10412
|
+
description: c.description,
|
|
10413
|
+
config: c.config,
|
|
10414
|
+
selectedTools: c.selectedTools,
|
|
10415
|
+
status: c.status
|
|
10416
|
+
}
|
|
10417
|
+
}));
|
|
10418
|
+
},
|
|
10419
|
+
async previewImport(tenantId, entities) {
|
|
10420
|
+
const store2 = getStore7();
|
|
10421
|
+
const existing = await store2.getAllConfigs(tenantId);
|
|
10422
|
+
const existingIds = new Set(existing.map((c) => c.id));
|
|
10423
|
+
const existingKeys = new Set(existing.map((c) => c.key));
|
|
10424
|
+
const conflicts = [];
|
|
10425
|
+
const insertions = [];
|
|
10426
|
+
for (const entity of entities) {
|
|
10427
|
+
const d = entity.data;
|
|
10428
|
+
const id = d.id;
|
|
10429
|
+
const key = d.key;
|
|
10430
|
+
if (existingIds.has(id)) {
|
|
10431
|
+
conflicts.push({
|
|
10432
|
+
_exportId: entity._exportId,
|
|
10433
|
+
entityType: "mcp_config",
|
|
10434
|
+
conflictType: "id_exists",
|
|
10435
|
+
existingId: id,
|
|
10436
|
+
existingName: d.name || key
|
|
10437
|
+
});
|
|
10438
|
+
} else if (key && existingKeys.has(key)) {
|
|
10439
|
+
conflicts.push({
|
|
10440
|
+
_exportId: entity._exportId,
|
|
10441
|
+
entityType: "mcp_config",
|
|
10442
|
+
conflictType: "unique_constraint",
|
|
10443
|
+
existingName: d.name || key,
|
|
10444
|
+
field: "key"
|
|
10445
|
+
});
|
|
10446
|
+
} else {
|
|
10447
|
+
insertions.push({
|
|
10448
|
+
_exportId: entity._exportId,
|
|
10449
|
+
entityType: "mcp_config",
|
|
10450
|
+
name: d.name || key
|
|
10451
|
+
});
|
|
10452
|
+
}
|
|
10453
|
+
}
|
|
10454
|
+
return { conflicts, insertions, errors: [] };
|
|
10455
|
+
},
|
|
10456
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10457
|
+
const store2 = getStore7();
|
|
10458
|
+
const data = entity.data;
|
|
10459
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10460
|
+
if (resolution.action === "overwrite") {
|
|
10461
|
+
try {
|
|
10462
|
+
await store2.deleteConfig(tenantId, id);
|
|
10463
|
+
} catch {
|
|
10464
|
+
}
|
|
10465
|
+
}
|
|
10466
|
+
await store2.createConfig(tenantId, id, {
|
|
10467
|
+
key: data.key,
|
|
10468
|
+
name: data.name,
|
|
10469
|
+
description: data.description,
|
|
10470
|
+
config: data.config,
|
|
10471
|
+
selectedTools: data.selectedTools
|
|
10472
|
+
});
|
|
10473
|
+
return { newId: id };
|
|
10474
|
+
}
|
|
10475
|
+
};
|
|
10476
|
+
|
|
10477
|
+
// src/export_registrations/connection.registration.ts
|
|
10478
|
+
var import_core44 = require("@axiom-lattice/core");
|
|
10479
|
+
function getStore8() {
|
|
10480
|
+
return (0, import_core44.getStoreLattice)("default", "connection").store;
|
|
10481
|
+
}
|
|
10482
|
+
async function listAllConnections(tenantId) {
|
|
10483
|
+
const store2 = getStore8();
|
|
10484
|
+
if (typeof store2.listByTenant !== "function") {
|
|
10485
|
+
throw new Error("ConnectionStore.listByTenant is not implemented. SQL bypass removed \u2014 upgrade your store adapter.");
|
|
10486
|
+
}
|
|
10487
|
+
return store2.listByTenant(tenantId);
|
|
10488
|
+
}
|
|
10489
|
+
var connectionRegistration = {
|
|
10490
|
+
entityType: "connection",
|
|
10491
|
+
label: "Connection(\u8FDE\u63A5)",
|
|
10492
|
+
category: "core",
|
|
10493
|
+
dependsOn: [],
|
|
10494
|
+
cascadeParents: [],
|
|
10495
|
+
async listForExport(tenantId) {
|
|
10496
|
+
const connections2 = await listAllConnections(tenantId);
|
|
10497
|
+
return connections2.map((c) => ({
|
|
10498
|
+
_exportId: "",
|
|
10499
|
+
data: {
|
|
10500
|
+
id: c.id,
|
|
10501
|
+
type: c.type,
|
|
10502
|
+
key: c.key,
|
|
10503
|
+
name: c.name,
|
|
10504
|
+
description: c.description,
|
|
10505
|
+
config: c.config
|
|
10506
|
+
}
|
|
10507
|
+
}));
|
|
10508
|
+
},
|
|
10509
|
+
async previewImport(tenantId, entities) {
|
|
10510
|
+
const existing = await listAllConnections(tenantId);
|
|
10511
|
+
const existingCompositeKeys = new Set(
|
|
10512
|
+
existing.map((c) => `${c.type}:${c.key}`)
|
|
10513
|
+
);
|
|
10514
|
+
const conflicts = [];
|
|
10515
|
+
const insertions = [];
|
|
10516
|
+
for (const entity of entities) {
|
|
10517
|
+
const d = entity.data;
|
|
10518
|
+
const compositeKey = `${d.type}:${d.key}`;
|
|
10519
|
+
if (existingCompositeKeys.has(compositeKey)) {
|
|
10520
|
+
conflicts.push({
|
|
10521
|
+
_exportId: entity._exportId,
|
|
10522
|
+
entityType: "connection",
|
|
10523
|
+
conflictType: "unique_constraint",
|
|
10524
|
+
existingName: `${d.type}:${d.key}`,
|
|
10525
|
+
field: "type+key"
|
|
10526
|
+
});
|
|
10527
|
+
} else {
|
|
10528
|
+
insertions.push({
|
|
10529
|
+
_exportId: entity._exportId,
|
|
10530
|
+
entityType: "connection",
|
|
10531
|
+
name: `${d.type}:${d.key}`
|
|
10532
|
+
});
|
|
10533
|
+
}
|
|
10534
|
+
}
|
|
10535
|
+
return { conflicts, insertions, errors: [] };
|
|
10536
|
+
},
|
|
10537
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10538
|
+
if (resolution.action === "skip") return {};
|
|
10539
|
+
const store2 = getStore8();
|
|
10540
|
+
const d = entity.data;
|
|
10541
|
+
const type = d.type;
|
|
10542
|
+
const key = d.key;
|
|
10543
|
+
if (resolution.action === "overwrite") {
|
|
10544
|
+
try {
|
|
10545
|
+
await store2.delete(tenantId, type, key);
|
|
10546
|
+
} catch {
|
|
10547
|
+
}
|
|
10548
|
+
}
|
|
10549
|
+
await store2.create({
|
|
10550
|
+
tenantId,
|
|
10551
|
+
type,
|
|
10552
|
+
key,
|
|
10553
|
+
name: d.name,
|
|
10554
|
+
description: d.description,
|
|
10555
|
+
config: d.config
|
|
10556
|
+
});
|
|
10557
|
+
return { newId: void 0 };
|
|
10558
|
+
}
|
|
10559
|
+
};
|
|
10560
|
+
|
|
10561
|
+
// src/export_registrations/collection.registration.ts
|
|
10562
|
+
var import_core45 = require("@axiom-lattice/core");
|
|
10563
|
+
function getStore9() {
|
|
10564
|
+
return (0, import_core45.getStoreLattice)("default", "collection").store;
|
|
10565
|
+
}
|
|
10566
|
+
var collectionRegistration = {
|
|
10567
|
+
entityType: "collection",
|
|
10568
|
+
label: "Collection(\u77E5\u8BC6\u5E93)",
|
|
10569
|
+
category: "core",
|
|
10570
|
+
dependsOn: [],
|
|
10571
|
+
cascadeParents: [],
|
|
10572
|
+
async listForExport(tenantId) {
|
|
10573
|
+
const store2 = getStore9();
|
|
10574
|
+
const collections = await store2.getAllCollections(tenantId);
|
|
10575
|
+
return collections.map((c) => ({
|
|
10576
|
+
_exportId: "",
|
|
10577
|
+
data: {
|
|
10578
|
+
id: c.id,
|
|
10579
|
+
name: c.name,
|
|
10580
|
+
label: c.label,
|
|
10581
|
+
embeddingKey: c.embeddingKey,
|
|
10582
|
+
schema: c.schema
|
|
10583
|
+
}
|
|
10584
|
+
}));
|
|
10585
|
+
},
|
|
10586
|
+
async previewImport(tenantId, entities) {
|
|
10587
|
+
const store2 = getStore9();
|
|
10588
|
+
const existing = await store2.getAllCollections(tenantId);
|
|
10589
|
+
const existingNames = new Set(existing.map((c) => c.name));
|
|
10590
|
+
const conflicts = [];
|
|
10591
|
+
const insertions = [];
|
|
10592
|
+
for (const entity of entities) {
|
|
10593
|
+
const d = entity.data;
|
|
10594
|
+
const name = d.name;
|
|
10595
|
+
if (existingNames.has(name)) {
|
|
10596
|
+
conflicts.push({
|
|
10597
|
+
_exportId: entity._exportId,
|
|
10598
|
+
entityType: "collection",
|
|
10599
|
+
conflictType: "unique_constraint",
|
|
10600
|
+
existingName: name,
|
|
10601
|
+
field: "name"
|
|
10602
|
+
});
|
|
10603
|
+
} else {
|
|
10604
|
+
insertions.push({
|
|
10605
|
+
_exportId: entity._exportId,
|
|
10606
|
+
entityType: "collection",
|
|
10607
|
+
name
|
|
10608
|
+
});
|
|
10609
|
+
}
|
|
10610
|
+
}
|
|
10611
|
+
return { conflicts, insertions, errors: [] };
|
|
10612
|
+
},
|
|
10613
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10614
|
+
if (resolution.action === "skip") return {};
|
|
10615
|
+
const store2 = getStore9();
|
|
10616
|
+
const d = entity.data;
|
|
10617
|
+
const name = d.name;
|
|
10618
|
+
if (resolution.action === "overwrite") {
|
|
10619
|
+
try {
|
|
10620
|
+
await store2.deleteCollection(tenantId, name);
|
|
10621
|
+
} catch {
|
|
10622
|
+
}
|
|
10623
|
+
}
|
|
10624
|
+
await store2.createCollection(tenantId, {
|
|
10625
|
+
name,
|
|
10626
|
+
label: d.label,
|
|
10627
|
+
embeddingKey: d.embeddingKey,
|
|
10628
|
+
schema: d.schema
|
|
10629
|
+
});
|
|
10630
|
+
return { newId: void 0 };
|
|
10631
|
+
}
|
|
10632
|
+
};
|
|
10633
|
+
|
|
10634
|
+
// src/export_registrations/channel-installation.registration.ts
|
|
10635
|
+
var import_core46 = require("@axiom-lattice/core");
|
|
10636
|
+
function getStore10() {
|
|
10637
|
+
return (0, import_core46.getStoreLattice)("default", "channelInstallation").store;
|
|
10638
|
+
}
|
|
10639
|
+
var channelInstallationRegistration = {
|
|
10640
|
+
entityType: "channel_installation",
|
|
10641
|
+
label: "Channel Installation(\u6E20\u9053\u5B89\u88C5)",
|
|
10642
|
+
category: "core",
|
|
10643
|
+
dependsOn: ["agent"],
|
|
10644
|
+
cascadeParents: [],
|
|
10645
|
+
referenceFields: { fallbackAgentId: "agent" },
|
|
10646
|
+
async listForExport(tenantId) {
|
|
10647
|
+
const store2 = getStore10();
|
|
10648
|
+
const installations = await store2.getInstallationsByTenant(tenantId);
|
|
10649
|
+
return installations.map((i) => ({
|
|
10650
|
+
_exportId: "",
|
|
10651
|
+
data: {
|
|
10652
|
+
id: i.id,
|
|
10653
|
+
channel: i.channel,
|
|
10654
|
+
name: i.name,
|
|
10655
|
+
config: i.config,
|
|
10656
|
+
enabled: i.enabled,
|
|
10657
|
+
fallbackAgentId: i.fallbackAgentId,
|
|
10658
|
+
rejectWhenNoBinding: i.rejectWhenNoBinding
|
|
10659
|
+
}
|
|
10660
|
+
}));
|
|
10661
|
+
},
|
|
10662
|
+
async previewImport(tenantId, entities) {
|
|
10663
|
+
const store2 = getStore10();
|
|
10664
|
+
const existing = await store2.getInstallationsByTenant(tenantId);
|
|
10665
|
+
const existingIds = new Set(existing.map((i) => i.id));
|
|
10666
|
+
const conflicts = [];
|
|
10667
|
+
const insertions = [];
|
|
10668
|
+
for (const entity of entities) {
|
|
10669
|
+
const d = entity.data;
|
|
10670
|
+
const id = d.id;
|
|
10671
|
+
if (existingIds.has(id)) {
|
|
10672
|
+
conflicts.push({
|
|
10673
|
+
_exportId: entity._exportId,
|
|
10674
|
+
entityType: "channel_installation",
|
|
10675
|
+
conflictType: "id_exists",
|
|
10676
|
+
existingId: id,
|
|
10677
|
+
existingName: d.name || id
|
|
10678
|
+
});
|
|
10679
|
+
} else {
|
|
10680
|
+
insertions.push({
|
|
10681
|
+
_exportId: entity._exportId,
|
|
10682
|
+
entityType: "channel_installation",
|
|
10683
|
+
name: d.name || id
|
|
10684
|
+
});
|
|
10685
|
+
}
|
|
10686
|
+
}
|
|
10687
|
+
return { conflicts, insertions, errors: [] };
|
|
10688
|
+
},
|
|
10689
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10690
|
+
const store2 = getStore10();
|
|
10691
|
+
const data = entity.data;
|
|
10692
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10693
|
+
if (resolution.action === "overwrite") {
|
|
10694
|
+
try {
|
|
10695
|
+
await store2.deleteInstallation(tenantId, id);
|
|
10696
|
+
} catch {
|
|
10697
|
+
}
|
|
10698
|
+
}
|
|
10699
|
+
await store2.createInstallation(tenantId, id, {
|
|
10700
|
+
channel: data.channel,
|
|
10701
|
+
name: data.name,
|
|
10702
|
+
config: data.config,
|
|
10703
|
+
enabled: data.enabled,
|
|
10704
|
+
fallbackAgentId: data.fallbackAgentId,
|
|
10705
|
+
rejectWhenNoBinding: data.rejectWhenNoBinding
|
|
10706
|
+
});
|
|
10707
|
+
return { newId: id };
|
|
10708
|
+
}
|
|
10709
|
+
};
|
|
10710
|
+
|
|
10711
|
+
// src/export_registrations/menu.registration.ts
|
|
10712
|
+
var import_core47 = require("@axiom-lattice/core");
|
|
10713
|
+
function getStore11() {
|
|
10714
|
+
return (0, import_core47.getStoreLattice)("default", "menu").store;
|
|
10715
|
+
}
|
|
10716
|
+
var menuRegistration = {
|
|
10717
|
+
entityType: "menu",
|
|
10718
|
+
label: "Menu(\u83DC\u5355)",
|
|
10719
|
+
category: "core",
|
|
10720
|
+
dependsOn: ["agent"],
|
|
10721
|
+
cascadeParents: [],
|
|
10722
|
+
async listForExport(tenantId) {
|
|
10723
|
+
const store2 = getStore11();
|
|
10724
|
+
const menus = await store2.list({ tenantId });
|
|
10725
|
+
return menus.map((m) => ({
|
|
10726
|
+
_exportId: "",
|
|
10727
|
+
data: {
|
|
10728
|
+
id: m.id,
|
|
10729
|
+
menuTarget: m.menuTarget,
|
|
10730
|
+
group: m.group,
|
|
10731
|
+
name: m.name,
|
|
10732
|
+
icon: m.icon,
|
|
10733
|
+
sortOrder: m.sortOrder,
|
|
10734
|
+
contentType: m.contentType,
|
|
10735
|
+
contentConfig: m.contentConfig,
|
|
10736
|
+
enabled: m.enabled
|
|
10737
|
+
}
|
|
10738
|
+
}));
|
|
10739
|
+
},
|
|
10740
|
+
async previewImport(tenantId, entities) {
|
|
10741
|
+
const store2 = getStore11();
|
|
10742
|
+
const existing = await store2.list({ tenantId });
|
|
10743
|
+
const existingIds = new Set(existing.map((m) => m.id));
|
|
10744
|
+
const conflicts = [];
|
|
10745
|
+
const insertions = [];
|
|
10746
|
+
for (const entity of entities) {
|
|
10747
|
+
const d = entity.data;
|
|
10748
|
+
const id = d.id;
|
|
10749
|
+
if (existingIds.has(id)) {
|
|
10750
|
+
conflicts.push({
|
|
10751
|
+
_exportId: entity._exportId,
|
|
10752
|
+
entityType: "menu",
|
|
10753
|
+
conflictType: "id_exists",
|
|
10754
|
+
existingId: id,
|
|
10755
|
+
existingName: d.name || id
|
|
10756
|
+
});
|
|
10757
|
+
} else {
|
|
10758
|
+
insertions.push({
|
|
10759
|
+
_exportId: entity._exportId,
|
|
10760
|
+
entityType: "menu",
|
|
10761
|
+
name: d.name || id
|
|
10762
|
+
});
|
|
10763
|
+
}
|
|
10764
|
+
}
|
|
10765
|
+
return { conflicts, insertions, errors: [] };
|
|
10766
|
+
},
|
|
10767
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10768
|
+
const store2 = getStore11();
|
|
10769
|
+
const d = entity.data;
|
|
10770
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : d.id;
|
|
10771
|
+
if (resolution.action === "overwrite") {
|
|
10772
|
+
try {
|
|
10773
|
+
await store2.delete(id);
|
|
10774
|
+
} catch {
|
|
10775
|
+
}
|
|
10776
|
+
}
|
|
10777
|
+
await store2.create({
|
|
10778
|
+
tenantId,
|
|
10779
|
+
menuTarget: d.menuTarget,
|
|
10780
|
+
group: d.group,
|
|
10781
|
+
name: d.name,
|
|
10782
|
+
icon: d.icon,
|
|
10783
|
+
sortOrder: d.sortOrder,
|
|
10784
|
+
contentType: d.contentType,
|
|
10785
|
+
contentConfig: d.contentConfig
|
|
10786
|
+
});
|
|
10787
|
+
return { newId: void 0 };
|
|
10788
|
+
}
|
|
10789
|
+
};
|
|
10790
|
+
|
|
10791
|
+
// src/export_registrations/task.registration.ts
|
|
10792
|
+
var import_core48 = require("@axiom-lattice/core");
|
|
10793
|
+
function getStore12() {
|
|
10794
|
+
return (0, import_core48.getStoreLattice)("default", "task").store;
|
|
10795
|
+
}
|
|
10796
|
+
var taskRegistration = {
|
|
10797
|
+
entityType: "task",
|
|
10798
|
+
label: "Task(\u4EFB\u52A1)",
|
|
10799
|
+
category: "core",
|
|
10800
|
+
dependsOn: ["agent"],
|
|
10801
|
+
cascadeParents: [],
|
|
10802
|
+
referenceFields: { ownerId: "agent", parentId: "task" },
|
|
10803
|
+
async listForExport(tenantId) {
|
|
10804
|
+
const store2 = getStore12();
|
|
10805
|
+
const tasks = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10806
|
+
return tasks.map((t) => ({
|
|
10807
|
+
_exportId: "",
|
|
10808
|
+
data: {
|
|
10809
|
+
id: t.id,
|
|
10810
|
+
title: t.title,
|
|
10811
|
+
description: t.description,
|
|
10812
|
+
status: t.status,
|
|
10813
|
+
priority: t.priority,
|
|
10814
|
+
dueDate: t.dueDate,
|
|
10815
|
+
ownerType: t.ownerType,
|
|
10816
|
+
ownerId: t.ownerId,
|
|
10817
|
+
metadata: t.metadata,
|
|
10818
|
+
parentId: t.parentId,
|
|
10819
|
+
sourceId: t.sourceId,
|
|
10820
|
+
context: t.context
|
|
10821
|
+
}
|
|
10822
|
+
}));
|
|
10823
|
+
},
|
|
10824
|
+
async previewImport(tenantId, entities) {
|
|
10825
|
+
const store2 = getStore12();
|
|
10826
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10827
|
+
const existingIds = new Set(existing.map((t) => t.id));
|
|
10828
|
+
const conflicts = [];
|
|
10829
|
+
const insertions = [];
|
|
10830
|
+
for (const entity of entities) {
|
|
10831
|
+
const d = entity.data;
|
|
10832
|
+
const id = d.id;
|
|
10833
|
+
if (existingIds.has(id)) {
|
|
10834
|
+
conflicts.push({
|
|
10835
|
+
_exportId: entity._exportId,
|
|
10836
|
+
entityType: "task",
|
|
10837
|
+
conflictType: "id_exists",
|
|
10838
|
+
existingId: id,
|
|
10839
|
+
existingName: d.title || id
|
|
10840
|
+
});
|
|
10841
|
+
} else {
|
|
10842
|
+
insertions.push({
|
|
10843
|
+
_exportId: entity._exportId,
|
|
10844
|
+
entityType: "task",
|
|
10845
|
+
name: d.title || id
|
|
10846
|
+
});
|
|
10847
|
+
}
|
|
10848
|
+
}
|
|
10849
|
+
return { conflicts, insertions, errors: [] };
|
|
10850
|
+
},
|
|
10851
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10852
|
+
const store2 = getStore12();
|
|
10853
|
+
const data = entity.data;
|
|
10854
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : data.id;
|
|
10855
|
+
if (resolution.action === "overwrite") {
|
|
10856
|
+
try {
|
|
10857
|
+
await store2.delete(tenantId, id);
|
|
10858
|
+
} catch {
|
|
10859
|
+
}
|
|
10860
|
+
}
|
|
10861
|
+
await store2.create({
|
|
10862
|
+
tenantId,
|
|
10863
|
+
ownerType: data.ownerType || "user",
|
|
10864
|
+
ownerId: data.ownerId || "",
|
|
10865
|
+
title: data.title,
|
|
10866
|
+
description: data.description,
|
|
10867
|
+
status: data.status,
|
|
10868
|
+
priority: data.priority,
|
|
10869
|
+
dueDate: data.dueDate,
|
|
10870
|
+
metadata: data.metadata,
|
|
10871
|
+
parentId: data.parentId,
|
|
10872
|
+
sourceId: data.sourceId,
|
|
10873
|
+
context: data.context
|
|
10874
|
+
});
|
|
10875
|
+
return { newId: id };
|
|
10876
|
+
}
|
|
10877
|
+
};
|
|
10878
|
+
|
|
10879
|
+
// src/export_registrations/a2a-api-key.registration.ts
|
|
10880
|
+
var import_core49 = require("@axiom-lattice/core");
|
|
10881
|
+
function getStore13() {
|
|
10882
|
+
return (0, import_core49.getStoreLattice)("default", "a2aApiKey").store;
|
|
10883
|
+
}
|
|
10884
|
+
var a2aApiKeyRegistration = {
|
|
10885
|
+
entityType: "a2a_api_key",
|
|
10886
|
+
label: "A2A API Key(API\u5BC6\u94A5)",
|
|
10887
|
+
category: "core",
|
|
10888
|
+
dependsOn: [],
|
|
10889
|
+
cascadeParents: [],
|
|
10890
|
+
async listForExport(tenantId) {
|
|
10891
|
+
const store2 = getStore13();
|
|
10892
|
+
const keys = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10893
|
+
return keys.map((k) => ({
|
|
10894
|
+
_exportId: "",
|
|
10895
|
+
data: {
|
|
10896
|
+
id: k.id,
|
|
10897
|
+
tenantId: k.tenantId,
|
|
10898
|
+
projectId: k.projectId,
|
|
10899
|
+
workspaceId: k.workspaceId,
|
|
10900
|
+
label: k.label,
|
|
10901
|
+
enabled: k.enabled
|
|
10902
|
+
}
|
|
10903
|
+
}));
|
|
10904
|
+
},
|
|
10905
|
+
async previewImport(tenantId, entities) {
|
|
10906
|
+
const store2 = getStore13();
|
|
10907
|
+
const existing = await store2.list({ tenantId, limit: 1e4, offset: 0 });
|
|
10908
|
+
const existingIds = new Set(existing.map((k) => k.id));
|
|
10909
|
+
const conflicts = [];
|
|
10910
|
+
const insertions = [];
|
|
10911
|
+
for (const entity of entities) {
|
|
10912
|
+
const d = entity.data;
|
|
10913
|
+
const id = d.id;
|
|
10914
|
+
if (existingIds.has(id)) {
|
|
10915
|
+
conflicts.push({
|
|
10916
|
+
_exportId: entity._exportId,
|
|
10917
|
+
entityType: "a2a_api_key",
|
|
10918
|
+
conflictType: "id_exists",
|
|
10919
|
+
existingId: id,
|
|
10920
|
+
existingName: d.label || id
|
|
10921
|
+
});
|
|
10922
|
+
} else {
|
|
10923
|
+
insertions.push({
|
|
10924
|
+
_exportId: entity._exportId,
|
|
10925
|
+
entityType: "a2a_api_key",
|
|
10926
|
+
name: d.label || id
|
|
10927
|
+
});
|
|
10928
|
+
}
|
|
10929
|
+
}
|
|
10930
|
+
return { conflicts, insertions, errors: [] };
|
|
10931
|
+
},
|
|
10932
|
+
async applyImport(tenantId, entity, resolution) {
|
|
10933
|
+
if (resolution.action === "skip") return {};
|
|
10934
|
+
const store2 = getStore13();
|
|
10935
|
+
const d = entity.data;
|
|
10936
|
+
if (resolution.action === "overwrite") {
|
|
10937
|
+
try {
|
|
10938
|
+
await store2.delete(d.id);
|
|
10939
|
+
} catch {
|
|
10940
|
+
}
|
|
10941
|
+
}
|
|
10942
|
+
await store2.create({
|
|
10943
|
+
tenantId,
|
|
10944
|
+
projectId: d.projectId,
|
|
10945
|
+
workspaceId: d.workspaceId,
|
|
10946
|
+
label: d.label
|
|
10947
|
+
});
|
|
10948
|
+
return { newId: void 0 };
|
|
10949
|
+
}
|
|
10950
|
+
};
|
|
10951
|
+
|
|
10952
|
+
// src/export_registrations/eval.registration.ts
|
|
10953
|
+
var import_core50 = require("@axiom-lattice/core");
|
|
10954
|
+
function getStore14() {
|
|
10955
|
+
return (0, import_core50.getStoreLattice)("default", "eval").store;
|
|
10956
|
+
}
|
|
10957
|
+
var evalRegistration = {
|
|
10958
|
+
entityType: "eval",
|
|
10959
|
+
label: "Eval(\u8BC4\u4F30)",
|
|
10960
|
+
category: "core",
|
|
10961
|
+
dependsOn: [],
|
|
10962
|
+
cascadeParents: [],
|
|
10963
|
+
referenceFields: { suiteId: "eval_suite", projectId: "eval_project", runId: "eval_run", caseId: "eval_case" },
|
|
10964
|
+
async listForExport(tenantId) {
|
|
10965
|
+
const store2 = getStore14();
|
|
10966
|
+
const projects = await store2.getProjectsByTenant(tenantId);
|
|
10967
|
+
const entities = [];
|
|
10968
|
+
for (const project of projects) {
|
|
10969
|
+
entities.push({
|
|
10970
|
+
_exportId: "",
|
|
10971
|
+
data: {
|
|
10972
|
+
_subType: "eval_project",
|
|
10973
|
+
id: project.id,
|
|
10974
|
+
name: project.name,
|
|
10975
|
+
description: project.description,
|
|
10976
|
+
version: project.version,
|
|
10977
|
+
judgeModelConfig: project.judgeModelConfig,
|
|
10978
|
+
targetServerConfig: project.targetServerConfig,
|
|
10979
|
+
concurrency: project.concurrency,
|
|
10980
|
+
reportConfig: project.reportConfig
|
|
10981
|
+
}
|
|
10982
|
+
});
|
|
10983
|
+
const suites = await store2.getSuitesByProject(tenantId, project.id);
|
|
10984
|
+
for (const suite of suites) {
|
|
10985
|
+
entities.push({
|
|
10986
|
+
_exportId: "",
|
|
10987
|
+
data: {
|
|
10988
|
+
_subType: "eval_suite",
|
|
10989
|
+
id: suite.id,
|
|
10990
|
+
projectId: suite.projectId,
|
|
10991
|
+
name: suite.name
|
|
10992
|
+
}
|
|
10993
|
+
});
|
|
10994
|
+
const cases = await store2.getCasesBySuite(tenantId, suite.id);
|
|
10995
|
+
for (const c of cases) {
|
|
10996
|
+
entities.push({
|
|
10997
|
+
_exportId: "",
|
|
10998
|
+
data: {
|
|
10999
|
+
_subType: "eval_case",
|
|
11000
|
+
id: c.id,
|
|
11001
|
+
suiteId: c.suiteId,
|
|
11002
|
+
inputMessage: c.inputMessage,
|
|
11003
|
+
inputFiles: c.inputFiles,
|
|
11004
|
+
steps: c.steps,
|
|
11005
|
+
outputType: c.outputType,
|
|
11006
|
+
contentAssertion: c.contentAssertion,
|
|
11007
|
+
rubrics: c.rubrics
|
|
11008
|
+
}
|
|
11009
|
+
});
|
|
11010
|
+
}
|
|
11011
|
+
}
|
|
11012
|
+
const runs = await store2.getRunsByTenant(tenantId, { projectId: project.id });
|
|
11013
|
+
for (const run of runs) {
|
|
11014
|
+
entities.push({
|
|
11015
|
+
_exportId: "",
|
|
11016
|
+
data: {
|
|
11017
|
+
_subType: "eval_run",
|
|
11018
|
+
id: run.id,
|
|
11019
|
+
projectId: run.projectId,
|
|
11020
|
+
status: run.status,
|
|
11021
|
+
concurrency: run.concurrency,
|
|
11022
|
+
totalCases: run.totalCases,
|
|
11023
|
+
passedCases: run.passedCases,
|
|
11024
|
+
failedCases: run.failedCases,
|
|
11025
|
+
avgScore: run.avgScore,
|
|
11026
|
+
error: run.error
|
|
11027
|
+
}
|
|
11028
|
+
});
|
|
11029
|
+
const results = await store2.getResultsByRun(tenantId, run.id);
|
|
11030
|
+
for (const result of results) {
|
|
11031
|
+
entities.push({
|
|
11032
|
+
_exportId: "",
|
|
11033
|
+
data: {
|
|
11034
|
+
_subType: "eval_run_result",
|
|
11035
|
+
id: result.id,
|
|
11036
|
+
runId: result.runId,
|
|
11037
|
+
suiteName: result.suiteName,
|
|
11038
|
+
caseId: result.caseId,
|
|
11039
|
+
pass: result.pass,
|
|
11040
|
+
score: result.score,
|
|
11041
|
+
summary: result.summary,
|
|
11042
|
+
dimensionResults: result.dimensionResults,
|
|
11043
|
+
durationMs: result.durationMs,
|
|
11044
|
+
messages: result.messages,
|
|
11045
|
+
logs: result.logs,
|
|
11046
|
+
error: result.error
|
|
11047
|
+
}
|
|
11048
|
+
});
|
|
11049
|
+
}
|
|
11050
|
+
}
|
|
11051
|
+
}
|
|
11052
|
+
return entities;
|
|
11053
|
+
},
|
|
11054
|
+
async previewImport(tenantId, entities) {
|
|
11055
|
+
const store2 = getStore14();
|
|
11056
|
+
const existingProjects = await store2.getProjectsByTenant(tenantId);
|
|
11057
|
+
const existingProjectIds = new Set(existingProjects.map((p) => p.id));
|
|
11058
|
+
const existingProjectNames = new Set(existingProjects.map((p) => p.name));
|
|
11059
|
+
const existingSuites = /* @__PURE__ */ new Map();
|
|
11060
|
+
const existingSuiteIds = /* @__PURE__ */ new Set();
|
|
11061
|
+
const existingCaseIds = /* @__PURE__ */ new Set();
|
|
11062
|
+
const existingRunIds = /* @__PURE__ */ new Set();
|
|
11063
|
+
const existingResultIds = /* @__PURE__ */ new Set();
|
|
11064
|
+
for (const project of existingProjects) {
|
|
11065
|
+
const suites = await store2.getSuitesByProject(tenantId, project.id);
|
|
11066
|
+
existingSuites.set(project.id, new Set(suites.map((s) => `${s.projectId}:${s.name}`)));
|
|
11067
|
+
for (const s of suites) {
|
|
11068
|
+
existingSuiteIds.add(s.id);
|
|
11069
|
+
try {
|
|
11070
|
+
const cases = await store2.getCasesBySuite(tenantId, s.id);
|
|
11071
|
+
for (const c of cases) existingCaseIds.add(c.id);
|
|
11072
|
+
} catch {
|
|
11073
|
+
}
|
|
11074
|
+
}
|
|
11075
|
+
}
|
|
11076
|
+
for (const project of existingProjects) {
|
|
11077
|
+
const runs = await store2.getRunsByTenant(tenantId, { projectId: project.id });
|
|
11078
|
+
for (const run of runs) {
|
|
11079
|
+
existingRunIds.add(run.id);
|
|
11080
|
+
try {
|
|
11081
|
+
const results = await store2.getResultsByRun(tenantId, run.id);
|
|
11082
|
+
for (const r of results) existingResultIds.add(r.id);
|
|
11083
|
+
} catch {
|
|
11084
|
+
}
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
11087
|
+
const conflicts = [];
|
|
11088
|
+
const insertions = [];
|
|
11089
|
+
for (const entity of entities) {
|
|
11090
|
+
const d = entity.data;
|
|
11091
|
+
const subType = d._subType;
|
|
11092
|
+
const id = d.id;
|
|
11093
|
+
switch (subType) {
|
|
11094
|
+
case "eval_project": {
|
|
11095
|
+
const name = d.name;
|
|
11096
|
+
if (existingProjectIds.has(id)) {
|
|
11097
|
+
conflicts.push({
|
|
11098
|
+
_exportId: entity._exportId,
|
|
11099
|
+
entityType: "eval_project",
|
|
11100
|
+
conflictType: "id_exists",
|
|
11101
|
+
existingId: id,
|
|
11102
|
+
existingName: name
|
|
11103
|
+
});
|
|
11104
|
+
} else if (name && existingProjectNames.has(name)) {
|
|
11105
|
+
conflicts.push({
|
|
11106
|
+
_exportId: entity._exportId,
|
|
11107
|
+
entityType: "eval_project",
|
|
11108
|
+
conflictType: "unique_constraint",
|
|
11109
|
+
existingName: name,
|
|
11110
|
+
field: "name"
|
|
11111
|
+
});
|
|
11112
|
+
} else {
|
|
11113
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_project", name });
|
|
11114
|
+
}
|
|
11115
|
+
break;
|
|
11116
|
+
}
|
|
11117
|
+
case "eval_suite": {
|
|
11118
|
+
const projectId = d.projectId;
|
|
11119
|
+
const name = d.name;
|
|
11120
|
+
const suiteKey = `${projectId}:${name}`;
|
|
11121
|
+
const projectSuites = existingSuites.get(projectId);
|
|
11122
|
+
if (existingSuiteIds.has(id)) {
|
|
11123
|
+
conflicts.push({
|
|
11124
|
+
_exportId: entity._exportId,
|
|
11125
|
+
entityType: "eval_suite",
|
|
11126
|
+
conflictType: "id_exists",
|
|
11127
|
+
existingId: id,
|
|
11128
|
+
existingName: name
|
|
11129
|
+
});
|
|
11130
|
+
} else if (projectSuites?.has(suiteKey)) {
|
|
11131
|
+
conflicts.push({
|
|
11132
|
+
_exportId: entity._exportId,
|
|
11133
|
+
entityType: "eval_suite",
|
|
11134
|
+
conflictType: "unique_constraint",
|
|
11135
|
+
existingName: name,
|
|
11136
|
+
field: "projectId+name"
|
|
11137
|
+
});
|
|
11138
|
+
} else {
|
|
11139
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_suite", name });
|
|
11140
|
+
}
|
|
11141
|
+
break;
|
|
11142
|
+
}
|
|
11143
|
+
case "eval_case": {
|
|
11144
|
+
if (existingCaseIds.has(id)) {
|
|
11145
|
+
conflicts.push({
|
|
11146
|
+
_exportId: entity._exportId,
|
|
11147
|
+
entityType: "eval_case",
|
|
11148
|
+
conflictType: "id_exists",
|
|
11149
|
+
existingId: id
|
|
11150
|
+
});
|
|
11151
|
+
} else {
|
|
11152
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_case", name: id });
|
|
11153
|
+
}
|
|
11154
|
+
break;
|
|
11155
|
+
}
|
|
11156
|
+
case "eval_run": {
|
|
11157
|
+
if (existingRunIds.has(id)) {
|
|
11158
|
+
conflicts.push({
|
|
11159
|
+
_exportId: entity._exportId,
|
|
11160
|
+
entityType: "eval_run",
|
|
11161
|
+
conflictType: "id_exists",
|
|
11162
|
+
existingId: id
|
|
11163
|
+
});
|
|
11164
|
+
} else {
|
|
11165
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_run", name: id });
|
|
11166
|
+
}
|
|
11167
|
+
break;
|
|
11168
|
+
}
|
|
11169
|
+
case "eval_run_result": {
|
|
11170
|
+
if (existingResultIds.has(id)) {
|
|
11171
|
+
conflicts.push({
|
|
11172
|
+
_exportId: entity._exportId,
|
|
11173
|
+
entityType: "eval_run_result",
|
|
11174
|
+
conflictType: "id_exists",
|
|
11175
|
+
existingId: id
|
|
11176
|
+
});
|
|
11177
|
+
} else {
|
|
11178
|
+
insertions.push({ _exportId: entity._exportId, entityType: "eval_run_result", name: id });
|
|
11179
|
+
}
|
|
11180
|
+
break;
|
|
11181
|
+
}
|
|
11182
|
+
}
|
|
11183
|
+
}
|
|
11184
|
+
return { conflicts, insertions, errors: [] };
|
|
11185
|
+
},
|
|
11186
|
+
async applyImport(tenantId, entity, resolution) {
|
|
11187
|
+
if (resolution.action === "skip") return {};
|
|
11188
|
+
const store2 = getStore14();
|
|
11189
|
+
const d = entity.data;
|
|
11190
|
+
const subType = d._subType;
|
|
11191
|
+
const id = resolution.action === "rename" && resolution.newId ? resolution.newId : d.id;
|
|
11192
|
+
switch (subType) {
|
|
11193
|
+
case "eval_project": {
|
|
11194
|
+
if (resolution.action === "overwrite") {
|
|
11195
|
+
try {
|
|
11196
|
+
await store2.deleteProject(tenantId, id);
|
|
11197
|
+
} catch {
|
|
11198
|
+
}
|
|
11199
|
+
}
|
|
11200
|
+
await store2.createProject(tenantId, id, {
|
|
11201
|
+
name: d.name,
|
|
11202
|
+
description: d.description,
|
|
11203
|
+
version: d.version,
|
|
11204
|
+
judgeModelConfig: d.judgeModelConfig,
|
|
11205
|
+
targetServerConfig: d.targetServerConfig,
|
|
11206
|
+
concurrency: d.concurrency,
|
|
11207
|
+
reportConfig: d.reportConfig
|
|
11208
|
+
});
|
|
11209
|
+
break;
|
|
11210
|
+
}
|
|
11211
|
+
case "eval_suite": {
|
|
11212
|
+
if (resolution.action === "overwrite") {
|
|
11213
|
+
try {
|
|
11214
|
+
await store2.deleteSuite(tenantId, id);
|
|
11215
|
+
} catch {
|
|
11216
|
+
}
|
|
11217
|
+
}
|
|
11218
|
+
await store2.createSuite(tenantId, d.projectId, id, {
|
|
11219
|
+
name: d.name
|
|
11220
|
+
});
|
|
11221
|
+
break;
|
|
11222
|
+
}
|
|
11223
|
+
case "eval_case": {
|
|
11224
|
+
if (resolution.action === "overwrite") {
|
|
11225
|
+
try {
|
|
11226
|
+
await store2.deleteCase(tenantId, id);
|
|
11227
|
+
} catch {
|
|
11228
|
+
}
|
|
11229
|
+
}
|
|
11230
|
+
await store2.createCase(tenantId, d.suiteId, id, {
|
|
11231
|
+
inputMessage: d.inputMessage,
|
|
11232
|
+
inputFiles: d.inputFiles,
|
|
11233
|
+
steps: d.steps,
|
|
11234
|
+
outputType: d.outputType,
|
|
11235
|
+
contentAssertion: d.contentAssertion,
|
|
11236
|
+
rubrics: d.rubrics
|
|
11237
|
+
});
|
|
11238
|
+
break;
|
|
11239
|
+
}
|
|
11240
|
+
case "eval_run": {
|
|
11241
|
+
if (resolution.action === "overwrite") {
|
|
11242
|
+
try {
|
|
11243
|
+
await store2.deleteRun(tenantId, id);
|
|
11244
|
+
} catch {
|
|
11245
|
+
}
|
|
11246
|
+
}
|
|
11247
|
+
await store2.createRun(tenantId, d.projectId, id, {
|
|
11248
|
+
totalCases: d.totalCases,
|
|
11249
|
+
concurrency: d.concurrency
|
|
11250
|
+
});
|
|
11251
|
+
break;
|
|
11252
|
+
}
|
|
11253
|
+
case "eval_run_result": {
|
|
11254
|
+
if (resolution.action === "overwrite") {
|
|
11255
|
+
try {
|
|
11256
|
+
await store2.deleteRunResult(tenantId, entity.data.id);
|
|
11257
|
+
} catch {
|
|
11258
|
+
}
|
|
11259
|
+
}
|
|
11260
|
+
await store2.createRunResult(tenantId, d.runId, id, {
|
|
11261
|
+
suiteName: d.suiteName,
|
|
11262
|
+
caseId: d.caseId,
|
|
11263
|
+
pass: d.pass,
|
|
11264
|
+
score: d.score,
|
|
11265
|
+
summary: d.summary,
|
|
11266
|
+
dimensionResults: d.dimensionResults,
|
|
11267
|
+
durationMs: d.durationMs,
|
|
11268
|
+
messages: d.messages,
|
|
11269
|
+
logs: d.logs,
|
|
11270
|
+
error: d.error
|
|
11271
|
+
});
|
|
11272
|
+
break;
|
|
11273
|
+
}
|
|
11274
|
+
}
|
|
11275
|
+
return { newId: id };
|
|
11276
|
+
}
|
|
11277
|
+
};
|
|
11278
|
+
|
|
11279
|
+
// src/export_registrations/index.ts
|
|
11280
|
+
function registerAllBuiltinEntities() {
|
|
11281
|
+
const registry = import_core51.ExportableEntityRegistry.getInstance();
|
|
11282
|
+
registry.register(skillRegistration);
|
|
11283
|
+
registry.register(agentRegistration);
|
|
11284
|
+
registry.register(bindingRegistration);
|
|
11285
|
+
registry.register(databaseConfigRegistration);
|
|
11286
|
+
registry.register(metricsConfigRegistration);
|
|
11287
|
+
registry.register(mcpConfigRegistration);
|
|
11288
|
+
registry.register(connectionRegistration);
|
|
11289
|
+
registry.register(collectionRegistration);
|
|
11290
|
+
registry.register(channelInstallationRegistration);
|
|
11291
|
+
registry.register(menuRegistration);
|
|
11292
|
+
registry.register(taskRegistration);
|
|
11293
|
+
registry.register(a2aApiKeyRegistration);
|
|
11294
|
+
registry.register(evalRegistration);
|
|
11295
|
+
}
|
|
11296
|
+
|
|
11297
|
+
// src/router/MessageRouter.ts
|
|
11298
|
+
var import_core52 = require("@axiom-lattice/core");
|
|
11299
|
+
var import_crypto10 = require("crypto");
|
|
11300
|
+
var BindingNotFoundError = class extends Error {
|
|
11301
|
+
constructor(message) {
|
|
11302
|
+
super(message);
|
|
11303
|
+
this.name = "BindingNotFoundError";
|
|
11304
|
+
}
|
|
11305
|
+
};
|
|
11306
|
+
var MessageRouter = class {
|
|
11307
|
+
constructor(config) {
|
|
11308
|
+
/**
|
|
11309
|
+
* Tracks reply subscriptions per thread+channel to avoid duplicate
|
|
11310
|
+
* `subscribeOnce` registrations and ensure proper cleanup.
|
|
9631
11311
|
*
|
|
9632
11312
|
* Key format: `{threadId}:{adapterChannel}:reply`
|
|
9633
11313
|
*/
|
|
@@ -9776,7 +11456,7 @@ var MessageRouter = class {
|
|
|
9776
11456
|
channel: message.channel,
|
|
9777
11457
|
adapterChannel: adapter.channel
|
|
9778
11458
|
}, "Thread resolved by adapter strategy");
|
|
9779
|
-
const threadStore = (0,
|
|
11459
|
+
const threadStore = (0, import_core52.getStoreLattice)("default", "thread").store;
|
|
9780
11460
|
try {
|
|
9781
11461
|
await threadStore.createThread(
|
|
9782
11462
|
tenantId,
|
|
@@ -9813,8 +11493,8 @@ var MessageRouter = class {
|
|
|
9813
11493
|
}
|
|
9814
11494
|
}
|
|
9815
11495
|
if (!threadId) {
|
|
9816
|
-
const threadStore = (0,
|
|
9817
|
-
const newThreadId = (0,
|
|
11496
|
+
const threadStore = (0, import_core52.getStoreLattice)("default", "thread").store;
|
|
11497
|
+
const newThreadId = (0, import_crypto10.randomUUID)();
|
|
9818
11498
|
console.log({
|
|
9819
11499
|
event: "dispatch:thread:create",
|
|
9820
11500
|
agentId,
|
|
@@ -9853,7 +11533,7 @@ var MessageRouter = class {
|
|
|
9853
11533
|
senderId: message.sender.id,
|
|
9854
11534
|
contentLength: message.content.text.length
|
|
9855
11535
|
}, "Dispatching to agent");
|
|
9856
|
-
const agent =
|
|
11536
|
+
const agent = import_core52.agentInstanceManager.getAgent({
|
|
9857
11537
|
tenant_id: tenantId,
|
|
9858
11538
|
assistant_id: agentId,
|
|
9859
11539
|
thread_id: threadId,
|
|
@@ -10098,7 +11778,7 @@ function createAuditLoggerMiddleware() {
|
|
|
10098
11778
|
}
|
|
10099
11779
|
|
|
10100
11780
|
// src/index.ts
|
|
10101
|
-
var
|
|
11781
|
+
var import_core56 = require("@axiom-lattice/core");
|
|
10102
11782
|
|
|
10103
11783
|
// src/swagger.ts
|
|
10104
11784
|
var import_swagger = __toESM(require("@fastify/swagger"));
|
|
@@ -10163,7 +11843,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
10163
11843
|
};
|
|
10164
11844
|
|
|
10165
11845
|
// src/services/agent_task_consumer.ts
|
|
10166
|
-
var
|
|
11846
|
+
var import_core53 = require("@axiom-lattice/core");
|
|
10167
11847
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
10168
11848
|
const {
|
|
10169
11849
|
assistant_id,
|
|
@@ -10181,17 +11861,17 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
10181
11861
|
console.log(
|
|
10182
11862
|
`\u5F00\u59CB\u5904\u7406\u4EFB\u52A1 [assistant_id: ${assistant_id}, thread_id: ${thread_id}]`
|
|
10183
11863
|
);
|
|
10184
|
-
const agent =
|
|
10185
|
-
await agent.addMessage({ input, command, custom_run_config: runConfig },
|
|
11864
|
+
const agent = import_core53.agentInstanceManager.getAgent({ assistant_id, thread_id, tenant_id, workspace_id: runConfig?.workspaceId, project_id: runConfig?.projectId, custom_run_config: runConfig });
|
|
11865
|
+
await agent.addMessage({ input, command, custom_run_config: runConfig }, import_core53.QueueMode.STEER);
|
|
10186
11866
|
if (callback_event) {
|
|
10187
11867
|
agent.subscribeOnce("message:completed", (evt) => {
|
|
10188
|
-
|
|
11868
|
+
import_core53.eventBus.publish(callback_event, {
|
|
10189
11869
|
success: true,
|
|
10190
11870
|
state: evt.state
|
|
10191
11871
|
});
|
|
10192
11872
|
if (main_thread_id && main_tenant_id) {
|
|
10193
11873
|
try {
|
|
10194
|
-
const mainAgent =
|
|
11874
|
+
const mainAgent = import_core53.agentInstanceManager.getAgent({
|
|
10195
11875
|
assistant_id: main_assistant_id ?? assistant_id,
|
|
10196
11876
|
thread_id: main_thread_id,
|
|
10197
11877
|
tenant_id: main_tenant_id,
|
|
@@ -10221,7 +11901,7 @@ ${summary}`
|
|
|
10221
11901
|
}
|
|
10222
11902
|
});
|
|
10223
11903
|
agent.subscribeOnce("message:interrupted", (evt) => {
|
|
10224
|
-
|
|
11904
|
+
import_core53.eventBus.publish(callback_event, {
|
|
10225
11905
|
success: true,
|
|
10226
11906
|
state: evt.state
|
|
10227
11907
|
});
|
|
@@ -10244,7 +11924,7 @@ ${summary}`
|
|
|
10244
11924
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
10245
11925
|
}
|
|
10246
11926
|
if (callback_event) {
|
|
10247
|
-
|
|
11927
|
+
import_core53.eventBus.publish(callback_event, {
|
|
10248
11928
|
success: false,
|
|
10249
11929
|
error: error instanceof Error ? error.message : String(error)
|
|
10250
11930
|
});
|
|
@@ -10281,7 +11961,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
10281
11961
|
* 初始化事件监听和队列轮询
|
|
10282
11962
|
*/
|
|
10283
11963
|
initialize() {
|
|
10284
|
-
|
|
11964
|
+
import_core53.eventBus.subscribe(import_core53.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
10285
11965
|
this.startPollingQueue();
|
|
10286
11966
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
10287
11967
|
}
|
|
@@ -10400,7 +12080,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
10400
12080
|
handleAgentTask(taskRequest).catch((error) => {
|
|
10401
12081
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
10402
12082
|
if (taskRequest.callback_event) {
|
|
10403
|
-
|
|
12083
|
+
import_core53.eventBus.publish(taskRequest.callback_event, {
|
|
10404
12084
|
success: false,
|
|
10405
12085
|
error: error instanceof Error ? error.message : String(error)
|
|
10406
12086
|
});
|
|
@@ -10415,7 +12095,7 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
|
|
|
10415
12095
|
var AgentTaskConsumer = _AgentTaskConsumer;
|
|
10416
12096
|
|
|
10417
12097
|
// src/index.ts
|
|
10418
|
-
var
|
|
12098
|
+
var import_core57 = require("@axiom-lattice/core");
|
|
10419
12099
|
var import_protocols5 = require("@axiom-lattice/protocols");
|
|
10420
12100
|
var import_meta = {};
|
|
10421
12101
|
process.on("unhandledRejection", (reason, promise) => {
|
|
@@ -10431,11 +12111,11 @@ var DEFAULT_LOGGER_CONFIG = {
|
|
|
10431
12111
|
var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
|
|
10432
12112
|
var logger5 = loggerLattice.client;
|
|
10433
12113
|
function initializeLogger(config) {
|
|
10434
|
-
if (
|
|
10435
|
-
|
|
12114
|
+
if (import_core57.loggerLatticeManager.hasLattice("default")) {
|
|
12115
|
+
import_core57.loggerLatticeManager.removeLattice("default");
|
|
10436
12116
|
}
|
|
10437
|
-
(0,
|
|
10438
|
-
return (0,
|
|
12117
|
+
(0, import_core57.registerLoggerLattice)("default", config);
|
|
12118
|
+
return (0, import_core57.getLoggerLattice)("default");
|
|
10439
12119
|
}
|
|
10440
12120
|
var app = (0, import_fastify.default)({
|
|
10441
12121
|
logger: false,
|
|
@@ -10546,7 +12226,7 @@ app.setErrorHandler((error, request, reply) => {
|
|
|
10546
12226
|
});
|
|
10547
12227
|
function getConfiguredSandboxProvider() {
|
|
10548
12228
|
const sandboxProviderType = process.env.SANDBOX_PROVIDER_TYPE || "microsandbox-remote";
|
|
10549
|
-
return (0,
|
|
12229
|
+
return (0, import_core57.createSandboxProvider)({
|
|
10550
12230
|
type: sandboxProviderType,
|
|
10551
12231
|
remoteBaseURL: process.env.SANDBOX_BASE_URL,
|
|
10552
12232
|
microsandboxServiceBaseURL: process.env.MICROSANDBOX_SERVICE_BASE_URL,
|
|
@@ -10562,7 +12242,7 @@ function getConfiguredSandboxProvider() {
|
|
|
10562
12242
|
}
|
|
10563
12243
|
async function restoreMcpConnections() {
|
|
10564
12244
|
try {
|
|
10565
|
-
const storeLattice = (0,
|
|
12245
|
+
const storeLattice = (0, import_core57.getStoreLattice)("default", "mcp");
|
|
10566
12246
|
const store2 = storeLattice.store;
|
|
10567
12247
|
if (!store2) {
|
|
10568
12248
|
logger5.info("MCP store not configured, skipping connection restoration");
|
|
@@ -10576,15 +12256,15 @@ async function restoreMcpConnections() {
|
|
|
10576
12256
|
for (const config of connectedConfigs) {
|
|
10577
12257
|
try {
|
|
10578
12258
|
const connection = convertToConnection2(config.config);
|
|
10579
|
-
|
|
12259
|
+
import_core57.mcpManager.addServer(config.key, connection);
|
|
10580
12260
|
} catch (err) {
|
|
10581
12261
|
logger5.warn(`Failed to prepare MCP server "${config.key}" for restoration`, { error: err });
|
|
10582
12262
|
}
|
|
10583
12263
|
}
|
|
10584
|
-
await
|
|
12264
|
+
await import_core57.mcpManager.connect();
|
|
10585
12265
|
for (const config of connectedConfigs) {
|
|
10586
12266
|
try {
|
|
10587
|
-
await
|
|
12267
|
+
await import_core57.mcpManager.registerToolsToToolLattice(config.key, config.selectedTools);
|
|
10588
12268
|
logger5.info(`MCP server "${config.key}" restored with ${config.selectedTools.length} tools`);
|
|
10589
12269
|
} catch (err) {
|
|
10590
12270
|
logger5.warn(`Failed to register tools for MCP server "${config.key}"`, { error: err });
|
|
@@ -10614,10 +12294,10 @@ var start = async (config) => {
|
|
|
10614
12294
|
const { wechatChannelAdapter: wechatChannelAdapter2 } = await Promise.resolve().then(() => (init_WechatChannelAdapter(), WechatChannelAdapter_exports));
|
|
10615
12295
|
adapterRegistry.register(wechatChannelAdapter2);
|
|
10616
12296
|
try {
|
|
10617
|
-
const { getStoreLattice:
|
|
10618
|
-
const bindingStore =
|
|
10619
|
-
const installationStore =
|
|
10620
|
-
(0,
|
|
12297
|
+
const { getStoreLattice: getStore15 } = await import("@axiom-lattice/core");
|
|
12298
|
+
const bindingStore = getStore15("default", "channelBinding").store;
|
|
12299
|
+
const installationStore = getStore15("default", "channelInstallation").store;
|
|
12300
|
+
(0, import_core56.setBindingRegistry)(bindingStore);
|
|
10621
12301
|
const router = new MessageRouter({
|
|
10622
12302
|
middlewares: [
|
|
10623
12303
|
createDeduplicationMiddleware(),
|
|
@@ -10630,7 +12310,7 @@ var start = async (config) => {
|
|
|
10630
12310
|
});
|
|
10631
12311
|
channelDeps = { router, installationStore };
|
|
10632
12312
|
try {
|
|
10633
|
-
const a2aKeyStore =
|
|
12313
|
+
const a2aKeyStore = getStore15("default", "a2aApiKey").store;
|
|
10634
12314
|
const a2a = await Promise.resolve().then(() => (init_a2a(), a2a_exports));
|
|
10635
12315
|
a2a.setA2AKeyStore(a2aKeyStore);
|
|
10636
12316
|
await a2a.refreshStoreKeyMap();
|
|
@@ -10642,28 +12322,29 @@ var start = async (config) => {
|
|
|
10642
12322
|
error: err instanceof Error ? err.message : String(err)
|
|
10643
12323
|
});
|
|
10644
12324
|
}
|
|
10645
|
-
(0,
|
|
12325
|
+
(0, import_core56.setEvalRunService)(evalRunner);
|
|
10646
12326
|
try {
|
|
10647
|
-
const menuStore = (0,
|
|
10648
|
-
(0,
|
|
12327
|
+
const menuStore = (0, import_core57.getStoreLattice)("default", "menu").store;
|
|
12328
|
+
(0, import_core56.setMenuRegistry)(menuStore);
|
|
10649
12329
|
logger5.info("Menu registry initialized");
|
|
10650
12330
|
} catch {
|
|
10651
12331
|
}
|
|
12332
|
+
registerAllBuiltinEntities();
|
|
10652
12333
|
if (channelDeps?.router) {
|
|
10653
12334
|
setChannelControllerDeps({ adapterRegistry, router: channelDeps.router });
|
|
10654
12335
|
}
|
|
10655
12336
|
registerLatticeRoutes(app, channelDeps);
|
|
10656
|
-
if (!
|
|
10657
|
-
|
|
12337
|
+
if (!import_core57.sandboxLatticeManager.hasLattice("default")) {
|
|
12338
|
+
import_core57.sandboxLatticeManager.registerLattice("default", getConfiguredSandboxProvider());
|
|
10658
12339
|
logger5.info("Registered sandbox manager from env configuration");
|
|
10659
12340
|
}
|
|
10660
12341
|
try {
|
|
10661
12342
|
const { ResourceController: ResourceController2 } = await Promise.resolve().then(() => (init_resources(), resources_exports));
|
|
10662
|
-
const sharedResourceStore = (0,
|
|
10663
|
-
const cache = new
|
|
12343
|
+
const sharedResourceStore = (0, import_core57.getStoreLattice)("default", "sharedResource").store;
|
|
12344
|
+
const cache = new import_core57.TokenCache();
|
|
10664
12345
|
const resourceController = new ResourceController2({
|
|
10665
12346
|
store: sharedResourceStore,
|
|
10666
|
-
sandboxManager:
|
|
12347
|
+
sandboxManager: import_core57.sandboxLatticeManager,
|
|
10667
12348
|
cache,
|
|
10668
12349
|
logger: logger5
|
|
10669
12350
|
});
|
|
@@ -10704,7 +12385,7 @@ var start = async (config) => {
|
|
|
10704
12385
|
}
|
|
10705
12386
|
}
|
|
10706
12387
|
if (process.env.AXIOM_RESTORE_PENDING_ON_STARTUP === "true") {
|
|
10707
|
-
|
|
12388
|
+
import_core57.agentInstanceManager.restore().then((stats) => {
|
|
10708
12389
|
logger5.info(`Agent recovery complete: ${stats.restored} threads restored, ${stats.errors} errors`);
|
|
10709
12390
|
}).catch((error) => {
|
|
10710
12391
|
logger5.error("Agent recovery failed", { error });
|