@axiom-lattice/gateway 2.1.33 → 2.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +17 -0
- package/dist/index.js +445 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +438 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/controllers/mcp-configs.ts +691 -0
- package/src/routes/index.ts +3 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/gateway@2.1.
|
|
2
|
+
> @axiom-lattice/gateway@2.1.35 build /home/runner/work/agentic/agentic/packages/gateway
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --clean --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
13
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
15
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
12
|
+
[32mCJS[39m [1mdist/index.js [22m[32m158.56 KB[39m
|
|
13
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m342.90 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 299ms
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m151.63 KB[39m
|
|
16
16
|
[32mESM[39m [1mdist/config-F3FCBSPH.mjs [22m[32m148.00 B[39m
|
|
17
17
|
[32mESM[39m [1mdist/chunk-FSASG3SB.mjs [22m[32m2.46 KB[39m
|
|
18
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
18
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m337.48 KB[39m
|
|
19
19
|
[32mESM[39m [1mdist/config-F3FCBSPH.mjs.map [22m[32m71.00 B[39m
|
|
20
20
|
[32mESM[39m [1mdist/chunk-FSASG3SB.mjs.map [22m[32m5.33 KB[39m
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 309ms
|
|
22
22
|
[34mDTS[39m Build start
|
|
23
|
-
[32mDTS[39m ⚡️ Build success in
|
|
23
|
+
[32mDTS[39m ⚡️ Build success in 10351ms
|
|
24
24
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.76 KB[39m
|
|
25
25
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m3.76 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @axiom-lattice/gateway
|
|
2
2
|
|
|
3
|
+
## 2.1.35
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 078a297: update team ui
|
|
8
|
+
- Updated dependencies [078a297]
|
|
9
|
+
- @axiom-lattice/protocols@2.1.17
|
|
10
|
+
- @axiom-lattice/core@2.1.30
|
|
11
|
+
- @axiom-lattice/queue-redis@1.0.16
|
|
12
|
+
|
|
13
|
+
## 2.1.34
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [07fc87d]
|
|
18
|
+
- @axiom-lattice/core@2.1.29
|
|
19
|
+
|
|
3
20
|
## 2.1.33
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -3659,12 +3659,437 @@ function registerMetricsServerConfigRoutes(app2) {
|
|
|
3659
3659
|
app2.post("/api/metrics-configs/test-datasources/:datasourceId/meta", testDatasourceMetrics);
|
|
3660
3660
|
}
|
|
3661
3661
|
|
|
3662
|
-
// src/controllers/
|
|
3662
|
+
// src/controllers/mcp-configs.ts
|
|
3663
3663
|
var import_core19 = require("@axiom-lattice/core");
|
|
3664
|
+
var import_crypto5 = require("crypto");
|
|
3665
|
+
function getTenantId3(request) {
|
|
3666
|
+
return request.headers["x-tenant-id"] || "default";
|
|
3667
|
+
}
|
|
3668
|
+
async function getMcpServerConfigList(request, reply) {
|
|
3669
|
+
const tenantId = getTenantId3(request);
|
|
3670
|
+
try {
|
|
3671
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3672
|
+
const store = storeLattice.store;
|
|
3673
|
+
const configs = await store.getAllConfigs(tenantId);
|
|
3674
|
+
return {
|
|
3675
|
+
success: true,
|
|
3676
|
+
message: "MCP server configurations retrieved successfully",
|
|
3677
|
+
data: {
|
|
3678
|
+
records: configs,
|
|
3679
|
+
total: configs.length
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
} catch (error) {
|
|
3683
|
+
console.error("Failed to get MCP server configs:", error);
|
|
3684
|
+
return {
|
|
3685
|
+
success: false,
|
|
3686
|
+
message: "Failed to retrieve MCP server configurations",
|
|
3687
|
+
data: {
|
|
3688
|
+
records: [],
|
|
3689
|
+
total: 0
|
|
3690
|
+
}
|
|
3691
|
+
};
|
|
3692
|
+
}
|
|
3693
|
+
}
|
|
3694
|
+
async function getMcpServerConfig(request, reply) {
|
|
3695
|
+
const tenantId = getTenantId3(request);
|
|
3696
|
+
const { key } = request.params;
|
|
3697
|
+
try {
|
|
3698
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3699
|
+
const store = storeLattice.store;
|
|
3700
|
+
const config2 = await store.getConfigByKey(tenantId, key);
|
|
3701
|
+
if (!config2) {
|
|
3702
|
+
return {
|
|
3703
|
+
success: false,
|
|
3704
|
+
message: "MCP server configuration not found"
|
|
3705
|
+
};
|
|
3706
|
+
}
|
|
3707
|
+
return {
|
|
3708
|
+
success: true,
|
|
3709
|
+
message: "MCP server configuration retrieved successfully",
|
|
3710
|
+
data: config2
|
|
3711
|
+
};
|
|
3712
|
+
} catch (error) {
|
|
3713
|
+
console.error("Failed to get MCP server config:", error);
|
|
3714
|
+
return {
|
|
3715
|
+
success: false,
|
|
3716
|
+
message: "Failed to retrieve MCP server configuration"
|
|
3717
|
+
};
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
async function createMcpServerConfig(request, reply) {
|
|
3721
|
+
const tenantId = getTenantId3(request);
|
|
3722
|
+
const body = request.body;
|
|
3723
|
+
try {
|
|
3724
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3725
|
+
const store = storeLattice.store;
|
|
3726
|
+
const existing = await store.getConfigByKey(tenantId, body.key);
|
|
3727
|
+
if (existing) {
|
|
3728
|
+
reply.code(409);
|
|
3729
|
+
return {
|
|
3730
|
+
success: false,
|
|
3731
|
+
message: "MCP server configuration with this key already exists"
|
|
3732
|
+
};
|
|
3733
|
+
}
|
|
3734
|
+
const id = body.id || (0, import_crypto5.randomUUID)();
|
|
3735
|
+
const config2 = await store.createConfig(tenantId, id, body);
|
|
3736
|
+
try {
|
|
3737
|
+
await connectAndRegisterTools(config2);
|
|
3738
|
+
await store.updateConfig(tenantId, id, { status: "connected" });
|
|
3739
|
+
config2.status = "connected";
|
|
3740
|
+
} catch (error) {
|
|
3741
|
+
console.warn("Failed to auto-connect MCP server:", error);
|
|
3742
|
+
await store.updateConfig(tenantId, id, { status: "error" });
|
|
3743
|
+
config2.status = "error";
|
|
3744
|
+
}
|
|
3745
|
+
reply.code(201);
|
|
3746
|
+
return {
|
|
3747
|
+
success: true,
|
|
3748
|
+
message: "MCP server configuration created successfully",
|
|
3749
|
+
data: config2
|
|
3750
|
+
};
|
|
3751
|
+
} catch (error) {
|
|
3752
|
+
console.error("Failed to create MCP server config:", error);
|
|
3753
|
+
return {
|
|
3754
|
+
success: false,
|
|
3755
|
+
message: "Failed to create MCP server configuration"
|
|
3756
|
+
};
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
async function updateMcpServerConfig(request, reply) {
|
|
3760
|
+
const tenantId = getTenantId3(request);
|
|
3761
|
+
const { key } = request.params;
|
|
3762
|
+
const updates = request.body;
|
|
3763
|
+
try {
|
|
3764
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3765
|
+
const store = storeLattice.store;
|
|
3766
|
+
const existing = await store.getConfigByKey(tenantId, key);
|
|
3767
|
+
if (!existing) {
|
|
3768
|
+
reply.code(404);
|
|
3769
|
+
return {
|
|
3770
|
+
success: false,
|
|
3771
|
+
message: "MCP server configuration not found"
|
|
3772
|
+
};
|
|
3773
|
+
}
|
|
3774
|
+
const shouldReconnect = updates.config !== void 0;
|
|
3775
|
+
const updated = await store.updateConfig(tenantId, existing.id, updates);
|
|
3776
|
+
if (!updated) {
|
|
3777
|
+
return {
|
|
3778
|
+
success: false,
|
|
3779
|
+
message: "Failed to update MCP server configuration"
|
|
3780
|
+
};
|
|
3781
|
+
}
|
|
3782
|
+
if (shouldReconnect) {
|
|
3783
|
+
try {
|
|
3784
|
+
if (import_core19.mcpManager.hasServer(key)) {
|
|
3785
|
+
await import_core19.mcpManager.removeServer(key);
|
|
3786
|
+
}
|
|
3787
|
+
await connectAndRegisterTools(updated);
|
|
3788
|
+
await store.updateConfig(tenantId, existing.id, { status: "connected" });
|
|
3789
|
+
updated.status = "connected";
|
|
3790
|
+
} catch (error) {
|
|
3791
|
+
console.warn("Failed to reconnect MCP server:", error);
|
|
3792
|
+
await store.updateConfig(tenantId, existing.id, { status: "error" });
|
|
3793
|
+
updated.status = "error";
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
return {
|
|
3797
|
+
success: true,
|
|
3798
|
+
message: "MCP server configuration updated successfully",
|
|
3799
|
+
data: updated
|
|
3800
|
+
};
|
|
3801
|
+
} catch (error) {
|
|
3802
|
+
console.error("Failed to update MCP server config:", error);
|
|
3803
|
+
return {
|
|
3804
|
+
success: false,
|
|
3805
|
+
message: "Failed to update MCP server configuration"
|
|
3806
|
+
};
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
async function deleteMcpServerConfig(request, reply) {
|
|
3810
|
+
const tenantId = getTenantId3(request);
|
|
3811
|
+
const { keyOrId } = request.params;
|
|
3812
|
+
try {
|
|
3813
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3814
|
+
const store = storeLattice.store;
|
|
3815
|
+
let config2 = await store.getConfigByKey(tenantId, keyOrId);
|
|
3816
|
+
let configKey = keyOrId;
|
|
3817
|
+
if (!config2) {
|
|
3818
|
+
config2 = await store.getConfigById(tenantId, keyOrId);
|
|
3819
|
+
if (config2) {
|
|
3820
|
+
configKey = config2.key;
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
if (!config2) {
|
|
3824
|
+
reply.code(404);
|
|
3825
|
+
return {
|
|
3826
|
+
success: false,
|
|
3827
|
+
message: "MCP server configuration not found"
|
|
3828
|
+
};
|
|
3829
|
+
}
|
|
3830
|
+
try {
|
|
3831
|
+
if (import_core19.mcpManager.hasServer(configKey)) {
|
|
3832
|
+
await import_core19.mcpManager.removeServer(configKey);
|
|
3833
|
+
}
|
|
3834
|
+
} catch (error) {
|
|
3835
|
+
console.warn("Failed to remove from MCP manager:", error);
|
|
3836
|
+
}
|
|
3837
|
+
const deleted = await store.deleteConfig(tenantId, config2.id);
|
|
3838
|
+
if (!deleted) {
|
|
3839
|
+
return {
|
|
3840
|
+
success: false,
|
|
3841
|
+
message: "Failed to delete MCP server configuration"
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
return {
|
|
3845
|
+
success: true,
|
|
3846
|
+
message: "MCP server configuration deleted successfully"
|
|
3847
|
+
};
|
|
3848
|
+
} catch (error) {
|
|
3849
|
+
console.error("Failed to delete MCP server config:", error);
|
|
3850
|
+
return {
|
|
3851
|
+
success: false,
|
|
3852
|
+
message: "Failed to delete MCP server configuration"
|
|
3853
|
+
};
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
async function testMcpServerConnection(request, reply) {
|
|
3857
|
+
const tenantId = getTenantId3(request);
|
|
3858
|
+
const { key } = request.params;
|
|
3859
|
+
try {
|
|
3860
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3861
|
+
const store = storeLattice.store;
|
|
3862
|
+
const config2 = await store.getConfigByKey(tenantId, key);
|
|
3863
|
+
if (!config2) {
|
|
3864
|
+
reply.code(404);
|
|
3865
|
+
return {
|
|
3866
|
+
success: false,
|
|
3867
|
+
message: "MCP server configuration not found"
|
|
3868
|
+
};
|
|
3869
|
+
}
|
|
3870
|
+
const startTime = Date.now();
|
|
3871
|
+
try {
|
|
3872
|
+
const testKey = `__test_${key}_${Date.now()}`;
|
|
3873
|
+
const connection = convertToConnection(config2.config);
|
|
3874
|
+
import_core19.mcpManager.addServer(testKey, connection);
|
|
3875
|
+
await import_core19.mcpManager.connect();
|
|
3876
|
+
const tools = await import_core19.mcpManager.getAllTools();
|
|
3877
|
+
const latency = Date.now() - startTime;
|
|
3878
|
+
await import_core19.mcpManager.removeServer(testKey);
|
|
3879
|
+
return {
|
|
3880
|
+
success: true,
|
|
3881
|
+
message: "Connection test successful",
|
|
3882
|
+
data: {
|
|
3883
|
+
connected: true,
|
|
3884
|
+
latency
|
|
3885
|
+
}
|
|
3886
|
+
};
|
|
3887
|
+
} catch (error) {
|
|
3888
|
+
return {
|
|
3889
|
+
success: true,
|
|
3890
|
+
message: "Connection test failed",
|
|
3891
|
+
data: {
|
|
3892
|
+
connected: false,
|
|
3893
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
3894
|
+
}
|
|
3895
|
+
};
|
|
3896
|
+
}
|
|
3897
|
+
} catch (error) {
|
|
3898
|
+
console.error("Failed to test MCP server connection:", error);
|
|
3899
|
+
return {
|
|
3900
|
+
success: false,
|
|
3901
|
+
message: "Failed to test MCP server connection",
|
|
3902
|
+
data: {
|
|
3903
|
+
connected: false,
|
|
3904
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
3905
|
+
}
|
|
3906
|
+
};
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
async function listMcpServerTools(request, reply) {
|
|
3910
|
+
const tenantId = getTenantId3(request);
|
|
3911
|
+
const { key } = request.params;
|
|
3912
|
+
try {
|
|
3913
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3914
|
+
const store = storeLattice.store;
|
|
3915
|
+
const config2 = await store.getConfigByKey(tenantId, key);
|
|
3916
|
+
if (!config2) {
|
|
3917
|
+
reply.code(404);
|
|
3918
|
+
return {
|
|
3919
|
+
success: false,
|
|
3920
|
+
message: "MCP server configuration not found"
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3923
|
+
if (!import_core19.mcpManager.hasServer(key)) {
|
|
3924
|
+
await connectAndRegisterTools(config2);
|
|
3925
|
+
}
|
|
3926
|
+
const tools = await import_core19.mcpManager.getAllTools();
|
|
3927
|
+
return {
|
|
3928
|
+
success: true,
|
|
3929
|
+
message: "Tools retrieved successfully",
|
|
3930
|
+
data: {
|
|
3931
|
+
tools
|
|
3932
|
+
}
|
|
3933
|
+
};
|
|
3934
|
+
} catch (error) {
|
|
3935
|
+
console.error("Failed to list MCP tools:", error);
|
|
3936
|
+
return {
|
|
3937
|
+
success: false,
|
|
3938
|
+
message: "Failed to retrieve tools"
|
|
3939
|
+
};
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
async function connectMcpServer(request, reply) {
|
|
3943
|
+
const tenantId = getTenantId3(request);
|
|
3944
|
+
const { key } = request.params;
|
|
3945
|
+
try {
|
|
3946
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3947
|
+
const store = storeLattice.store;
|
|
3948
|
+
const config2 = await store.getConfigByKey(tenantId, key);
|
|
3949
|
+
if (!config2) {
|
|
3950
|
+
reply.code(404);
|
|
3951
|
+
return {
|
|
3952
|
+
success: false,
|
|
3953
|
+
message: "MCP server configuration not found"
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
await connectAndRegisterTools(config2);
|
|
3957
|
+
const updated = await store.updateConfig(tenantId, config2.id, {
|
|
3958
|
+
status: "connected"
|
|
3959
|
+
});
|
|
3960
|
+
return {
|
|
3961
|
+
success: true,
|
|
3962
|
+
message: "MCP server connected successfully",
|
|
3963
|
+
data: updated || config2
|
|
3964
|
+
};
|
|
3965
|
+
} catch (error) {
|
|
3966
|
+
console.error("Failed to connect MCP server:", error);
|
|
3967
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3968
|
+
const store = storeLattice.store;
|
|
3969
|
+
const config2 = await store.getConfigByKey(tenantId, key);
|
|
3970
|
+
if (config2) {
|
|
3971
|
+
await store.updateConfig(tenantId, config2.id, { status: "error" });
|
|
3972
|
+
}
|
|
3973
|
+
return {
|
|
3974
|
+
success: false,
|
|
3975
|
+
message: `Failed to connect MCP server: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
3976
|
+
};
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
async function disconnectMcpServer(request, reply) {
|
|
3980
|
+
const tenantId = getTenantId3(request);
|
|
3981
|
+
const { key } = request.params;
|
|
3982
|
+
try {
|
|
3983
|
+
const storeLattice = (0, import_core19.getStoreLattice)("default", "mcp");
|
|
3984
|
+
const store = storeLattice.store;
|
|
3985
|
+
const config2 = await store.getConfigByKey(tenantId, key);
|
|
3986
|
+
if (!config2) {
|
|
3987
|
+
reply.code(404);
|
|
3988
|
+
return {
|
|
3989
|
+
success: false,
|
|
3990
|
+
message: "MCP server configuration not found"
|
|
3991
|
+
};
|
|
3992
|
+
}
|
|
3993
|
+
if (import_core19.mcpManager.hasServer(key)) {
|
|
3994
|
+
await import_core19.mcpManager.removeServer(key);
|
|
3995
|
+
}
|
|
3996
|
+
const updated = await store.updateConfig(tenantId, config2.id, {
|
|
3997
|
+
status: "disconnected"
|
|
3998
|
+
});
|
|
3999
|
+
return {
|
|
4000
|
+
success: true,
|
|
4001
|
+
message: "MCP server disconnected successfully",
|
|
4002
|
+
data: updated || config2
|
|
4003
|
+
};
|
|
4004
|
+
} catch (error) {
|
|
4005
|
+
console.error("Failed to disconnect MCP server:", error);
|
|
4006
|
+
return {
|
|
4007
|
+
success: false,
|
|
4008
|
+
message: "Failed to disconnect MCP server"
|
|
4009
|
+
};
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
async function testMcpServerTools(request, reply) {
|
|
4013
|
+
const body = request.body;
|
|
4014
|
+
try {
|
|
4015
|
+
if (!body.config) {
|
|
4016
|
+
reply.code(400);
|
|
4017
|
+
return {
|
|
4018
|
+
success: false,
|
|
4019
|
+
message: "config is required"
|
|
4020
|
+
};
|
|
4021
|
+
}
|
|
4022
|
+
const testKey = `__test_${Date.now()}`;
|
|
4023
|
+
const connection = convertToConnection(body.config);
|
|
4024
|
+
import_core19.mcpManager.addServer(testKey, connection);
|
|
4025
|
+
await import_core19.mcpManager.connect();
|
|
4026
|
+
const tools = await import_core19.mcpManager.getAllTools();
|
|
4027
|
+
await import_core19.mcpManager.removeServer(testKey);
|
|
4028
|
+
return {
|
|
4029
|
+
success: true,
|
|
4030
|
+
message: "Tools retrieved successfully",
|
|
4031
|
+
data: {
|
|
4032
|
+
tools
|
|
4033
|
+
}
|
|
4034
|
+
};
|
|
4035
|
+
} catch (error) {
|
|
4036
|
+
console.error("Failed to test MCP server tools:", error);
|
|
4037
|
+
return {
|
|
4038
|
+
success: false,
|
|
4039
|
+
message: `Failed to retrieve tools: ${error instanceof Error ? error.message : String(error)}`
|
|
4040
|
+
};
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
function convertToConnection(config2) {
|
|
4044
|
+
const baseConfig = {
|
|
4045
|
+
env: config2.env
|
|
4046
|
+
};
|
|
4047
|
+
if (config2.transport === "stdio") {
|
|
4048
|
+
return {
|
|
4049
|
+
...baseConfig,
|
|
4050
|
+
transport: "stdio",
|
|
4051
|
+
command: config2.command,
|
|
4052
|
+
args: config2.args || []
|
|
4053
|
+
};
|
|
4054
|
+
} else {
|
|
4055
|
+
return {
|
|
4056
|
+
...baseConfig,
|
|
4057
|
+
transport: config2.transport === "streamable_http" ? "http" : config2.transport,
|
|
4058
|
+
url: config2.url
|
|
4059
|
+
};
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
async function connectAndRegisterTools(config2) {
|
|
4063
|
+
const connection = convertToConnection(config2.config);
|
|
4064
|
+
import_core19.mcpManager.addServer(config2.key, connection);
|
|
4065
|
+
await import_core19.mcpManager.connect();
|
|
4066
|
+
const allTools = await import_core19.mcpManager.getAllTools();
|
|
4067
|
+
const selectedTools = allTools.filter(
|
|
4068
|
+
(tool) => config2.selectedTools.includes(tool.name)
|
|
4069
|
+
);
|
|
4070
|
+
for (const tool of selectedTools) {
|
|
4071
|
+
import_core19.toolLatticeManager.registerExistingTool(tool.name, tool);
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
function registerMcpServerConfigRoutes(app2) {
|
|
4075
|
+
app2.get("/api/mcp-servers", getMcpServerConfigList);
|
|
4076
|
+
app2.get("/api/mcp-servers/:key", getMcpServerConfig);
|
|
4077
|
+
app2.post("/api/mcp-servers", createMcpServerConfig);
|
|
4078
|
+
app2.put("/api/mcp-servers/:key", updateMcpServerConfig);
|
|
4079
|
+
app2.delete("/api/mcp-servers/:keyOrId", deleteMcpServerConfig);
|
|
4080
|
+
app2.post("/api/mcp-servers/:key/test", testMcpServerConnection);
|
|
4081
|
+
app2.get("/api/mcp-servers/:key/tools", listMcpServerTools);
|
|
4082
|
+
app2.post("/api/mcp-servers/:key/connect", connectMcpServer);
|
|
4083
|
+
app2.post("/api/mcp-servers/:key/disconnect", disconnectMcpServer);
|
|
4084
|
+
app2.post("/api/mcp-servers/test-tools", testMcpServerTools);
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
// src/controllers/users.ts
|
|
4088
|
+
var import_core20 = require("@axiom-lattice/core");
|
|
3664
4089
|
var import_uuid4 = require("uuid");
|
|
3665
4090
|
var UsersController = class {
|
|
3666
4091
|
constructor() {
|
|
3667
|
-
this.userStore = (0,
|
|
4092
|
+
this.userStore = (0, import_core20.getStoreLattice)("default", "user").store;
|
|
3668
4093
|
}
|
|
3669
4094
|
async listUsers(request, reply) {
|
|
3670
4095
|
const { email } = request.query;
|
|
@@ -3742,11 +4167,11 @@ function registerUserRoutes(app2) {
|
|
|
3742
4167
|
}
|
|
3743
4168
|
|
|
3744
4169
|
// src/controllers/tenants.ts
|
|
3745
|
-
var
|
|
4170
|
+
var import_core21 = require("@axiom-lattice/core");
|
|
3746
4171
|
var import_uuid5 = require("uuid");
|
|
3747
4172
|
var TenantsController = class {
|
|
3748
4173
|
constructor() {
|
|
3749
|
-
this.tenantStore = (0,
|
|
4174
|
+
this.tenantStore = (0, import_core21.getStoreLattice)("default", "tenant").store;
|
|
3750
4175
|
}
|
|
3751
4176
|
// ==================== Tenant CRUD ====================
|
|
3752
4177
|
async listTenants(request, reply) {
|
|
@@ -3810,7 +4235,7 @@ function registerTenantRoutes(app2) {
|
|
|
3810
4235
|
}
|
|
3811
4236
|
|
|
3812
4237
|
// src/controllers/auth.ts
|
|
3813
|
-
var
|
|
4238
|
+
var import_core22 = require("@axiom-lattice/core");
|
|
3814
4239
|
var import_uuid6 = require("uuid");
|
|
3815
4240
|
var defaultAuthConfig = {
|
|
3816
4241
|
autoApproveUsers: true,
|
|
@@ -3819,9 +4244,9 @@ var defaultAuthConfig = {
|
|
|
3819
4244
|
};
|
|
3820
4245
|
var AuthController = class {
|
|
3821
4246
|
constructor(config2 = {}) {
|
|
3822
|
-
this.userStore = (0,
|
|
3823
|
-
this.tenantStore = (0,
|
|
3824
|
-
this.userTenantLinkStore = (0,
|
|
4247
|
+
this.userStore = (0, import_core22.getStoreLattice)("default", "user").store;
|
|
4248
|
+
this.tenantStore = (0, import_core22.getStoreLattice)("default", "tenant").store;
|
|
4249
|
+
this.userTenantLinkStore = (0, import_core22.getStoreLattice)("default", "userTenantLink").store;
|
|
3825
4250
|
this.config = { ...defaultAuthConfig, ...config2 };
|
|
3826
4251
|
}
|
|
3827
4252
|
async register(request, reply) {
|
|
@@ -4258,6 +4683,7 @@ var registerLatticeRoutes = (app2) => {
|
|
|
4258
4683
|
registerWorkspaceRoutes(app2);
|
|
4259
4684
|
registerDatabaseConfigRoutes(app2);
|
|
4260
4685
|
registerMetricsServerConfigRoutes(app2);
|
|
4686
|
+
registerMcpServerConfigRoutes(app2);
|
|
4261
4687
|
registerUserRoutes(app2);
|
|
4262
4688
|
registerTenantRoutes(app2);
|
|
4263
4689
|
registerAuthRoutes(app2, {
|
|
@@ -4329,7 +4755,7 @@ var configureSwagger = async (app2, customSwaggerConfig, customSwaggerUiConfig)
|
|
|
4329
4755
|
};
|
|
4330
4756
|
|
|
4331
4757
|
// src/services/agent_task_consumer.ts
|
|
4332
|
-
var
|
|
4758
|
+
var import_core23 = require("@axiom-lattice/core");
|
|
4333
4759
|
var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
4334
4760
|
const {
|
|
4335
4761
|
assistant_id,
|
|
@@ -4395,7 +4821,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
4395
4821
|
}
|
|
4396
4822
|
if (callback_event) {
|
|
4397
4823
|
const state = await agent_state({ assistant_id, thread_id });
|
|
4398
|
-
|
|
4824
|
+
import_core23.eventBus.publish(callback_event, {
|
|
4399
4825
|
success: true,
|
|
4400
4826
|
state,
|
|
4401
4827
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -4409,7 +4835,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
4409
4835
|
await response.text();
|
|
4410
4836
|
if (callback_event) {
|
|
4411
4837
|
const state = await agent_state({ assistant_id, thread_id });
|
|
4412
|
-
|
|
4838
|
+
import_core23.eventBus.publish(callback_event, {
|
|
4413
4839
|
success: true,
|
|
4414
4840
|
state,
|
|
4415
4841
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -4436,7 +4862,7 @@ var handleAgentTask = async (taskRequest, retryCount = 0) => {
|
|
|
4436
4862
|
return handleAgentTask(taskRequest, nextRetryCount);
|
|
4437
4863
|
}
|
|
4438
4864
|
if (callback_event) {
|
|
4439
|
-
|
|
4865
|
+
import_core23.eventBus.publish(callback_event, {
|
|
4440
4866
|
success: false,
|
|
4441
4867
|
error: error instanceof Error ? error.message : String(error),
|
|
4442
4868
|
config: { assistant_id, thread_id, tenant_id }
|
|
@@ -4474,7 +4900,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
4474
4900
|
* 初始化事件监听和队列轮询
|
|
4475
4901
|
*/
|
|
4476
4902
|
initialize() {
|
|
4477
|
-
|
|
4903
|
+
import_core23.eventBus.subscribe(import_core23.AGENT_TASK_EVENT, this.trigger_agent_task.bind(this));
|
|
4478
4904
|
this.startPollingQueue();
|
|
4479
4905
|
console.log("Agent\u4EFB\u52A1\u6D88\u8D39\u8005\u5DF2\u542F\u52A8\u5E76\u76D1\u542C\u4EFB\u52A1\u4E8B\u4EF6\u548C\u961F\u5217");
|
|
4480
4906
|
}
|
|
@@ -4593,7 +5019,7 @@ var _AgentTaskConsumer = class _AgentTaskConsumer {
|
|
|
4593
5019
|
handleAgentTask(taskRequest).catch((error) => {
|
|
4594
5020
|
console.error("\u5904\u7406Agent\u4EFB\u52A1\u65F6\u53D1\u751F\u672A\u6355\u83B7\u7684\u9519\u8BEF:", error);
|
|
4595
5021
|
if (taskRequest.callback_event) {
|
|
4596
|
-
|
|
5022
|
+
import_core23.eventBus.publish(taskRequest.callback_event, {
|
|
4597
5023
|
success: false,
|
|
4598
5024
|
error: error instanceof Error ? error.message : String(error),
|
|
4599
5025
|
config: {
|
|
@@ -4613,7 +5039,7 @@ _AgentTaskConsumer.agent_run_endpoint = "http://localhost:4001/api/runs";
|
|
|
4613
5039
|
var AgentTaskConsumer = _AgentTaskConsumer;
|
|
4614
5040
|
|
|
4615
5041
|
// src/index.ts
|
|
4616
|
-
var
|
|
5042
|
+
var import_core24 = require("@axiom-lattice/core");
|
|
4617
5043
|
var import_protocols2 = require("@axiom-lattice/protocols");
|
|
4618
5044
|
process.on("unhandledRejection", (reason, promise) => {
|
|
4619
5045
|
console.error("\u672A\u5904\u7406\u7684Promise\u62D2\u7EDD:", reason);
|
|
@@ -4628,11 +5054,11 @@ var DEFAULT_LOGGER_CONFIG = {
|
|
|
4628
5054
|
var loggerLattice = initializeLogger(DEFAULT_LOGGER_CONFIG);
|
|
4629
5055
|
var logger = loggerLattice.client;
|
|
4630
5056
|
function initializeLogger(config2) {
|
|
4631
|
-
if (
|
|
4632
|
-
|
|
5057
|
+
if (import_core24.loggerLatticeManager.hasLattice("default")) {
|
|
5058
|
+
import_core24.loggerLatticeManager.removeLattice("default");
|
|
4633
5059
|
}
|
|
4634
|
-
(0,
|
|
4635
|
-
return (0,
|
|
5060
|
+
(0, import_core24.registerLoggerLattice)("default", config2);
|
|
5061
|
+
return (0, import_core24.getLoggerLattice)("default");
|
|
4636
5062
|
}
|
|
4637
5063
|
var app = (0, import_fastify.default)({
|
|
4638
5064
|
logger: false,
|