@paymanai/payman-typescript-ask-sdk 4.0.25 → 4.0.26
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 +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +17 -2
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.js
CHANGED
|
@@ -297,6 +297,8 @@ function getEventMessage(event) {
|
|
|
297
297
|
}
|
|
298
298
|
case "RUN_IN_PROGRESS":
|
|
299
299
|
return event.partialText || "Thinking...";
|
|
300
|
+
case "LLM_CALL_STARTED":
|
|
301
|
+
return event.description || "";
|
|
300
302
|
case "RUN_COMPLETED":
|
|
301
303
|
return "Agent run completed";
|
|
302
304
|
case "RUN_FAILED":
|
|
@@ -434,7 +436,8 @@ function createInitialV2State() {
|
|
|
434
436
|
finalData: void 0,
|
|
435
437
|
steps: [],
|
|
436
438
|
stepCounter: 0,
|
|
437
|
-
currentExecutingStepId: void 0
|
|
439
|
+
currentExecutingStepId: void 0,
|
|
440
|
+
trailingActivity: false
|
|
438
441
|
};
|
|
439
442
|
}
|
|
440
443
|
function upsertUserAction(state, req) {
|
|
@@ -456,6 +459,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
456
459
|
if (typeof eventType === "string" && eventType.toUpperCase() === "KEEP_ALIVE") {
|
|
457
460
|
if (event.executionId) state.executionId = event.executionId;
|
|
458
461
|
if (event.sessionId) state.sessionId = event.sessionId;
|
|
462
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
459
463
|
const description = typeof event.description === "string" ? event.description : "";
|
|
460
464
|
if (description) {
|
|
461
465
|
for (let i = state.steps.length - 1; i >= 0; i--) {
|
|
@@ -490,7 +494,12 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
490
494
|
state.lastEventType = eventType;
|
|
491
495
|
break;
|
|
492
496
|
}
|
|
497
|
+
case "LLM_CALL_STARTED":
|
|
498
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
499
|
+
state.lastEventType = eventType;
|
|
500
|
+
break;
|
|
493
501
|
case "INTENT_STARTED": {
|
|
502
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
494
503
|
const stepId = `step-${state.stepCounter++}`;
|
|
495
504
|
state.steps.push({
|
|
496
505
|
id: stepId,
|
|
@@ -506,6 +515,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
506
515
|
break;
|
|
507
516
|
}
|
|
508
517
|
case "INTENT_COMPLETED": {
|
|
518
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
509
519
|
const intentStep = state.steps.find((s) => s.eventType === "INTENT_STARTED" && s.status === "in_progress");
|
|
510
520
|
if (intentStep) {
|
|
511
521
|
intentStep.status = "completed";
|
|
@@ -537,6 +547,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
537
547
|
step.status = "completed";
|
|
538
548
|
}
|
|
539
549
|
});
|
|
550
|
+
state.trailingActivity = false;
|
|
540
551
|
state.lastEventType = eventType;
|
|
541
552
|
break;
|
|
542
553
|
}
|
|
@@ -608,6 +619,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
608
619
|
case "WORKFLOW_ERROR":
|
|
609
620
|
state.hasError = true;
|
|
610
621
|
state.errorMessage = event.errorMessage || event.message || "Workflow error";
|
|
622
|
+
state.trailingActivity = false;
|
|
611
623
|
state.lastEventType = eventType;
|
|
612
624
|
break;
|
|
613
625
|
// ---- K2 pipeline stage lifecycle events ----
|
|
@@ -902,7 +914,9 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
902
914
|
const latestUsefulStep = [...state.steps].reverse().find(
|
|
903
915
|
(s) => s.message && !isBlandStatus(s.message)
|
|
904
916
|
);
|
|
905
|
-
const
|
|
917
|
+
const eventTypeUpper = typeof event.eventType === "string" ? event.eventType.toUpperCase() : "";
|
|
918
|
+
const liveEventLabel = eventTypeUpper === "KEEP_ALIVE" || eventTypeUpper === "LLM_CALL_STARTED" ? useful(getEventMessage(event)) : void 0;
|
|
919
|
+
const currentMessage = useful(activeStep?.message) ?? useful(lastInProgressStep?.message) ?? liveEventLabel ?? latestUsefulStep?.message ?? useful(getEventMessage(event)) ?? // Last-resort: every candidate is bland (very first event,
|
|
906
920
|
// nothing useful seen yet). Render the bland label so the
|
|
907
921
|
// bubble isn't blank.
|
|
908
922
|
activeStep?.message ?? lastInProgressStep?.message ?? getEventMessage(event);
|
|
@@ -927,6 +941,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
927
941
|
streamingContent: state.finalResponse,
|
|
928
942
|
content: "",
|
|
929
943
|
currentMessage,
|
|
944
|
+
hasTrailingActivity: state.trailingActivity,
|
|
930
945
|
streamProgress: "processing",
|
|
931
946
|
isError: false,
|
|
932
947
|
steps: [...state.steps],
|