@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.mjs
CHANGED
|
@@ -274,6 +274,8 @@ function getEventMessage(event) {
|
|
|
274
274
|
}
|
|
275
275
|
case "RUN_IN_PROGRESS":
|
|
276
276
|
return event.partialText || "Thinking...";
|
|
277
|
+
case "LLM_CALL_STARTED":
|
|
278
|
+
return event.description || "";
|
|
277
279
|
case "RUN_COMPLETED":
|
|
278
280
|
return "Agent run completed";
|
|
279
281
|
case "RUN_FAILED":
|
|
@@ -411,7 +413,8 @@ function createInitialV2State() {
|
|
|
411
413
|
finalData: void 0,
|
|
412
414
|
steps: [],
|
|
413
415
|
stepCounter: 0,
|
|
414
|
-
currentExecutingStepId: void 0
|
|
416
|
+
currentExecutingStepId: void 0,
|
|
417
|
+
trailingActivity: false
|
|
415
418
|
};
|
|
416
419
|
}
|
|
417
420
|
function upsertUserAction(state, req) {
|
|
@@ -433,6 +436,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
433
436
|
if (typeof eventType === "string" && eventType.toUpperCase() === "KEEP_ALIVE") {
|
|
434
437
|
if (event.executionId) state.executionId = event.executionId;
|
|
435
438
|
if (event.sessionId) state.sessionId = event.sessionId;
|
|
439
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
436
440
|
const description = typeof event.description === "string" ? event.description : "";
|
|
437
441
|
if (description) {
|
|
438
442
|
for (let i = state.steps.length - 1; i >= 0; i--) {
|
|
@@ -467,7 +471,12 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
467
471
|
state.lastEventType = eventType;
|
|
468
472
|
break;
|
|
469
473
|
}
|
|
474
|
+
case "LLM_CALL_STARTED":
|
|
475
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
476
|
+
state.lastEventType = eventType;
|
|
477
|
+
break;
|
|
470
478
|
case "INTENT_STARTED": {
|
|
479
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
471
480
|
const stepId = `step-${state.stepCounter++}`;
|
|
472
481
|
state.steps.push({
|
|
473
482
|
id: stepId,
|
|
@@ -483,6 +492,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
483
492
|
break;
|
|
484
493
|
}
|
|
485
494
|
case "INTENT_COMPLETED": {
|
|
495
|
+
if (state.finalResponse) state.trailingActivity = true;
|
|
486
496
|
const intentStep = state.steps.find((s) => s.eventType === "INTENT_STARTED" && s.status === "in_progress");
|
|
487
497
|
if (intentStep) {
|
|
488
498
|
intentStep.status = "completed";
|
|
@@ -514,6 +524,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
514
524
|
step.status = "completed";
|
|
515
525
|
}
|
|
516
526
|
});
|
|
527
|
+
state.trailingActivity = false;
|
|
517
528
|
state.lastEventType = eventType;
|
|
518
529
|
break;
|
|
519
530
|
}
|
|
@@ -585,6 +596,7 @@ function processStreamEventV2(rawEvent, state) {
|
|
|
585
596
|
case "WORKFLOW_ERROR":
|
|
586
597
|
state.hasError = true;
|
|
587
598
|
state.errorMessage = event.errorMessage || event.message || "Workflow error";
|
|
599
|
+
state.trailingActivity = false;
|
|
588
600
|
state.lastEventType = eventType;
|
|
589
601
|
break;
|
|
590
602
|
// ---- K2 pipeline stage lifecycle events ----
|
|
@@ -879,7 +891,9 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
879
891
|
const latestUsefulStep = [...state.steps].reverse().find(
|
|
880
892
|
(s) => s.message && !isBlandStatus(s.message)
|
|
881
893
|
);
|
|
882
|
-
const
|
|
894
|
+
const eventTypeUpper = typeof event.eventType === "string" ? event.eventType.toUpperCase() : "";
|
|
895
|
+
const liveEventLabel = eventTypeUpper === "KEEP_ALIVE" || eventTypeUpper === "LLM_CALL_STARTED" ? useful(getEventMessage(event)) : void 0;
|
|
896
|
+
const currentMessage = useful(activeStep?.message) ?? useful(lastInProgressStep?.message) ?? liveEventLabel ?? latestUsefulStep?.message ?? useful(getEventMessage(event)) ?? // Last-resort: every candidate is bland (very first event,
|
|
883
897
|
// nothing useful seen yet). Render the bland label so the
|
|
884
898
|
// bubble isn't blank.
|
|
885
899
|
activeStep?.message ?? lastInProgressStep?.message ?? getEventMessage(event);
|
|
@@ -904,6 +918,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
|
|
|
904
918
|
streamingContent: state.finalResponse,
|
|
905
919
|
content: "",
|
|
906
920
|
currentMessage,
|
|
921
|
+
hasTrailingActivity: state.trailingActivity,
|
|
907
922
|
streamProgress: "processing",
|
|
908
923
|
isError: false,
|
|
909
924
|
steps: [...state.steps],
|