@streamoid/agent 0.4.5 → 0.4.6

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.js CHANGED
@@ -5865,7 +5865,6 @@ function ChatMessage({ type: e, children: t, userData: n, showAvatar: o = !0 })
5865
5865
  n && (o ? /* @__PURE__ */ jsx(UserAvatar, { userData: n }) : /* @__PURE__ */ jsx("div", { className: "shrink-0 size-[32px]" }))
5866
5866
  ] }) }) }) }) }) : /* @__PURE__ */ jsx("div", { className: "relative shrink-0 w-full", children: /* @__PURE__ */ jsx("div", { className: "size-full", children: /* @__PURE__ */ jsx("div", { className: "box-border content-stretch flex flex-col gap-[8px] items-start pl-0 pr-0 sm:pr-[120px] py-0 relative w-full", children: /* @__PURE__ */ jsx("div", { className: "content-stretch flex flex-col gap-[8px] items-end justify-center relative shrink-0 w-full", children: /* @__PURE__ */ jsx("div", { className: "content-stretch flex flex-col gap-[8px] items-start relative shrink-0 w-full min-w-0 overflow-x-visible", children: t }) }) }) }) });
5867
5867
  }
5868
- const IC_LIST_LEADING_OFFSET_PX = 20;
5869
5868
  function formatSubAgentLabel(e) {
5870
5869
  const t = (e ?? "").trim().replace(/\b\w/g, (n) => n.toUpperCase()).replace(/\s+Agent$/i, "").trim();
5871
5870
  return t ? `Using ${t}...` : "Using a sub-agent...";
@@ -5936,11 +5935,6 @@ function getStatusClasses(e) {
5936
5935
  return "border-[var(--alias-border-warning)] bg-[var(--alias-surface-warning)] text-[var(--alias-text---icons-warningcont)] dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100";
5937
5936
  }
5938
5937
  }
