@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.native.js
CHANGED
|
@@ -456,7 +456,9 @@ var chatStore = {
|
|
|
456
456
|
storage.set(key, JSON.stringify(messages));
|
|
457
457
|
},
|
|
458
458
|
delete(key) {
|
|
459
|
-
storage
|
|
459
|
+
const s = storage;
|
|
460
|
+
if (typeof s.remove === "function") s.remove(key);
|
|
461
|
+
else if (typeof s.delete === "function") s.delete(key);
|
|
460
462
|
}
|
|
461
463
|
};
|
|
462
464
|
|
|
@@ -998,6 +1000,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
998
1000
|
const abortController = externalAbortController ?? new AbortController();
|
|
999
1001
|
abortControllerRef.current = abortController;
|
|
1000
1002
|
const state = createInitialV2State();
|
|
1003
|
+
const streamStartedAt = Date.now();
|
|
1001
1004
|
const updateMessage = (update) => {
|
|
1002
1005
|
if (abortController.signal.aborted) return;
|
|
1003
1006
|
setMessages(
|
|
@@ -1024,7 +1027,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
1024
1027
|
const eventType = event.eventType;
|
|
1025
1028
|
if (eventType === "USER_ACTION_REQUIRED" && state.userActionRequest) {
|
|
1026
1029
|
callbacksRef.current.onUserActionRequired?.(state.userActionRequest);
|
|
1027
|
-
} else if (eventType.startsWith("USER_ACTION_") && eventType !== "USER_ACTION_REQUIRED") {
|
|
1030
|
+
} else if (typeof eventType === "string" && eventType.startsWith("USER_ACTION_") && eventType !== "USER_ACTION_REQUIRED") {
|
|
1028
1031
|
const msg = getUserActionDisplayMessage(
|
|
1029
1032
|
eventType,
|
|
1030
1033
|
event.message?.trim() || event.errorMessage?.trim() || getEventMessage(event)
|
|
@@ -1132,7 +1135,8 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
1132
1135
|
currentExecutingStepId: void 0,
|
|
1133
1136
|
userActionResult: state.userActionResult,
|
|
1134
1137
|
formattedThinkingText: state.hasError ? void 0 : state.formattedThinkingText || void 0,
|
|
1135
|
-
isResolvingImages: needsImageResolve
|
|
1138
|
+
isResolvingImages: needsImageResolve,
|
|
1139
|
+
thinkingDurationSec: state.hasError ? void 0 : Math.max(0, Math.round((Date.now() - streamStartedAt) / 1e3))
|
|
1136
1140
|
};
|
|
1137
1141
|
setMessages(
|
|
1138
1142
|
(prev) => prev.map(
|
|
@@ -1350,9 +1354,9 @@ function streamKeyFor(scopeKey, sessionId) {
|
|
|
1350
1354
|
function useChatV2(config, callbacks = {}) {
|
|
1351
1355
|
const scopeKey = react.useMemo(() => buildScopeKey(config), [
|
|
1352
1356
|
config.session?.userId,
|
|
1353
|
-
config.workflow
|
|
1354
|
-
config.workflow
|
|
1355
|
-
config.workflow
|
|
1357
|
+
config.workflow?.id,
|
|
1358
|
+
config.workflow?.version,
|
|
1359
|
+
config.workflow?.stage
|
|
1356
1360
|
]);
|
|
1357
1361
|
const initialSessionId = chatStore.get(scopeKey).find((m) => m.sessionId)?.sessionId ?? config.session?.initialId ?? void 0;
|
|
1358
1362
|
const [messages, setMessages] = react.useState(() => {
|