mcp-use 1.11.0-canary.17 → 1.11.0-canary.19

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CODE_MODE_AGENT_PROMPT
3
- } from "./chunk-ETMSIR6K.js";
3
+ } from "./chunk-DDBBDHDD.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-3GQAWCBQ.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  Telemetry,
6
6
  generateUUID
7
- } from "./chunk-JQMHLTXF.js";
7
+ } from "./chunk-2CX2RMGM.js";
8
8
  import {
9
9
  __name
10
10
  } from "./chunk-3GQAWCBQ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MCPClient
3
- } from "./chunk-ETMSIR6K.js";
3
+ } from "./chunk-DDBBDHDD.js";
4
4
  import {
5
5
  LangChainAdapter
6
6
  } from "./chunk-MFSO5PUW.js";
@@ -8,7 +8,7 @@ import {
8
8
  Telemetry,
9
9
  extractModelInfo,
10
10
  getPackageVersion
11
- } from "./chunk-JQMHLTXF.js";
11
+ } from "./chunk-2CX2RMGM.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-FRUZDWXH.js";
package/dist/index.cjs CHANGED
@@ -2790,7 +2790,7 @@ __name(generateUUID, "generateUUID");
2790
2790
  init_logging();
2791
2791
 
2792
2792
  // src/version.ts
2793
- var VERSION = "1.11.0-canary.17";
2793
+ var VERSION = "1.11.0-canary.19";
2794
2794
  function getPackageVersion() {
2795
2795
  return VERSION;
2796
2796
  }
@@ -2960,12 +2960,26 @@ var Telemetry = class _Telemetry {
2960
2960
  "Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
2961
2961
  );
2962
2962
  this._posthogLoading = this._initPostHog();
2963
- try {
2964
- this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
2965
- } catch (e) {
2966
- logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
2963
+ if (this._runtimeEnvironment !== "browser") {
2964
+ try {
2965
+ this._scarfClient = new ScarfEventLogger(
2966
+ this.SCARF_GATEWAY_URL,
2967
+ 3e3
2968
+ );
2969
+ } catch (e) {
2970
+ logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
2971
+ this._scarfClient = null;
2972
+ }
2973
+ } else {
2967
2974
  this._scarfClient = null;
2968
2975
  }
2976
+ if (this._storageCapability === "filesystem" && this._scarfClient) {
2977
+ setTimeout(() => {
2978
+ this.trackPackageDownload({ triggered_by: "initialization" }).catch(
2979
+ (e) => logger.debug(`Failed to track package download: ${e}`)
2980
+ );
2981
+ }, 0);
2982
+ }
2969
2983
  }
2970
2984
  }
2971
2985
  _checkTelemetryDisabled() {
@@ -3090,47 +3104,65 @@ var Telemetry = class _Telemetry {
3090
3104
  break;
3091
3105
  case "session-only":
3092
3106
  default:
3093
- this._currUserId = `session-${generateUUID()}`;
3094
- logger.debug(
3095
- `Using session-based user ID (${this._runtimeEnvironment} environment)`
3096
- );
3107
+ try {
3108
+ this._currUserId = `session-${generateUUID()}`;
3109
+ } catch (uuidError) {
3110
+ this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3111
+ }
3097
3112
  break;
3098
3113
  }
3099
- if (this._storageCapability === "filesystem" && this._currUserId) {
3100
- this._trackPackageDownloadInternal(this._currUserId, {
3101
- triggered_by: "user_id_property"
3102
- }).catch((e) => logger.debug(`Failed to track package download: ${e}`));
3103
- }
3104
3114
  } catch (e) {
3105
- logger.debug(`Failed to get/create user ID: ${e}`);
3106
3115
  this._currUserId = this.UNKNOWN_USER_ID;
3107
3116
  }
3108
3117
  return this._currUserId;
3109
3118
  }
3110
3119
  /**
3111
3120
  * Get or create user ID from filesystem (Node.js/Bun)
3121
+ * Falls back to session ID if filesystem operations fail
3112
3122
  */
