@paymanai/payman-ask-sdk 4.0.17 → 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.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +966 -24
- package/dist/index.native.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { MessageDisplay, AgentStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, ActiveUserAction, UserNotification } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
-
export { APIConfig, ActiveUserAction, AgentStage, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, resendUserAction, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { APIConfig, ActiveUserAction, AgentStage, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, expireUserAction, resendUserAction, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
5
5
|
import { ClassValue } from 'clsx';
|
|
6
6
|
|
|
7
7
|
declare const NEGATIVE_FEEDBACK_REASONS: readonly [{
|
|
@@ -358,6 +358,7 @@ type MessageListV2Props = {
|
|
|
358
358
|
onCancelUserAction?: (userActionId: string) => Promise<void>;
|
|
359
359
|
/** Resend a prompt (e.g. resend a verification code). */
|
|
360
360
|
onResendUserAction?: (userActionId: string) => Promise<void>;
|
|
361
|
+
onExpireUserAction?: (userActionId: string) => Promise<void>;
|
|
361
362
|
/** Dismiss a one-way notification. */
|
|
362
363
|
onDismissNotification?: (id: string) => void;
|
|
363
364
|
/** Persist thumbs-up/down feedback (rejects on failure). */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { MessageDisplay, AgentStage, ChatCallbacks as ChatCallbacks$1, ChatConfig as ChatConfig$1, ActiveUserAction, UserNotification } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
-
export { APIConfig, ActiveUserAction, AgentStage, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, resendUserAction, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
4
|
+
export { APIConfig, ActiveUserAction, AgentStage, ChunkDisplay, JsonSchemaField, JsonSchemaOption, MessageDisplay, MessageRole, RequestedSchema, SessionParams, StreamProgress, StreamingStep, UseChatV2Return, UseVoiceReturn, UserActionKind, UserActionRequest, UserActionStaleError, UserActionState, UserActionStatus, UserActionSubAction, UserNotification, VerificationType, VoiceCallbacks, VoiceConfig, VoicePermissions, VoiceResult, VoiceState, cancelUserAction, expireUserAction, resendUserAction, submitUserAction, useChatV2, useVoice } from '@paymanai/payman-typescript-ask-sdk';
|
|
5
5
|
import { ClassValue } from 'clsx';
|
|
6
6
|
|
|
7
7
|
declare const NEGATIVE_FEEDBACK_REASONS: readonly [{
|
|
@@ -358,6 +358,7 @@ type MessageListV2Props = {
|
|
|
358
358
|
onCancelUserAction?: (userActionId: string) => Promise<void>;
|
|
359
359
|
/** Resend a prompt (e.g. resend a verification code). */
|
|
360
360
|
onResendUserAction?: (userActionId: string) => Promise<void>;
|
|
361
|
+
onExpireUserAction?: (userActionId: string) => Promise<void>;
|
|
361
362
|
/** Dismiss a one-way notification. */
|
|
362
363
|
onDismissNotification?: (id: string) => void;
|
|
363
364
|
/** Persist thumbs-up/down feedback (rejects on failure). */
|
package/dist/index.js
CHANGED
|
@@ -1104,6 +1104,9 @@ async function cancelUserAction(config, userActionId) {
|
|
|
1104
1104
|
async function resendUserAction(config, userActionId) {
|
|
1105
1105
|
return sendUserActionRequest(config, userActionId, "resend");
|
|
1106
1106
|
}
|
|
1107
|
+
async function expireUserAction(config, userActionId) {
|
|
1108
|
+
return sendUserActionRequest(config, userActionId, "expired");
|
|
1109
|
+
}
|
|
1107
1110
|
var EMPTY_USER_ACTION_STATE = { prompts: [], notifications: [] };
|
|
1108
1111
|
function upsertPrompt(prompts, req) {
|
|
1109
1112
|
const active = { ...req, status: "pending" };
|
|
@@ -1395,6 +1398,19 @@ function useChatV2(config, callbacks = {}) {
|
|
|
1395
1398
|
},
|
|
1396
1399
|
[setPromptStatus]
|
|
1397
1400
|
);
|
|
1401
|
+
const expireUserAction2 = react.useCallback(
|
|
1402
|
+
async (userActionId) => {
|
|
1403
|
+
setPromptStatus(userActionId, "expired");
|
|
1404
|
+
try {
|
|
1405
|
+
await expireUserAction(configRef.current, userActionId);
|
|
1406
|
+
} catch (error) {
|
|
1407
|
+
if (error instanceof UserActionStaleError) return;
|
|
1408
|
+
callbacksRef.current.onError?.(error);
|
|
1409
|
+
throw error;
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
[setPromptStatus]
|
|
1413
|
+
);
|
|
1398
1414
|
const dismissNotification = react.useCallback((id) => {
|
|
1399
1415
|
setUserActionState((prev) => ({
|
|
1400
1416
|
...prev,
|
|
@@ -1474,6 +1490,7 @@ function useChatV2(config, callbacks = {}) {
|
|
|
1474
1490
|
submitUserAction: submitUserAction2,
|
|
1475
1491
|
cancelUserAction: cancelUserAction2,
|
|
1476
1492
|
resendUserAction: resendUserAction2,
|
|
1493
|
+
expireUserAction: expireUserAction2,
|
|
1477
1494
|
dismissNotification
|
|
1478
1495
|
};
|
|
1479
1496
|
}
|
|
@@ -4657,6 +4674,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4657
4674
|
onSubmitUserAction,
|
|
4658
4675
|
onCancelUserAction,
|
|
4659
4676
|
onResendUserAction,
|
|
4677
|
+
onExpireUserAction,
|
|
4660
4678
|
onDismissNotification,
|
|
4661
4679
|
onSubmitFeedback,
|
|
4662
4680
|
typingSpeed = 4
|
|
@@ -4668,6 +4686,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4668
4686
|
const isNearBottomRef = react.useRef(true);
|
|
4669
4687
|
const [showScrollBtn, setShowScrollBtn] = react.useState(false);
|
|
4670
4688
|
const [expiredPromptViewState, setExpiredPromptViewState] = react.useState({});
|
|
4689
|
+
const expiredUserActionIdsRef = react.useRef(/* @__PURE__ */ new Set());
|
|
4671
4690
|
const prevCountRef = react.useRef(messages.length);
|
|
4672
4691
|
const pauseStickUntilUserMessageRef = react.useRef(false);
|
|
4673
4692
|
const followingBottomRef = react.useRef(true);
|
|
@@ -4705,7 +4724,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4705
4724
|
].join(PROMPT_KEY_SEPARATOR);
|
|
4706
4725
|
}, [isStreaming, messages, notifications, userActionPrompts]);
|
|
4707
4726
|
const handleUserActionExpired = react.useCallback(
|
|
4708
|
-
(promptKey) => {
|
|
4727
|
+
(promptKey, userActionId) => {
|
|
4709
4728
|
setExpiredPromptViewState((prev) => {
|
|
4710
4729
|
if (prev[promptKey]) return prev;
|
|
4711
4730
|
return {
|
|
@@ -4713,8 +4732,13 @@ var MessageListV2 = react.forwardRef(
|
|
|
4713
4732
|
[promptKey]: { baseline: messageActivityFingerprint, hidden: false }
|
|
4714
4733
|
};
|
|
4715
4734
|
});
|
|
4735
|
+
if (!expiredUserActionIdsRef.current.has(userActionId)) {
|
|
4736
|
+
expiredUserActionIdsRef.current.add(userActionId);
|
|
4737
|
+
void onExpireUserAction?.(userActionId)?.catch(() => {
|
|
4738
|
+
});
|
|
4739
|
+
}
|
|
4716
4740
|
},
|
|
4717
|
-
[messageActivityFingerprint]
|
|
4741
|
+
[messageActivityFingerprint, onExpireUserAction]
|
|
4718
4742
|
);
|
|
4719
4743
|
react.useEffect(() => {
|
|
4720
4744
|
setExpiredPromptViewState((prev) => {
|
|
@@ -4733,6 +4757,12 @@ var MessageListV2 = react.forwardRef(
|
|
|
4733
4757
|
}, [messageActivityFingerprint]);
|
|
4734
4758
|
react.useEffect(() => {
|
|
4735
4759
|
const livePromptKeys = new Set((userActionPrompts ?? []).map(getPromptViewKey));
|
|
4760
|
+
const liveUserActionIds = new Set((userActionPrompts ?? []).map((p) => p.userActionId));
|
|
4761
|
+
for (const userActionId of expiredUserActionIdsRef.current) {
|
|
4762
|
+
if (!liveUserActionIds.has(userActionId)) {
|
|
4763
|
+
expiredUserActionIdsRef.current.delete(userActionId);
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4736
4766
|
setExpiredPromptViewState((prev) => {
|
|
4737
4767
|
let changed = false;
|
|
4738
4768
|
const next = {};
|
|
@@ -4898,7 +4928,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4898
4928
|
onSubmit: onSubmitUserAction ?? noop,
|
|
4899
4929
|
onCancel: onCancelUserAction ?? noop,
|
|
4900
4930
|
onResend: onResendUserAction ?? noop,
|
|
4901
|
-
onExpired: () => handleUserActionExpired(promptKey)
|
|
4931
|
+
onExpired: () => handleUserActionExpired(promptKey, prompt.userActionId)
|
|
4902
4932
|
},
|
|
4903
4933
|
promptKey
|
|
4904
4934
|
);
|
|
@@ -6110,6 +6140,7 @@ var PaymanChatInner = react.forwardRef(function PaymanChatInner2({
|
|
|
6110
6140
|
const submitUserAction2 = chat.submitUserAction ?? NOOP_ASYNC;
|
|
6111
6141
|
const cancelUserAction2 = chat.cancelUserAction ?? NOOP_ASYNC;
|
|
6112
6142
|
const resendUserAction2 = chat.resendUserAction ?? NOOP_ASYNC;
|
|
6143
|
+
const expireUserAction2 = chat.expireUserAction ?? NOOP_ASYNC;
|
|
6113
6144
|
const dismissNotification = chat.dismissNotification ?? NOOP;
|
|
6114
6145
|
const isUserActionSupported = typeof chat.submitUserAction === "function" && typeof chat.cancelUserAction === "function" && typeof chat.resendUserAction === "function";
|
|
6115
6146
|
const {
|
|
@@ -6510,6 +6541,7 @@ var PaymanChatInner = react.forwardRef(function PaymanChatInner2({
|
|
|
6510
6541
|
onSubmitUserAction: isUserActionSupported ? submitUserAction2 : void 0,
|
|
6511
6542
|
onCancelUserAction: isUserActionSupported ? cancelUserAction2 : void 0,
|
|
6512
6543
|
onResendUserAction: isUserActionSupported ? resendUserAction2 : void 0,
|
|
6544
|
+
onExpireUserAction: isUserActionSupported ? expireUserAction2 : void 0,
|
|
6513
6545
|
onDismissNotification: dismissNotification,
|
|
6514
6546
|
onSubmitFeedback: handleSubmitFeedback
|
|
6515
6547
|
}
|
|
@@ -6599,6 +6631,7 @@ exports.UserActionStaleError = UserActionStaleError;
|
|
|
6599
6631
|
exports.cancelUserAction = cancelUserAction;
|
|
6600
6632
|
exports.captureSentryError = captureSentryError;
|
|
6601
6633
|
exports.cn = cn;
|
|
6634
|
+
exports.expireUserAction = expireUserAction;
|
|
6602
6635
|
exports.formatDate = formatDate;
|
|
6603
6636
|
exports.resendUserAction = resendUserAction;
|
|
6604
6637
|
exports.submitUserAction = submitUserAction;
|