@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 CHANGED
@@ -201,6 +201,14 @@ type MessageDisplay = {
201
201
  isStreaming?: boolean;
202
202
  streamingContent?: string;
203
203
  currentMessage?: string;
204
+ /**
205
+ * True while work events (tool calls, LLM-call boundaries, keep-alive
206
+ * heartbeats) are arriving AFTER answer text already started streaming —
207
+ * e.g. the agent-builder streams an instant acknowledgment and then does
208
+ * its real work. Tells the UI to keep a live status line below the
209
+ * already-rendered text instead of showing just a frozen cursor.
210
+ */
211
+ hasTrailingActivity?: boolean;
204
212
  streamProgress?: StreamProgress;
205
213
  steps?: StreamingStep[];
206
214
  isCancelled?: boolean;
@@ -558,6 +566,16 @@ type V2EventProcessorState = {
558
566
  currentExecutingStepId?: string;
559
567
  /** Server-computed wall-clock duration captured from RUN_COMPLETED's `totalTimeMs`. */
560
568
  totalElapsedMs?: number;
569
+ /**
570
+ * True once work events (tool calls, LLM-call boundaries, keep-alive
571
+ * heartbeats) arrive AFTER answer text has started streaming. The
572
+ * agent-builder streams an instant acknowledgment first and then does
573
+ * its real work — this tells the UI to keep a live status line below
574
+ * the already-rendered text. Plain answer streaming (formatter deltas
575
+ * with no trailing work) never sets it. Sticky until the run ends so
576
+ * the status line doesn't flicker during think-gaps between tools.
577
+ */
578
+ trailingActivity: boolean;
561
579
  };
562
580
  declare function createInitialV2State(): V2EventProcessorState;
563
581
  declare function processStreamEventV2(rawEvent: StreamEvent, state: V2EventProcessorState): V2EventProcessorState;
package/dist/index.d.ts CHANGED
@@ -201,6 +201,14 @@ type MessageDisplay = {
201
201
  isStreaming?: boolean;
202
202
  streamingContent?: string;
203
203
  currentMessage?: string;
204
+ /**
205
+ * True while work events (tool calls, LLM-call boundaries, keep-alive
206
+ * heartbeats) are arriving AFTER answer text already started streaming —
207
+ * e.g. the agent-builder streams an instant acknowledgment and then does
208
+ * its real work. Tells the UI to keep a live status line below the
209
+ * already-rendered text instead of showing just a frozen cursor.
210
+ */
211
+ hasTrailingActivity?: boolean;
204
212
  streamProgress?: StreamProgress;
205
213
  steps?: StreamingStep[];
206
214
  isCancelled?: boolean;
@@ -558,6 +566,16 @@ type V2EventProcessorState = {
558
566
  currentExecutingStepId?: string;
559
567
  /** Server-computed wall-clock duration captured from RUN_COMPLETED's `totalTimeMs`. */
560
568
  totalElapsedMs?: number;
569
+ /**
570
+ * True once work events (tool calls, LLM-call boundaries, keep-alive
571
+ * heartbeats) arrive AFTER answer text has started streaming. The
572
+ * agent-builder streams an instant acknowledgment first and then does
573
+ * its real work — this tells the UI to keep a live status line below
574
+ * the already-rendered text. Plain answer streaming (formatter deltas
575
+ * with no trailing work) never sets it. Sticky until the run ends so
576
+ * the status line doesn't flicker during think-gaps between tools.
577
+ */
578
+ trailingActivity: boolean;
561
579
  };
562
580
  declare function createInitialV2State(): V2EventProcessorState;
563
581
  declare function processStreamEventV2(rawEvent: StreamEvent, state: V2EventProcessorState): V2EventProcessorState;
package/dist/index.js CHANGED
@@ -276,6 +276,8 @@ function getEventMessage(event) {
276
276
  }
277
277
  case "RUN_IN_PROGRESS":
278
278
  return event.partialText || "Thinking...";
279
+ case "LLM_CALL_STARTED":
280
+ return event.description || "";
279
281
  case "RUN_COMPLETED":
280
282
  return "Agent run completed";
281
283
  case "RUN_FAILED":
@@ -413,7 +415,8 @@ function createInitialV2State() {
413
415
  finalData: void 0,
414
416
  steps: [],
415
417
  stepCounter: 0,
416
- currentExecutingStepId: void 0
418
+ currentExecutingStepId: void 0,
419
+ trailingActivity: false
417
420
  };
418
421
  }
419
422
  function upsertUserAction(state, req) {
@@ -435,6 +438,7 @@ function processStreamEventV2(rawEvent, state) {
435
438
  if (typeof eventType === "string" && eventType.toUpperCase() === "KEEP_ALIVE") {
436
439
  if (event.executionId) state.executionId = event.executionId;
437
440
  if (event.sessionId) state.sessionId = event.sessionId;
441
+ if (state.finalResponse) state.trailingActivity = true;
438
442
  const description = typeof event.description === "string" ? event.description : "";
439
443
  if (description) {
440
444
  for (let i = state.steps.length - 1; i >= 0; i--) {
@@ -469,7 +473,12 @@ function processStreamEventV2(rawEvent, state) {
469
473
  state.lastEventType = eventType;
470
474
  break;
471
475
  }
476
+ case "LLM_CALL_STARTED":
477
+ if (state.finalResponse) state.trailingActivity = true;
478
+ state.lastEventType = eventType;
479
+ break;
472
480
  case "INTENT_STARTED": {
481
+ if (state.finalResponse) state.trailingActivity = true;
473
482
  const stepId = `step-${state.stepCounter++}`;
474
483
  state.steps.push({
475
484
  id: stepId,
@@ -485,6 +494,7 @@ function processStreamEventV2(rawEvent, state) {
485
494
  break;
486
495
  }
487
496
  case "INTENT_COMPLETED": {
497
+ if (state.finalResponse) state.trailingActivity = true;
488
498
  const intentStep = state.steps.find((s) => s.eventType === "INTENT_STARTED" && s.status === "in_progress");
489
499
  if (intentStep) {
490
500
  intentStep.status = "completed";
@@ -516,6 +526,7 @@ function processStreamEventV2(rawEvent, state) {
516
526
  step.status = "completed";
517
527
  }
518
528
  });
529
+ state.trailingActivity = false;
519
530
  state.lastEventType = eventType;
520
531
  break;
521
532
  }
@@ -587,6 +598,7 @@ function processStreamEventV2(rawEvent, state) {
587
598
  case "WORKFLOW_ERROR":
588
599
  state.hasError = true;
589
600
  state.errorMessage = event.errorMessage || event.message || "Workflow error";
601
+ state.trailingActivity = false;
590
602
  state.lastEventType = eventType;
591
603
  break;
592
604
  // ---- K2 pipeline stage lifecycle events ----
@@ -881,7 +893,9 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
881
893
  const latestUsefulStep = [...state.steps].reverse().find(
882
894
  (s) => s.message && !isBlandStatus(s.message)
883
895
  );
884
- const currentMessage = useful(activeStep?.message) ?? useful(lastInProgressStep?.message) ?? latestUsefulStep?.message ?? useful(getEventMessage(event)) ?? // Last-resort: every candidate is bland (very first event,
896
+ const eventTypeUpper = typeof event.eventType === "string" ? event.eventType.toUpperCase() : "";
897
+ const liveEventLabel = eventTypeUpper === "KEEP_ALIVE" || eventTypeUpper === "LLM_CALL_STARTED" ? useful(getEventMessage(event)) : void 0;
898
+ const currentMessage = useful(activeStep?.message) ?? useful(lastInProgressStep?.message) ?? liveEventLabel ?? latestUsefulStep?.message ?? useful(getEventMessage(event)) ?? // Last-resort: every candidate is bland (very first event,
885
899
  // nothing useful seen yet). Render the bland label so the
886
900
  // bubble isn't blank.
887
901
  activeStep?.message ?? lastInProgressStep?.message ?? getEventMessage(event);
@@ -906,6 +920,7 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
906
920
  streamingContent: state.finalResponse,
907
921
  content: "",
908
922
  currentMessage,
923
+ hasTrailingActivity: state.trailingActivity,
909
924
  streamProgress: "processing",
910
925
  isError: false,
911
926
  steps: [...state.steps],