mcp-use 1.10.0-canary.10 → 1.10.0-canary.11
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/.tsbuildinfo +1 -1
- package/dist/{chunk-ZMA4JG4C.js → chunk-5S5DWSKI.js} +1 -1
- package/dist/{chunk-NBSNYHID.js → chunk-5UB2K5L6.js} +51 -2
- package/dist/{chunk-BPP5XYP6.js → chunk-B5N3LQQU.js} +1 -1
- package/dist/{chunk-NRALSDBH.js → chunk-KMTBWOVS.js} +1 -1
- package/dist/{chunk-BFSVTG6G.js → chunk-LXYUQEEE.js} +24 -2
- package/dist/{chunk-PL645KUX.js → chunk-NNQUSDFU.js} +1 -1
- package/dist/{chunk-6EYDSXO6.js → chunk-PESKSVLQ.js} +344 -157
- package/dist/index.cjs +419 -161
- package/dist/index.js +14 -8
- package/dist/src/agents/index.cjs +337 -151
- package/dist/src/agents/index.js +4 -4
- package/dist/src/browser.cjs +371 -151
- package/dist/src/browser.d.ts +3 -0
- package/dist/src/browser.d.ts.map +1 -1
- package/dist/src/browser.js +13 -5
- package/dist/src/client/base.d.ts.map +1 -1
- package/dist/src/client/browser.d.ts +1 -0
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/client/prompts.cjs +3 -9
- package/dist/src/client/prompts.js +3 -3
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/react/index.cjs +414 -151
- package/dist/src/react/index.d.ts +3 -0
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/index.js +13 -4
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +756 -569
- package/dist/src/server/index.js +5 -5
- package/dist/src/telemetry/events.d.ts +28 -0
- package/dist/src/telemetry/events.d.ts.map +1 -1
- package/dist/src/telemetry/index.d.ts +4 -4
- package/dist/src/telemetry/index.d.ts.map +1 -1
- package/dist/src/telemetry/telemetry.d.ts +74 -11
- package/dist/src/telemetry/telemetry.d.ts.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/{tool-execution-helpers-XFVBSRXM.js → tool-execution-helpers-OOVLOJYH.js} +2 -2
- package/package.json +4 -3
package/dist/src/react/index.cjs
CHANGED
|
@@ -31,12 +31,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/react/index.ts
|
|
32
32
|
var react_exports = {};
|
|
33
33
|
__export(react_exports, {
|
|
34
|
+
BrowserTelemetry: () => Tel,
|
|
34
35
|
ErrorBoundary: () => ErrorBoundary,
|
|
35
36
|
Image: () => Image,
|
|
36
37
|
McpUseProvider: () => McpUseProvider,
|
|
38
|
+
Tel: () => Tel,
|
|
39
|
+
Telemetry: () => Telemetry,
|
|
37
40
|
ThemeProvider: () => ThemeProvider,
|
|
38
41
|
WidgetControls: () => WidgetControls,
|
|
39
42
|
onMcpAuthorization: () => onMcpAuthorization,
|
|
43
|
+
setBrowserTelemetrySource: () => setTelemetrySource,
|
|
44
|
+
setTelemetrySource: () => setTelemetrySource,
|
|
40
45
|
useMcp: () => useMcp,
|
|
41
46
|
useWidget: () => useWidget,
|
|
42
47
|
useWidgetProps: () => useWidgetProps,
|
|
@@ -82,9 +87,9 @@ var import_streamableHttp = require("@mcp-use/modelcontextprotocol-sdk/client/st
|
|
|
82
87
|
async function getNodeModules() {
|
|
83
88
|
if (typeof process !== "undefined" && process.platform) {
|
|
84
89
|
try {
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
return { fs:
|
|
90
|
+
const fs = await import("fs");
|
|
91
|
+
const path = await import("path");
|
|
92
|
+
return { fs: fs.default, path: path.default };
|
|
88
93
|
} catch {
|
|
89
94
|
return { fs: null, path: null };
|
|
90
95
|
}
|
|
@@ -515,19 +520,6 @@ var SseConnectionManager = class extends ConnectionManager {
|
|
|
515
520
|
// src/connectors/base.ts
|
|
516
521
|
var import_types = require("@mcp-use/modelcontextprotocol-sdk/types.js");
|
|
517
522
|
|
|
518
|
-
// src/telemetry/telemetry.ts
|
|
519
|
-
var fs = __toESM(require("fs"), 1);
|
|
520
|
-
var os = __toESM(require("os"), 1);
|
|
521
|
-
var path = __toESM(require("path"), 1);
|
|
522
|
-
var import_posthog_node = require("posthog-node");
|
|
523
|
-
|
|
524
|
-
// src/server/utils/runtime.ts
|
|
525
|
-
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
526
|
-
function generateUUID() {
|
|
527
|
-
return globalThis.crypto.randomUUID();
|
|
528
|
-
}
|
|
529
|
-
__name(generateUUID, "generateUUID");
|
|
530
|
-
|
|
531
523
|
// src/telemetry/events.ts
|
|
532
524
|
var BaseTelemetryEvent = class {
|
|
533
525
|
static {
|
|
@@ -803,7 +795,8 @@ var MCPClientInitEvent = class extends BaseTelemetryEvent {
|
|
|
803
795
|
all_callbacks: this.data.allCallbacks,
|
|
804
796
|
verify: this.data.verify,
|
|
805
797
|
servers: this.data.servers,
|
|
806
|
-
num_servers: this.data.numServers
|
|
798
|
+
num_servers: this.data.numServers,
|
|
799
|
+
is_browser: this.data.isBrowser
|
|
807
800
|
};
|
|
808
801
|
}
|
|
809
802
|
};
|
|
@@ -828,9 +821,62 @@ var ConnectorInitEvent = class extends BaseTelemetryEvent {
|
|
|
828
821
|
};
|
|
829
822
|
}
|
|
830
823
|
};
|
|
824
|
+
var ClientAddServerEvent = class extends BaseTelemetryEvent {
|
|
825
|
+
constructor(data) {
|
|
826
|
+
super();
|
|
827
|
+
this.data = data;
|
|
828
|
+
}
|
|
829
|
+
static {
|
|
830
|
+
__name(this, "ClientAddServerEvent");
|
|
831
|
+
}
|
|
832
|
+
get name() {
|
|
833
|
+
return "client_add_server";
|
|
834
|
+
}
|
|
835
|
+
get properties() {
|
|
836
|
+
const { serverName, serverConfig } = this.data;
|
|
837
|
+
const url = serverConfig.url;
|
|
838
|
+
return {
|
|
839
|
+
server_name: serverName,
|
|
840
|
+
server_url_domain: url ? this._extractHostname(url) : null,
|
|
841
|
+
transport: serverConfig.transport ?? null,
|
|
842
|
+
has_auth: !!(serverConfig.authToken || serverConfig.authProvider)
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
_extractHostname(url) {
|
|
846
|
+
try {
|
|
847
|
+
return new URL(url).hostname;
|
|
848
|
+
} catch {
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
var ClientRemoveServerEvent = class extends BaseTelemetryEvent {
|
|
854
|
+
constructor(data) {
|
|
855
|
+
super();
|
|
856
|
+
this.data = data;
|
|
857
|
+
}
|
|
858
|
+
static {
|
|
859
|
+
__name(this, "ClientRemoveServerEvent");
|
|
860
|
+
}
|
|
861
|
+
get name() {
|
|
862
|
+
return "client_remove_server";
|
|
863
|
+
}
|
|
864
|
+
get properties() {
|
|
865
|
+
return {
|
|
866
|
+
server_name: this.data.serverName
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
|
|
871
|
+
// src/server/utils/runtime.ts
|
|
872
|
+
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
873
|
+
function generateUUID() {
|
|
874
|
+
return globalThis.crypto.randomUUID();
|
|
875
|
+
}
|
|
876
|
+
__name(generateUUID, "generateUUID");
|
|
831
877
|
|
|
832
878
|
// src/version.ts
|
|
833
|
-
var VERSION = "1.10.0-canary.
|
|
879
|
+
var VERSION = "1.10.0-canary.11";
|
|
834
880
|
function getPackageVersion() {
|
|
835
881
|
return VERSION;
|
|
836
882
|
}
|
|
@@ -852,12 +898,12 @@ function detectRuntimeEnvironment() {
|
|
|
852
898
|
if (typeof globalThis.EdgeRuntime !== "undefined") {
|
|
853
899
|
return "edge";
|
|
854
900
|
}
|
|
855
|
-
if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined" && typeof fs !== "undefined" && typeof fs.existsSync === "function") {
|
|
856
|
-
return "node";
|
|
857
|
-
}
|
|
858
901
|
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
859
902
|
return "browser";
|
|
860
903
|
}
|
|
904
|
+
if (typeof process !== "undefined" && typeof process.versions?.node !== "undefined") {
|
|
905
|
+
return "node";
|
|
906
|
+
}
|
|
861
907
|
return "unknown";
|
|
862
908
|
} catch {
|
|
863
909
|
return "unknown";
|
|
@@ -894,11 +940,6 @@ function getRuntimeEnvironment() {
|
|
|
894
940
|
return cachedEnvironment;
|
|
895
941
|
}
|
|
896
942
|
__name(getRuntimeEnvironment, "getRuntimeEnvironment");
|
|
897
|
-
function isNodeJSEnvironment2() {
|
|
898
|
-
const env = getRuntimeEnvironment();
|
|
899
|
-
return env === "node" || env === "bun";
|
|
900
|
-
}
|
|
901
|
-
__name(isNodeJSEnvironment2, "isNodeJSEnvironment");
|
|
902
943
|
var ScarfEventLogger = class {
|
|
903
944
|
static {
|
|
904
945
|
__name(this, "ScarfEventLogger");
|
|
@@ -930,71 +971,40 @@ var ScarfEventLogger = class {
|
|
|
930
971
|
}
|
|
931
972
|
}
|
|
932
973
|
};
|
|
933
|
-
function getCacheHome() {
|
|
934
|
-
if (!isNodeJSEnvironment2()) {
|
|
935
|
-
return "/tmp/mcp_use_cache";
|
|
936
|
-
}
|
|
937
|
-
const envVar = process.env.XDG_CACHE_HOME;
|
|
938
|
-
if (envVar && path.isAbsolute(envVar)) {
|
|
939
|
-
return envVar;
|
|
940
|
-
}
|
|
941
|
-
const platform = process.platform;
|
|
942
|
-
const homeDir = os.homedir();
|
|
943
|
-
if (platform === "win32") {
|
|
944
|
-
const appdata = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
945
|
-
if (appdata) {
|
|
946
|
-
return appdata;
|
|
947
|
-
}
|
|
948
|
-
return path.join(homeDir, "AppData", "Local");
|
|
949
|
-
} else if (platform === "darwin") {
|
|
950
|
-
return path.join(homeDir, "Library", "Caches");
|
|
951
|
-
} else {
|
|
952
|
-
return path.join(homeDir, ".cache");
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
__name(getCacheHome, "getCacheHome");
|
|
956
974
|
var Telemetry = class _Telemetry {
|
|
957
975
|
static {
|
|
958
976
|
__name(this, "Telemetry");
|
|
959
977
|
}
|
|
960
978
|
static instance = null;
|
|
961
|
-
USER_ID_PATH = path.join(
|
|
962
|
-
getCacheHome(),
|
|
963
|
-
"mcp_use_3",
|
|
964
|
-
"telemetry_user_id"
|
|
965
|
-
);
|
|
966
|
-
VERSION_DOWNLOAD_PATH = path.join(
|
|
967
|
-
getCacheHome(),
|
|
968
|
-
"mcp_use",
|
|
969
|
-
"download_version"
|
|
970
|
-
);
|
|
971
979
|
PROJECT_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
972
980
|
HOST = "https://eu.i.posthog.com";
|
|
973
981
|
SCARF_GATEWAY_URL = "https://mcpuse.gateway.scarf.sh/events-ts";
|
|
974
982
|
UNKNOWN_USER_ID = "UNKNOWN_USER_ID";
|
|
975
983
|
_currUserId = null;
|
|
976
|
-
|
|
984
|
+
_posthogNodeClient = null;
|
|
985
|
+
_posthogBrowserClient = null;
|
|
986
|
+
_posthogLoading = null;
|
|
977
987
|
_scarfClient = null;
|
|
978
988
|
_runtimeEnvironment;
|
|
979
989
|
_storageCapability;
|
|
980
990
|
_source;
|
|
991
|
+
// Node.js specific paths (lazily computed)
|
|
992
|
+
_userIdPath = null;
|
|
993
|
+
_versionDownloadPath = null;
|
|
981
994
|
constructor() {
|
|
982
995
|
this._runtimeEnvironment = getRuntimeEnvironment();
|
|
983
996
|
this._storageCapability = getStorageCapability(this._runtimeEnvironment);
|
|
984
997
|
this._source = typeof process !== "undefined" && process.env?.MCP_USE_TELEMETRY_SOURCE || this._runtimeEnvironment;
|
|
985
|
-
const telemetryDisabled =
|
|
998
|
+
const telemetryDisabled = this._checkTelemetryDisabled();
|
|
986
999
|
const canSupportTelemetry = this._runtimeEnvironment !== "unknown";
|
|
987
|
-
const isServerlessEnvironment = [
|
|
988
|
-
"cloudflare-workers",
|
|
989
|
-
"edge",
|
|
990
|
-
"deno"
|
|
991
|
-
].includes(this._runtimeEnvironment);
|
|
992
1000
|
if (telemetryDisabled) {
|
|
993
|
-
this.
|
|
1001
|
+
this._posthogNodeClient = null;
|
|
1002
|
+
this._posthogBrowserClient = null;
|
|
994
1003
|
this._scarfClient = null;
|
|
995
|
-
logger.debug("Telemetry disabled via environment
|
|
1004
|
+
logger.debug("Telemetry disabled via environment/localStorage");
|
|
996
1005
|
} else if (!canSupportTelemetry) {
|
|
997
|
-
this.
|
|
1006
|
+
this._posthogNodeClient = null;
|
|
1007
|
+
this._posthogBrowserClient = null;
|
|
998
1008
|
this._scarfClient = null;
|
|
999
1009
|
logger.debug(
|
|
1000
1010
|
`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`
|
|
@@ -1003,27 +1013,7 @@ var Telemetry = class _Telemetry {
|
|
|
1003
1013
|
logger.info(
|
|
1004
1014
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
1005
1015
|
);
|
|
1006
|
-
|
|
1007
|
-
try {
|
|
1008
|
-
const posthogOptions = {
|
|
1009
|
-
host: this.HOST,
|
|
1010
|
-
disableGeoip: false
|
|
1011
|
-
};
|
|
1012
|
-
if (isServerlessEnvironment) {
|
|
1013
|
-
posthogOptions.flushAt = 1;
|
|
1014
|
-
posthogOptions.flushInterval = 0;
|
|
1015
|
-
}
|
|
1016
|
-
this._posthogClient = new import_posthog_node.PostHog(
|
|
1017
|
-
this.PROJECT_API_KEY,
|
|
1018
|
-
posthogOptions
|
|
1019
|
-
);
|
|
1020
|
-
} catch (e) {
|
|
1021
|
-
logger.warn(`Failed to initialize PostHog telemetry: ${e}`);
|
|
1022
|
-
this._posthogClient = null;
|
|
1023
|
-
}
|
|
1024
|
-
} else {
|
|
1025
|
-
this._posthogClient = null;
|
|
1026
|
-
}
|
|
1016
|
+
this._posthogLoading = this._initPostHog();
|
|
1027
1017
|
try {
|
|
1028
1018
|
this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
|
|
1029
1019
|
} catch (e) {
|
|
@@ -1032,6 +1022,75 @@ var Telemetry = class _Telemetry {
|
|
|
1032
1022
|
}
|
|
1033
1023
|
}
|
|
1034
1024
|
}
|
|
1025
|
+
_checkTelemetryDisabled() {
|
|
1026
|
+
if (typeof process !== "undefined" && process.env?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false") {
|
|
1027
|
+
return true;
|
|
1028
|
+
}
|
|
1029
|
+
if (typeof localStorage !== "undefined" && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") {
|
|
1030
|
+
return true;
|
|
1031
|
+
}
|
|
1032
|
+
return false;
|
|
1033
|
+
}
|
|
1034
|
+
async _initPostHog() {
|
|
1035
|
+
const isBrowser = this._runtimeEnvironment === "browser";
|
|
1036
|
+
if (isBrowser) {
|
|
1037
|
+
await this._initPostHogBrowser();
|
|
1038
|
+
} else {
|
|
1039
|
+
await this._initPostHogNode();
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
async _initPostHogBrowser() {
|
|
1043
|
+
try {
|
|
1044
|
+
const posthogModule = await import("posthog-js");
|
|
1045
|
+
const posthog = posthogModule.default || posthogModule.posthog;
|
|
1046
|
+
if (!posthog || typeof posthog.init !== "function") {
|
|
1047
|
+
throw new Error("posthog-js module did not export expected interface");
|
|
1048
|
+
}
|
|
1049
|
+
posthog.init(this.PROJECT_API_KEY, {
|
|
1050
|
+
api_host: this.HOST,
|
|
1051
|
+
persistence: "localStorage",
|
|
1052
|
+
autocapture: false,
|
|
1053
|
+
// We only want explicit captures
|
|
1054
|
+
capture_pageview: false,
|
|
1055
|
+
// We don't want automatic pageview tracking
|
|
1056
|
+
disable_session_recording: true,
|
|
1057
|
+
// No session recording
|
|
1058
|
+
loaded: /* @__PURE__ */ __name(() => {
|
|
1059
|
+
logger.debug("PostHog browser client initialized");
|
|
1060
|
+
}, "loaded")
|
|
1061
|
+
});
|
|
1062
|
+
this._posthogBrowserClient = posthog;
|
|
1063
|
+
} catch (e) {
|
|
1064
|
+
logger.warn(`Failed to initialize PostHog browser telemetry: ${e}`);
|
|
1065
|
+
this._posthogBrowserClient = null;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
async _initPostHogNode() {
|
|
1069
|
+
try {
|
|
1070
|
+
const { PostHog } = await import("posthog-node");
|
|
1071
|
+
const isServerlessEnvironment = [
|
|
1072
|
+
"cloudflare-workers",
|
|
1073
|
+
"edge",
|
|
1074
|
+
"deno"
|
|
1075
|
+
].includes(this._runtimeEnvironment);
|
|
1076
|
+
const posthogOptions = {
|
|
1077
|
+
host: this.HOST,
|
|
1078
|
+
disableGeoip: false
|
|
1079
|
+
};
|
|
1080
|
+
if (isServerlessEnvironment) {
|
|
1081
|
+
posthogOptions.flushAt = 1;
|
|
1082
|
+
posthogOptions.flushInterval = 0;
|
|
1083
|
+
}
|
|
1084
|
+
this._posthogNodeClient = new PostHog(
|
|
1085
|
+
this.PROJECT_API_KEY,
|
|
1086
|
+
posthogOptions
|
|
1087
|
+
);
|
|
1088
|
+
logger.debug("PostHog Node.js client initialized");
|
|
1089
|
+
} catch (e) {
|
|
1090
|
+
logger.warn(`Failed to initialize PostHog Node.js telemetry: ${e}`);
|
|
1091
|
+
this._posthogNodeClient = null;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1035
1094
|
/**
|
|
1036
1095
|
* Get the detected runtime environment
|
|
1037
1096
|
*/
|
|
@@ -1067,10 +1126,9 @@ var Telemetry = class _Telemetry {
|
|
|
1067
1126
|
}
|
|
1068
1127
|
/**
|
|
1069
1128
|
* Check if telemetry is enabled.
|
|
1070
|
-
* Returns false if telemetry was disabled via environment variable or if not in Node.js environment.
|
|
1071
1129
|
*/
|
|
1072
1130
|
get isEnabled() {
|
|
1073
|
-
return this.
|
|
1131
|
+
return this._posthogNodeClient !== null || this._posthogBrowserClient !== null || this._scarfClient !== null;
|
|
1074
1132
|
}
|
|
1075
1133
|
get userId() {
|
|
1076
1134
|
if (this._currUserId) {
|
|
@@ -1079,10 +1137,10 @@ var Telemetry = class _Telemetry {
|
|
|
1079
1137
|
try {
|
|
1080
1138
|
switch (this._storageCapability) {
|
|
1081
1139
|
case "filesystem":
|
|
1082
|
-
this._currUserId = this.
|
|
1140
|
+
this._currUserId = this._getUserIdFromFilesystem();
|
|
1083
1141
|
break;
|
|
1084
1142
|
case "localStorage":
|
|
1085
|
-
this._currUserId = this.
|
|
1143
|
+
this._currUserId = this._getUserIdFromLocalStorage();
|
|
1086
1144
|
break;
|
|
1087
1145
|
case "session-only":
|
|
1088
1146
|
default:
|
|
@@ -1093,7 +1151,7 @@ var Telemetry = class _Telemetry {
|
|
|
1093
1151
|
break;
|
|
1094
1152
|
}
|
|
1095
1153
|
if (this._storageCapability === "filesystem" && this._currUserId) {
|
|
1096
|
-
this.
|
|
1154
|
+
this._trackPackageDownloadInternal(this._currUserId, {
|
|
1097
1155
|
triggered_by: "user_id_property"
|
|
1098
1156
|
}).catch((e) => logger.debug(`Failed to track package download: ${e}`));
|
|
1099
1157
|
}
|
|
@@ -1106,22 +1164,32 @@ var Telemetry = class _Telemetry {
|
|
|
1106
1164
|
/**
|
|
1107
1165
|
* Get or create user ID from filesystem (Node.js/Bun)
|
|
1108
1166
|
*/
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1167
|
+
_getUserIdFromFilesystem() {
|
|
1168
|
+
const fs = require("fs");
|
|
1169
|
+
const os = require("os");
|
|
1170
|
+
const path = require("path");
|
|
1171
|
+
if (!this._userIdPath) {
|
|
1172
|
+
this._userIdPath = path.join(
|
|
1173
|
+
this._getCacheHome(os, path),
|
|
1174
|
+
"mcp_use_3",
|
|
1175
|
+
"telemetry_user_id"
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
const isFirstTime = !fs.existsSync(this._userIdPath);
|
|
1111
1179
|
if (isFirstTime) {
|
|
1112
|
-
logger.debug(`Creating user ID path: ${this.
|
|
1113
|
-
fs.mkdirSync(path.dirname(this.
|
|
1180
|
+
logger.debug(`Creating user ID path: ${this._userIdPath}`);
|
|
1181
|
+
fs.mkdirSync(path.dirname(this._userIdPath), { recursive: true });
|
|
1114
1182
|
const newUserId = generateUUID();
|
|
1115
|
-
fs.writeFileSync(this.
|
|
1116
|
-
logger.debug(`User ID path created: ${this.
|
|
1183
|
+
fs.writeFileSync(this._userIdPath, newUserId);
|
|
1184
|
+
logger.debug(`User ID path created: ${this._userIdPath}`);
|
|
1117
1185
|
return newUserId;
|
|
1118
1186
|
}
|
|
1119
|
-
return fs.readFileSync(this.
|
|
1187
|
+
return fs.readFileSync(this._userIdPath, "utf-8").trim();
|
|
1120
1188
|
}
|
|
1121
1189
|
/**
|
|
1122
1190
|
* Get or create user ID from localStorage (Browser)
|
|
1123
1191
|
*/
|
|
1124
|
-
|
|
1192
|
+
_getUserIdFromLocalStorage() {
|
|
1125
1193
|
try {
|
|
1126
1194
|
let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
1127
1195
|
if (!userId) {
|
|
@@ -1135,60 +1203,89 @@ var Telemetry = class _Telemetry {
|
|
|
1135
1203
|
return `session-${generateUUID()}`;
|
|
1136
1204
|
}
|
|
1137
1205
|
}
|
|
1206
|
+
_getCacheHome(os, path) {
|
|
1207
|
+
const envVar = process.env.XDG_CACHE_HOME;
|
|
1208
|
+
if (envVar && path.isAbsolute(envVar)) {
|
|
1209
|
+
return envVar;
|
|
1210
|
+
}
|
|
1211
|
+
const platform = process.platform;
|
|
1212
|
+
const homeDir = os.homedir();
|
|
1213
|
+
if (platform === "win32") {
|
|
1214
|
+
const appdata = process.env.LOCALAPPDATA || process.env.APPDATA;
|
|
1215
|
+
if (appdata) {
|
|
1216
|
+
return appdata;
|
|
1217
|
+
}
|
|
1218
|
+
return path.join(homeDir, "AppData", "Local");
|
|
1219
|
+
} else if (platform === "darwin") {
|
|
1220
|
+
return path.join(homeDir, "Library", "Caches");
|
|
1221
|
+
} else {
|
|
1222
|
+
return path.join(homeDir, ".cache");
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1138
1225
|
async capture(event) {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
if (!this.
|
|
1226
|
+
if (this._posthogLoading) {
|
|
1227
|
+
await this._posthogLoading;
|
|
1228
|
+
}
|
|
1229
|
+
if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
|
|
1143
1230
|
return;
|
|
1144
1231
|
}
|
|
1145
|
-
|
|
1232
|
+
const properties = { ...event.properties };
|
|
1233
|
+
properties.mcp_use_version = getPackageVersion();
|
|
1234
|
+
properties.language = "typescript";
|
|
1235
|
+
properties.source = this._source;
|
|
1236
|
+
properties.runtime = this._runtimeEnvironment;
|
|
1237
|
+
if (this._posthogNodeClient) {
|
|
1146
1238
|
try {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
properties.language = "typescript";
|
|
1150
|
-
properties.source = this._source;
|
|
1151
|
-
properties.runtime = this._runtimeEnvironment;
|
|
1152
|
-
logger.debug(`CAPTURE: PostHog Event ${event.name}`);
|
|
1153
|
-
logger.debug(
|
|
1154
|
-
`CAPTURE: PostHog Properties ${JSON.stringify(properties)}`
|
|
1155
|
-
);
|
|
1156
|
-
this._posthogClient.capture({
|
|
1239
|
+
logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
|
|
1240
|
+
this._posthogNodeClient.capture({
|
|
1157
1241
|
distinctId: this.userId,
|
|
1158
1242
|
event: event.name,
|
|
1159
1243
|
properties
|
|
1160
1244
|
});
|
|
1161
1245
|
} catch (e) {
|
|
1162
|
-
logger.debug(`Failed to track PostHog event ${event.name}: ${e}`);
|
|
1246
|
+
logger.debug(`Failed to track PostHog Node event ${event.name}: ${e}`);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
if (this._posthogBrowserClient) {
|
|
1250
|
+
try {
|
|
1251
|
+
logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
|
|
1252
|
+
this._posthogBrowserClient.capture(event.name, {
|
|
1253
|
+
...properties,
|
|
1254
|
+
distinct_id: this.userId
|
|
1255
|
+
});
|
|
1256
|
+
} catch (e) {
|
|
1257
|
+
logger.debug(
|
|
1258
|
+
`Failed to track PostHog Browser event ${event.name}: ${e}`
|
|
1259
|
+
);
|
|
1163
1260
|
}
|
|
1164
1261
|
}
|
|
1165
1262
|
if (this._scarfClient) {
|
|
1166
1263
|
try {
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
properties.runtime = this._runtimeEnvironment;
|
|
1174
|
-
await this._scarfClient.logEvent(properties);
|
|
1264
|
+
const scarfProperties = {
|
|
1265
|
+
...properties,
|
|
1266
|
+
user_id: this.userId,
|
|
1267
|
+
event: event.name
|
|
1268
|
+
};
|
|
1269
|
+
await this._scarfClient.logEvent(scarfProperties);
|
|
1175
1270
|
} catch (e) {
|
|
1176
1271
|
logger.debug(`Failed to track Scarf event ${event.name}: ${e}`);
|
|
1177
1272
|
}
|
|
1178
1273
|
}
|
|
1179
1274
|
}
|
|
1275
|
+
// ============================================================================
|
|
1276
|
+
// Package Download Tracking (Node.js only)
|
|
1277
|
+
// ============================================================================
|
|
1180
1278
|
/**
|
|
1181
1279
|
* Track package download event.
|
|
1182
1280
|
* This is a public wrapper that safely accesses userId.
|
|
1183
1281
|
*/
|
|
1184
1282
|
async trackPackageDownload(properties) {
|
|
1185
|
-
return this.
|
|
1283
|
+
return this._trackPackageDownloadInternal(this.userId, properties);
|
|
1186
1284
|
}
|
|
1187
1285
|
/**
|
|
1188
1286
|
* Internal method to track package download with explicit userId.
|
|
1189
|
-
* This avoids circular dependency when called from the userId getter.
|
|
1190
1287
|
*/
|
|
1191
|
-
async
|
|
1288
|
+
async _trackPackageDownloadInternal(userId, properties) {
|
|
1192
1289
|
if (!this._scarfClient) {
|
|
1193
1290
|
return;
|
|
1194
1291
|
}
|
|
@@ -1196,22 +1293,32 @@ var Telemetry = class _Telemetry {
|
|
|
1196
1293
|
return;
|
|
1197
1294
|
}
|
|
1198
1295
|
try {
|
|
1296
|
+
const fs = require("fs");
|
|
1297
|
+
const path = require("path");
|
|
1298
|
+
const os = require("os");
|
|
1299
|
+
if (!this._versionDownloadPath) {
|
|
1300
|
+
this._versionDownloadPath = path.join(
|
|
1301
|
+
this._getCacheHome(os, path),
|
|
1302
|
+
"mcp_use",
|
|
1303
|
+
"download_version"
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1199
1306
|
const currentVersion = getPackageVersion();
|
|
1200
1307
|
let shouldTrack = false;
|
|
1201
1308
|
let firstDownload = false;
|
|
1202
|
-
if (!fs.existsSync(this.
|
|
1309
|
+
if (!fs.existsSync(this._versionDownloadPath)) {
|
|
1203
1310
|
shouldTrack = true;
|
|
1204
1311
|
firstDownload = true;
|
|
1205
|
-
fs.mkdirSync(path.dirname(this.
|
|
1312
|
+
fs.mkdirSync(path.dirname(this._versionDownloadPath), {
|
|
1206
1313
|
recursive: true
|
|
1207
1314
|
});
|
|
1208
|
-
fs.writeFileSync(this.
|
|
1315
|
+
fs.writeFileSync(this._versionDownloadPath, currentVersion);
|
|
1209
1316
|
} else {
|
|
1210
|
-
const savedVersion = fs.readFileSync(this.
|
|
1317
|
+
const savedVersion = fs.readFileSync(this._versionDownloadPath, "utf-8").trim();
|
|
1211
1318
|
if (currentVersion > savedVersion) {
|
|
1212
1319
|
shouldTrack = true;
|
|
1213
1320
|
firstDownload = false;
|
|
1214
|
-
fs.writeFileSync(this.
|
|
1321
|
+
fs.writeFileSync(this._versionDownloadPath, currentVersion);
|
|
1215
1322
|
}
|
|
1216
1323
|
}
|
|
1217
1324
|
if (shouldTrack) {
|
|
@@ -1245,9 +1352,6 @@ var Telemetry = class _Telemetry {
|
|
|
1245
1352
|
// ============================================================================
|
|
1246
1353
|
/**
|
|
1247
1354
|
* Track server run event directly from an MCPServer instance.
|
|
1248
|
-
* This extracts the necessary data from the server and creates the event.
|
|
1249
|
-
* @param server - The MCPServer instance (or any object conforming to MCPServerTelemetryInfo)
|
|
1250
|
-
* @param transport - The transport type (e.g., "http", "stdio", "supabase")
|
|
1251
1355
|
*/
|
|
1252
1356
|
async trackServerRunFromServer(server, transport) {
|
|
1253
1357
|
if (!this.isEnabled) return;
|
|
@@ -1293,33 +1397,125 @@ var Telemetry = class _Telemetry {
|
|
|
1293
1397
|
const event = new ConnectorInitEvent(data);
|
|
1294
1398
|
await this.capture(event);
|
|
1295
1399
|
}
|
|
1400
|
+
async trackClientAddServer(serverName, serverConfig) {
|
|
1401
|
+
if (!this.isEnabled) return;
|
|
1402
|
+
const event = new ClientAddServerEvent({ serverName, serverConfig });
|
|
1403
|
+
await this.capture(event);
|
|
1404
|
+
}
|
|
1405
|
+
async trackClientRemoveServer(serverName) {
|
|
1406
|
+
if (!this.isEnabled) return;
|
|
1407
|
+
const event = new ClientRemoveServerEvent({ serverName });
|
|
1408
|
+
await this.capture(event);
|
|
1409
|
+
}
|
|
1410
|
+
// ============================================================================
|
|
1411
|
+
// React Hook / Browser specific events
|
|
1412
|
+
// ============================================================================
|
|
1413
|
+
async trackUseMcpConnection(data) {
|
|
1414
|
+
if (!this.isEnabled) return;
|
|
1415
|
+
await this.capture({
|
|
1416
|
+
name: "usemcp_connection",
|
|
1417
|
+
properties: {
|
|
1418
|
+
url_domain: new URL(data.url).hostname,
|
|
1419
|
+
// Only domain for privacy
|
|
1420
|
+
transport_type: data.transportType,
|
|
1421
|
+
success: data.success,
|
|
1422
|
+
error_type: data.errorType ?? null,
|
|
1423
|
+
connection_time_ms: data.connectionTimeMs ?? null,
|
|
1424
|
+
has_oauth: data.hasOAuth,
|
|
1425
|
+
has_sampling: data.hasSampling,
|
|
1426
|
+
has_elicitation: data.hasElicitation
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
async trackUseMcpToolCall(data) {
|
|
1431
|
+
if (!this.isEnabled) return;
|
|
1432
|
+
await this.capture({
|
|
1433
|
+
name: "usemcp_tool_call",
|
|
1434
|
+
properties: {
|
|
1435
|
+
tool_name: data.toolName,
|
|
1436
|
+
success: data.success,
|
|
1437
|
+
error_type: data.errorType ?? null,
|
|
1438
|
+
execution_time_ms: data.executionTimeMs ?? null
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
async trackUseMcpResourceRead(data) {
|
|
1443
|
+
if (!this.isEnabled) return;
|
|
1444
|
+
await this.capture({
|
|
1445
|
+
name: "usemcp_resource_read",
|
|
1446
|
+
properties: {
|
|
1447
|
+
resource_uri_scheme: data.resourceUri.split(":")[0],
|
|
1448
|
+
// Only scheme for privacy
|
|
1449
|
+
success: data.success,
|
|
1450
|
+
error_type: data.errorType ?? null
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
// ============================================================================
|
|
1455
|
+
// Browser-specific Methods
|
|
1456
|
+
// ============================================================================
|
|
1457
|
+
/**
|
|
1458
|
+
* Identify the current user (useful for linking sessions)
|
|
1459
|
+
* Browser only - no-op in Node.js
|
|
1460
|
+
*/
|
|
1461
|
+
identify(userId, properties) {
|
|
1462
|
+
if (this._posthogBrowserClient) {
|
|
1463
|
+
try {
|
|
1464
|
+
this._posthogBrowserClient.identify(userId, properties);
|
|
1465
|
+
} catch (e) {
|
|
1466
|
+
logger.debug(`Failed to identify user: ${e}`);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Reset the user identity (useful for logout)
|
|
1472
|
+
* Browser only - no-op in Node.js
|
|
1473
|
+
*/
|
|
1474
|
+
reset() {
|
|
1475
|
+
if (this._posthogBrowserClient) {
|
|
1476
|
+
try {
|
|
1477
|
+
this._posthogBrowserClient.reset();
|
|
1478
|
+
} catch (e) {
|
|
1479
|
+
logger.debug(`Failed to reset user: ${e}`);
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
this._currUserId = null;
|
|
1483
|
+
}
|
|
1484
|
+
// ============================================================================
|
|
1485
|
+
// Node.js-specific Methods
|
|
1486
|
+
// ============================================================================
|
|
1487
|
+
/**
|
|
1488
|
+
* Flush the telemetry queue (Node.js only)
|
|
1489
|
+
*/
|
|
1296
1490
|
flush() {
|
|
1297
|
-
if (this.
|
|
1491
|
+
if (this._posthogNodeClient) {
|
|
1298
1492
|
try {
|
|
1299
|
-
this.
|
|
1493
|
+
this._posthogNodeClient.flush();
|
|
1300
1494
|
logger.debug("PostHog client telemetry queue flushed");
|
|
1301
1495
|
} catch (e) {
|
|
1302
1496
|
logger.debug(`Failed to flush PostHog client: ${e}`);
|
|
1303
1497
|
}
|
|
1304
1498
|
}
|
|
1305
|
-
if (this._scarfClient) {
|
|
1306
|
-
logger.debug("Scarf telemetry events sent immediately (no flush needed)");
|
|
1307
|
-
}
|
|
1308
1499
|
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Shutdown the telemetry client (Node.js only)
|
|
1502
|
+
*/
|
|
1309
1503
|
shutdown() {
|
|
1310
|
-
if (this.
|
|
1504
|
+
if (this._posthogNodeClient) {
|
|
1311
1505
|
try {
|
|
1312
|
-
this.
|
|
1506
|
+
this._posthogNodeClient.shutdown();
|
|
1313
1507
|
logger.debug("PostHog client shutdown successfully");
|
|
1314
1508
|
} catch (e) {
|
|
1315
1509
|
logger.debug(`Error shutting down PostHog client: ${e}`);
|
|
1316
1510
|
}
|
|
1317
1511
|
}
|
|
1318
|
-
if (this._scarfClient) {
|
|
1319
|
-
logger.debug("Scarf telemetry client shutdown (no action needed)");
|
|
1320
|
-
}
|
|
1321
1512
|
}
|
|
1322
1513
|
};
|
|
1514
|
+
var Tel = Telemetry;
|
|
1515
|
+
function setTelemetrySource(source) {
|
|
1516
|
+
Tel.getInstance().setSource(source);
|
|
1517
|
+
}
|
|
1518
|
+
__name(setTelemetrySource, "setTelemetrySource");
|
|
1323
1519
|
|
|
1324
1520
|
// src/connectors/base.ts
|
|
1325
1521
|
var BaseConnector = class {
|
|
@@ -2602,11 +2798,13 @@ var BaseMCPClient = class {
|
|
|
2602
2798
|
addServer(name, serverConfig) {
|
|
2603
2799
|
this.config.mcpServers = this.config.mcpServers || {};
|
|
2604
2800
|
this.config.mcpServers[name] = serverConfig;
|
|
2801
|
+
Tel.getInstance().trackClientAddServer(name, serverConfig);
|
|
2605
2802
|
}
|
|
2606
2803
|
removeServer(name) {
|
|
2607
2804
|
if (this.config.mcpServers?.[name]) {
|
|
2608
2805
|
delete this.config.mcpServers[name];
|
|
2609
2806
|
this.activeSessions = this.activeSessions.filter((n) => n !== name);
|
|
2807
|
+
Tel.getInstance().trackClientRemoveServer(name);
|
|
2610
2808
|
}
|
|
2611
2809
|
}
|
|
2612
2810
|
getServerNames() {
|
|
@@ -2714,6 +2912,25 @@ var BrowserMCPClient = class _BrowserMCPClient extends BaseMCPClient {
|
|
|
2714
2912
|
}
|
|
2715
2913
|
constructor(config) {
|
|
2716
2914
|
super(config);
|
|
2915
|
+
this._trackClientInit();
|
|
2916
|
+
}
|
|
2917
|
+
_trackClientInit() {
|
|
2918
|
+
const servers = Object.keys(this.config.mcpServers ?? {});
|
|
2919
|
+
Tel.getInstance().trackMCPClientInit({
|
|
2920
|
+
codeMode: false,
|
|
2921
|
+
// Browser client doesn't support code mode
|
|
2922
|
+
sandbox: false,
|
|
2923
|
+
// Sandbox not supported in browser
|
|
2924
|
+
allCallbacks: false,
|
|
2925
|
+
// Will be set per-server
|
|
2926
|
+
verify: false,
|
|
2927
|
+
servers,
|
|
2928
|
+
numServers: servers.length,
|
|
2929
|
+
isBrowser: true
|
|
2930
|
+
// Browser MCPClient
|
|
2931
|
+
}).catch(
|
|
2932
|
+
(e) => logger.debug(`Failed to track BrowserMCPClient init: ${e}`)
|
|
2933
|
+
);
|
|
2717
2934
|
}
|
|
2718
2935
|
static fromDict(cfg) {
|
|
2719
2936
|
return new _BrowserMCPClient(cfg);
|
|
@@ -3124,8 +3341,20 @@ function useMcp(options) {
|
|
|
3124
3341
|
}
|
|
3125
3342
|
}
|
|
3126
3343
|
connectingRef.current = false;
|
|
3344
|
+
if (url) {
|
|
3345
|
+
Tel.getInstance().trackUseMcpConnection({
|
|
3346
|
+
url,
|
|
3347
|
+
transportType,
|
|
3348
|
+
success: false,
|
|
3349
|
+
errorType: connectionError?.name || "UnknownError",
|
|
3350
|
+
hasOAuth: !!authProviderRef.current,
|
|
3351
|
+
hasSampling: !!samplingCallback,
|
|
3352
|
+
hasElicitation: !!onElicitation
|
|
3353
|
+
}).catch(() => {
|
|
3354
|
+
});
|
|
3355
|
+
}
|
|
3127
3356
|
},
|
|
3128
|
-
[addLog]
|
|
3357
|
+
[addLog, url, transportType, samplingCallback, onElicitation]
|
|
3129
3358
|
);
|
|
3130
3359
|
const connect = (0, import_react.useCallback)(async () => {
|
|
3131
3360
|
if (!enabled || !url) {
|
|
@@ -3234,6 +3463,15 @@ function useMcp(options) {
|
|
|
3234
3463
|
);
|
|
3235
3464
|
setState("ready");
|
|
3236
3465
|
successfulTransportRef.current = transportTypeParam;
|
|
3466
|
+
Tel.getInstance().trackUseMcpConnection({
|
|
3467
|
+
url,
|
|
3468
|
+
transportType: transportTypeParam,
|
|
3469
|
+
success: true,
|
|
3470
|
+
hasOAuth: !!authProviderRef.current,
|
|
3471
|
+
hasSampling: !!samplingCallback,
|
|
3472
|
+
hasElicitation: !!onElicitation
|
|
3473
|
+
}).catch(() => {
|
|
3474
|
+
});
|
|
3237
3475
|
setTools(session.connector.tools || []);
|
|
3238
3476
|
const resourcesResult = await session.connector.listAllResources();
|
|
3239
3477
|
setResources(resourcesResult.resources || []);
|
|
@@ -3358,6 +3596,7 @@ function useMcp(options) {
|
|
|
3358
3596
|
);
|
|
3359
3597
|
}
|
|
3360
3598
|
addLog("info", `Calling tool: ${name}`, args);
|
|
3599
|
+
const startTime = Date.now();
|
|
3361
3600
|
try {
|
|
3362
3601
|
const serverName = "inspector-server";
|
|
3363
3602
|
const session = clientRef.current.getSession(serverName);
|
|
@@ -3370,9 +3609,22 @@ function useMcp(options) {
|
|
|
3370
3609
|
options2
|
|
3371
3610
|
);
|
|
3372
3611
|
addLog("info", `Tool "${name}" call successful:`, result);
|
|
3612
|
+
Tel.getInstance().trackUseMcpToolCall({
|
|
3613
|
+
toolName: name,
|
|
3614
|
+
success: true,
|
|
3615
|
+
executionTimeMs: Date.now() - startTime
|
|
3616
|
+
}).catch(() => {
|
|
3617
|
+
});
|
|
3373
3618
|
return result;
|
|
3374
3619
|
} catch (err) {
|
|
3375
3620
|
addLog("error", `Tool "${name}" call failed:`, err);
|
|
3621
|
+
Tel.getInstance().trackUseMcpToolCall({
|
|
3622
|
+
toolName: name,
|
|
3623
|
+
success: false,
|
|
3624
|
+
errorType: err instanceof Error ? err.name : "UnknownError",
|
|
3625
|
+
executionTimeMs: Date.now() - startTime
|
|
3626
|
+
}).catch(() => {
|
|
3627
|
+
});
|
|
3376
3628
|
throw err;
|
|
3377
3629
|
}
|
|
3378
3630
|
},
|
|
@@ -3522,9 +3774,20 @@ function useMcp(options) {
|
|
|
3522
3774
|
}
|
|
3523
3775
|
const result = await session.connector.readResource(uri);
|
|
3524
3776
|
addLog("info", "Resource read successful:", result);
|
|
3777
|
+
Tel.getInstance().trackUseMcpResourceRead({
|
|
3778
|
+
resourceUri: uri,
|
|
3779
|
+
success: true
|
|
3780
|
+
}).catch(() => {
|
|
3781
|
+
});
|
|
3525
3782
|
return result;
|
|
3526
3783
|
} catch (err) {
|
|
3527
3784
|
addLog("error", "Resource read failed:", err);
|
|
3785
|
+
Tel.getInstance().trackUseMcpResourceRead({
|
|
3786
|
+
resourceUri: uri,
|
|
3787
|
+
success: false,
|
|
3788
|
+
errorType: err instanceof Error ? err.name : "UnknownError"
|
|
3789
|
+
}).catch(() => {
|
|
3790
|
+
});
|
|
3528
3791
|
throw err;
|
|
3529
3792
|
}
|
|
3530
3793
|
},
|
|
@@ -4654,8 +4917,8 @@ __name(WidgetControls, "WidgetControls");
|
|
|
4654
4917
|
var import_react7 = __toESM(require("react"), 1);
|
|
4655
4918
|
function getBasename() {
|
|
4656
4919
|
if (typeof window === "undefined") return "/";
|
|
4657
|
-
const
|
|
4658
|
-
const match =
|
|
4920
|
+
const path = window.location.pathname;
|
|
4921
|
+
const match = path.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);
|
|
4659
4922
|
if (match) {
|
|
4660
4923
|
return match[1];
|
|
4661
4924
|
}
|