@paymanai/payman-typescript-ask-sdk 2.0.1 → 2.0.3
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +10 -6
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
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(
|
|
@@ -992,7 +993,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
992
993
|
const eventType = event.eventType;
|
|
993
994
|
if (eventType === "USER_ACTION_REQUIRED" && state.userActionRequest) {
|
|
994
995
|
callbacksRef.current.onUserActionRequired?.(state.userActionRequest);
|
|
995
|
-
} else if (eventType.startsWith("USER_ACTION_") && eventType !== "USER_ACTION_REQUIRED") {
|
|
996
|
+
} else if (typeof eventType === "string" && eventType.startsWith("USER_ACTION_") && eventType !== "USER_ACTION_REQUIRED") {
|
|
996
997
|
const msg = getUserActionDisplayMessage(
|
|
997
998
|
eventType,
|
|
998
999
|
event.message?.trim() || event.errorMessage?.trim() || getEventMessage(event)
|
|
@@ -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
|
|
1322
|
-
config.workflow
|
|
1323
|
-
config.workflow
|
|
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(() => {
|