@nekzus/liop 2.1.0-alpha.13 → 2.1.0-alpha.15
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/dist/bin/agent.js +7 -5
- package/dist/bin/agent.js.map +1 -1
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +2 -1
- package/dist/{chunk-UVO7DII3.js → chunk-4LQPDN3W.js} +108 -15
- package/dist/chunk-4LQPDN3W.js.map +1 -0
- package/dist/chunk-636UOVSO.js +714 -0
- package/dist/chunk-636UOVSO.js.map +1 -0
- package/dist/{chunk-NJRSFFD7.js → chunk-74CISO2I.js} +60 -22
- package/dist/chunk-74CISO2I.js.map +1 -0
- package/dist/{chunk-E5QBDD5E.js → chunk-CRZBVFDV.js} +169 -22
- package/dist/chunk-CRZBVFDV.js.map +1 -0
- package/dist/chunk-JIJPZFR2.js +51 -0
- package/dist/chunk-JIJPZFR2.js.map +1 -0
- package/dist/{chunk-HB5DXX3Q.js → chunk-KF4DCCU3.js} +232 -48
- package/dist/chunk-KF4DCCU3.js.map +1 -0
- package/dist/chunk-OIMJZ64E.js +441 -0
- package/dist/chunk-OIMJZ64E.js.map +1 -0
- package/dist/chunk-PYKRQAER.js +77 -0
- package/dist/chunk-PYKRQAER.js.map +1 -0
- package/dist/{chunk-J3WPBMJ5.js → chunk-SONUORBT.js} +95 -6
- package/dist/chunk-SONUORBT.js.map +1 -0
- package/dist/{chunk-2JLG4DET.js → chunk-UBOQZVV5.js} +261 -107
- package/dist/chunk-UBOQZVV5.js.map +1 -0
- package/dist/chunk-WSW6YJNY.js +168 -0
- package/dist/chunk-WSW6YJNY.js.map +1 -0
- package/dist/client.d.ts +3 -2
- package/dist/client.js +4 -3
- package/dist/gateway.d.ts +5 -110
- package/dist/gateway.js +5 -4
- package/dist/hybrid-CF__0YnC.d.ts +170 -0
- package/dist/{index-BlGc0iym.d.ts → index-BW95kAL4.d.ts} +63 -2
- package/dist/index-cMV0_yD9.d.ts +200 -0
- package/dist/index.d.ts +267 -7
- package/dist/index.js +266 -13
- package/dist/index.js.map +1 -1
- package/dist/mesh.d.ts +14 -0
- package/dist/mesh.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -4
- package/dist/{types-sKeUxuky.d.ts → types-lJIxBlWF.d.ts} +71 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/workers/logic-execution.d.ts +1 -0
- package/dist/workers/logic-execution.js +17 -1
- package/dist/workers/logic-execution.js.map +1 -1
- package/package.json +79 -31
- package/dist/chunk-2JLG4DET.js.map +0 -1
- package/dist/chunk-CT6NHSYP.js +0 -30
- package/dist/chunk-CT6NHSYP.js.map +0 -1
- package/dist/chunk-E5QBDD5E.js.map +0 -1
- package/dist/chunk-HB5DXX3Q.js.map +0 -1
- package/dist/chunk-IJHTRIZC.js +0 -56
- package/dist/chunk-IJHTRIZC.js.map +0 -1
- package/dist/chunk-J3WPBMJ5.js.map +0 -1
- package/dist/chunk-NJRSFFD7.js.map +0 -1
- package/dist/chunk-PHTWUTY7.js +0 -300
- package/dist/chunk-PHTWUTY7.js.map +0 -1
- package/dist/chunk-RDWCGZ2A.js +0 -87
- package/dist/chunk-RDWCGZ2A.js.map +0 -1
- package/dist/chunk-UVO7DII3.js.map +0 -1
- package/dist/index-qM8ZH8sC.d.ts +0 -101
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { LiopVerifier } from './chunk-32ADSAJS.js';
|
|
2
2
|
import { Kyber768Wrapper } from './chunk-QLCOEP5J.js';
|
|
3
|
-
import { authorizeRequest } from './chunk-
|
|
4
|
-
import { liopV1, createChannelCredentials } from './chunk-
|
|
3
|
+
import { authorizeRequest, Dilithium65Wrapper } from './chunk-OIMJZ64E.js';
|
|
4
|
+
import { liopV1, createChannelCredentials, GRPC_CHANNEL_OPTIONS } from './chunk-WSW6YJNY.js';
|
|
5
|
+
import { MCP_PROTOCOL_VERSION, MCP_LEGACY_SUPPORT_ENABLED, isLegacyRequest, adaptResponseForLegacyClient, MCP_PROTOCOL_VERSION_LEGACY, buildLegacyInitializeResponse } from './chunk-PYKRQAER.js';
|
|
5
6
|
import { log } from './chunk-72MNYFR6.js';
|
|
6
7
|
import * as crypto2 from 'crypto';
|
|
7
8
|
import * as grpc from '@grpc/grpc-js';
|
|
@@ -831,6 +832,9 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
831
832
|
static MANIFEST_FAILURE_BASE_COOLDOWN_MS = 15e3;
|
|
832
833
|
static MANIFEST_FAILURE_MAX_COOLDOWN_MS = 5 * 6e4;
|
|
833
834
|
static MANIFEST_SKIP_LOG_THROTTLE_MS = 3e4;
|
|
835
|
+
getManifestCacheSize() {
|
|
836
|
+
return this.manifestCache.size;
|
|
837
|
+
}
|
|
834
838
|
shouldSkipManifestQuery(peerId) {
|
|
835
839
|
const state = this.manifestFailureState.get(peerId);
|
|
836
840
|
if (!state) return false;
|
|
@@ -861,6 +865,23 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
861
865
|
lastSkipLogAt: 0
|
|
862
866
|
});
|
|
863
867
|
}
|
|
868
|
+
/**
|
|
869
|
+
* Detects the protocol era of an incoming request.
|
|
870
|
+
* Modern requests carry '_meta' with protocol version "2026-07-28" or use modern RPCs.
|
|
871
|
+
* Legacy requests use 'initialize' handshake or lack '_meta' envelopes.
|
|
872
|
+
*/
|
|
873
|
+
detectEra(request) {
|
|
874
|
+
const params = request.params;
|
|
875
|
+
const meta = params?._meta;
|
|
876
|
+
const version = meta?.["io.modelcontextprotocol/protocolVersion"];
|
|
877
|
+
if (version === MCP_PROTOCOL_VERSION) {
|
|
878
|
+
return "modern";
|
|
879
|
+
}
|
|
880
|
+
if (MCP_LEGACY_SUPPORT_ENABLED && isLegacyRequest(request)) {
|
|
881
|
+
return "legacy";
|
|
882
|
+
}
|
|
883
|
+
return "modern";
|
|
884
|
+
}
|
|
864
885
|
async dispatch(request, authInfo) {
|
|
865
886
|
const { method, params, id } = request;
|
|
866
887
|
log.info(`[LIOP-Router] Processing: ${method}`);
|
|
@@ -882,12 +903,42 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
882
903
|
}
|
|
883
904
|
}
|
|
884
905
|
switch (method) {
|
|
885
|
-
|
|
906
|
+
/** @mcp-legacy Initialize handshake for 2025-era clients. Remove when v1 EOL. */
|
|
907
|
+
case "initialize": {
|
|
908
|
+
if (!MCP_LEGACY_SUPPORT_ENABLED) {
|
|
909
|
+
return {
|
|
910
|
+
jsonrpc: "2.0",
|
|
911
|
+
id,
|
|
912
|
+
error: {
|
|
913
|
+
code: -32601,
|
|
914
|
+
message: "Method retired: initialize (MCP 2026-07-28 is stateless)"
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
log.info(
|
|
919
|
+
"[LIOP-Router] \u26A0\uFE0F Legacy MCP client detected (2025-era initialize)."
|
|
920
|
+
);
|
|
921
|
+
return buildLegacyInitializeResponse(
|
|
922
|
+
this.liopServer.getServerInfo(),
|
|
923
|
+
id
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
/** @mcp-legacy Initialized notification for 2025-era clients. Remove when v1 EOL. */
|
|
927
|
+
case "notifications/initialized":
|
|
928
|
+
if (!MCP_LEGACY_SUPPORT_ENABLED) return null;
|
|
929
|
+
this.kickDiscoveryAfterInitialized().catch(() => {
|
|
930
|
+
});
|
|
931
|
+
return null;
|
|
932
|
+
case "notifications/cancelled":
|
|
933
|
+
return null;
|
|
934
|
+
// No-op for MCP spec compliance
|
|
935
|
+
case "server/discover":
|
|
886
936
|
return {
|
|
887
937
|
jsonrpc: "2.0",
|
|
888
938
|
id,
|
|
889
939
|
result: {
|
|
890
|
-
|
|
940
|
+
resultType: "complete",
|
|
941
|
+
supportedVersions: MCP_LEGACY_SUPPORT_ENABLED ? [MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_LEGACY] : [MCP_PROTOCOL_VERSION],
|
|
891
942
|
capabilities: {
|
|
892
943
|
tools: { listChanged: true },
|
|
893
944
|
resources: { listChanged: true },
|
|
@@ -896,13 +947,6 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
896
947
|
serverInfo: this.liopServer.getServerInfo()
|
|
897
948
|
}
|
|
898
949
|
};
|
|
899
|
-
case "notifications/initialized":
|
|
900
|
-
this.kickDiscoveryAfterInitialized().catch(() => {
|
|
901
|
-
});
|
|
902
|
-
return null;
|
|
903
|
-
case "notifications/cancelled":
|
|
904
|
-
return null;
|
|
905
|
-
// No-op for MCP spec compliance
|
|
906
950
|
case "ping":
|
|
907
951
|
return { jsonrpc: "2.0", id, result: {} };
|
|
908
952
|
case "tools/list": {
|
|
@@ -924,7 +968,9 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
924
968
|
additionalProperties: false
|
|
925
969
|
}
|
|
926
970
|
};
|
|
927
|
-
const allTools = [diagnosticTool, ...listedLocals, ...remoteTools]
|
|
971
|
+
const allTools = [diagnosticTool, ...listedLocals, ...remoteTools].sort(
|
|
972
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
973
|
+
);
|
|
928
974
|
const telemetry = TokenTelemetryEngine.getInstance();
|
|
929
975
|
const toolsPayload = JSON.stringify(allTools);
|
|
930
976
|
const toolsResponsePayload = JSON.stringify({ tools: allTools });
|
|
@@ -934,24 +980,47 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
934
980
|
estimatedInputTokens: telemetry.countTokens(toolsPayload),
|
|
935
981
|
estimatedOutputTokens: telemetry.countTokens(toolsResponsePayload)
|
|
936
982
|
});
|
|
937
|
-
|
|
983
|
+
const era = this.detectEra(request);
|
|
984
|
+
let response = {
|
|
938
985
|
jsonrpc: "2.0",
|
|
939
986
|
id,
|
|
940
987
|
result: {
|
|
988
|
+
resultType: "complete",
|
|
989
|
+
ttlMs: 3e5,
|
|
990
|
+
cacheScope: "public",
|
|
941
991
|
tools: allTools
|
|
942
992
|
}
|
|
943
993
|
};
|
|
994
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
995
|
+
response = adaptResponseForLegacyClient(response);
|
|
996
|
+
}
|
|
997
|
+
return response;
|
|
944
998
|
}
|
|
945
|
-
case "tools/call":
|
|
946
|
-
|
|
999
|
+
case "tools/call": {
|
|
1000
|
+
const response = await this.transcodeMcpToLiop(
|
|
947
1001
|
id,
|
|
948
1002
|
params,
|
|
949
1003
|
authInfo?.token
|
|
950
1004
|
);
|
|
1005
|
+
if (!response) return null;
|
|
1006
|
+
const era = this.detectEra(request);
|
|
1007
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1008
|
+
return adaptResponseForLegacyClient(response);
|
|
1009
|
+
}
|
|
1010
|
+
if (response.result && typeof response.result === "object") {
|
|
1011
|
+
const resObj = response.result;
|
|
1012
|
+
if (!resObj.resultType) {
|
|
1013
|
+
resObj.resultType = "complete";
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
return response;
|
|
1017
|
+
}
|
|
951
1018
|
case "resources/list": {
|
|
952
1019
|
const localResources = this.liopServer.listResources();
|
|
953
1020
|
const remoteResources = await this.getRemoteResources();
|
|
954
|
-
const allResources = [...localResources, ...remoteResources]
|
|
1021
|
+
const allResources = [...localResources, ...remoteResources].sort(
|
|
1022
|
+
(a, b) => a.uri.localeCompare(b.uri)
|
|
1023
|
+
);
|
|
955
1024
|
const rlTelemetry = TokenTelemetryEngine.getInstance();
|
|
956
1025
|
const rlPayload = JSON.stringify(allResources);
|
|
957
1026
|
rlTelemetry.record({
|
|
@@ -960,11 +1029,21 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
960
1029
|
estimatedInputTokens: 0,
|
|
961
1030
|
estimatedOutputTokens: rlTelemetry.countTokens(rlPayload)
|
|
962
1031
|
});
|
|
963
|
-
|
|
1032
|
+
const era = this.detectEra(request);
|
|
1033
|
+
let response = {
|
|
964
1034
|
jsonrpc: "2.0",
|
|
965
1035
|
id,
|
|
966
|
-
result: {
|
|
1036
|
+
result: {
|
|
1037
|
+
resultType: "complete",
|
|
1038
|
+
ttlMs: 3e5,
|
|
1039
|
+
cacheScope: "public",
|
|
1040
|
+
resources: allResources
|
|
1041
|
+
}
|
|
967
1042
|
};
|
|
1043
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1044
|
+
response = adaptResponseForLegacyClient(response);
|
|
1045
|
+
}
|
|
1046
|
+
return response;
|
|
968
1047
|
}
|
|
969
1048
|
case "resources/read": {
|
|
970
1049
|
const typedParams = params;
|
|
@@ -987,7 +1066,23 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
987
1066
|
estimatedOutputTokens: rrTelemetry.countTokens(rrOutputPayload),
|
|
988
1067
|
durationMs: Date.now() - rrStartTime
|
|
989
1068
|
});
|
|
990
|
-
|
|
1069
|
+
const era = this.detectEra(request);
|
|
1070
|
+
const rawResult = typeof result === "object" && result !== null ? {
|
|
1071
|
+
resultType: "complete",
|
|
1072
|
+
ttlMs: 6e4,
|
|
1073
|
+
cacheScope: "private",
|
|
1074
|
+
...result
|
|
1075
|
+
} : {
|
|
1076
|
+
resultType: "complete",
|
|
1077
|
+
ttlMs: 6e4,
|
|
1078
|
+
cacheScope: "private",
|
|
1079
|
+
contents: result
|
|
1080
|
+
};
|
|
1081
|
+
let response = { jsonrpc: "2.0", id, result: rawResult };
|
|
1082
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1083
|
+
response = adaptResponseForLegacyClient(response);
|
|
1084
|
+
}
|
|
1085
|
+
return response;
|
|
991
1086
|
} catch (err) {
|
|
992
1087
|
const targetUri = typedParams.uri;
|
|
993
1088
|
for (const { manifest } of this.manifestCache.values()) {
|
|
@@ -998,10 +1093,14 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
998
1093
|
log.info(
|
|
999
1094
|
`[LIOP-Router] Resolved resource ${targetUri} from cache (Peer: ${manifest.peerId})`
|
|
1000
1095
|
);
|
|
1001
|
-
|
|
1096
|
+
const era = this.detectEra(request);
|
|
1097
|
+
let response = {
|
|
1002
1098
|
jsonrpc: "2.0",
|
|
1003
1099
|
id,
|
|
1004
1100
|
result: {
|
|
1101
|
+
resultType: "complete",
|
|
1102
|
+
ttlMs: 6e4,
|
|
1103
|
+
cacheScope: "private",
|
|
1005
1104
|
contents: [
|
|
1006
1105
|
{
|
|
1007
1106
|
uri: remoteResource.uri,
|
|
@@ -1011,6 +1110,10 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
1011
1110
|
]
|
|
1012
1111
|
}
|
|
1013
1112
|
};
|
|
1113
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1114
|
+
response = adaptResponseForLegacyClient(response);
|
|
1115
|
+
}
|
|
1116
|
+
return response;
|
|
1014
1117
|
}
|
|
1015
1118
|
}
|
|
1016
1119
|
return {
|
|
@@ -1024,7 +1127,7 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
1024
1127
|
}
|
|
1025
1128
|
}
|
|
1026
1129
|
case "prompts/list": {
|
|
1027
|
-
const promptsList = this.liopServer.listPrompts();
|
|
1130
|
+
const promptsList = this.liopServer.listPrompts().sort((a, b) => a.name.localeCompare(b.name));
|
|
1028
1131
|
const plTelemetry = TokenTelemetryEngine.getInstance();
|
|
1029
1132
|
const plPayload = JSON.stringify(promptsList);
|
|
1030
1133
|
plTelemetry.record({
|
|
@@ -1033,11 +1136,21 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
1033
1136
|
estimatedInputTokens: 0,
|
|
1034
1137
|
estimatedOutputTokens: plTelemetry.countTokens(plPayload)
|
|
1035
1138
|
});
|
|
1036
|
-
|
|
1139
|
+
const era = this.detectEra(request);
|
|
1140
|
+
let response = {
|
|
1037
1141
|
jsonrpc: "2.0",
|
|
1038
1142
|
id,
|
|
1039
|
-
result: {
|
|
1143
|
+
result: {
|
|
1144
|
+
resultType: "complete",
|
|
1145
|
+
ttlMs: 3e5,
|
|
1146
|
+
cacheScope: "public",
|
|
1147
|
+
prompts: promptsList
|
|
1148
|
+
}
|
|
1040
1149
|
};
|
|
1150
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1151
|
+
response = adaptResponseForLegacyClient(response);
|
|
1152
|
+
}
|
|
1153
|
+
return response;
|
|
1041
1154
|
}
|
|
1042
1155
|
case "prompts/get": {
|
|
1043
1156
|
const typedParams = params;
|
|
@@ -1067,7 +1180,13 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
1067
1180
|
estimatedOutputTokens: pgTelemetry.countTokens(pgOutputPayload),
|
|
1068
1181
|
durationMs: Date.now() - pgStartTime
|
|
1069
1182
|
});
|
|
1070
|
-
|
|
1183
|
+
const era = this.detectEra(request);
|
|
1184
|
+
const rawResult = typeof result === "object" && result !== null ? { resultType: "complete", ...result } : result;
|
|
1185
|
+
let response = { jsonrpc: "2.0", id, result: rawResult };
|
|
1186
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1187
|
+
response = adaptResponseForLegacyClient(response);
|
|
1188
|
+
}
|
|
1189
|
+
return response;
|
|
1071
1190
|
} catch (err) {
|
|
1072
1191
|
return {
|
|
1073
1192
|
jsonrpc: "2.0",
|
|
@@ -1079,6 +1198,37 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
1079
1198
|
};
|
|
1080
1199
|
}
|
|
1081
1200
|
}
|
|
1201
|
+
case "resources/templates/list": {
|
|
1202
|
+
const era = this.detectEra(request);
|
|
1203
|
+
let response = {
|
|
1204
|
+
jsonrpc: "2.0",
|
|
1205
|
+
id,
|
|
1206
|
+
result: {
|
|
1207
|
+
resultType: "complete",
|
|
1208
|
+
ttlMs: 3e5,
|
|
1209
|
+
cacheScope: "public",
|
|
1210
|
+
resourceTemplates: []
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1214
|
+
response = adaptResponseForLegacyClient(response);
|
|
1215
|
+
}
|
|
1216
|
+
return response;
|
|
1217
|
+
}
|
|
1218
|
+
case "subscriptions/listen": {
|
|
1219
|
+
const era = this.detectEra(request);
|
|
1220
|
+
let response = {
|
|
1221
|
+
jsonrpc: "2.0",
|
|
1222
|
+
id,
|
|
1223
|
+
result: {
|
|
1224
|
+
resultType: "complete"
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
if (era === "legacy" && MCP_LEGACY_SUPPORT_ENABLED) {
|
|
1228
|
+
response = adaptResponseForLegacyClient(response);
|
|
1229
|
+
}
|
|
1230
|
+
return response;
|
|
1231
|
+
}
|
|
1082
1232
|
default:
|
|
1083
1233
|
return {
|
|
1084
1234
|
jsonrpc: "2.0",
|
|
@@ -1224,6 +1374,24 @@ var LiopMcpRouter = class _LiopMcpRouter {
|
|
|
1224
1374
|
for (const result of queryResults) {
|
|
1225
1375
|
if (result.status === "fulfilled" && result.value?.manifest) {
|
|
1226
1376
|
const { peerId, manifest } = result.value;
|
|
1377
|
+
if (manifest.pqcSignature && manifest.pqcPublicKey) {
|
|
1378
|
+
const isValid = Dilithium65Wrapper.verifyManifest(
|
|
1379
|
+
manifest,
|
|
1380
|
+
manifest.pqcSignature,
|
|
1381
|
+
manifest.pqcPublicKey
|
|
1382
|
+
);
|
|
1383
|
+
if (!isValid) {
|
|
1384
|
+
log.warn(
|
|
1385
|
+
`[LIOP-Router] \u26A0\uFE0F Tampered manifest rejected for peer ${peerId} (ML-DSA-65 signature invalid)`
|
|
1386
|
+
);
|
|
1387
|
+
this.recordManifestQueryFailure(peerId);
|
|
1388
|
+
errorCount++;
|
|
1389
|
+
continue;
|
|
1390
|
+
}
|
|
1391
|
+
log.info(
|
|
1392
|
+
`[LIOP-Router] \u{1F512} ML-DSA-65 (FIPS 204) Manifest attestation verified for peer ${peerId}`
|
|
1393
|
+
);
|
|
1394
|
+
}
|
|
1227
1395
|
this.manifestCache.set(peerId, {
|
|
1228
1396
|
manifest,
|
|
1229
1397
|
cachedAt: Date.now()
|
|
@@ -1671,28 +1839,42 @@ ${cachedToolList}` : "\nNo remote tools discovered yet.",
|
|
|
1671
1839
|
manifestEntry = this.manifestCache.get(peerId);
|
|
1672
1840
|
}
|
|
1673
1841
|
}
|
|
1674
|
-
const shouldRemapGrpcPorts = process.env.LIOP_USE_PUBLISHED_GRPC_PORTS === "1" || process.env.LIOP_DOCKER_MAP === "true" || process.env.LIOP_DEV_MODE === "true" || process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
|
|
1675
|
-
if (shouldRemapGrpcPorts && manifestEntry) {
|
|
1676
|
-
const providerName = manifestEntry.manifest.serverInfo?.name?.toLowerCase() || "";
|
|
1677
|
-
if (providerName.includes("vault")) grpcPort = 13011;
|
|
1678
|
-
else if (providerName.includes("bank")) grpcPort = 13021;
|
|
1679
|
-
else if (providerName.includes("oracle")) grpcPort = 13031;
|
|
1680
|
-
}
|
|
1681
1842
|
const addrs = await this.meshNode.resolvePeer(peerId);
|
|
1843
|
+
const nexusUrl = process.env.LIOP_NEXUS_URL || "";
|
|
1844
|
+
const isDockerDemo = nexusUrl.includes("127.0.0.1:13000") || nexusUrl.includes("localhost:13000") || nexusUrl.includes("127.0.0.1:13001") || nexusUrl.includes("localhost:13001");
|
|
1845
|
+
const isDockerPort = addrs.some(
|
|
1846
|
+
(a) => a.includes("13001") || a.includes("13003") || a.includes("13004") || a.includes("13005") || a.includes("13011") || a.includes("13021") || a.includes("13031")
|
|
1847
|
+
);
|
|
1848
|
+
const shouldRemapGrpcPorts = process.env.LIOP_USE_PUBLISHED_GRPC_PORTS === "1" || process.env.LIOP_DOCKER_MAP === "true" || process.env.LIOP_DEV_MODE === "true" || process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test" || isDockerDemo || isDockerPort;
|
|
1849
|
+
if (shouldRemapGrpcPorts) {
|
|
1850
|
+
const providerName = manifestEntry?.manifest?.serverInfo?.name?.toLowerCase() || "";
|
|
1851
|
+
const tn = toolName.toLowerCase();
|
|
1852
|
+
if (providerName.includes("vault") || tn.includes("medical")) {
|
|
1853
|
+
grpcPort = 13011;
|
|
1854
|
+
} else if (providerName.includes("bank") || tn.includes("bank")) {
|
|
1855
|
+
grpcPort = 13021;
|
|
1856
|
+
} else if (providerName.includes("oracle") || tn.includes("hft") || tn.includes("market")) {
|
|
1857
|
+
grpcPort = 13031;
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1682
1860
|
let targetAddr = null;
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
const
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1861
|
+
if (shouldRemapGrpcPorts) {
|
|
1862
|
+
targetAddr = `127.0.0.1:${grpcPort}`;
|
|
1863
|
+
} else {
|
|
1864
|
+
const os = await import('os');
|
|
1865
|
+
const localInterfaces = Object.values(os.networkInterfaces()).flat().filter((i) => i?.family === "IPv4").map((i) => i?.address);
|
|
1866
|
+
for (const addr of addrs) {
|
|
1867
|
+
const parts = addr.split("/");
|
|
1868
|
+
const ipIdx = parts.indexOf("ip4");
|
|
1869
|
+
if (ipIdx !== -1) {
|
|
1870
|
+
const advertisedIp = parts[ipIdx + 1];
|
|
1871
|
+
if (advertisedIp === "127.0.0.1" || localInterfaces.includes(advertisedIp)) {
|
|
1872
|
+
targetAddr = `127.0.0.1:${grpcPort}`;
|
|
1873
|
+
break;
|
|
1874
|
+
}
|
|
1875
|
+
if (!targetAddr) {
|
|
1876
|
+
targetAddr = `${advertisedIp}:${grpcPort}`;
|
|
1877
|
+
}
|
|
1696
1878
|
}
|
|
1697
1879
|
}
|
|
1698
1880
|
}
|
|
@@ -1704,7 +1886,8 @@ ${cachedToolList}` : "\nNo remote tools discovered yet.",
|
|
|
1704
1886
|
);
|
|
1705
1887
|
const remoteClient = new liopV1.LogicMesh(
|
|
1706
1888
|
targetAddr,
|
|
1707
|
-
createChannelCredentials()
|
|
1889
|
+
createChannelCredentials(),
|
|
1890
|
+
GRPC_CHANNEL_OPTIONS
|
|
1708
1891
|
);
|
|
1709
1892
|
return this.performTranscoding(
|
|
1710
1893
|
id,
|
|
@@ -1868,7 +2051,8 @@ ${cachedToolList}` : "\nNo remote tools discovered yet.",
|
|
|
1868
2051
|
const { ciphertext, sharedSecret } = await Kyber768Wrapper.encapsulateAsymmetric(
|
|
1869
2052
|
response.kyber_public_key
|
|
1870
2053
|
);
|
|
1871
|
-
const
|
|
2054
|
+
const embeddedArgs = params?.arguments ?? (params?.payload !== void 0 ? params : {});
|
|
2055
|
+
const embeddedArgsJson = JSON.stringify(embeddedArgs);
|
|
1872
2056
|
const proxyLogic = `return { "__liop_proxy_tool": "${toolName}", "__liop_proxy_args": ${embeddedArgsJson} };`;
|
|
1873
2057
|
const nonce = crypto2.randomBytes(12);
|
|
1874
2058
|
const sealedLogic = this.encryptWithNonce(
|
|
@@ -1972,5 +2156,5 @@ ${cachedToolList}` : "\nNo remote tools discovered yet.",
|
|
|
1972
2156
|
};
|
|
1973
2157
|
|
|
1974
2158
|
export { HeuristicTokenEstimator, LiopMcpRouter, LiopOTelBridge, RealTokenEstimator, TokenTelemetryEngine, createSyncTokenEstimator, createTokenEstimator };
|
|
1975
|
-
//# sourceMappingURL=chunk-
|
|
1976
|
-
//# sourceMappingURL=chunk-
|
|
2159
|
+
//# sourceMappingURL=chunk-KF4DCCU3.js.map
|
|
2160
|
+
//# sourceMappingURL=chunk-KF4DCCU3.js.map
|