@paymanai/payman-typescript-ask-sdk 2.0.1 → 2.0.2

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
@@ -966,6 +966,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
966
966
  const abortController = externalAbortController ?? new AbortController();
967
967
  abortControllerRef.current = abortController;
968
968
  const state = createInitialV2State();
969
+ const streamStartedAt = Date.now();
969
970
  const updateMessage = (update) => {
970
971
  if (abortController.signal.aborted) return;
971
972
  setMessages(
@@ -1100,7 +1101,8 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
1100
1101
  currentExecutingStepId: void 0,
1101
1102
  userActionResult: state.userActionResult,
1102
1103
  formattedThinkingText: state.hasError ? void 0 : state.formattedThinkingText || void 0,
1103
- isResolvingImages: needsImageResolve
1104
+ isResolvingImages: needsImageResolve,
1105
+ thinkingDurationSec: state.hasError ? void 0 : Math.max(0, Math.round((Date.now() - streamStartedAt) / 1e3))
1104
1106
  };
1105
1107
  setMessages(
1106
1108
  (prev) => prev.map(
@@ -1318,9 +1320,9 @@ function streamKeyFor(scopeKey, sessionId) {
1318
1320
  function useChatV2(config, callbacks = {}) {
1319
1321
  const scopeKey = useMemo(() => buildScopeKey(config), [
1320
1322
  config.session?.userId,
1321
- config.workflow.id,
1322
- config.workflow.version,
1323
- config.workflow.stage
1323
+ config.workflow?.id,
1324
+ config.workflow?.version,
1325
+ config.workflow?.stage
1324
1326
  ]);
1325
1327
  const initialSessionId = chatStore.get(scopeKey).find((m) => m.sessionId)?.sessionId ?? config.session?.initialId ?? void 0;
1326
1328
  const [messages, setMessages] = useState(() => {