@malette/agent-sdk 0.1.3-beta.4 → 0.1.3-beta.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
@@ -1053,6 +1053,7 @@ var useAgentStore = zustand.create()(
1053
1053
  tools: [],
1054
1054
  skills: [],
1055
1055
  subAgentConfigs: [],
1056
+ mainAgentPublicId: "",
1056
1057
  mainAgentName: "",
1057
1058
  artifacts: {},
1058
1059
  artifactOrder: [],
@@ -1063,6 +1064,7 @@ var useAgentStore = zustand.create()(
1063
1064
  setSkills: (skills) => set({ skills }, false, "setSkills"),
1064
1065
  setShowItemTime: (showItemTime) => set({ showItemTime }, false, "setShowItemTime"),
1065
1066
  setSubAgentConfigs: (subAgentConfigs) => set({ subAgentConfigs }, false, "setSubAgentConfigs"),
1067
+ setMainAgentPublicId: (mainAgentPublicId) => set({ mainAgentPublicId }, false, "setMainAgentPublicId"),
1066
1068
  setMainAgentName: (mainAgentName) => set({ mainAgentName }, false, "setMainAgentName"),
1067
1069
  setMainAgentIcon: (mainAgentIcon) => set({ mainAgentIcon }, false, "setMainAgentIcon"),
1068
1070
  addSession: (session) => set(
@@ -13878,6 +13880,16 @@ var ThoughtTimelineCard = React24.memo(function ThoughtTimelineCard2({ thought,
13878
13880
  const withoutJsonImages = removeJsonImageUrls(withoutTags);
13879
13881
  const cleaned = sanitizeMarkdownContent(parseThinkingContent(withoutJsonImages));
13880
13882
  if (!cleaned || !cleaned.trim()) return null;
13883
+ const lineCount = React24.useMemo(() => cleaned.split("\n").length, [cleaned]);
13884
+ React24__namespace.default.useEffect(() => {
13885
+ if (isLoading) {
13886
+ setExpanded(true);
13887
+ } else {
13888
+ if (lineCount > 3) {
13889
+ setExpanded(false);
13890
+ }
13891
+ }
13892
+ }, [isLoading, lineCount]);
13881
13893
  const htmlCodeBlockMatch = cleaned.match(/```(?:html|htm)\n([\s\S]*?)(?:\n```|$)/);
13882
13894
  const isBareHtml = !htmlCodeBlockMatch && (cleaned.trimStart().startsWith("<!DOCTYPE") || cleaned.trimStart().startsWith("<html"));
13883
13895
  const isHtmlContent = !!htmlCodeBlockMatch || isBareHtml;
@@ -13946,11 +13958,45 @@ var ThoughtTimelineCard = React24.memo(function ThoughtTimelineCard2({ thought,
13946
13958
  }) })
13947
13959
  ] });
13948
13960
  }
13949
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 py-2", children: [
13950
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm leading-relaxed max-w-none [&_*]:break-words", children: [
13951
- /* @__PURE__ */ jsxRuntime.jsx(MarkdownContent, { content: preventSetextHeadings(cleaned), skipImages, config, variant: "thought" }),
13952
- isLoading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-2 h-4 ml-0.5 bg-[#d8ff00] animate-pulse rounded-sm" })
13953
- ] }) }),
13961
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-1", children: [
13962
+ !isLoading && /* @__PURE__ */ jsxRuntime.jsxs(
13963
+ "button",
13964
+ {
13965
+ onClick: () => setExpanded(!expanded),
13966
+ className: "w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/40 transition-all duration-150 group",
13967
+ children: [
13968
+ /* @__PURE__ */ jsxRuntime.jsx(
13969
+ "svg",
13970
+ {
13971
+ width: "12",
13972
+ height: "12",
13973
+ viewBox: "0 0 12 12",
13974
+ fill: "none",
13975
+ className: `flex-shrink-0 text-zinc-500 transition-transform duration-200 ${expanded ? "rotate-90" : "rotate-0"}`,
13976
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.5 3L7.5 6L4.5 9", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
13977
+ }
13978
+ ),
13979
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: expanded ? "\u9690\u85CF\u63A8\u7406\u8FC7\u7A0B" : "\u663E\u793A\u63A8\u7406\u8FC7\u7A0B" }),
13980
+ !expanded && cleaned.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-zinc-600 truncate flex-1 text-left pl-2", children: [
13981
+ cleaned.slice(0, 30).replace(/\n/g, " "),
13982
+ cleaned.length > 30 ? "..." : ""
13983
+ ] })
13984
+ ]
13985
+ }
13986
+ ),
13987
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `overflow-hidden transition-all duration-250 ease-out ${expanded ? "mt-1" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs(
13988
+ "div",
13989
+ {
13990
+ className: `${expanded ? "block" : "hidden"} relative`,
13991
+ children: [
13992
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-[17px] top-0 bottom-0 w-px bg-zinc-800" }),
13993
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-6 pl-3 py-2 border-l border-transparent", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm leading-relaxed max-w-none [&_*]:break-words text-zinc-300", children: [
13994
+ /* @__PURE__ */ jsxRuntime.jsx(MarkdownContent, { content: preventSetextHeadings(cleaned), skipImages, config, variant: "thought" }),
13995
+ isLoading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-2 h-4 ml-0.5 bg-[#d8ff00] animate-pulse rounded-sm" })
13996
+ ] }) })
13997
+ ]
13998
+ }
13999
+ ) }),
13954
14000
  thought?.raw?.length > 0 && showItemTime && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-zinc-500 mt-2", children: new Date(
13955
14001
  thought.raw[thought.raw.length - 1]?.gmt_create || thought.raw[thought.raw.length - 1]?.gmtCreate || thought.raw[thought.raw.length - 1]?.timestamp || ""
13956
14002
  ).toLocaleTimeString("zh-CN", {
@@ -13961,7 +14007,7 @@ var ThoughtTimelineCard = React24.memo(function ThoughtTimelineCard2({ thought,
13961
14007
  minute: "2-digit",
13962
14008
  second: "2-digit"
13963
14009
  }) })
13964
- ] }) });
14010
+ ] });
13965
14011
  });
13966
14012
  function formatDuration(ms) {
13967
14013
  if (ms < 1e3) return `${ms}ms`;
@@ -15334,6 +15380,7 @@ function useTimelineItems({
15334
15380
  const subAgents = useAgentStore((state) => state.subAgents);
15335
15381
  const subAgentPanels = useAgentStore((state) => state.multiAgent.subAgentPanels);
15336
15382
  const subAgentConfigs = useAgentStore((state) => state.subAgentConfigs);
15383
+ const mainAgentPublicId = useAgentStore((state) => state.mainAgentPublicId);
15337
15384
  const mainAgentName = useAgentStore((state) => state.mainAgentName);
15338
15385
  const mainAgentIcon = useAgentStore((state) => state.mainAgentIcon);
15339
15386
  return React24.useMemo(() => {
@@ -15354,7 +15401,9 @@ function useTimelineItems({
15354
15401
  return fromConfig?.icon || fromConfig?.avatar;
15355
15402
  };
15356
15403
  const normalizeAgentId = (rawAgentId) => {
15357
- return rawAgentId || null;
15404
+ if (!rawAgentId) return null;
15405
+ if (mainAgentPublicId && rawAgentId === mainAgentPublicId) return null;
15406
+ return rawAgentId;
15358
15407
  };
15359
15408
  const extra = message.extraData || {};
15360
15409
  const extraToolCalls = extra.tool_calls || [];
@@ -15740,7 +15789,7 @@ ${m.content}`;
15740
15789
  return true;
