@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.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +36 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -15
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +17 -11
- 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
|
@@ -873,17 +873,6 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
873
873
|
signal: abortController.signal,
|
|
874
874
|
onEvent: (event) => {
|
|
875
875
|
if (abortController.signal.aborted) return;
|
|
876
|
-
try {
|
|
877
|
-
const et = event?.eventType;
|
|
878
|
-
if (et === "RUN_IN_PROGRESS" || et === "INTENT_PROGRESS" || et === "THINKING_DELTA") {
|
|
879
|
-
const len = (event.partialText ?? event.text ?? "").length;
|
|
880
|
-
console.log(`[stream] ${et} (+${len} chars)`);
|
|
881
|
-
} else {
|
|
882
|
-
console.log(`[stream] ${et ?? "?"}:`, JSON.stringify(event));
|
|
883
|
-
}
|
|
884
|
-
} catch {
|
|
885
|
-
console.log("[stream] (unserializable event)", event?.eventType);
|
|
886
|
-
}
|
|
887
876
|
processStreamEventV2(event, state);
|
|
888
877
|
if (state.lastUserAction) {
|
|
889
878
|
callbacksRef.current.onUserActionRequired?.(state.lastUserAction);
|
|
@@ -1115,6 +1104,9 @@ async function cancelUserAction(config, userActionId) {
|
|
|
1115
1104
|
async function resendUserAction(config, userActionId) {
|
|
1116
1105
|
return sendUserActionRequest(config, userActionId, "resend");
|
|
1117
1106
|
}
|
|
1107
|
+
async function expireUserAction(config, userActionId) {
|
|
1108
|
+
return sendUserActionRequest(config, userActionId, "expired");
|
|
1109
|
+
}
|
|
1118
1110
|
var EMPTY_USER_ACTION_STATE = { prompts: [], notifications: [] };
|
|
1119
1111
|
function upsertPrompt(prompts, req) {
|
|
1120
1112
|
const active = { ...req, status: "pending" };
|
|
@@ -1406,6 +1398,19 @@ function useChatV2(config, callbacks = {}) {
|
|
|
1406
1398
|
},
|
|
1407
1399
|
[setPromptStatus]
|
|
1408
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
|
+
);
|
|
1409
1414
|
const dismissNotification = react.useCallback((id) => {
|
|
1410
1415
|
setUserActionState((prev) => ({
|
|
1411
1416
|
...prev,
|
|
@@ -1485,6 +1490,7 @@ function useChatV2(config, callbacks = {}) {
|
|
|
1485
1490
|
submitUserAction: submitUserAction2,
|
|
1486
1491
|
cancelUserAction: cancelUserAction2,
|
|
1487
1492
|
resendUserAction: resendUserAction2,
|
|
1493
|
+
expireUserAction: expireUserAction2,
|
|
1488
1494
|
dismissNotification
|
|
1489
1495
|
};
|
|
1490
1496
|
}
|
|
@@ -4668,6 +4674,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4668
4674
|
onSubmitUserAction,
|
|
4669
4675
|
onCancelUserAction,
|
|
4670
4676
|
onResendUserAction,
|
|
4677
|
+
onExpireUserAction,
|
|
4671
4678
|
onDismissNotification,
|
|
4672
4679
|
onSubmitFeedback,
|
|
4673
4680
|
typingSpeed = 4
|
|
@@ -4679,6 +4686,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4679
4686
|
const isNearBottomRef = react.useRef(true);
|
|
4680
4687
|
const [showScrollBtn, setShowScrollBtn] = react.useState(false);
|
|
4681
4688
|
const [expiredPromptViewState, setExpiredPromptViewState] = react.useState({});
|
|
4689
|
+
const expiredUserActionIdsRef = react.useRef(/* @__PURE__ */ new Set());
|
|
4682
4690
|
const prevCountRef = react.useRef(messages.length);
|
|
4683
4691
|
const pauseStickUntilUserMessageRef = react.useRef(false);
|
|
4684
4692
|
const followingBottomRef = react.useRef(true);
|
|
@@ -4716,7 +4724,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4716
4724
|
].join(PROMPT_KEY_SEPARATOR);
|
|
4717
4725
|
}, [isStreaming, messages, notifications, userActionPrompts]);
|
|
4718
4726
|
const handleUserActionExpired = react.useCallback(
|
|
4719
|
-
(promptKey) => {
|
|
4727
|
+
(promptKey, userActionId) => {
|
|
4720
4728
|
setExpiredPromptViewState((prev) => {
|
|
4721
4729
|
if (prev[promptKey]) return prev;
|
|
4722
4730
|
return {
|
|
@@ -4724,8 +4732,13 @@ var MessageListV2 = react.forwardRef(
|
|
|
4724
4732
|
[promptKey]: { baseline: messageActivityFingerprint, hidden: false }
|
|
4725
4733
|
};
|
|
4726
4734
|
});
|
|
4735
|
+
if (!expiredUserActionIdsRef.current.has(userActionId)) {
|
|
4736
|
+
expiredUserActionIdsRef.current.add(userActionId);
|
|
4737
|
+
void onExpireUserAction?.(userActionId)?.catch(() => {
|
|
4738
|
+
});
|
|
4739
|
+
}
|
|
4727
4740
|
},
|
|
4728
|
-
[messageActivityFingerprint]
|
|
4741
|
+
[messageActivityFingerprint, onExpireUserAction]
|
|
4729
4742
|
);
|
|
4730
4743
|
react.useEffect(() => {
|
|
4731
4744
|
setExpiredPromptViewState((prev) => {
|
|
@@ -4744,6 +4757,12 @@ var MessageListV2 = react.forwardRef(
|
|
|
4744
4757
|
}, [messageActivityFingerprint]);
|
|
4745
4758
|
react.useEffect(() => {
|
|
4746
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
|
+
}
|
|
4747
4766
|
setExpiredPromptViewState((prev) => {
|
|
4748
4767
|
let changed = false;
|
|
4749
4768
|
const next = {};
|
|
@@ -4909,7 +4928,7 @@ var MessageListV2 = react.forwardRef(
|
|
|
4909
4928
|
onSubmit: onSubmitUserAction ?? noop,
|
|
4910
4929
|
onCancel: onCancelUserAction ?? noop,
|
|
4911
4930
|
onResend: onResendUserAction ?? noop,
|
|
4912
|
-
onExpired: () => handleUserActionExpired(promptKey)
|
|
4931
|
+
onExpired: () => handleUserActionExpired(promptKey, prompt.userActionId)
|
|
4913
4932
|
},
|
|
4914
4933
|
promptKey
|
|
4915
4934
|
);
|
|
@@ -6121,6 +6140,7 @@ var PaymanChatInner = react.forwardRef(function PaymanChatInner2({
|
|
|
6121
6140
|
const submitUserAction2 = chat.submitUserAction ?? NOOP_ASYNC;
|
|
6122
6141
|
const cancelUserAction2 = chat.cancelUserAction ?? NOOP_ASYNC;
|
|
6123
6142
|
const resendUserAction2 = chat.resendUserAction ?? NOOP_ASYNC;
|
|
6143
|
+
const expireUserAction2 = chat.expireUserAction ?? NOOP_ASYNC;
|
|
6124
6144
|
const dismissNotification = chat.dismissNotification ?? NOOP;
|
|
6125
6145
|
const isUserActionSupported = typeof chat.submitUserAction === "function" && typeof chat.cancelUserAction === "function" && typeof chat.resendUserAction === "function";
|
|
6126
6146
|
const {
|
|
@@ -6521,6 +6541,7 @@ var PaymanChatInner = react.forwardRef(function PaymanChatInner2({
|
|
|
6521
6541
|
onSubmitUserAction: isUserActionSupported ? submitUserAction2 : void 0,
|
|
6522
6542
|
onCancelUserAction: isUserActionSupported ? cancelUserAction2 : void 0,
|
|
6523
6543
|
onResendUserAction: isUserActionSupported ? resendUserAction2 : void 0,
|
|
6544
|
+
onExpireUserAction: isUserActionSupported ? expireUserAction2 : void 0,
|
|
6524
6545
|
onDismissNotification: dismissNotification,
|
|
6525
6546
|
onSubmitFeedback: handleSubmitFeedback
|
|
6526
6547
|
}
|
|
@@ -6610,6 +6631,7 @@ exports.UserActionStaleError = UserActionStaleError;
|
|
|
6610
6631
|
exports.cancelUserAction = cancelUserAction;
|
|
6611
6632
|
exports.captureSentryError = captureSentryError;
|
|
6612
6633
|
exports.cn = cn;
|
|
6634
|
+
exports.expireUserAction = expireUserAction;
|
|
6613
6635
|
exports.formatDate = formatDate;
|
|
6614
6636
|
exports.resendUserAction = resendUserAction;
|
|
6615
6637
|
exports.submitUserAction = submitUserAction;
|