5939
- function parseStamp(e) {
5940
- if (typeof e != "string" || !e.trim()) return;
5941
- const t = Date.parse(e);
5942
- return Number.isFinite(t) ? t : void 0;
5943
- }
5944
5938
  function parseSteps(e, t) {
5945
5939
  if (!e) return [];
5946
5940
  const n = e.split(`
@@ -6047,14 +6041,13 @@ function parseSteps(e, t) {
6047
6041
  message: b.message,
6048
6042
  status: "pending",
6049
6043
  toolName: b.tool_name,
6050
- key: E,
6051
- startedAt: parseStamp(b.created_at)
6044
+ key: E
6052
6045
  }), s.set(E, j), l.set(j, b.message), c = j;
6053
6046
  }
6054
6047
  } else if (b.event === "END") {
6055
6048
  const j = s.get(E);
6056
6049
  if (j !== void 0 && o[j]?.kind === "step")
6057
- o[j].status = "completed", o[j].endedAt = parseStamp(b.created_at), !o[j].toolName && b.tool_name && (o[j].toolName = b.tool_name), c === j && (c = null);
6050
+ o[j].status = "completed", !o[j].toolName && b.tool_name && (o[j].toolName = b.tool_name), c === j && (c = null);
6058
6051
  else
6059
6052
  continue;
6060
6053
  } else if (b.event === "PROGRESS") {
@@ -6072,15 +6065,7 @@ function parseSteps(e, t) {
6072
6065
  }
6073
6066
  return o;
6074
6067
  }
6075
- function formatElapsed(e) {
6076
- if (e < 1e3) return `${Math.max(1, Math.round(e / 100)) / 10}s`;
6077
- if (e < 6e4) return `${(e / 1e3).toFixed(1)}s`;
6078
- const t = Math.floor(e / 6e4), n = Math.round(e % 6e4 / 1e3);
6079
- return n ? `${t}m ${n}s` : `${t}m`;
6080
- }
6081
- const MIN_REPORTABLE_ELAPSED_MS = 400;
6082
- function ToolStepRow({ step: e, now: t }) {
6083
- const n = e.startedAt, o = e.status === "completed" ? e.endedAt ?? t : void 0, s = n === void 0 ? void 0 : Math.max(0, (o ?? t) - n), l = s !== void 0 && s >= MIN_REPORTABLE_ELAPSED_MS ? formatElapsed(s) : void 0;
6068
+ function ToolStepRow({ step: e }) {
6084
6069
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[600px] items-center gap-2", children: [
6085
6070
  /* @__PURE__ */ jsx("div", { className: "flex h-[26px] w-[20px] shrink-0 items-center px-[2px]", children: /* @__PURE__ */ jsx(ScThinkingStepIcon, { state: mapIconState(e.status) }) }),
6086
6071
  /* @__PURE__ */ jsxs("p", { className: "m-0 min-w-0 flex-1 truncate text-[12px] leading-[18px] text-[var(--alias-text---icons-primary)] dark:text-[#E6E6E6]", children: [
@@ -6089,15 +6074,7 @@ function ToolStepRow({ step: e, now: t }) {
6089
6074
  * information, unlike the tool-name restatement this row replaced, but
6090
6075
  * it does not deserve a line of its own either. */
6091
6076
  /* @__PURE__ */ jsx("span", { className: "text-[var(--alias-text---icons-tertiary)] dark:text-[#9E9E9E]", children: ` · ${e.description}` })
6092
- ] }),
6093
- l && /* @__PURE__ */ jsx(
6094
- "span",
6095
- {
6096
- "data-testid": "tool-step-elapsed",
6097
- className: "shrink-0 tabular-nums text-[11px] leading-[16px] text-[var(--alias-text---icons-tertiary)] dark:text-[#7D7D7D]",
6098
- children: l
6099
- }
6100
- )
6077
+ ] })
6101
6078
  ] });
6102
6079
  }
6103
6080
  function mapIconState(e) {
@@ -6115,8 +6092,7 @@ function PlanPreviewCard({ label: e, plan: t }) {
6115
6092
  return /* @__PURE__ */ jsxs(
6116
6093
  "div",
6117
6094
  {
6118
- className: "ml-[20px] w-fit overflow-hidden rounded-[8px] border border-[var(--alias-border-subtle)] bg-[var(--alias-surface-base)] dark:border-white/10 dark:bg-white/[0.03]",
6119
- style: { marginLeft: IC_LIST_LEADING_OFFSET_PX },
6095
+ className: "w-fit overflow-hidden rounded-[8px] border border-[var(--alias-border-subtle)] bg-[var(--alias-surface-base)] dark:border-white/10 dark:bg-white/[0.03]",
6120
6096
  children: [
6121
6097
  /* @__PURE__ */ jsxs(
6122
6098
  "button",
@@ -6154,39 +6130,34 @@ function PlanPreviewCard({ label: e, plan: t }) {
6154
6130
  );
6155
6131
  }
6156
6132
  function AgentSteps({ content: e, isLoading: t = !1, completedStepIds: n, previouslyStartedIds: o }) {
6157
- const s = useRef(/* @__PURE__ */ new Map()), l = useMemo(() => {
6158
- const j = parseSteps(e, o);
6133
+ const s = useMemo(() => {
6134
+ const h = parseSteps(e, o);
6159
6135
  if (n)
6160
- for (const M of j)
6161
- M.kind === "step" && M.status === "pending" && M.key && n.has(M.key) && (M.status = "completed");
6162
- t || j.forEach((M) => {
6163
- M.kind === "step" && M.status === "pending" && (M.status = "completed");
6164
- });
6165
- const T = s.current;
6166
- for (const M of j) {
6167
- if (M.kind !== "step" || M.startedAt !== void 0) continue;
6168
- const I = M.key ?? M.message;
6169
- let P = T.get(I);
6170
- P === void 0 && (P = Date.now(), T.set(I, P)), M.startedAt = P;
6171
- }
6172
- return j;
6173
- }, [e, t, n, o]), c = l.length > 0 && l.every((j) => j.kind !== "step" || j.status === "completed"), f = l.some((j) => j.kind === "step" && j.status === "pending"), [h, g] = useState(() => Date.now());
6174
- if (useEffect(() => {
6175
- if (!f) return;
6176
- g(Date.now());
6177
- const j = window.setInterval(() => g(Date.now()), 1e3);
6178
- return () => window.clearInterval(j);
6179
- }, [f]), l.length === 0) return null;
6180
- const b = l.filter((j) => j.kind === "step"), E = l.filter((j) => j.kind !== "step");
6136
+ for (const g of h)
6137
+ g.kind === "step" && g.status === "pending" && g.key && n.has(g.key) && (g.status = "completed");
6138
+ return t || h.forEach((g) => {
6139
+ g.kind === "step" && g.status === "pending" && (g.status = "completed");
6140
+ }), h;
6141
+ }, [e, t, n, o]), l = s.length > 0 && s.every((h) => h.kind !== "step" || h.status === "completed");
6142
+ if (s.length === 0) return null;
6143
+ const c = s.filter((h) => h.kind === "step"), f = s.filter((h) => h.kind !== "step");
6181
6144
  return /* @__PURE__ */ jsxs(motion$1.div, { layout: !0, className: "max-w-full mt-[4px]", transition: stepsTransition, children: [
6182
- E.length > 0 && /* @__PURE__ */ jsx(motion$1.div, { layout: !0, className: "mb-1 flex flex-col gap-1", transition: stepsTransition, children: E.map((j, T) => /* @__PURE__ */ jsx(motion$1.div, { layout: "position", transition: stepsTransition, children: j.kind === "subAgent" ? /* @__PURE__ */ jsx(ScSubAgent, { text: j.label }) : j.kind === "planLine" ? /* @__PURE__ */ jsx(
6183
- "p",
6184
- {
6185
- "data-testid": "plan-line",
6186
- className: "m-0 pl-[20px] text-[13px] leading-[20px] text-[var(--alias-text---icons-secondary)] dark:text-[#D0D0D0]",
6187
- children: j.message
6188
- }
6189
- ) : /* @__PURE__ */ jsx(PlanPreviewCard, { label: j.label, plan: j.plan }) }, getStableStepKey(j, T))) }),
6145
+ f.length > 0 && /* @__PURE__ */ jsx(motion$1.div, { layout: !0, className: "mb-1 flex flex-col gap-1", transition: stepsTransition, children: f.map((h, g) => /* @__PURE__ */ jsx(motion$1.div, { layout: "position", transition: stepsTransition, children: h.kind === "subAgent" ? /* @__PURE__ */ jsx(ScSubAgent, { text: h.label }) : h.kind === "planLine" ? (
6146
+ /* Sized and set like the assistant's own prose (MessageBlocks
6147
+ * uses text-[15px] leading-relaxed): this IS the agent talking,
6148
+ * lifted out of the message it wrote, and at 13px beside a 15px
6149
+ * answer it read as a different font rather than as the same
6150
+ * voice. The step rows stay smaller -- they are machine output
6151
+ * and the size difference there is the hierarchy. */
6152
+ /* @__PURE__ */ jsx(
6153
+ "p",
6154
+ {
6155
+ "data-testid": "plan-line",
6156
+ className: "m-0 text-[15px] leading-relaxed text-[var(--alias-text---icons-secondary)] dark:text-[#D0D0D0]",
6157
+ children: h.message
6158
+ }
6159
+ )
6160
+ ) : /* @__PURE__ */ jsx(PlanPreviewCard, { label: h.label, plan: h.plan }) }, getStableStepKey(h, g))) }),
6190
6161
  /* @__PURE__ */ jsxs(
6191
6162
  motion$1.div,
6192
6163
  {
@@ -6195,21 +6166,21 @@ function AgentSteps({ content: e, isLoading: t = !1, completedStepIds: n, previo
6195
6166
  className: "flex flex-col gap-1",
6196
6167
  transition: stepsTransition,
6197
6168
  children: [
6198
- b.map((j, T) => /* @__PURE__ */ jsx(
6169
+ c.map((h, g) => /* @__PURE__ */ jsx(
6199
6170
  motion$1.div,
6200
6171
  {
6201
6172
  layout: "position",
6202
6173
  initial: { opacity: 0, y: 6 },
6203
6174
  animate: { opacity: 1, y: 0 },
6204
6175
  transition: stepsTransition,
6205
- children: j.kind === "step" && /* @__PURE__ */ jsxs(Fragment, { children: [
6206
- /* @__PURE__ */ jsx(ToolStepRow, { step: j, now: h }),
6207
- j.planData && /* @__PURE__ */ jsx(PlanPreviewCard, { label: j.planData.label, plan: j.planData.plan })
6176
+ children: h.kind === "step" && /* @__PURE__ */ jsxs(Fragment, { children: [
6177
+ /* @__PURE__ */ jsx(ToolStepRow, { step: h }),
6178
+ h.planData && /* @__PURE__ */ jsx(PlanPreviewCard, { label: h.planData.label, plan: h.planData.plan })
6208
6179
  ] })
6209
6180
  },
6210
- getStableStepKey(j, T)
6181
+ getStableStepKey(h, g)
6211
6182
  )),
6212
- t && c && /* @__PURE__ */ jsx(
6183
+ t && l && /* @__PURE__ */ jsx(
6213
6184
  motion$1.div,
6214
6185
  {
6215
6186
  layout: !0,
@@ -6219,8 +6190,7 @@ function AgentSteps({ content: e, isLoading: t = !1, completedStepIds: n, previo
6219
6190
  children: /* @__PURE__ */ jsx(
6220
6191
  ToolStepRow,
6221
6192
  {
6222
- step: { kind: "step", message: "Planning next steps", status: "pending" },
6223
- now: h
6193
+ step: { kind: "step", message: "Planning next steps", status: "pending" }
6224
6194
  }
6225
6195
  )
6226
6196
  },
@@ -16856,9 +16826,13 @@ function MessageFeedbackControls({
16856
16826
  children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-3.5" })
16857
16827
  }
16858
16828
  ),
16859
- Ke && et && /* @__PURE__ */ jsx(
16829
+ Ke && et && /* The ONLY duration in a turn, now that the step rows no longer carry
16830
+ * their own. Kept testable because that is the invariant: one number,
16831
+ * here, saying how long the answer took. */
16832
+ /* @__PURE__ */ jsx(
16860
16833
  "span",
16861
16834
  {
16835
+ "data-testid": "turn-duration",
16862
16836
  title: Ke.full,
16863
16837
  className: "text-[11px] leading-none text-[var(--alias-text---icons-tertiary)]",
16864
16838
  children: et