15741
15790
  });
15742
15791
  return filtered.map((item, index) => ({ ...item, id: `${item.kind}-${item.id}-${index}` }));
15743
- }, [message, isUser, toolCalls, components, plan, thoughts, includeThoughts, includeMessage, messageContent, messageTs, thoughtMergeWindowMs, subAgents, subAgentPanels, subAgentConfigs, mainAgentName, mainAgentIcon]);
15792
+ }, [message, isUser, toolCalls, components, plan, thoughts, includeThoughts, includeMessage, messageContent, messageTs, thoughtMergeWindowMs, subAgents, subAgentPanels, subAgentConfigs, mainAgentPublicId, mainAgentName, mainAgentIcon]);
15744
15793
  }
15745
15794
  function __insertCSS(code3) {
15746
15795
  if (typeof document == "undefined") return;
@@ -23792,6 +23841,10 @@ function useSessionManager({
23792
23841
  setMessages
23793
23842
  } = useAgentStore();
23794
23843
  React24.useEffect(() => {
23844
+ setCurrentSession(null);
23845
+ setMessages([]);
23846
+ clearArtifacts();
23847
+ setLoading(true);
23795
23848
  sessionService.list({ projectId, agentId, pageSize: 100 }).then(async (res) => {
23796
23849
  if (res.success && res.data) {
23797
23850
  const list2 = res.data.list.map((s) => ({
@@ -23801,7 +23854,7 @@ function useSessionManager({
23801
23854
  setSessions(list2);
23802
23855
  }
23803
23856
  }).finally(() => setLoading(false));
23804
- }, [projectId, agentId, setSessions]);
23857
+ }, [projectId, agentId, setSessions, setCurrentSession, setMessages, clearArtifacts]);
23805
23858
  const loadMessages = React24.useCallback(async (sessionId) => {
23806
23859
  const res = await sessionService.getMessages(sessionId, { pageNo: 1, pageSize: 100 });
23807
23860
  if (res.success && res.data?.list) {
@@ -23848,10 +23901,11 @@ function useSessionManager({
23848
23901
  if (s?.sessionId) {
23849
23902
  addSession(s);
23850
23903
  setCurrentSession(s);
23904
+ onSessionIdChange?.(s.sessionId);
23851
23905
  setMessages([]);
23852
23906
  clearArtifacts();
23853
23907
  }
23854
- }, [projectId, agentId, addSession, setCurrentSession, setMessages, clearArtifacts]);
23908
+ }, [projectId, agentId, addSession, setCurrentSession, onSessionIdChange, setMessages, clearArtifacts]);
23855
23909
  const handleSelect = React24.useCallback(async (s) => {
23856
23910
  setCurrentSession(s);
23857
23911
  onSessionIdChange?.(s.sessionId);
@@ -24366,6 +24420,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
24366
24420
  setSkills,
24367
24421
  setShowItemTime,
24368
24422
  setSubAgentConfigs,
24423
+ setMainAgentPublicId,
24369
24424
  setMainAgentName,
24370
24425
  setMainAgentIcon,
24371
24426
  setSubAgents
@@ -24514,6 +24569,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
24514
24569
  agentService.get(agentId).then((res) => {
24515
24570
  if (res.success && res.data) {
24516
24571
  const agentData = res.data;
24572
+ if (agentData.publicId) setMainAgentPublicId(agentData.publicId);
24517
24573
  if (agentData.name) setMainAgentName(agentData.name);
24518
24574
  if (agentData.icon) setMainAgentIcon(agentData.icon);
24519
24575
  const subConfigs = agentData.multiAgentConfig?.subAgentConfigs;