@chrryai/chrry 1.7.35 → 1.7.39

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/index.d.mts CHANGED
@@ -1629,13 +1629,14 @@ declare const getApps: ({ API_URL, token, chrryUrl, appId, }: {
1629
1629
  error: string;
1630
1630
  status: number;
1631
1631
  }>;
1632
- declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, }: {
1632
+ declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, storeSlug, }: {
1633
1633
  API_URL?: string;
1634
1634
  token: string;
1635
1635
  appId?: string;
1636
1636
  chrryUrl?: string;
1637
1637
  pathname?: string;
1638
1638
  skipCache?: boolean;
1639
+ storeSlug?: string;
1639
1640
  }) => Promise<appWithStore>;
1640
1641
  declare const getTranslations: ({ API_URL, token, locale, }?: {
1641
1642
  API_URL?: string;
package/dist/index.d.ts CHANGED
@@ -1629,13 +1629,14 @@ declare const getApps: ({ API_URL, token, chrryUrl, appId, }: {
1629
1629
  error: string;
1630
1630
  status: number;
1631
1631
  }>;
1632
- declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, }: {
1632
+ declare const getApp: ({ API_URL, token, appId, chrryUrl, skipCache, pathname, storeSlug, }: {
1633
1633
  API_URL?: string;
1634
1634
  token: string;
1635
1635
  appId?: string;
1636
1636
  chrryUrl?: string;
1637
1637
  pathname?: string;
1638
1638
  skipCache?: boolean;
1639
+ storeSlug?: string;
1639
1640
  }) => Promise<appWithStore>;
1640
1641
  declare const getTranslations: ({ API_URL, token, locale, }?: {
1641
1642
  API_URL?: string;
package/dist/index.js CHANGED
@@ -2434,13 +2434,15 @@ var init_lib = __esm({
2434
2434
  appId,
2435
2435
  chrryUrl,
2436
2436
  skipCache,
2437
- pathname
2437
+ pathname,
2438
+ storeSlug
2438
2439
  }) => {
2439
2440
  const params = new URLSearchParams();
2440
2441
  if (chrryUrl) params.append("chrryUrl", chrryUrl);
2441
2442
  if (appId) params.append("appId", appId);
2442
2443
  if (pathname) params.append("pathname", encodeURIComponent(pathname));
2443
2444
  if (skipCache) params.append("skipCache", "true");
2445
+ if (storeSlug) params.append("storeSlug", storeSlug);
2444
2446
  const url = `${API_URL2}/apps${params.toString() ? `?${params.toString()}` : ""}`;
2445
2447
  const response = await fetch(url, {
2446
2448
  headers: {
@@ -3264,7 +3266,7 @@ var init_utils = __esm({
3264
3266
  };
3265
3267
  isFirefox = typeof navigator !== "undefined" && navigator?.userAgent?.includes("Firefox");
3266
3268
  config = getSiteConfig(getClientHostname2());
3267
- VERSION = config.version || "1.7.35";
3269
+ VERSION = config.version || "1.7.39";
3268
3270
  getSlugFromPathname = (path) => {
3269
3271
  return getAppAndStoreSlugs(path, {
3270
3272
  defaultAppSlug: config.slug,
@@ -23730,7 +23732,15 @@ function AuthProvider({
23730
23732
  import_react_hot_toast.default.error(error);
23731
23733
  }
23732
23734
  }, [error]);
23733
- const { isExtension: isExtension2, isStandalone: isStandalone2, isFirefox: isFirefox2, device, os, browser: browser2 } = usePlatform();
23735
+ const {
23736
+ isExtension: isExtension2,
23737
+ isStandalone: isStandalone2,
23738
+ isFirefox: isFirefox2,
23739
+ device,
23740
+ os,
23741
+ browser: browser2,
23742
+ isNative: isNative2
23743
+ } = usePlatform();
23734
23744
  const env = isDevelopment ? "development" : "production";
23735
23745
  const setEnv = (env2) => {
23736
23746
  fetchSession();
@@ -23798,6 +23808,33 @@ function AuthProvider({
23798
23808
  setIsCookieReady(true);
23799
23809
  }
23800
23810
  }, [isExtension2]);
23811
+ const merge = (prevApps, newApps) => {
23812
+ const existingAppsMap = new Map(prevApps.map((app2) => [app2.id, app2]));
23813
+ newApps.forEach((newApp2) => {
23814
+ const existingApp = existingAppsMap.get(newApp2.id);
23815
+ if (newApp2.name === "MyAgent") {
23816
+ }
23817
+ if (existingApp && hasStoreApps(newApp2)) {
23818
+ existingAppsMap.set(newApp2.id, newApp2);
23819
+ } else {
23820
+ existingAppsMap.set(newApp2.id, newApp2);
23821
+ }
23822
+ });
23823
+ return Array.from(existingAppsMap.values());
23824
+ };
23825
+ const [userBaseApp, setUserBaseApp] = (0, import_react20.useState)(
23826
+ session2?.userBaseApp
23827
+ );
23828
+ const userBaseStore = userBaseApp?.store;
23829
+ const [guestBaseApp, setGuestBaseApp] = (0, import_react20.useState)(
23830
+ session2?.guestBaseApp
23831
+ );
23832
+ const accountApp = userBaseApp || guestBaseApp;
23833
+ const setBaseAccountApp = (app2) => {
23834
+ user && setUserBaseApp(app2);
23835
+ guest && setGuestBaseApp(app2);
23836
+ };
23837
+ const guestBaseStore = guestBaseApp?.store;
23801
23838
  function processSession(sessionData2) {
23802
23839
  if (sessionData2) {
23803
23840
  setSession(sessionData2);
@@ -23868,13 +23905,39 @@ function AuthProvider({
23868
23905
  removeParams("signIn");
23869
23906
  }
23870
23907
  };
23908
+ const [newApp, setNewApp] = (0, import_react20.useState)(void 0);
23909
+ const [updatedApp, setUpdatedApp] = (0, import_react20.useState)(
23910
+ void 0
23911
+ );
23912
+ const [loadingAppId, setLoadingAppId] = (0, import_react20.useState)(
23913
+ void 0
23914
+ );
23915
+ const allApps = merge(
23916
+ session2?.app?.store?.apps || [],
23917
+ userBaseApp ? [userBaseApp] : guestBaseApp ? [guestBaseApp] : []
23918
+ );
23919
+ const [storeApps, setAllApps] = (0, import_react20.useState)(allApps);
23920
+ const getAppSlug2 = (targetApp, defaultSlug = "/") => getAppSlug_default({ targetApp, defaultSlug, pathname, baseApp });
23921
+ const baseAppInternal = storeApps.find((item) => {
23922
+ if (!item) return false;
23923
+ if (siteConfig.slug === item.slug && item.store?.slug === siteConfig.storeSlug) {
23924
+ return true;
23925
+ }
23926
+ });
23927
+ const [baseApp, setBaseApp] = (0, import_react20.useState)(
23928
+ baseAppInternal
23929
+ );
23930
+ const [app, setAppInternal] = (0, import_react20.useState)(props.app || session2?.app || baseApp);
23931
+ const appId = newApp?.id || updatedApp?.id || loadingAppId || app?.id;
23932
+ const [isSavingApp, setIsSavingApp] = (0, import_react20.useState)(false);
23933
+ const [isManagingApp, setIsManagingApp] = (0, import_react20.useState)(false);
23871
23934
  const {
23872
23935
  data: sessionSwr,
23873
23936
  mutate: refetchSession,
23874
23937
  isLoading: isSessionLoading,
23875
23938
  error: sessionError
23876
23939
  } = (0, import_swr.default)(
23877
- (isExtension2 ? isStorageReady && isCookieReady : true) && (fingerprint || token) && deviceId && shouldFetchSession && !isRemovingApp ? "session" : null,
23940
+ (isExtension2 ? isStorageReady && isCookieReady : true) && fingerprint && token && deviceId && shouldFetchSession && !isRemovingApp && !isSavingApp && !isManagingApp ? "session" : null,
23878
23941
  async () => {
23879
23942
  try {
23880
23943
  const result = await getSession({
@@ -23999,54 +24062,11 @@ function AuthProvider({
23999
24062
  isPWA
24000
24063
  });
24001
24064
  };
24002
- const merge = (prevApps, newApps) => {
24003
- const existingAppsMap = new Map(prevApps.map((app2) => [app2.id, app2]));
24004
- newApps.forEach((newApp2) => {
24005
- const existingApp = existingAppsMap.get(newApp2.id);
24006
- if (newApp2.name === "MyAgent") {
24007
- }
24008
- if (existingApp && hasStoreApps(newApp2)) {
24009
- existingAppsMap.set(newApp2.id, newApp2);
24010
- } else {
24011
- existingAppsMap.set(newApp2.id, newApp2);
24012
- }
24013
- });
24014
- return Array.from(existingAppsMap.values());
24015
- };
24016
- const [userBaseApp, setUserBaseApp] = (0, import_react20.useState)(
24017
- session2?.userBaseApp
24018
- );
24019
- const userBaseStore = userBaseApp?.store;
24020
- const [guestBaseApp, setGuestBaseApp] = (0, import_react20.useState)(
24021
- session2?.guestBaseApp
24022
- );
24023
- const accountApp = userBaseApp || guestBaseApp;
24024
- const setBaseAccountApp = (app2) => {
24025
- user && setUserBaseApp(app2);
24026
- guest && setGuestBaseApp(app2);
24027
- };
24028
- const guestBaseStore = guestBaseApp?.store;
24029
- const allApps = merge(
24030
- sessionData?.app?.store?.apps || [],
24031
- userBaseApp ? [userBaseApp] : guestBaseApp ? [guestBaseApp] : []
24032
- );
24033
- const [storeApps, setAllApps] = (0, import_react20.useState)(allApps);
24034
- const getAppSlug2 = (targetApp, defaultSlug = "/") => getAppSlug_default({ targetApp, defaultSlug, pathname, baseApp });
24035
- const baseAppInternal = storeApps.find((item) => {
24036
- if (!item) return false;
24037
- if (siteConfig.slug === item.slug && item.store?.slug === siteConfig.storeSlug) {
24038
- return true;
24039
- }
24040
- });
24041
- const [baseApp, setBaseApp] = (0, import_react20.useState)(
24042
- baseAppInternal
24043
- );
24044
24065
  (0, import_react20.useEffect)(() => {
24045
24066
  hasStoreApps(baseAppInternal) && setBaseApp(baseAppInternal);
24046
24067
  }, [baseAppInternal]);
24047
24068
  const threadId = getThreadId(pathname);
24048
24069
  const threadIdRef = (0, import_react20.useRef)(threadId);
24049
- const [app, setAppInternal] = (0, import_react20.useState)(props.app || session2?.app || baseApp);
24050
24070
  (0, import_react20.useEffect)(() => {
24051
24071
  const signInParam = searchParams.get("signIn");
24052
24072
  const currentPart = signInParam;
@@ -24168,10 +24188,6 @@ function AuthProvider({
24168
24188
  "lastAppId",
24169
24189
  void 0
24170
24190
  );
24171
- const [newApp, setNewApp] = (0, import_react20.useState)(void 0);
24172
- const [updatedApp, setUpdatedApp] = (0, import_react20.useState)(
24173
- void 0
24174
- );
24175
24191
  const mergeApps = (0, import_react20.useCallback)(
24176
24192
  (newApps) => {
24177
24193
  setAllApps(merge(storeApps, newApps));
@@ -24184,9 +24200,6 @@ function AuthProvider({
24184
24200
  shouldFetchSession && await refetchSession();
24185
24201
  };
24186
24202
  const [isSplash, setIsSplash] = (0, import_react20.useState)(true);
24187
- const [loadingAppId, setLoadingAppId] = (0, import_react20.useState)(
24188
- void 0
24189
- );
24190
24203
  const [loadingApp, setLoadingAppInternal] = (0, import_react20.useState)(void 0);
24191
24204
  const setLoadingApp = (appWithStore) => {
24192
24205
  setLoadingAppId(appWithStore?.id);
@@ -24198,8 +24211,6 @@ function AuthProvider({
24198
24211
  const sushi = storeApps?.find((app2) => app2.slug === "sushi");
24199
24212
  const focus2 = storeApps?.find((app2) => app2.slug === "focus");
24200
24213
  const accountAppId = userBaseApp?.id || guestBaseApp?.id;
24201
- const appId = newApp?.id || updatedApp?.id || loadingAppId || app?.id;
24202
- const [isManagingApp, setIsManagingApp] = (0, import_react20.useState)(false);
24203
24214
  const {
24204
24215
  data: storeAppsSwr,
24205
24216
  mutate: refetchApps,
@@ -24207,29 +24218,24 @@ function AuthProvider({
24207
24218
  } = (0, import_swr.default)(token && !isRemovingApp && ["app", appId], async () => {
24208
24219
  try {
24209
24220
  if (!token) return;
24210
- const app2 = await getApp({
24221
+ const result = await getApp({
24211
24222
  token,
24212
24223
  appId,
24213
24224
  chrryUrl,
24214
24225
  pathname,
24215
- skipCache: !!accountAppId || appId === accountAppId || !!newApp?.id || isManagingApp
24226
+ skipCache: appId !== app?.id || appId === accountAppId
24216
24227
  });
24217
- return app2;
24228
+ return result;
24218
24229
  } catch (error2) {
24219
24230
  captureException(error2);
24220
24231
  }
24221
24232
  });
24222
- (0, import_react20.useEffect)(() => {
24223
- if (newApp?.id || updatedApp?.id) {
24224
- refetchApps();
24225
- }
24226
- }, [newApp?.id, updatedApp?.id]);
24227
24233
  (0, import_react20.useEffect)(() => {
24228
24234
  if (storeAppsSwr) {
24229
24235
  storeAppsSwr.store?.apps?.find((app2) => app2.id === loadingAppId) && setLoadingApp(void 0);
24230
24236
  mergeApps(storeAppsSwr.store?.apps || []);
24231
24237
  }
24232
- }, [storeAppsSwr, guest, user, newApp, updatedApp, loadingAppId]);
24238
+ }, [storeAppsSwr]);
24233
24239
  const canShowFocus = !!(focus2 && app && app?.id === focus2.id && !threadId);
24234
24240
  const [showFocus, setShowFocus] = (0, import_react20.useState)(canShowFocus);
24235
24241
  (0, import_react20.useEffect)(() => {
@@ -24451,6 +24457,7 @@ function AuthProvider({
24451
24457
  setApp(n);
24452
24458
  setStore(n.store);
24453
24459
  setSlug(getAppSlug2(n) || "");
24460
+ return;
24454
24461
  }
24455
24462
  const u = storeAppsSwr?.store?.apps.find((app2) => app2.id === updatedApp?.id);
24456
24463
  if (u) {
@@ -24462,6 +24469,7 @@ function AuthProvider({
24462
24469
  setApp(u);
24463
24470
  setStore(u.store);
24464
24471
  setSlug(getAppSlug2(u) || "");
24472
+ return;
24465
24473
  }
24466
24474
  if (!matchedApp && thread2?.appId) {
24467
24475
  const threadApp = storeApps.find((app2) => app2.id === thread2.appId);
@@ -24537,7 +24545,6 @@ function AuthProvider({
24537
24545
  console.warn("PerformanceObserver not supported:", error2);
24538
24546
  }
24539
24547
  }, [track]);
24540
- const [isSavingApp, setIsSavingApp] = (0, import_react20.useState)(false);
24541
24548
  const [shouldFetchTasks, setShouldFetchTasks] = (0, import_react20.useState)(false);
24542
24549
  const [isLoadingTasks, setIsLoadingTasks] = (0, import_react20.useState)(false);
24543
24550
  const { data: tasksData, mutate: refetchTasks } = (0, import_swr.default)(
@@ -24853,7 +24860,7 @@ function DataProvider({ children, ...rest }) {
24853
24860
  const [instructions, setInstructions] = (0, import_react21.useState)([]);
24854
24861
  const [affiliateStats, setAffiliateStats] = (0, import_react21.useState)(null);
24855
24862
  const [loadingAffiliateStats, setLoadingAffiliateStats] = (0, import_react21.useState)(false);
24856
- const VERSION4 = "1.7.35";
24863
+ const VERSION4 = "1.7.39";
24857
24864
  const [weather, setWeather] = useLocalStorage2("weather", user?.weather || guest?.weather || void 0);
24858
24865
  const {
24859
24866
  API_URL: API_URL2,
@@ -26018,7 +26025,7 @@ function AppProvider({ children }) {
26018
26025
  Object.entries(payload).forEach(([key, value]) => {
26019
26026
  newSearchParams.set(key, String(value));
26020
26027
  });
26021
- const slug2 = userBaseApp?.store?.slug || guestBaseApp?.store?.slug || baseApp?.store?.slug;
26028
+ const slug2 = baseApp?.store?.slug;
26022
26029
  const newUrl = `/${slug2 === chrry?.slug ? "" : slug2 ?? chrry?.slug}/${app?.slug}?${newSearchParams.toString()}`;
26023
26030
  push(newUrl);
26024
26031
  } else {
@@ -27063,6 +27070,11 @@ function ChatProvider({
27063
27070
  }
27064
27071
  }, [appStatus?.part]);
27065
27072
  const [shouldFetchThread, setShouldFetchThread] = (0, import_react29.useState)(!auth.threadData);
27073
+ (0, import_react29.useEffect)(() => {
27074
+ if (threadId && auth?.threadData?.thread.id !== threadId && !shouldFetchThread) {
27075
+ setShouldFetchThread(true);
27076
+ }
27077
+ }, [threadId, auth?.threadData?.thread.id, shouldFetchThread]);
27066
27078
  const [until, setUntil] = (0, import_react29.useState)(1);
27067
27079
  const [liked, setLiked] = (0, import_react29.useState)(void 0);
27068
27080
  const [isLoading, setIsLoading] = (0, import_react29.useState)(!!threadId);
@@ -27174,8 +27186,8 @@ function ChatProvider({
27174
27186
  setSelectedAgent(a);
27175
27187
  setDebateAgent(null);
27176
27188
  }, [app, aiAgents]);
27177
- const { isDevelopment: isDevelopment2, isE2E: isE2E3, actions } = useData();
27178
- const hourlyLimit = isDevelopment2 && !isE2E3 ? 5e4 : getHourlyLimit({
27189
+ const { isDevelopment: isDevelopment2, isE2E: isE2E4, actions } = useData();
27190
+ const hourlyLimit = isDevelopment2 && !isE2E4 ? 5e4 : getHourlyLimit({
27179
27191
  member: user,
27180
27192
  guest
27181
27193
  });
@@ -43006,7 +43018,7 @@ function SignIn({
43006
43018
  const { t: t5 } = useAppContext();
43007
43019
  const {
43008
43020
  FRONTEND_URL: FRONTEND_URL2,
43009
- isE2E: isE2E3,
43021
+ isE2E: isE2E4,
43010
43022
  isCI: isCI2,
43011
43023
  API_URL: API_URL2,
43012
43024
  TEST_GUEST_FINGERPRINTS,
@@ -43038,7 +43050,7 @@ function SignIn({
43038
43050
  window.removeEventListener("keydown", handleKeyDown);
43039
43051
  };
43040
43052
  }, [part]);
43041
- const E2E = isE2E3 || fingerprint && (TEST_GUEST_FINGERPRINTS.includes(fingerprint) || TEST_MEMBER_FINGERPRINTS.includes(fingerprint));
43053
+ const E2E = isE2E4 || fingerprint && (TEST_GUEST_FINGERPRINTS.includes(fingerprint) || TEST_MEMBER_FINGERPRINTS.includes(fingerprint));
43042
43054
  const handleSignIn = async (part2) => {
43043
43055
  if (E2E) {
43044
43056
  part2 = "credentials";
@@ -43902,7 +43914,7 @@ function Subscribe({
43902
43914
  const checkoutSuccessUrl = (() => {
43903
43915
  params.set("checkout", "success");
43904
43916
  params.set("purchaseType", part2);
43905
- isE2E2 && fingerprint && params.set("fp", fingerprint);
43917
+ token && params.set("auth_token", token);
43906
43918
  return `${FRONTEND_URL2}/?${params.toString()}&session_id={CHECKOUT_SESSION_ID}`;
43907
43919
  })();
43908
43920
  const checkoutCancelUrl = (() => {
@@ -50869,7 +50881,7 @@ var init_Thread = __esm({
50869
50881
  }
50870
50882
  if (isE2E2)
50871
50883
  console.log("\u{1F916} onStreamingUpdate", {
50872
- content,
50884
+ content: content.replace(/__REASONING__.*?__\/REASONING__/gs, ""),
50873
50885
  clientId,
50874
50886
  aiAgent,
50875
50887
  isWebSearchEnabled: isWebSearchEnabled2,