@paymanai/payman-typescript-ask-sdk 1.2.5 → 1.2.7

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.mjs CHANGED
@@ -160,6 +160,8 @@ function getEventMessage(event) {
160
160
  return event.workerName ? `${event.workerName} thinking...` : "Thinking...";
161
161
  case "INTENT_THINKING_CONT":
162
162
  return event.message || "";
163
+ case "KEEP_ALIVE":
164
+ return "";
163
165
  default:
164
166
  return eventType;
165
167
  }
@@ -196,6 +198,9 @@ function completeLastInProgressStep(steps) {
196
198
  }
197
199
  function processStreamEvent(event, state) {
198
200
  const eventType = event.eventType;
201
+ if (typeof eventType === "string" && eventType.toUpperCase() === "KEEP_ALIVE") {
202
+ return state;
203
+ }
199
204
  const message = getEventMessage(event);
200
205
  if (eventType !== "INTENT_THINKING" && eventType !== "INTENT_THINKING_CONT") {
201
206
  if (state.currentThinkingStepId) {
@@ -778,6 +783,11 @@ function useStreamManager(config, callbacks, setMessages, setIsWaitingForRespons
778
783
  if (abortController.signal.aborted) {
779
784
  return;
780
785
  }
786
+ if (typeof event.eventType === "string" && event.eventType.toUpperCase() === "KEEP_ALIVE") {
787
+ if (event.executionId) state.executionId = event.executionId;
788
+ if (event.sessionId) state.currentSessionId = event.sessionId;
789
+ return;
790
+ }
781
791
  if (event.executionId) state.executionId = event.executionId;
782
792
  if (event.sessionId) state.currentSessionId = event.sessionId;
783
793
  const activeThinkingLengthBeforeProcess = state.activeThinkingText?.length ?? 0;
@@ -1035,7 +1045,7 @@ function useChat(config, callbacks = {}) {
1035
1045
  if (userId) {
1036
1046
  activeStreamStore.complete(userId);
1037
1047
  }
1038
- if (newSessionId && newSessionId !== sessionIdRef.current) {
1048
+ if (!abortController.signal.aborted && newSessionId && newSessionId !== sessionIdRef.current) {
1039
1049
  sessionIdRef.current = newSessionId;
1040
1050
  }
1041
1051
  },