@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.d.ts CHANGED
@@ -48,11 +48,8 @@ export declare interface AssetPanelState {
48
48
  autoOpenedAssets: Map<string, number>;
49
49
  registerAssetPanelHost: () => void;
50
50
  unregisterAssetPanelHost: () => void;
51
- openAsset: (assetId: string, meta?: {
52
- name?: string;
53
- type?: AssetType;
54
- embedSearchParams?: Record<string, string> | null;
55
- }) => void;
51
+ openAsset: (assetId: string, meta?: AssetTabMeta) => void;
52
+ updateTabMeta: (assetId: string, meta: AssetTabMeta) => void;
56
53
  closeTab: (assetId: string) => void;
57
54
  setActiveTab: (assetId: string) => void;
58
55
  setViewMode: (mode: ViewMode) => void;
@@ -71,6 +68,12 @@ export declare interface AssetTab {
71
68
  embedSearchParams: Record<string, string> | null;
72
69
  }
73
70
 
71
+ declare interface AssetTabMeta {
72
+ name?: string | null;
73
+ type?: AssetType;
74
+ embedSearchParams?: Record<string, string> | null;
75
+ }
76
+
74
77
  export declare type AssetType = 'presentation' | 'spreadsheet' | 'document' | 'notebook' | 'unknown';
75
78
 
76
79
  export declare const AthenaAssistantActionBar: FC<AthenaAssistantActionBarProps>;
package/dist/index.js CHANGED
@@ -19849,14 +19849,20 @@ const joinExternalMessages = (messages) => {
19849
19849
  )
19850
19850
  );
19851
19851
  }
19852
+ const { messages: existingMessages, ...toolCallRest } = toolCall;
19852
19853
  const updatedToolCall = {
19853
- ...toolCall,
19854
+ ...toolCallRest,
19854
19855
  result: output.result,
19855
19856
  artifact: output.artifact,
19856
19857
  isError: output.isError,
19857
- messages: output.messages
19858
+ ...(output.messages ?? existingMessages) !== void 0 && {
19859
+ messages: output.messages ?? existingMessages
19860
+ }
19858
19861
  };
19859
- bindExternalStoreMessage(updatedToolCall, [...getExternalStoreMessages(toolCall), output]);
19862
+ bindExternalStoreMessage(updatedToolCall, [
19863
+ ...getExternalStoreMessages(toolCallRest),
19864
+ output
19865
+ ]);
19860
19866
  assistantMessage.content[toolCallIdx] = updatedToolCall;
