@agents24/chat-react 0.5.48 → 0.5.50

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/ui/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
+ defaultAgentChatStatusLabels,
2
3
  getActiveStreamingTextPartId,
3
4
  getAgentChatActivity,
4
5
  useStreamingText
5
- } from "../chunk-3UKX2RRE.js";
6
+ } from "../chunk-7EDOWQZW.js";
6
7
  import {
7
8
  attachmentFileAccept,
8
9
  canonicalInputMimeType,
@@ -3510,7 +3511,7 @@ function resolvedHitlLabel(part) {
3510
3511
 
3511
3512
  // src/ui/tool-sessions.tsx
3512
3513
  import * as React15 from "react";
3513
- import { ChevronDown as ChevronDown2, ChevronRight as ChevronRight2 } from "lucide-react";
3514
+ import { ChevronDown as ChevronDown2, ChevronRight as ChevronRight2, Clock } from "lucide-react";
3514
3515
  import { ThinkingOrb } from "thinking-orbs";
3515
3516
 
3516
3517
  // src/ui/completed-tool-activity.tsx
@@ -3644,6 +3645,9 @@ function isAgentChatSubagent(part) {
3644
3645
  function isAgentChatToolRunning(part) {
3645
3646
  return part.state === "input-available" || part.state === "input-streaming";
3646
3647
  }
3648
+ function isAgentChatToolWaiting(part, callIds) {
3649
+ return !!part.toolCallId && isAgentChatToolRunning(part) && callIds?.has(part.toolCallId) === true;
3650
+ }
3647
3651
  function latestRunningAgentChatToolId(parts) {
3648
3652
  const active = [...parts].reverse().find(isAgentChatToolRunning);
3649
3653
  return active?.toolCallId || active?.id || null;
@@ -3762,7 +3766,7 @@ function AgentChatActivityRow({
3762
3766
  return /* @__PURE__ */ jsx16("div", { className: "a24-tool-trigger-row a24-tool-trigger-row--root", "data-agents24-model-turn": modelTurnId, role: "status", children: onSelect ? /* @__PURE__ */ jsx16("button", { className: "a24-tool-trigger a24-tool-trigger--root a24-tool-trigger--active", onClick: onSelect, type: "button", children: content }) : /* @__PURE__ */ jsx16("div", { className: "a24-tool-trigger a24-tool-trigger--root a24-tool-trigger--active", children: content }) });
3763
3767
  }
3764
3768
  function AgentChatModelTurnRow({ part }) {
3765
- return /* @__PURE__ */ jsx16(AgentChatActivityRow, { label: "Planning next moves", modelTurnId: part.modelTurnId });
3769
+ return /* @__PURE__ */ jsx16(AgentChatActivityRow, { label: defaultAgentChatStatusLabels.planning, modelTurnId: part.modelTurnId });
3766
3770
  }
3767
3771
  function AgentChatNodeActivityRow({
3768
3772
  renderActivityIcon,
@@ -3836,21 +3840,26 @@ function ToolDisclosure({
3836
3840
  renderActivityIcon,
3837
3841
  completedIcon,
3838
3842
  accessibleLabel,
3839
- accessory
3843
+ accessory,
3844
+ waitingLabel
3840
3845
  }) {
3841
3846
  const [open, setOpen] = React15.useState(false);
3842
3847
  const contentId = React15.useId();
3843
3848
  const expandable = React15.Children.toArray(children).length > 0;
3844
- const leadingIcon = showOrb ? /* @__PURE__ */ jsx16(ToolActivityOrb, { label: statusLabel || "Working", kind: grouped ? "group" : "tool", part, renderActivityIcon }) : completedIcon;
3849
+ const leadingIcon = waitingLabel ? /* @__PURE__ */ jsx16("span", { "aria-hidden": "true", className: "a24-tool-completed-icon", children: /* @__PURE__ */ jsx16(Clock, {}) }) : showOrb ? /* @__PURE__ */ jsx16(ToolActivityOrb, { label: statusLabel || "Working", kind: grouped ? "group" : "tool", part, renderActivityIcon }) : completedIcon;
3850
+ const triggerLabel = /* @__PURE__ */ jsxs12(Fragment4, { children: [
3851
+ /* @__PURE__ */ jsx16("span", { className: "a24-tool-trigger__label", children: label }),
3852
+ waitingLabel ? /* @__PURE__ */ jsx16("span", { className: "a24-tool-trigger__status", children: waitingLabel }) : null
3853
+ ] });
3845
3854
  if (!expandable) {
3846
3855
  const triggerClassName = cn("a24-tool-trigger", root && "a24-tool-trigger--root", root && !leadingIcon && "a24-tool-trigger--without-orb", error && "a24-tool-trigger--error", loading && "a24-tool-trigger--active");
3847
3856
  return /* @__PURE__ */ jsxs12("div", { className: cn("a24-tool-trigger-row", root && "a24-tool-trigger-row--root"), children: [
3848
3857
  onSelect && part ? /* @__PURE__ */ jsxs12("button", { className: triggerClassName, onClick: () => onSelect(part), type: "button", children: [
3849
3858
  leadingIcon,
3850
- /* @__PURE__ */ jsx16("span", { className: "a24-tool-trigger__label", children: label })
3859
+ triggerLabel
3851
3860
  ] }) : /* @__PURE__ */ jsxs12("div", { className: triggerClassName, children: [
3852
3861
  leadingIcon,
3853
- /* @__PURE__ */ jsx16("span", { className: "a24-tool-trigger__label", children: label })
3862
+ triggerLabel
3854
3863
  ] }),
3855
3864
  accessory
3856
3865
  ] });
@@ -3873,7 +3882,7 @@ function ToolDisclosure({
3873
3882
  type: "button",
3874
3883
  children: [
3875
3884
  leadingIcon,
3876
- /* @__PURE__ */ jsx16("span", { className: "a24-tool-trigger__label", children: label }),
3885
+ triggerLabel,
3877
3886
  open ? /* @__PURE__ */ jsx16(ChevronDown2, { "aria-hidden": "true", className: "a24-tool-trigger__chevron" }) : /* @__PURE__ */ jsx16(ChevronRight2, { "aria-hidden": "true", className: "a24-tool-trigger__chevron" })
3878
3887
  ]
3879
3888
  }
@@ -3932,17 +3941,20 @@ function AgentChatToolRow({
3932
3941
  part,
3933
3942
  root = true,
3934
3943
  showOrb,
3935
- slots
3944
+ slots,
3945
+ statusLabels,
3946
+ waitingToolCallIds
3936
3947
  }) {
3937
- const active = isActive(part, activeToolId);
3948
+ const waiting = isAgentChatToolWaiting(part, waitingToolCallIds);
3949
+ const active = !waiting && isActive(part, activeToolId);
3938
3950
  const failed = part.state === "output-error";
3939
3951
  const failureMessage = part.failure?.message || null;
3940
- const detail = failed ? failureMessage : optionalText(part.presentation.detail);
3952
+ const detail = failed ? failureMessage : optionalText(part.presentation.detail) ?? (waiting ? statusLabels?.toolWaitingDetail ?? defaultAgentChatStatusLabels.toolWaitingDetail : null);
3941
3953
  const hostDetails = failed ? null : slots?.renderToolDetails?.(part);
3942
3954
  const deterministicLabel = toolRowLabel(part, Boolean(slots?.onResourceAction));
3943
3955
  const generatedLabel = slots?.toolLabelMode !== "deterministic" ? part.presentation.generatedActivity?.title : void 0;
3944
3956
  const context = toolSlotContext(active, deterministicLabel, part, slots);
3945
- return /* @__PURE__ */ jsx16("div", { "data-agents24-tool-part": part.type, "data-state": part.state, children: /* @__PURE__ */ jsxs12(
3957
+ return /* @__PURE__ */ jsx16("div", { "data-agents24-tool-part": part.type, "data-state": waiting ? "waiting" : part.state, children: /* @__PURE__ */ jsxs12(
3946
3958
  ToolDisclosure,
3947
3959
  {
3948
3960
  renderActivityIcon: slots?.renderActivityIcon,
@@ -3957,6 +3969,7 @@ function AgentChatToolRow({
3957
3969
  root,
3958
3970
  showOrb: isAgentChatToolRunning(part) && (showOrb ?? active),
3959
3971
  statusLabel: active ? generatedLabel ?? context.label : void 0,
3972
+ waitingLabel: waiting ? statusLabels?.waiting ?? defaultAgentChatStatusLabels.waiting : void 0,
3960
3973
  children: [
3961
3974
  detail ? /* @__PURE__ */ jsx16("div", { className: cn("a24-tool-detail", failed && "a24-tool-detail--error"), children: detail }) : null,
3962
3975
  hostDetails
@@ -3973,7 +3986,9 @@ function AgentChatToolSession({
3973
3986
  leadingModelTurn,
3974
3987
  modelTurn,
3975
3988
  parts,
3976
- slots
3989
+ slots,
3990
+ statusLabels,
3991
+ waitingToolCallIds
3977
3992
  }) {
3978
3993
  const presentedLiveRef = React15.useRef(false);
3979
3994
  if (isLive && isLatestActivity) presentedLiveRef.current = true;
@@ -3986,21 +4001,27 @@ function AgentChatToolSession({
3986
4001
  activeToolId,
3987
4002
  part: parts[0],
3988
4003
  showOrb: isLive === void 0 ? void 0 : isLive && isLatestActivity,
3989
- slots
4004
+ slots,
4005
+ statusLabels,
4006
+ waitingToolCallIds
3990
4007
  }
3991
4008
  );
3992
4009
  }
4010
+ const waitingParts = waitingToolCallIds?.size ? parts.filter((part) => isAgentChatToolWaiting(part, waitingToolCallIds)) : [];
4011
+ const waiting = waitingParts.length > 0;
3993
4012
  const visibleIndex = running ? activeIndex : parts.length - 1;
3994
- const visiblePart = parts[visibleIndex];
4013
+ const visiblePart = waitingParts.at(-1) ?? parts[visibleIndex];
3995
4014
  const planning = Boolean(modelTurn);
4015
+ const planningLabel = statusLabels?.planning ?? defaultAgentChatStatusLabels.planning;
3996
4016
  const presentingActivity = isLatestActivity && (planning || running || isLive);
3997
4017
  const failed = isLatestActivity && (visiblePart.state === "output-error" || visiblePart.state === "cancelled");
3998
4018
  const generatedGroupTitle = slots?.toolLabelMode !== "deterministic" ? parts.findLast((part) => part.presentation.generatedActivity?.groupTitle)?.presentation.generatedActivity?.groupTitle : void 0;
3999
- const sessionOpen = isSessionOpen ?? presentingActivity;
4019
+ const sessionOpen = waiting || (isSessionOpen ?? presentingActivity);
4000
4020
  const actions2 = sessionOpen ? [] : completedToolActions(parts);
4001
4021
  const recap = !sessionOpen && slots?.toolLabelMode !== "deterministic" ? completedRecap : void 0;
4002
4022
  const recapActions = recap ? recap.actions : actions2;
4003
- const label = sessionOpen ? generatedGroupTitle ?? (planning ? "Planning next moves" : toolRowLabel(visiblePart, true)) : recap?.label ?? completedToolSummary(actions2, parts);
4023
+ const waitingTitle = waitingParts.length === 1 ? (slots?.toolLabelMode === "deterministic" ? void 0 : visiblePart.presentation.generatedActivity?.title) ?? toolRowLabel(visiblePart, true) : void 0;
4024
+ const label = sessionOpen ? waitingTitle ?? generatedGroupTitle ?? (planning ? planningLabel : toolRowLabel(visiblePart, true)) : recap?.label ?? completedToolSummary(actions2, parts);
4004
4025
  const customLabel = slots?.renderToolGroupLabel?.({ parts, phase: sessionOpen ? "live" : "completed", label, actions: actions2, recap });
4005
4026
  const groupIconMode = slots?.groupIconMode ?? "per-action";
4006
4027
  const perAction = customLabel == null && recapActions && recapActions.length > 1 && groupIconMode === "per-action";
@@ -4008,12 +4029,12 @@ function AgentChatToolSession({
4008
4029
  const reel = /* @__PURE__ */ jsx16(
4009
4030
  ToolActivityReel,
4010
4031
  {
4011
- initialLabel: leadingModelTurn && !generatedGroupTitle ? "Planning next moves" : void 0,
4032
+ initialLabel: leadingModelTurn && !generatedGroupTitle ? planningLabel : void 0,
4012
4033
  initialShownAt: leadingModelTurn?.timestamp,
4013
4034
  label: liveReelLabel
4014
4035
  }
4015
4036
  );
4016
- const labelContent = sessionOpen && presentedLiveRef.current ? /* @__PURE__ */ jsx16("span", { className: presentingActivity ? "a24-tool-shimmer" : void 0, children: customLabel != null && typeof customLabel !== "string" ? customLabel : reel }) : customLabel ?? (perAction ? /* @__PURE__ */ jsx16(CompletedToolActionList, { actions: recapActions, parts, renderIcon: slots?.renderCompletedToolIcon }) : label);
4037
+ const labelContent = sessionOpen && !waiting && presentedLiveRef.current ? /* @__PURE__ */ jsx16("span", { className: presentingActivity ? "a24-tool-shimmer" : void 0, children: customLabel != null && typeof customLabel !== "string" ? customLabel : reel }) : customLabel ?? (perAction ? /* @__PURE__ */ jsx16(CompletedToolActionList, { actions: recapActions, parts, renderIcon: slots?.renderCompletedToolIcon }) : label);
4017
4038
  const leadingIcon = !sessionOpen && !perAction && groupIconMode !== "none" ? completedToolIcon(
4018
4039
  "group",
4019
4040
  recap ? parts : actions2[0]?.parts ?? [visiblePart],
@@ -4029,13 +4050,24 @@ function AgentChatToolSession({
4029
4050
  error: failed,
4030
4051
  grouped: true,
4031
4052
  label: labelContent,
4032
- loading: presentingActivity && sessionOpen,
4053
+ loading: presentingActivity && sessionOpen && !waiting,
4033
4054
  onExpandedChange: slots?.onExpandedChange,
4034
4055
  part: visiblePart,
4035
4056
  root: true,
4036
4057
  showOrb: sessionOpen && isLive && isLatestActivity,
4037
4058
  statusLabel: label,
4038
- children: /* @__PURE__ */ jsx16(ToolList, { children: parts.map((part) => /* @__PURE__ */ jsx16("div", { role: "listitem", children: /* @__PURE__ */ jsx16(AgentChatToolRow, { activeToolId, part, root: false, slots }) }, part.id)) })
4059
+ waitingLabel: waiting ? statusLabels?.waiting ?? defaultAgentChatStatusLabels.waiting : void 0,
4060
+ children: /* @__PURE__ */ jsx16(ToolList, { children: parts.map((part) => /* @__PURE__ */ jsx16("div", { role: "listitem", children: /* @__PURE__ */ jsx16(
4061
+ AgentChatToolRow,
4062
+ {
4063
+ activeToolId,
4064
+ part,
4065
+ root: false,
4066
+ slots,
4067
+ statusLabels,
4068
+ waitingToolCallIds
4069
+ }
4070
+ ) }, part.id)) })
4039
4071
  }
4040
4072
  );
4041
4073
  }
@@ -4326,6 +4358,7 @@ function AgentResponseTimeline({
4326
4358
  parts: displayParts,
4327
4359
  renderUiBlocks,
4328
4360
  responseProps,
4361
+ statusLabels,
4329
4362
  toolSlots: suppliedToolSlots,
4330
4363
  toolViewMode = "closed",
4331
4364
  toolLabelMode
@@ -4336,6 +4369,8 @@ function AgentResponseTimeline({
4336
4369
  const liveToolActivity = canShowToolActivity && !message.isFinal && !message.responseCompletion && (isLoading || message.activity?.status === "running");
4337
4370
  const parts = (displayParts || message.parts || []).filter((part) => part.kind !== "data" && (part.kind !== "text" || Boolean(part.text.trim())) && (part.kind !== "reasoning" || Boolean(part.text?.trim() || part.label?.trim())) && (part.kind !== "tool" || !isInternalAskUserTool(part)) && (part.kind !== "hitl" || part.hitlKind === "user_input" || part.status === "pending" || getHitlActionState?.(part)?.status === "accepted") && (part.kind !== "model-turn" || part.turnKind === "agent" && !message.isFinal && !message.responseCompletion && (!message.activity || message.activity.status === "running")) && (part.kind !== "node-activity" || nodeActivityMode === "all" || nodeActivityMode === "default" && part.defaultChatVisible));
4338
4371
  const toolParts = parts.filter((part) => part.kind === "tool");
4372
+ const waitingCallIds = !message.isFinal && !message.responseCompletion && message.activity?.status === "waiting" && message.activity.waitingToolCallIds?.length ? new Set(message.activity.waitingToolCallIds) : void 0;
4373
+ const hasVisibleWaitingTool = waitingCallIds && toolParts.some((part) => !isAgentChatSubagent(part) && isAgentChatToolWaiting(part, waitingCallIds));
4339
4374
  const activeToolId = canShowToolActivity ? latestRunningAgentChatToolId(toolParts) : null;
4340
4375
  const activeTextPartId = getActiveStreamingTextPartId(
4341
4376
  { ...message, parts: [...parts] },
@@ -4348,7 +4383,18 @@ function AgentResponseTimeline({
4348
4383
  const isLatestActivity = segmentIndex === segments.length - 1;
4349
4384
  if (segment.kind === "tool" && toolViewMode === "expanded") {
4350
4385
  const showOrb = liveToolActivity && Boolean(activeToolId && (segment.part.id === activeToolId || segment.part.toolCallId === activeToolId));
4351
- rendered.push(/* @__PURE__ */ jsx17(AgentChatToolRow, { activeToolId, part: segment.part, showOrb, slots: toolSlots }, segment.part.id));
4386
+ rendered.push(/* @__PURE__ */ jsx17(
4387
+ AgentChatToolRow,
4388
+ {
4389
+ activeToolId,
4390
+ part: segment.part,
4391
+ showOrb,
4392
+ slots: toolSlots,
4393
+ statusLabels,
4394
+ waitingToolCallIds: waitingCallIds
4395
+ },
4396
+ segment.part.id
4397
+ ));
4352
4398
  continue;
4353
4399
  }
4354
4400
  if (segment.kind === "tool" || segment.kind === "tool-session") {
@@ -4368,7 +4414,9 @@ function AgentResponseTimeline({
4368
4414
  parts: session.parts,
4369
4415
  leadingModelTurn: session.leadingModelTurn,
4370
4416
  modelTurn: session.modelTurn,
4371
- slots: toolSlots
4417
+ slots: toolSlots,
4418
+ statusLabels,
4419
+ waitingToolCallIds: waitingCallIds
4372
4420
  },
4373
4421
  `tool-session-${session.parts[0].id}`
4374
4422
  ));
@@ -4382,7 +4430,15 @@ function AgentResponseTimeline({
4382
4430
  if (part.kind === "model-turn") {
4383
4431
  const key = activeActivityClaimed ? part.id : `${message.id}-active-activity`;
4384
4432
  activeActivityClaimed = true;
4385
- rendered.push(/* @__PURE__ */ jsx17(AgentChatActivityRow, { renderActivityIcon: toolSlots?.renderActivityIcon, label: "Planning next moves", modelTurnId: part.modelTurnId }, key));
4433
+ rendered.push(/* @__PURE__ */ jsx17(
4434
+ AgentChatActivityRow,
4435
+ {
4436
+ renderActivityIcon: toolSlots?.renderActivityIcon,
4437
+ label: statusLabels?.planning ?? defaultAgentChatStatusLabels.planning,
4438
+ modelTurnId: part.modelTurnId
4439
+ },
4440
+ key
4441
+ ));
4386
4442
  continue;
4387
4443
  }
4388
4444
  if (part.kind === "node-activity") {
@@ -4420,19 +4476,12 @@ function AgentResponseTimeline({
4420
4476
  rendered.push(/* @__PURE__ */ jsx17(MessageResponse, { children: message.content }, `${message.id}-fallback`));
4421
4477
  }
4422
4478
  const activity = getAgentChatActivity(message, parts, isLoading);
4423
- if (activity) {
4424
- const labels = {
4425
- thinking: "Thinking",
4426
- capacity: "Waiting for provider capacity",
4427
- waiting: "Waiting for external work",
4428
- interrupted: "Waiting to resume",
4429
- cancelling: "Cancelling"
4430
- };
4479
+ if (activity && (activity !== "waiting" || !hasVisibleWaitingTool)) {
4431
4480
  rendered.push(/* @__PURE__ */ jsx17(
4432
4481
  AgentChatActivityRow,
4433
4482
  {
4434
4483
  renderActivityIcon: toolSlots?.renderActivityIcon,
4435
- label: labels[activity]
4484
+ label: statusLabels?.[activity] ?? defaultAgentChatStatusLabels[activity]
4436
4485
  },
4437
4486
  `${message.id}-active-activity`
4438
4487
  ));
@@ -4625,6 +4674,7 @@ function AgentChatMessage({
4625
4674
  dir,
4626
4675
  getHitlActionState,
4627
4676
  hitlLabels,
4677
+ statusLabels,
4628
4678
  onHitlPaint,
4629
4679
  message,
4630
4680
  nodeActivityMode,
@@ -4693,6 +4743,7 @@ function AgentChatMessage({
4693
4743
  {
4694
4744
  getHitlActionState,
4695
4745
  hitlLabels,
4746
+ statusLabels,
4696
4747
  onHitlPaint,
4697
4748
  isLoading: isStreaming,
4698
4749
  message,
@@ -5031,6 +5082,7 @@ export {
5031
5082
  contextStatusMetrics,
5032
5083
  createAgentChatComposerFile,
5033
5084
  createDictationComposerFile,
5085
+ defaultAgentChatStatusLabels,
5034
5086
  defaultHitlSubmissionLabels,
5035
5087
  processorSource as dictationPcmWorkletSource,
5036
5088
  getAgentChatActivity,
@@ -5038,6 +5090,7 @@ export {
5038
5090
  hitlTitle,
5039
5091
  isAgentChatSubagent,
5040
5092
  isAgentChatToolRunning,
5093
+ isAgentChatToolWaiting,
5041
5094
  isHitlSubmissionCompact,
5042
5095
  latestRunningAgentChatToolId,
5043
5096
  markerVariants,