3113
3123
  _getUserIdFromFilesystem() {
3114
- const fs2 = require("fs");
3115
- const os = require("os");
3116
- const path2 = require("path");
3117
- if (!this._userIdPath) {
3118
- this._userIdPath = path2.join(
3119
- this._getCacheHome(os, path2),
3120
- "mcp_use_3",
3121
- "telemetry_user_id"
3122
- );
3123
- }
3124
- const isFirstTime = !fs2.existsSync(this._userIdPath);
3125
- if (isFirstTime) {
3126
- logger.debug(`Creating user ID path: ${this._userIdPath}`);
3127
- fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
3128
- const newUserId = generateUUID();
3129
- fs2.writeFileSync(this._userIdPath, newUserId);
3130
- logger.debug(`User ID path created: ${this._userIdPath}`);
3131
- return newUserId;
3124
+ try {
3125
+ let fs2, os, path2;
3126
+ try {
3127
+ fs2 = require("fs");
3128
+ os = require("os");
3129
+ path2 = require("path");
3130
+ } catch (requireError) {
3131
+ try {
3132
+ const sessionId = `session-${generateUUID()}`;
3133
+ return sessionId;
3134
+ } catch (uuidError) {
3135
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3136
+ }
3137
+ }
3138
+ if (!this._userIdPath) {
3139
+ this._userIdPath = path2.join(
3140
+ this._getCacheHome(os, path2),
3141
+ "mcp_use_3",
3142
+ "telemetry_user_id"
3143
+ );
3144
+ }
3145
+ const isFirstTime = !fs2.existsSync(this._userIdPath);
3146
+ if (isFirstTime) {
3147
+ fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
3148
+ let newUserId;
3149
+ try {
3150
+ newUserId = generateUUID();
3151
+ } catch (uuidError) {
3152
+ newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3153
+ }
3154
+ fs2.writeFileSync(this._userIdPath, newUserId);
3155
+ return newUserId;
3156
+ }
3157
+ const userId = fs2.readFileSync(this._userIdPath, "utf-8").trim();
3158
+ return userId;
3159
+ } catch (e) {
3160
+ try {
3161
+ return `session-${generateUUID()}`;
3162
+ } catch (uuidError) {
3163
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3164
+ }
3132
3165
  }
3133
- return fs2.readFileSync(this._userIdPath, "utf-8").trim();
3134
3166
  }
3135
3167
  /**
3136
3168
  * Get or create user ID from localStorage (Browser)
@@ -3139,14 +3171,22 @@ var Telemetry = class _Telemetry {
3139
3171
  try {
3140
3172
  let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
3141
3173
  if (!userId) {
3142
- userId = generateUUID();
3174
+ try {
3175
+ userId = generateUUID();
3176
+ } catch (uuidError) {
3177
+ userId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3178
+ }
3143
3179
  localStorage.setItem(USER_ID_STORAGE_KEY, userId);
3144
- logger.debug(`Created new browser user ID`);
3145
3180
  }
3146
3181
  return userId;
3147
3182
  } catch (e) {
3148
- logger.debug(`localStorage access failed: ${e}`);
3149
- return `session-${generateUUID()}`;
3183
+ let sessionId;
3184
+ try {
3185
+ sessionId = `session-${generateUUID()}`;
3186
+ } catch (uuidError) {
3187
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
3188
+ }
3189
+ return sessionId;
3150
3190
  }
3151
3191
  }
3152
3192
  _getCacheHome(os, path2) {
@@ -3175,6 +3215,7 @@ var Telemetry = class _Telemetry {
3175
3215
  if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
3176
3216
  return;
3177
3217
  }
3218
+ const currentUserId = this.userId;
3178
3219
  const properties = { ...event.properties };
3179
3220
  properties.mcp_use_version = getPackageVersion();
3180
3221
  properties.language = "typescript";
@@ -3182,9 +3223,8 @@ var Telemetry = class _Telemetry {
3182
3223
  properties.runtime = this._runtimeEnvironment;
3183
3224
  if (this._posthogNodeClient) {
3184
3225
  try {
3185
- logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
3186
3226
  this._posthogNodeClient.capture({
3187
- distinctId: this.userId,
3227
+ distinctId: currentUserId,
3188
3228
  event: event.name,
3189
3229
  properties
3190
3230
  });
@@ -3194,10 +3234,9 @@ var Telemetry = class _Telemetry {
3194
3234
  }
3195
3235
  if (this._posthogBrowserClient) {
3196
3236
  try {
3197
- logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
3198
3237
  this._posthogBrowserClient.capture(event.name, {
3199
3238
  ...properties,
3200
- distinct_id: this.userId
3239
+ distinct_id: currentUserId
3201
3240
  });
3202
3241
  } catch (e) {
3203
3242
  logger.debug(
@@ -3209,7 +3248,7 @@ var Telemetry = class _Telemetry {
3209
3248
  try {
3210
3249
  const scarfProperties = {
3211
3250
  ...properties,
3212
- user_id: this.userId,
3251
+ user_id: currentUserId,
3213
3252
  event: event.name
3214
3253
  };
3215
3254
  await this._scarfClient.logEvent(scarfProperties);
package/dist/index.js CHANGED
@@ -9,9 +9,10 @@ import {
9
9
  streamEventsToAISDKWithTools
10
10
  } from "./chunk-LGDFGYRL.js";
11
11
  import "./chunk-GXNAXUDI.js";
12
+ import "./chunk-JQKKMUCT.js";
12
13
  import {
13
14
  PROMPTS
14
- } from "./chunk-XZM65NMN.js";
15
+ } from "./chunk-MIZSOV27.js";
15
16
  import {
16
17
  AcquireActiveMCPServerTool,
17
18
  AddMCPServerFromConfigTool,
@@ -26,7 +27,7 @@ import {
26
27
  getSupportedProviders,
27
28
  isValidLLMString,
28
29
  parseLLMString
29
- } from "./chunk-LQJZY6OD.js";
30
+ } from "./chunk-XWY3UCBV.js";
30
31
  import "./chunk-JRGQRPTN.js";
31
32
  import {
32
33
  BaseCodeExecutor,
@@ -36,11 +37,10 @@ import {
36
37
  VMCodeExecutor,
37
38
  isVMAvailable,
38
39
  loadConfigFile
39
- } from "./chunk-ETMSIR6K.js";
40
+ } from "./chunk-DDBBDHDD.js";
40
41
  import {
41
42
  BaseAdapter
42
43
  } from "./chunk-MFSO5PUW.js";
43
- import "./chunk-JQKKMUCT.js";
44
44
  import {
45
45
  ErrorBoundary,
46
46
  Image,
@@ -52,28 +52,28 @@ import {
52
52
  useWidgetProps,
53
53
  useWidgetState,
54
54
  useWidgetTheme
55
- } from "./chunk-HNNUDW4Q.js";
56
- import "./chunk-NTB5TTZW.js";
55
+ } from "./chunk-ERDKUHUF.js";
56
+ import "./chunk-7KWUIU7I.js";
57
+ import {
58
+ BrowserOAuthClientProvider,
59
+ onMcpAuthorization
60
+ } from "./chunk-J75I2C26.js";
57
61
  import {
58
62
  BaseConnector,
59
63
  HttpConnector,
60
64
  MCPSession
61
- } from "./chunk-QEEFUZ22.js";
65
+ } from "./chunk-5QAH2BZN.js";
62
66
  import {
63
67
  Tel,
64
68
  Telemetry,
65
69
  VERSION,
66
70
  getPackageVersion,
67
71
  setTelemetrySource
68
- } from "./chunk-JQMHLTXF.js";
72
+ } from "./chunk-2CX2RMGM.js";
69
73
  import {
70
74
  Logger,
71
75
  logger
72
76
  } from "./chunk-FRUZDWXH.js";
73
- import {
74
- BrowserOAuthClientProvider,
75
- onMcpAuthorization
76
- } from "./chunk-J75I2C26.js";
77
77
  import {
78
78
  __name
79
79
  } from "./chunk-3GQAWCBQ.js";
@@ -1417,7 +1417,7 @@ __name(generateUUID, "generateUUID");
1417
1417
  init_logging();
1418
1418
 
1419
1419
  // src/version.ts
1420
- var VERSION = "1.11.0-canary.17";
1420
+ var VERSION = "1.11.0-canary.19";
1421
1421
  function getPackageVersion() {
1422
1422
  return VERSION;
1423
1423
  }
@@ -1587,12 +1587,26 @@ var Telemetry = class _Telemetry {
1587
1587
  "Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
1588
1588
  );
1589
1589
  this._posthogLoading = this._initPostHog();
1590
- try {
1591
- this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
1592
- } catch (e) {
1593
- logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
1590
+ if (this._runtimeEnvironment !== "browser") {
1591
+ try {
1592
+ this._scarfClient = new ScarfEventLogger(
1593
+ this.SCARF_GATEWAY_URL,
1594
+ 3e3
1595
+ );
1596
+ } catch (e) {
1597
+ logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
1598
+ this._scarfClient = null;
1599
+ }
1600
+ } else {
1594
1601
  this._scarfClient = null;
1595
1602
  }
1603
+ if (this._storageCapability === "filesystem" && this._scarfClient) {
1604
+ setTimeout(() => {
1605
+ this.trackPackageDownload({ triggered_by: "initialization" }).catch(
1606
+ (e) => logger.debug(`Failed to track package download: ${e}`)
1607
+ );
1608
+ }, 0);
1609
+ }
1596
1610
  }
1597
1611
  }
1598
1612
  _checkTelemetryDisabled() {
@@ -1717,47 +1731,65 @@ var Telemetry = class _Telemetry {
1717
1731
  break;
1718
1732
  case "session-only":
1719
1733
  default:
1720
- this._currUserId = `session-${generateUUID()}`;
1721
- logger.debug(
1722
- `Using session-based user ID (${this._runtimeEnvironment} environment)`
1723
- );
1734
+ try {
1735
+ this._currUserId = `session-${generateUUID()}`;
1736
+ } catch (uuidError) {
1737
+ this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1738
+ }
1724
1739
  break;
1725
1740
  }
1726
- if (this._storageCapability === "filesystem" && this._currUserId) {
1727
- this._trackPackageDownloadInternal(this._currUserId, {
1728
- triggered_by: "user_id_property"
1729
- }).catch((e) => logger.debug(`Failed to track package download: ${e}`));
1730
- }
1731
1741
  } catch (e) {
1732
- logger.debug(`Failed to get/create user ID: ${e}`);
1733
1742
  this._currUserId = this.UNKNOWN_USER_ID;
1734
1743
  }
1735
1744
  return this._currUserId;
1736
1745
  }
1737
1746
  /**
1738
1747
  * Get or create user ID from filesystem (Node.js/Bun)
1748
+ * Falls back to session ID if filesystem operations fail
1739
1749
  */
1740
1750
  _getUserIdFromFilesystem() {
1741
- const fs2 = require("fs");
1742
- const os = require("os");
1743
- const path2 = require("path");
1744
- if (!this._userIdPath) {
1745
- this._userIdPath = path2.join(
1746
- this._getCacheHome(os, path2),
1747
- "mcp_use_3",
1748
- "telemetry_user_id"
1749
- );
1750
- }
1751
- const isFirstTime = !fs2.existsSync(this._userIdPath);
1752
- if (isFirstTime) {
1753
- logger.debug(`Creating user ID path: ${this._userIdPath}`);
1754
- fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
1755
- const newUserId = generateUUID();
1756
- fs2.writeFileSync(this._userIdPath, newUserId);
1757
- logger.debug(`User ID path created: ${this._userIdPath}`);
1758
- return newUserId;
1751
+ try {
1752
+ let fs2, os, path2;
1753
+ try {
1754
+ fs2 = require("fs");
1755
+ os = require("os");
1756
+ path2 = require("path");
1757
+ } catch (requireError) {
1758
+ try {
1759
+ const sessionId = `session-${generateUUID()}`;
1760
+ return sessionId;
1761
+ } catch (uuidError) {
1762
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1763
+ }
1764
+ }
1765
+ if (!this._userIdPath) {
1766
+ this._userIdPath = path2.join(
1767
+ this._getCacheHome(os, path2),
1768
+ "mcp_use_3",
1769
+ "telemetry_user_id"
1770
+ );
1771
+ }
1772
+ const isFirstTime = !fs2.existsSync(this._userIdPath);
1773
+ if (isFirstTime) {
1774
+ fs2.mkdirSync(path2.dirname(this._userIdPath), { recursive: true });
1775
+ let newUserId;
1776
+ try {
1777
+ newUserId = generateUUID();
1778
+ } catch (uuidError) {
1779
+ newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1780
+ }
1781
+ fs2.writeFileSync(this._userIdPath, newUserId);
1782
+ return newUserId;
1783
+ }
1784
+ const userId = fs2.readFileSync(this._userIdPath, "utf-8").trim();
1785
+ return userId;
1786
+ } catch (e) {
1787
+ try {
1788
+ return `session-${generateUUID()}`;
1789
+ } catch (uuidError) {
1790
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1791
+ }
1759
1792
  }
1760
- return fs2.readFileSync(this._userIdPath, "utf-8").trim();
1761
1793
  }
1762
1794
  /**
1763
1795
  * Get or create user ID from localStorage (Browser)
@@ -1766,14 +1798,22 @@ var Telemetry = class _Telemetry {
1766
1798
  try {
1767
1799
  let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
1768
1800
  if (!userId) {
1769
- userId = generateUUID();
1801
+ try {
1802
+ userId = generateUUID();
1803
+ } catch (uuidError) {
1804
+ userId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1805
+ }
1770
1806
  localStorage.setItem(USER_ID_STORAGE_KEY, userId);
1771
- logger.debug(`Created new browser user ID`);
1772
1807
  }
1773
1808
  return userId;
1774
1809
  } catch (e) {
1775
- logger.debug(`localStorage access failed: ${e}`);
1776
- return `session-${generateUUID()}`;
1810
+ let sessionId;
1811
+ try {
1812
+ sessionId = `session-${generateUUID()}`;
1813
+ } catch (uuidError) {
1814
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
1815
+ }
1816
+ return sessionId;
1777
1817
  }
1778
1818
  }
1779
1819
  _getCacheHome(os, path2) {
@@ -1802,6 +1842,7 @@ var Telemetry = class _Telemetry {
1802
1842
  if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
1803
1843
  return;
1804
1844
  }
1845
+ const currentUserId = this.userId;
1805
1846
  const properties = { ...event.properties };
1806
1847
  properties.mcp_use_version = getPackageVersion();
1807
1848
  properties.language = "typescript";
@@ -1809,9 +1850,8 @@ var Telemetry = class _Telemetry {
1809
1850
  properties.runtime = this._runtimeEnvironment;
1810
1851
  if (this._posthogNodeClient) {
1811
1852
  try {
1812
- logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
1813
1853
  this._posthogNodeClient.capture({
1814
- distinctId: this.userId,
1854
+ distinctId: currentUserId,
1815
1855
  event: event.name,
1816
1856
  properties
1817
1857
  });
@@ -1821,10 +1861,9 @@ var Telemetry = class _Telemetry {
1821
1861
  }
1822
1862
  if (this._posthogBrowserClient) {
1823
1863
  try {
1824
- logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
1825
1864
  this._posthogBrowserClient.capture(event.name, {
1826
1865
  ...properties,
1827
- distinct_id: this.userId
1866
+ distinct_id: currentUserId
1828
1867
  });
1829
1868
  } catch (e) {
1830
1869
  logger.debug(
@@ -1836,7 +1875,7 @@ var Telemetry = class _Telemetry {
1836
1875
  try {
1837
1876
  const scarfProperties = {
1838
1877
  ...properties,
1839
- user_id: this.userId,
1878
+ user_id: currentUserId,
1840
1879
  event: event.name
1841
1880
  };
1842
1881
  await this._scarfClient.logEvent(scarfProperties);
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  BaseAgent,
3
3
  PROMPTS
4
- } from "../../chunk-XZM65NMN.js";
4
+ } from "../../chunk-MIZSOV27.js";
5
5
  import {
6
6
  MCPAgent,
7
7
  RemoteAgent
8
- } from "../../chunk-LQJZY6OD.js";
8
+ } from "../../chunk-XWY3UCBV.js";
9
9
  import "../../chunk-JRGQRPTN.js";
10
- import "../../chunk-ETMSIR6K.js";
10
+ import "../../chunk-DDBBDHDD.js";
11
11
  import "../../chunk-MFSO5PUW.js";
12
- import "../../chunk-QEEFUZ22.js";
13
- import "../../chunk-JQMHLTXF.js";
12
+ import "../../chunk-5QAH2BZN.js";
13
+ import "../../chunk-2CX2RMGM.js";
14
14
  import "../../chunk-FRUZDWXH.js";
15
15
  import "../../chunk-3GQAWCBQ.js";
16
16
  export {