@paymanai/payman-ask-sdk 4.0.18 → 4.0.19

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.
@@ -868,17 +868,6 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
868
868
  signal: abortController.signal,
869
869
  onEvent: (event) => {
870
870
  if (abortController.signal.aborted) return;
871
- try {
872
- const et = event?.eventType;
873
- if (et === "RUN_IN_PROGRESS" || et === "INTENT_PROGRESS" || et === "THINKING_DELTA") {
874
- const len = (event.partialText ?? event.text ?? "").length;
875
- console.log(`[stream] ${et} (+${len} chars)`);
876
- } else {
877
- console.log(`[stream] ${et ?? "?"}:`, JSON.stringify(event));
878
- }
879
- } catch {
880
- console.log("[stream] (unserializable event)", event?.eventType);
881
- }
882
871
  processStreamEventV2(event, state);
883
872
  if (state.lastUserAction) {
884
873
  callbacksRef.current.onUserActionRequired?.(state.lastUserAction);
@@ -1110,6 +1099,9 @@ async function cancelUserAction(config, userActionId) {
1110
1099
  async function resendUserAction(config, userActionId) {
1111
1100
  return sendUserActionRequest(config, userActionId, "resend");
1112
1101
  }
1102
+ async function expireUserAction(config, userActionId) {
1103
+ return sendUserActionRequest(config, userActionId, "expired");
1104
+ }
1113
1105
  var EMPTY_USER_ACTION_STATE = { prompts: [], notifications: [] };
1114
1106
  function upsertPrompt(prompts, req) {
1115
1107
  const active = { ...req, status: "pending" };
@@ -1401,6 +1393,19 @@ function useChatV2(config, callbacks = {}) {
1401
1393
  },
1402
1394
  [setPromptStatus]
1403
1395
  );
1396
+ const expireUserAction2 = react.useCallback(
1397
+ async (userActionId) => {
1398
+ setPromptStatus(userActionId, "expired");
1399
+ try {
1400
+ await expireUserAction(configRef.current, userActionId);
1401
+ } catch (error) {
1402
+ if (error instanceof UserActionStaleError) return;
1403
+ callbacksRef.current.onError?.(error);
1404
+ throw error;
1405
+ }
1406
+ },
1407
+ [setPromptStatus]
1408
+ );
1404
1409
  const dismissNotification = react.useCallback((id) => {
1405
1410
  setUserActionState((prev) => ({
1406
1411
  ...prev,
@@ -1480,6 +1485,7 @@ function useChatV2(config, callbacks = {}) {
1480
1485
  submitUserAction: submitUserAction2,
1481
1486
  cancelUserAction: cancelUserAction2,
1482
1487
  resendUserAction: resendUserAction2,
1488
+ expireUserAction: expireUserAction2,
1483
1489
  dismissNotification
1484
1490
  };
1485
1491
  }