@athenaintel/react 0.9.16 → 0.9.18

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.cjs CHANGED
@@ -19867,14 +19867,20 @@ const joinExternalMessages = (messages) => {
19867
19867
  )
19868
19868
  );
19869
19869
  }
19870
+ const { messages: existingMessages, ...toolCallRest } = toolCall;
19870
19871
  const updatedToolCall = {
19871
- ...toolCall,
19872
+ ...toolCallRest,
19872
19873
  result: output.result,
19873
19874
  artifact: output.artifact,
19874
19875
  isError: output.isError,
19875
- messages: output.messages
19876
+ ...(output.messages ?? existingMessages) !== void 0 && {
19877
+ messages: output.messages ?? existingMessages
19878
+ }
19876
19879
  };
19877
- bindExternalStoreMessage(updatedToolCall, [...getExternalStoreMessages(toolCall), output]);
19880
+ bindExternalStoreMessage(updatedToolCall, [
19881
+ ...getExternalStoreMessages(toolCallRest),
19882
+ output
19883
+ ]);
19878
19884
  assistantMessage.content[toolCallIdx] = updatedToolCall;
19879
19885
  } else {
19880
19886
  console.warn(
@@ -19883,10 +19889,14 @@ const joinExternalMessages = (messages) => {
19883
19889
  }
19884
19890
  } else {
19885
19891
  const role = output.role;
19886
- const content = (typeof output.content === "string" ? [{ type: "text", text: output.content }] : output.content).map((c) => {
19892
+ const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
19893
+ const content = rawContent.flatMap((c) => {
19894
+ if (!c || typeof c !== "object") {
19895
+ return [];
19896
+ }
19887
19897
  const mapped = { ...c };
19888
19898
  bindExternalStoreMessage(mapped, output);
19889
- return mapped;
19899
+ return [mapped];
19890
19900
  });
19891
19901
  switch (role) {
19892
19902
  case "system":
@@ -20017,7 +20027,13 @@ const convertExternalMessages = (messages, callback, isRunning, metadata) => {
20017
20027
  const callbackResults = [];
20018
20028
  for (const message of messages) {
20019
20029
  const output = callback(message, metadata);
20020
- const outputs = Array.isArray(output) ? output : [output];
20030
+ const rawOutputs = Array.isArray(output) ? output : [output];
20031
+ const outputs = rawOutputs.filter(
20032
+ (candidate) => candidate != null
20033
+ );
20034
+ if (outputs.length === 0) {
20035
+ continue;
20036
+ }
20021
20037
  const result = { input: message, outputs };
20022
20038
  callbackResults.push(result);
20023
20039
  }
@@ -20040,37 +20056,40 @@ const warnForUnknownMessagePartType = (type) => {
20040
20056
  };
20041
20057
  const contentToParts = (content) => {
20042
20058
  if (typeof content === "string") return [{ type: "text", text: content }];
20043
- return content.map((part) => {
20059
+ return content.flatMap((part) => {
20060
+ if (!part || typeof part !== "object" || !("type" in part)) {
20061
+ return [];
20062
+ }
20044
20063
  const type = part.type;
20045
20064
  switch (type) {
20046
20065
  case "text":
20047
- return { type: "text", text: part.text };
20066
+ return [{ type: "text", text: part.text }];
20048
20067
  case "text_delta":
20049
- return { type: "text", text: part.text };
20068
+ return [{ type: "text", text: part.text }];
20050
20069
  case "image_url":
20051
20070
  if (typeof part.image_url === "string") {
20052
- return { type: "image", image: part.image_url };
20071
+ return [{ type: "image", image: part.image_url }];
20053
20072
  }
20054
- return {
20073
+ return [{
20055
20074
  type: "image",
20056
20075
  image: part.image_url.url
20057
- };
20076
+ }];
20058
20077
  case "thinking":
20059
- return { type: "reasoning", text: part.thinking };
20078
+ return [{ type: "reasoning", text: part.thinking }];
20060
20079
  case "reasoning":
20061
- return {
20080
+ return [{
20062
20081
  type: "reasoning",
20063
20082
  text: part.summary.map((s) => s.text).join("\n\n\n")
20064
- };
20083
+ }];
20065
20084
  case "tool_use":
20066
- return null;
20085
+ return [];
20067
20086
  case "input_json_delta":
20068
- return null;
20087
+ return [];
20069
20088
  default:
20070
20089
  warnForUnknownMessagePartType(type);
20071
- return null;
20090
+ return [];
20072
20091
  }
20073
- }).filter((a) => a !== null);
20092
+ });
20074
20093
  };
20075
20094
  const getNumberAtPath = (value, path) => {
20076
20095
  let current = value;
@@ -20175,7 +20194,7 @@ const convertLangChainMessage = (message) => {
20175
20194
  (_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
20176
20195
  ...normalizedContent,
20177
20196
  ...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
20178
- ].filter((c) => c !== void 0);
20197
+ ].filter((c) => c != null);
20179
20198
  return {
20180
20199
  role: "assistant",
20181
20200
  id: message.id,
@@ -20198,6 +20217,8 @@ const convertLangChainMessage = (message) => {
20198
20217
  isError: message.status === "error"
20199
20218
  };
20200
20219
  }
20220
+ default:
20221
+ return null;
20201
20222
  }
20202
20223
  };
20203
20224
  const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {
@@ -58892,6 +58913,22 @@ const useAssetPanelStore = create()(
58892
58913
  };
58893
58914
  return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
58894
58915
  }),
58916
+ updateTabMeta: (assetId, meta) => set2((s) => {
58917
+ const existing = s.tabs.find((t) => t.id === assetId);
58918
+ if (!existing) {
58919
+ return {};
58920
+ }
58921
+ return {
58922
+ tabs: s.tabs.map(
58923
+ (t) => t.id === assetId ? {
58924
+ ...t,
58925
+ name: meta.name ?? t.name,
58926
+ type: meta.type ?? t.type,
58927
+ embedSearchParams: meta.embedSearchParams ?? t.embedSearchParams
58928
+ } : t
58929
+ )
58930
+ };
58931
+ }),
58895
58932
  closeTab: (assetId) => set2((s) => {
58896
58933
  var _a2;
58897
58934
  const tabs = s.tabs.filter((t) => t.id !== assetId);
@@ -65272,6 +65309,15 @@ const normalizeAssetType = (value) => {
65272
65309
  const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
65273
65310
  return EMBED_ASSET_TYPE_ALIASES[normalizedValue] ?? null;
65274
65311
  };
65312
+ const getEmbedSearchParamsCacheKey = (embedSearchParams) => {
65313
+ if (!embedSearchParams || Object.keys(embedSearchParams).length === 0) {
65314
+ return "{}";
65315
+ }
65316
+ const sortedEntries = Object.entries(embedSearchParams).sort(
65317
+ ([left], [right]) => left.localeCompare(right)
65318
+ );
65319
+ return JSON.stringify(Object.fromEntries(sortedEntries));
65320
+ };
65275
65321
  const appendEmbedSearchParams = ({
65276
65322
  embedUrl,
65277
65323
  embedSearchParams
@@ -65315,7 +65361,7 @@ function useAssetEmbed(assetId, options = {
65315
65361
  setAssetType(null);
65316
65362
  return;
65317
65363
  }
65318
- const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}:${JSON.stringify(embedSearchParams ?? {})}`;
65364
+ const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}:${getEmbedSearchParamsCacheKey(embedSearchParams)}`;
65319
65365
  const cached = embedCache.get(cacheKey);
65320
65366
  if (cached && cached.expiresAt > Date.now() / 1e3) {
65321
65367
  setEmbedUrl(cached.url);
@@ -65408,7 +65454,7 @@ const AssetIframe = React.memo(
65408
65454
  if (nextName === tabName && nextType === tabType) {
65409
65455
  return;
65410
65456
  }
65411
- useAssetPanelStore.getState().openAsset(tabId, {
65457
+ useAssetPanelStore.getState().updateTabMeta(tabId, {
65412
65458
  name: nextName ?? void 0,
65413
65459
  type: nextType
65414
65460
  });
@@ -65474,7 +65520,7 @@ const PanelContent = ({
65474
65520
  return /* @__PURE__ */ jsxRuntime.jsx(
65475
65521
  "div",
65476
65522
  {
65477
- className: `flex-1 overflow-hidden ${isTiled ? `${gridClass} gap-px bg-border/60` : ""}`,
65523
+ className: cn("flex-1 overflow-hidden", isTiled && gridClass, isTiled && "gap-px bg-border/60"),
65478
65524
  children: tabs.map((tab) => {
65479
65525
  const isActive2 = tab.id === activeTabId;
65480
65526
  const config2 = ASSET_TYPE_CONFIG[tab.type];
@@ -65541,7 +65587,10 @@ const TabBar = () => {
65541
65587
  return /* @__PURE__ */ jsxRuntime.jsxs(
65542
65588
  "div",
65543
65589
  {
65544
- className: `group flex max-w-[180px] shrink-0 cursor-pointer items-center gap-1.5 border-r border-border/40 px-3 py-1.5 text-xs ${isActive2 ? "border-b-2 border-b-primary bg-background text-foreground" : "text-muted-foreground hover:bg-background/50 hover:text-foreground"}`,
65590
+ className: cn(
65591
+ "group flex max-w-[180px] shrink-0 cursor-pointer items-center gap-1.5 border-r border-border/40 px-3 py-1.5 text-xs",
65592
+ isActive2 ? "border-b-2 border-b-primary bg-background text-foreground" : "text-muted-foreground hover:bg-background/50 hover:text-foreground"
65593
+ ),
65545
65594
  onClick: () => setActiveTab(tab.id),
65546
65595
  children: [
65547
65596
  /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { className: "size-3 shrink-0" }),
@@ -65583,7 +65632,10 @@ const PanelHeader = ({ fullscreen }) => {
65583
65632
  "button",
65584
65633
  {
65585
65634
  onClick: () => setViewMode(isTiled ? "tabs" : "tiled"),
65586
- className: `flex size-7 items-center justify-center rounded-lg transition-colors ${isTiled ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-accent hover:text-foreground"}`,
65635
+ className: cn(
65636
+ "flex size-7 items-center justify-center rounded-lg transition-colors",
65637
+ isTiled ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-accent hover:text-foreground"
65638
+ ),
65587
65639
  title: isTiled ? "Switch to tabs" : "Tile all assets",
65588
65640
  children: isTiled ? /* @__PURE__ */ jsxRuntime.jsx(Layers, { className: "size-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(LayoutGrid, { className: "size-3.5" })
65589
65641
  }