@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.
@@ -998,6 +998,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
998
998
  const abortController = externalAbortController ?? new AbortController();
999
999
  abortControllerRef.current = abortController;
1000
1000
  const state = createInitialV2State();
1001
+ const streamStartedAt = Date.now();
1001
1002
  const updateMessage = (update) => {
1002
1003
  if (abortController.signal.aborted) return;
1003
1004
  setMessages(
@@ -1132,7 +1133,8 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
1132
1133
  currentExecutingStepId: void 0,
1133
1134
  userActionResult: state.userActionResult,
1134
1135
  formattedThinkingText: state.hasError ? void 0 : state.formattedThinkingText || void 0,
1135
- isResolvingImages: needsImageResolve
1136
+ isResolvingImages: needsImageResolve,
1137
+ thinkingDurationSec: state.hasError ? void 0 : Math.max(0, Math.round((Date.now() - streamStartedAt) / 1e3))
1136
1138
  };
1137
1139
  setMessages(
1138
1140
  (prev) => prev.map(
@@ -1350,9 +1352,9 @@ function streamKeyFor(scopeKey, sessionId) {
1350
1352
  function useChatV2(config, callbacks = {}) {
1351
1353
  const scopeKey = react.useMemo(() => buildScopeKey(config), [
1352
1354
  config.session?.userId,
1353
- config.workflow.id,
1354
- config.workflow.version,
1355
- config.workflow.stage
1355
+ config.workflow?.id,
1356
+ config.workflow?.version,
1357
+ config.workflow?.stage
1356
1358
  ]);
1357
1359
  const initialSessionId = chatStore.get(scopeKey).find((m) => m.sessionId)?.sessionId ?? config.session?.initialId ?? void 0;
1358
1360
  const [messages, setMessages] = react.useState(() => {