@modelnex/sdk 0.5.49 → 0.5.50

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.js CHANGED
@@ -4546,6 +4546,7 @@ function useTourPlayback({
4546
4546
  const runIdRef = (0, import_react12.useRef)(initialPersistedTourSessionRef.current?.runId ?? null);
4547
4547
  const turnIdRef = (0, import_react12.useRef)(null);
4548
4548
  const startRequestedRef = (0, import_react12.useRef)(false);
4549
+ const serverStateRef = (0, import_react12.useRef)(null);
4549
4550
  const playbackOwnerIdRef = (0, import_react12.useRef)(`playback-owner-${Math.random().toString(36).slice(2, 10)}`);
4550
4551
  const claimedPlaybackOwnerKeyRef = (0, import_react12.useRef)(null);
4551
4552
  const socketRef = (0, import_react12.useRef)(null);
@@ -4565,6 +4566,7 @@ function useTourPlayback({
4565
4566
  toursApiBaseRef.current = toursApiBase;
4566
4567
  pendingTourRef.current = pendingTour;
4567
4568
  showCaptionsRef.current = showCaptions;
4569
+ serverStateRef.current = serverState;
4568
4570
  const releasePlaybackOwnership = (0, import_react12.useCallback)(() => {
4569
4571
  const claimedKey = claimedPlaybackOwnerKeyRef.current;
4570
4572
  if (!claimedKey) return;
@@ -4605,6 +4607,7 @@ function useTourPlayback({
4605
4607
  emitTourInit(socket, currentWebsiteId, profile);
4606
4608
  };
4607
4609
  const handleServerState = (payload) => {
4610
+ serverStateRef.current = payload;
4608
4611
  if (typeof payload?.runId === "number") {
4609
4612
  runIdRef.current = payload.runId;
4610
4613
  }
@@ -5268,6 +5271,9 @@ function useTourPlayback({
5268
5271
  claimedPlaybackOwnerKeyRef.current = ownerKey;
5269
5272
  skipRequestedRef.current = false;
5270
5273
  startRequestedRef.current = false;
5274
+ setPendingTour(null);
5275
+ pendingTourRef.current = null;
5276
+ pendingTourOptionsRef.current = null;
5271
5277
  const total = tourData.totalSteps ?? tour?.steps?.length ?? 0;
5272
5278
  const requestedStepIndex = typeof tourData.currentStepIndex === "number" ? tourData.currentStepIndex : 0;
5273
5279
  const clampedStepIndex = Math.max(0, Math.min(requestedStepIndex, Math.max(0, total - 1)));
@@ -5574,6 +5580,14 @@ function useTourPlayback({
5574
5580
  }, { devMode: devModeRef.current });
5575
5581
  return;
5576
5582
  }
5583
+ if (serverStateRef.current?.isActive && typeof serverStateRef.current?.runId === "number") {
5584
+ emitSdkDebugLog("[TourClient] Ignoring start request because the server already has an active run", {
5585
+ tourId: tour.id,
5586
+ activeRunId: serverStateRef.current.runId,
5587
+ activeStepIndex: serverStateRef.current.stepIndex
5588
+ }, { devMode: devModeRef.current });
5589
+ return;
5590
+ }
5577
5591
  setPendingTour(null);
5578
5592
  pendingTourRef.current = null;
5579
5593
  let retries = 0;
package/dist/index.mjs CHANGED
@@ -3717,6 +3717,7 @@ function useTourPlayback({
3717
3717
  const runIdRef = useRef7(initialPersistedTourSessionRef.current?.runId ?? null);
3718
3718
  const turnIdRef = useRef7(null);
3719
3719
  const startRequestedRef = useRef7(false);
3720
+ const serverStateRef = useRef7(null);
3720
3721
  const playbackOwnerIdRef = useRef7(`playback-owner-${Math.random().toString(36).slice(2, 10)}`);
3721
3722
  const claimedPlaybackOwnerKeyRef = useRef7(null);
3722
3723
  const socketRef = useRef7(null);
@@ -3736,6 +3737,7 @@ function useTourPlayback({
3736
3737
  toursApiBaseRef.current = toursApiBase;
3737
3738
  pendingTourRef.current = pendingTour;
3738
3739
  showCaptionsRef.current = showCaptions;
3740
+ serverStateRef.current = serverState;
3739
3741
  const releasePlaybackOwnership = useCallback6(() => {
3740
3742
  const claimedKey = claimedPlaybackOwnerKeyRef.current;
3741
3743
  if (!claimedKey) return;
@@ -3776,6 +3778,7 @@ function useTourPlayback({
3776
3778
  emitTourInit(socket, currentWebsiteId, profile);
3777
3779
  };
3778
3780
  const handleServerState = (payload) => {
3781
+ serverStateRef.current = payload;
3779
3782
  if (typeof payload?.runId === "number") {
3780
3783
  runIdRef.current = payload.runId;
3781
3784
  }
@@ -4439,6 +4442,9 @@ function useTourPlayback({
4439
4442
  claimedPlaybackOwnerKeyRef.current = ownerKey;
4440
4443
  skipRequestedRef.current = false;
4441
4444
  startRequestedRef.current = false;
4445
+ setPendingTour(null);
4446
+ pendingTourRef.current = null;
4447
+ pendingTourOptionsRef.current = null;
4442
4448
  const total = tourData.totalSteps ?? tour?.steps?.length ?? 0;
4443
4449
  const requestedStepIndex = typeof tourData.currentStepIndex === "number" ? tourData.currentStepIndex : 0;
4444
4450
  const clampedStepIndex = Math.max(0, Math.min(requestedStepIndex, Math.max(0, total - 1)));
@@ -4745,6 +4751,14 @@ function useTourPlayback({
4745
4751
  }, { devMode: devModeRef.current });
4746
4752
  return;
4747
4753
  }
4754
+ if (serverStateRef.current?.isActive && typeof serverStateRef.current?.runId === "number") {
4755
+ emitSdkDebugLog("[TourClient] Ignoring start request because the server already has an active run", {
4756
+ tourId: tour.id,
4757
+ activeRunId: serverStateRef.current.runId,
4758
+ activeStepIndex: serverStateRef.current.stepIndex
4759
+ }, { devMode: devModeRef.current });
4760
+ return;
4761
+ }
4748
4762
  setPendingTour(null);
4749
4763
  pendingTourRef.current = null;
4750
4764
  let retries = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelnex/sdk",
3
- "version": "0.5.49",
3
+ "version": "0.5.50",
4
4
  "description": "React SDK for natural language control of web apps via AI agents",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",