19861
19867
  } else {
19862
19868
  console.warn(
@@ -19865,10 +19871,14 @@ const joinExternalMessages = (messages) => {
19865
19871
  }
19866
19872
  } else {
19867
19873
  const role = output.role;
19868
- const content = (typeof output.content === "string" ? [{ type: "text", text: output.content }] : output.content).map((c) => {
19874
+ const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
19875
+ const content = rawContent.flatMap((c) => {
19876
+ if (!c || typeof c !== "object") {
19877
+ return [];
19878
+ }
19869
19879
  const mapped = { ...c };
19870
19880
  bindExternalStoreMessage(mapped, output);
19871
- return mapped;
19881
+ return [mapped];
19872
19882
  });
19873
19883
  switch (role) {
19874
19884
  case "system":
@@ -19999,7 +20009,13 @@ const convertExternalMessages = (messages, callback, isRunning, metadata) => {
19999
20009
  const callbackResults = [];
20000
20010
  for (const message of messages) {
20001
20011
  const output = callback(message, metadata);
20002
- const outputs = Array.isArray(output) ? output : [output];
20012
+ const rawOutputs = Array.isArray(output) ? output : [output];
20013
+ const outputs = rawOutputs.filter(
20014
+ (candidate) => candidate != null
20015
+ );
20016
+ if (outputs.length === 0) {
20017
+ continue;
20018
+ }
20003
20019
  const result = { input: message, outputs };
20004
20020
  callbackResults.push(result);
20005
20021
  }
@@ -20022,37 +20038,40 @@ const warnForUnknownMessagePartType = (type) => {
20022
20038
  };
20023
20039
  const contentToParts = (content) => {
20024
20040
  if (typeof content === "string") return [{ type: "text", text: content }];
20025
- return content.map((part) => {
20041
+ return content.flatMap((part) => {
20042
+ if (!part || typeof part !== "object" || !("type" in part)) {
20043
+ return [];
20044
+ }
20026
20045
  const type = part.type;
20027
20046
  switch (type) {
20028
20047
  case "text":
20029
- return { type: "text", text: part.text };
20048
+ return [{ type: "text", text: part.text }];
20030
20049
  case "text_delta":
20031
- return { type: "text", text: part.text };
20050
+ return [{ type: "text", text: part.text }];
20032
20051
  case "image_url":
20033
20052
  if (typeof part.image_url === "string") {
20034
- return { type: "image", image: part.image_url };
20053
+ return [{ type: "image", image: part.image_url }];
20035
20054
  }
20036
- return {
20055
+ return [{
20037
20056
  type: "image",
20038
20057
  image: part.image_url.url
20039
- };
20058
+ }];
20040
20059
  case "thinking":
20041
- return { type: "reasoning", text: part.thinking };
20060
+ return [{ type: "reasoning", text: part.thinking }];
20042
20061
  case "reasoning":
20043
- return {
20062
+ return [{
20044
20063
  type: "reasoning",
20045
20064
  text: part.summary.map((s) => s.text).join("\n\n\n")
20046
- };
20065
+ }];
20047
20066
  case "tool_use":
20048
- return null;
20067
+ return [];
20049
20068
  case "input_json_delta":
20050
- return null;
20069
+ return [];
20051
20070
  default:
20052
20071
  warnForUnknownMessagePartType(type);
20053
- return null;
20072
+ return [];
20054
20073
  }
20055
- }).filter((a) => a !== null);
20074
+ });
20056
20075
  };
20057
20076
  const getNumberAtPath = (value, path) => {
20058
20077
  let current = value;
@@ -20157,7 +20176,7 @@ const convertLangChainMessage = (message) => {
20157
20176
  (_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
20158
20177
  ...normalizedContent,
20159
20178
  ...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
20160
- ].filter((c) => c !== void 0);
20179
+ ].filter((c) => c != null);
20161
20180
  return {
20162
20181
  role: "assistant",
20163
20182
  id: message.id,
@@ -20180,6 +20199,8 @@ const convertLangChainMessage = (message) => {
20180
20199
  isError: message.status === "error"
20181
20200
  };
20182
20201
  }
20202
+ default:
20203
+ return null;
20183
20204
  }
20184
20205
  };
20185
20206
  const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {
@@ -58874,6 +58895,22 @@ const useAssetPanelStore = create()(
58874
58895
  };
58875
58896
  return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
58876
58897
  }),
58898
+ updateTabMeta: (assetId, meta) => set2((s) => {
58899
+ const existing = s.tabs.find((t) => t.id === assetId);
58900
+ if (!existing) {
58901
+ return {};
58902
+ }
58903
+ return {
58904
+ tabs: s.tabs.map(
58905
+ (t) => t.id === assetId ? {
58906
+ ...t,
58907
+ name: meta.name ?? t.name,
58908
+ type: meta.type ?? t.type,
58909
+ embedSearchParams: meta.embedSearchParams ?? t.embedSearchParams
58910
+ } : t
58911
+ )
58912
+ };
58913
+ }),
58877
58914
  closeTab: (assetId) => set2((s) => {
58878
58915
  var _a2;
58879
58916
  const tabs = s.tabs.filter((t) => t.id !== assetId);
@@ -65254,6 +65291,15 @@ const normalizeAssetType = (value) => {
65254
65291
  const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
65255
65292
  return EMBED_ASSET_TYPE_ALIASES[normalizedValue] ?? null;
65256
65293
  };
65294
+ const getEmbedSearchParamsCacheKey = (embedSearchParams) => {
65295
+ if (!embedSearchParams || Object.keys(embedSearchParams).length === 0) {
65296
+ return "{}";
65297
+ }
65298
+ const sortedEntries = Object.entries(embedSearchParams).sort(
65299
+ ([left], [right]) => left.localeCompare(right)
65300
+ );
65301
+ return JSON.stringify(Object.fromEntries(sortedEntries));
65302
+ };
65257
65303
  const appendEmbedSearchParams = ({
65258
65304
  embedUrl,
65259
65305
  embedSearchParams
@@ -65297,7 +65343,7 @@ function useAssetEmbed(assetId, options = {
65297
65343
  setAssetType(null);
65298
65344
  return;
65299
65345
  }
65300
- const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}:${JSON.stringify(embedSearchParams ?? {})}`;
65346
+ const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}:${getEmbedSearchParamsCacheKey(embedSearchParams)}`;
65301
65347
  const cached = embedCache.get(cacheKey);
65302
65348
  if (cached && cached.expiresAt > Date.now() / 1e3) {
65303
65349
  setEmbedUrl(cached.url);
@@ -65390,7 +65436,7 @@ const AssetIframe = memo(
65390
65436
  if (nextName === tabName && nextType === tabType) {
65391
65437
  return;
65392
65438
  }
65393
- useAssetPanelStore.getState().openAsset(tabId, {
65439
+ useAssetPanelStore.getState().updateTabMeta(tabId, {
65394
65440
  name: nextName ?? void 0,
65395
65441
  type: nextType
65396
65442
  });
@@ -65456,7 +65502,7 @@ const PanelContent = ({
65456
65502
  return /* @__PURE__ */ jsx(
65457
65503
  "div",
65458
65504
  {
65459
- className: `flex-1 overflow-hidden ${isTiled ? `${gridClass} gap-px bg-border/60` : ""}`,
65505
+ className: cn("flex-1 overflow-hidden", isTiled && gridClass, isTiled && "gap-px bg-border/60"),
65460
65506
  children: tabs.map((tab) => {
65461
65507
  const isActive2 = tab.id === activeTabId;
65462
65508
  const config2 = ASSET_TYPE_CONFIG[tab.type];
@@ -65523,7 +65569,10 @@ const TabBar = () => {
65523
65569
  return /* @__PURE__ */ jsxs(
65524
65570
  "div",
65525
65571
  {
65526
- 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"}`,
65572
+ className: cn(
65573
+ "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",
65574
+ isActive2 ? "border-b-2 border-b-primary bg-background text-foreground" : "text-muted-foreground hover:bg-background/50 hover:text-foreground"
65575
+ ),
65527
65576
  onClick: () => setActiveTab(tab.id),
65528
65577
  children: [
65529
65578
  /* @__PURE__ */ jsx(TypeIcon, { className: "size-3 shrink-0" }),
@@ -65565,7 +65614,10 @@ const PanelHeader = ({ fullscreen }) => {
65565
65614
  "button",
65566
65615
  {
65567
65616
  onClick: () => setViewMode(isTiled ? "tabs" : "tiled"),
65568
- 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"}`,
65617
+ className: cn(
65618
+ "flex size-7 items-center justify-center rounded-lg transition-colors",
65619
+ isTiled ? "bg-primary/10 text-primary" : "text-muted-foreground hover:bg-accent hover:text-foreground"
65620
+ ),
65569
65621
  title: isTiled ? "Switch to tabs" : "Tile all assets",
65570
65622
  children: isTiled ? /* @__PURE__ */ jsx(Layers, { className: "size-3.5" }) : /* @__PURE__ */ jsx(LayoutGrid, { className: "size-3.5" })
65571
65623
  }