@athenaintel/react 0.1.0 → 0.2.0

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
@@ -6416,10 +6416,10 @@ class ThreadMessageConverter {
6416
6416
  constructor() {
6417
6417
  __publicField(this, "cache", /* @__PURE__ */ new WeakMap());
6418
6418
  }
6419
- convertMessages(messages, converter2) {
6419
+ convertMessages(messages, converter) {
6420
6420
  return messages.map((m, idx) => {
6421
6421
  const cached = this.cache.get(m);
6422
- const newMessage = converter2(cached, m, idx);
6422
+ const newMessage = converter(cached, m, idx);
6423
6423
  this.cache.set(m, newMessage);
6424
6424
  return newMessage;
6425
6425
  });
@@ -9073,8 +9073,8 @@ function useRunManager(config2) {
9073
9073
  cancel
9074
9074
  };
9075
9075
  }
9076
- function useConvertedState(converter2, agentState, pendingCommands, isSending, toolStatuses) {
9077
- return useMemo(() => converter2(agentState, { pendingCommands, isSending, toolStatuses }), [converter2, agentState, pendingCommands, isSending, toolStatuses]);
9076
+ function useConvertedState(converter, agentState, pendingCommands, isSending, toolStatuses) {
9077
+ return useMemo(() => converter(agentState, { pendingCommands, isSending, toolStatuses }), [converter, agentState, pendingCommands, isSending, toolStatuses]);
9078
9078
  }
9079
9079
  const convertAppendMessageToCommand = (message) => {
9080
9080
  var _a2;
@@ -20575,7 +20575,6 @@ const safeStringify = (value) => {
20575
20575
  return "[Unable to serialize tool result]";
20576
20576
  }
20577
20577
  };
20578
- const optimisticMessageCache = /* @__PURE__ */ new Map();
20579
20578
  const commandsToMessages = (commands) => {
20580
20579
  return commands.flatMap((c) => {
20581
20580
  if (c.type === "add-message") {
@@ -20620,7 +20619,7 @@ const getTrackingIdFromMessage = (msg) => {
20620
20619
  }
20621
20620
  return void 0;
20622
20621
  };
20623
- const converter = (state, connectionMetadata) => {
20622
+ const createConverter = (optimisticMessageCache) => (state, connectionMetadata) => {
20624
20623
  const validatedState = parseLangGraphState(state);
20625
20624
  const backendTrackingIds = /* @__PURE__ */ new Set();
20626
20625
  for (const msg of validatedState.messages) {
@@ -20737,6 +20736,8 @@ const useAthenaRuntime = (config2) => {
20737
20736
  () => Array.from(/* @__PURE__ */ new Set([...tools, ...frontendToolIds])),
20738
20737
  [tools, frontendToolIds]
20739
20738
  );
20739
+ const optimisticMessageCache = useRef(/* @__PURE__ */ new Map()).current;
20740
+ const converter = useMemo(() => createConverter(optimisticMessageCache), [optimisticMessageCache]);
20740
20741
  const tokenRef = useRef(token);
20741
20742
  tokenRef.current = token;
20742
20743
  const apiKeyRef = useRef(apiKey);
@@ -20752,49 +20753,57 @@ const useAthenaRuntime = (config2) => {
20752
20753
  Accept: "text/event-stream"
20753
20754
  }),
20754
20755
  onResponse: () => {
20755
- console.log("[AthenaSDK] Stream connected");
20756
+ if (process.env.NODE_ENV !== "production") {
20757
+ console.log("[AthenaSDK] Stream connected");
20758
+ }
20756
20759
  },
20757
20760
  onFinish: () => {
20758
- console.log("[AthenaSDK] Stream completed");
20761
+ if (process.env.NODE_ENV !== "production") {
20762
+ console.log("[AthenaSDK] Stream completed");
20763
+ }
20759
20764
  },
20760
20765
  onError: (error2, { commands, updateState }) => {
20761
20766
  const pendingCommands = commandsToMessages(commands);
20762
20767
  const isInvalidStringLength = error2 instanceof RangeError && /Invalid string length/i.test(error2.message);
20763
20768
  const userErrorMessage = isInvalidStringLength ? "The response was too large to process. Try reducing the amount of content in a single request or starting a new chat." : error2.message;
20764
20769
  updateState((state) => {
20765
- const newState = {
20766
- ...state,
20767
- messages: [...state.messages, ...pendingCommands]
20768
- };
20769
- const lastAssistantMessage = newState.messages.filter((m) => m.type === "ai").at(-1);
20770
- if (lastAssistantMessage) {
20771
- lastAssistantMessage.status = {
20772
- type: "incomplete",
20773
- reason: "error",
20774
- error: userErrorMessage
20770
+ const messages = [...state.messages, ...pendingCommands];
20771
+ const lastAiIdx = messages.findLastIndex((m) => m.type === "ai");
20772
+ if (lastAiIdx !== -1) {
20773
+ messages[lastAiIdx] = {
20774
+ ...messages[lastAiIdx],
20775
+ status: {
20776
+ type: "incomplete",
20777
+ reason: "error",
20778
+ error: userErrorMessage
20779
+ }
20775
20780
  };
20776
20781
  }
20777
- return newState;
20782
+ return { ...state, messages };
20778
20783
  });
20779
- console.error("[AthenaSDK] Error:", error2.message);
20784
+ if (process.env.NODE_ENV !== "production") {
20785
+ console.error("[AthenaSDK] Error:", error2.message);
20786
+ }
20780
20787
  },
20781
20788
  onCancel: async ({ commands, updateState }) => {
20782
20789
  const pendingCommands = commandsToMessages(commands);
20783
20790
  updateState((state) => {
20784
- const newState = {
20785
- ...state,
20786
- messages: [...state.messages, ...pendingCommands]
20787
- };
20788
- const lastAssistantMessage = newState.messages.filter((m) => m.type === "ai").at(-1);
20789
- if (lastAssistantMessage) {
20790
- lastAssistantMessage.status = {
20791
- type: "incomplete",
20792
- reason: "cancelled"
20791
+ const messages = [...state.messages, ...pendingCommands];
20792
+ const lastAiIdx = messages.findLastIndex((m) => m.type === "ai");
20793
+ if (lastAiIdx !== -1) {
20794
+ messages[lastAiIdx] = {
20795
+ ...messages[lastAiIdx],
20796
+ status: {
20797
+ type: "incomplete",
20798
+ reason: "cancelled"
20799
+ }
20793
20800
  };
20794
20801
  }
20795
- return newState;
20802
+ return { ...state, messages };
20796
20803
  });
20797
- console.log("[AthenaSDK] Cancelled");
20804
+ if (process.env.NODE_ENV !== "production") {
20805
+ console.log("[AthenaSDK] Cancelled");
20806
+ }
20798
20807
  },
20799
20808
  capabilities: {
20800
20809
  edit: false
@@ -20839,10 +20848,7 @@ const useAthenaRuntime = (config2) => {
20839
20848
  },
20840
20849
  get threadId() {
20841
20850
  return threadId;
20842
- },
20843
- credentials: "include",
20844
- mode: "cors",
20845
- cache: "no-store"
20851
+ }
20846
20852
  }
20847
20853
  });
20848
20854
  return runtime;
@@ -24070,6 +24076,14 @@ function TooltipContent({
24070
24076
  }
24071
24077
  ) });
24072
24078
  }
24079
+ const AthenaContext = createContext(null);
24080
+ function useAthenaConfig() {
24081
+ const ctx = useContext(AthenaContext);
24082
+ if (!ctx) {
24083
+ throw new Error("[AthenaSDK] useAthenaConfig must be used within <AthenaProvider>");
24084
+ }
24085
+ return ctx;
24086
+ }
24073
24087
  function AthenaProvider({
24074
24088
  children,
24075
24089
  apiKey,
@@ -24085,15 +24099,16 @@ function AthenaProvider({
24085
24099
  systemPrompt,
24086
24100
  threadId
24087
24101
  }) {
24088
- const frontendToolNames = Object.keys(frontendTools);
24102
+ const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
24089
24103
  const aui = useAui({
24090
24104
  tools: Tools({ toolkit: frontendTools })
24091
24105
  });
24092
24106
  const parentAuthToken = useParentAuth();
24093
24107
  const effectiveToken = tokenProp ?? parentAuthToken;
24108
+ const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
24094
24109
  const runtime = useAthenaRuntime({
24095
24110
  apiUrl,
24096
- backendUrl,
24111
+ backendUrl: effectiveBackendUrl,
24097
24112
  apiKey,
24098
24113
  token: effectiveToken,
24099
24114
  model,
@@ -24105,7 +24120,11 @@ function AthenaProvider({
24105
24120
  systemPrompt,
24106
24121
  threadId
24107
24122
  });
24108
- return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) });
24123
+ const athenaConfig = useMemo(
24124
+ () => ({ backendUrl: effectiveBackendUrl, apiKey, token: effectiveToken }),
24125
+ [effectiveBackendUrl, apiKey, effectiveToken]
24126
+ );
24127
+ return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
24109
24128
  }
24110
24129
  function OrderedMap(content) {
24111
24130
  this.content = content;
@@ -59546,7 +59565,7 @@ function useMentionSuggestions(tools) {
59546
59565
  addItems(cache, items, "root");
59547
59566
  return new Store({ registry, cache });
59548
59567
  }, []);
59549
- useMemo(() => {
59568
+ useEffect(() => {
59550
59569
  const { cache } = store.state;
59551
59570
  for (const item of cache.items.values()) {
59552
59571
  item.visibleInScopes.delete("root");
@@ -59708,6 +59727,9 @@ const MentionSuggestionsExtension = Extension.create({
59708
59727
  };
59709
59728
  },
59710
59729
  addProseMirrorPlugins() {
59730
+ if (!this.options.store) {
59731
+ throw new Error("[MentionSuggestionsExtension] A `store` option is required.");
59732
+ }
59711
59733
  return [
59712
59734
  index_default({
59713
59735
  editor: this.editor,
@@ -60007,29 +60029,29 @@ const createLucideIcon = (iconName, iconNode) => {
60007
60029
  * This source code is licensed under the ISC license.
60008
60030
  * See the LICENSE file in the root directory of this source tree.
60009
60031
  */
60010
- const __iconNode$s = [
60032
+ const __iconNode$B = [
60011
60033
  ["path", { d: "M12 5v14", key: "s699le" }],
60012
60034
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
60013
60035
  ];
60014
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$s);
60036
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$B);
60015
60037
  /**
60016
60038
  * @license lucide-react v0.575.0 - ISC
60017
60039
  *
60018
60040
  * This source code is licensed under the ISC license.
60019
60041
  * See the LICENSE file in the root directory of this source tree.
60020
60042
  */
60021
- const __iconNode$r = [
60043
+ const __iconNode$A = [
60022
60044
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
60023
60045
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
60024
60046
  ];
60025
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$r);
60047
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$A);
60026
60048
  /**
60027
60049
  * @license lucide-react v0.575.0 - ISC
60028
60050
  *
60029
60051
  * This source code is licensed under the ISC license.
60030
60052
  * See the LICENSE file in the root directory of this source tree.
60031
60053
  */
60032
- const __iconNode$q = [
60054
+ const __iconNode$z = [
60033
60055
  ["path", { d: "M12 7v14", key: "1akyts" }],
60034
60056
  [
60035
60057
  "path",
@@ -60039,14 +60061,14 @@ const __iconNode$q = [
60039
60061
  }
60040
60062
  ]
60041
60063
  ];
60042
- const BookOpen = createLucideIcon("book-open", __iconNode$q);
60064
+ const BookOpen = createLucideIcon("book-open", __iconNode$z);
60043
60065
  /**
60044
60066
  * @license lucide-react v0.575.0 - ISC
60045
60067
  *
60046
60068
  * This source code is licensed under the ISC license.
60047
60069
  * See the LICENSE file in the root directory of this source tree.
60048
60070
  */
60049
- const __iconNode$p = [
60071
+ const __iconNode$y = [
60050
60072
  ["path", { d: "M12 18V5", key: "adv99a" }],
60051
60073
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
60052
60074
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -60056,148 +60078,148 @@ const __iconNode$p = [
60056
60078
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
60057
60079
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
60058
60080
  ];
60059
- const Brain = createLucideIcon("brain", __iconNode$p);
60081
+ const Brain = createLucideIcon("brain", __iconNode$y);
60060
60082
  /**
60061
60083
  * @license lucide-react v0.575.0 - ISC
60062
60084
  *
60063
60085
  * This source code is licensed under the ISC license.
60064
60086
  * See the LICENSE file in the root directory of this source tree.
60065
60087
  */
60066
- const __iconNode$o = [
60088
+ const __iconNode$x = [
60067
60089
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
60068
60090
  ["path", { d: "M18 17V9", key: "2bz60n" }],
60069
60091
  ["path", { d: "M13 17V5", key: "1frdt8" }],
60070
60092
  ["path", { d: "M8 17v-3", key: "17ska0" }]
60071
60093
  ];
60072
- const ChartColumn = createLucideIcon("chart-column", __iconNode$o);
60094
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$x);
60073
60095
  /**
60074
60096
  * @license lucide-react v0.575.0 - ISC
60075
60097
  *
60076
60098
  * This source code is licensed under the ISC license.
60077
60099
  * See the LICENSE file in the root directory of this source tree.
60078
60100
  */
60079
- const __iconNode$n = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60080
- const Check = createLucideIcon("check", __iconNode$n);
60101
+ const __iconNode$w = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60102
+ const Check = createLucideIcon("check", __iconNode$w);
60081
60103
  /**
60082
60104
  * @license lucide-react v0.575.0 - ISC
60083
60105
  *
60084
60106
  * This source code is licensed under the ISC license.
60085
60107
  * See the LICENSE file in the root directory of this source tree.
60086
60108
  */
60087
- const __iconNode$m = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60088
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$m);
60109
+ const __iconNode$v = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60110
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$v);
60089
60111
  /**
60090
60112
  * @license lucide-react v0.575.0 - ISC
60091
60113
  *
60092
60114
  * This source code is licensed under the ISC license.
60093
60115
  * See the LICENSE file in the root directory of this source tree.
60094
60116
  */
60095
- const __iconNode$l = [
60117
+ const __iconNode$u = [
60096
60118
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60097
60119
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
60098
60120
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
60099
60121
  ];
60100
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$l);
60122
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$u);
60101
60123
  /**
60102
60124
  * @license lucide-react v0.575.0 - ISC
60103
60125
  *
60104
60126
  * This source code is licensed under the ISC license.
60105
60127
  * See the LICENSE file in the root directory of this source tree.
60106
60128
  */
60107
- const __iconNode$k = [
60129
+ const __iconNode$t = [
60108
60130
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60109
60131
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
60110
60132
  ];
60111
- const CircleCheck = createLucideIcon("circle-check", __iconNode$k);
60133
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$t);
60112
60134
  /**
60113
60135
  * @license lucide-react v0.575.0 - ISC
60114
60136
  *
60115
60137
  * This source code is licensed under the ISC license.
60116
60138
  * See the LICENSE file in the root directory of this source tree.
60117
60139
  */
60118
- const __iconNode$j = [
60140
+ const __iconNode$s = [
60119
60141
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60120
60142
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
60121
60143
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
60122
60144
  ];
60123
- const CircleX = createLucideIcon("circle-x", __iconNode$j);
60145
+ const CircleX = createLucideIcon("circle-x", __iconNode$s);
60124
60146
  /**
60125
60147
  * @license lucide-react v0.575.0 - ISC
60126
60148
  *
60127
60149
  * This source code is licensed under the ISC license.
60128
60150
  * See the LICENSE file in the root directory of this source tree.
60129
60151
  */
60130
- const __iconNode$i = [
60152
+ const __iconNode$r = [
60131
60153
  ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
60132
60154
  ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
60133
60155
  ];
60134
- const Code = createLucideIcon("code", __iconNode$i);
60156
+ const Code = createLucideIcon("code", __iconNode$r);
60135
60157
  /**
60136
60158
  * @license lucide-react v0.575.0 - ISC
60137
60159
  *
60138
60160
  * This source code is licensed under the ISC license.
60139
60161
  * See the LICENSE file in the root directory of this source tree.
60140
60162
  */
60141
- const __iconNode$h = [
60163
+ const __iconNode$q = [
60142
60164
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
60143
60165
  ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
60144
60166
  ];
60145
- const Copy = createLucideIcon("copy", __iconNode$h);
60167
+ const Copy = createLucideIcon("copy", __iconNode$q);
60146
60168
  /**
60147
60169
  * @license lucide-react v0.575.0 - ISC
60148
60170
  *
60149
60171
  * This source code is licensed under the ISC license.
60150
60172
  * See the LICENSE file in the root directory of this source tree.
60151
60173
  */
60152
- const __iconNode$g = [
60174
+ const __iconNode$p = [
60153
60175
  ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
60154
60176
  ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
60155
60177
  ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
60156
60178
  ];
60157
- const Database = createLucideIcon("database", __iconNode$g);
60179
+ const Database = createLucideIcon("database", __iconNode$p);
60158
60180
  /**
60159
60181
  * @license lucide-react v0.575.0 - ISC
60160
60182
  *
60161
60183
  * This source code is licensed under the ISC license.
60162
60184
  * See the LICENSE file in the root directory of this source tree.
60163
60185
  */
60164
- const __iconNode$f = [
60186
+ const __iconNode$o = [
60165
60187
  ["path", { d: "M12 15V3", key: "m9g1x1" }],
60166
60188
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
60167
60189
  ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
60168
60190
  ];
60169
- const Download = createLucideIcon("download", __iconNode$f);
60191
+ const Download = createLucideIcon("download", __iconNode$o);
60170
60192
  /**
60171
60193
  * @license lucide-react v0.575.0 - ISC
60172
60194
  *
60173
60195
  * This source code is licensed under the ISC license.
60174
60196
  * See the LICENSE file in the root directory of this source tree.
60175
60197
  */
60176
- const __iconNode$e = [
60198
+ const __iconNode$n = [
60177
60199
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
60178
60200
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
60179
60201
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
60180
60202
  ];
60181
- const Ellipsis = createLucideIcon("ellipsis", __iconNode$e);
60203
+ const Ellipsis = createLucideIcon("ellipsis", __iconNode$n);
60182
60204
  /**
60183
60205
  * @license lucide-react v0.575.0 - ISC
60184
60206
  *
60185
60207
  * This source code is licensed under the ISC license.
60186
60208
  * See the LICENSE file in the root directory of this source tree.
60187
60209
  */
60188
- const __iconNode$d = [
60210
+ const __iconNode$m = [
60189
60211
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60190
60212
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
60191
60213
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
60192
60214
  ];
60193
- const ExternalLink = createLucideIcon("external-link", __iconNode$d);
60215
+ const ExternalLink = createLucideIcon("external-link", __iconNode$m);
60194
60216
  /**
60195
60217
  * @license lucide-react v0.575.0 - ISC
60196
60218
  *
60197
60219
  * This source code is licensed under the ISC license.
60198
60220
  * See the LICENSE file in the root directory of this source tree.
60199
60221
  */
60200
- const __iconNode$c = [
60222
+ const __iconNode$l = [
60201
60223
  [
60202
60224
  "path",
60203
60225
  {
@@ -60209,14 +60231,35 @@ const __iconNode$c = [
60209
60231
  ["path", { d: "M9 15h6", key: "cctwl0" }],
60210
60232
  ["path", { d: "M12 18v-6", key: "17g6i2" }]
60211
60233
  ];
60212
- const FilePlus = createLucideIcon("file-plus", __iconNode$c);
60234
+ const FilePlus = createLucideIcon("file-plus", __iconNode$l);
60213
60235
  /**
60214
60236
  * @license lucide-react v0.575.0 - ISC
60215
60237
  *
60216
60238
  * This source code is licensed under the ISC license.
60217
60239
  * See the LICENSE file in the root directory of this source tree.
60218
60240
  */
60219
- const __iconNode$b = [
60241
+ const __iconNode$k = [
60242
+ [
60243
+ "path",
60244
+ {
60245
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
60246
+ key: "1oefj6"
60247
+ }
60248
+ ],
60249
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
60250
+ ["path", { d: "M8 13h2", key: "yr2amv" }],
60251
+ ["path", { d: "M14 13h2", key: "un5t4a" }],
60252
+ ["path", { d: "M8 17h2", key: "2yhykz" }],
60253
+ ["path", { d: "M14 17h2", key: "10kma7" }]
60254
+ ];
60255
+ const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$k);
60256
+ /**
60257
+ * @license lucide-react v0.575.0 - ISC
60258
+ *
60259
+ * This source code is licensed under the ISC license.
60260
+ * See the LICENSE file in the root directory of this source tree.
60261
+ */
60262
+ const __iconNode$j = [
60220
60263
  [
60221
60264
  "path",
60222
60265
  {
@@ -60229,26 +60272,94 @@ const __iconNode$b = [
60229
60272
  ["path", { d: "M16 13H8", key: "t4e002" }],
60230
60273
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
60231
60274
  ];
60232
- const FileText = createLucideIcon("file-text", __iconNode$b);
60275
+ const FileText = createLucideIcon("file-text", __iconNode$j);
60233
60276
  /**
60234
60277
  * @license lucide-react v0.575.0 - ISC
60235
60278
  *
60236
60279
  * This source code is licensed under the ISC license.
60237
60280
  * See the LICENSE file in the root directory of this source tree.
60238
60281
  */
60239
- const __iconNode$a = [
60282
+ const __iconNode$i = [
60283
+ [
60284
+ "path",
60285
+ {
60286
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
60287
+ key: "1oefj6"
60288
+ }
60289
+ ],
60290
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
60291
+ ];
60292
+ const File$1 = createLucideIcon("file", __iconNode$i);
60293
+ /**
60294
+ * @license lucide-react v0.575.0 - ISC
60295
+ *
60296
+ * This source code is licensed under the ISC license.
60297
+ * See the LICENSE file in the root directory of this source tree.
60298
+ */
60299
+ const __iconNode$h = [
60240
60300
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60241
60301
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
60242
60302
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
60243
60303
  ];
60244
- const Globe = createLucideIcon("globe", __iconNode$a);
60304
+ const Globe = createLucideIcon("globe", __iconNode$h);
60245
60305
  /**
60246
60306
  * @license lucide-react v0.575.0 - ISC
60247
60307
  *
60248
60308
  * This source code is licensed under the ISC license.
60249
60309
  * See the LICENSE file in the root directory of this source tree.
60250
60310
  */
60251
- const __iconNode$9 = [
60311
+ const __iconNode$g = [
60312
+ [
60313
+ "path",
60314
+ {
60315
+ d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
60316
+ key: "zw3jo"
60317
+ }
60318
+ ],
60319
+ [
60320
+ "path",
60321
+ {
60322
+ d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
60323
+ key: "1wduqc"
60324
+ }
60325
+ ],
60326
+ [
60327
+ "path",
60328
+ {
60329
+ d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
60330
+ key: "kqbvx6"
60331
+ }
60332
+ ]
60333
+ ];
60334
+ const Layers = createLucideIcon("layers", __iconNode$g);
60335
+ /**
60336
+ * @license lucide-react v0.575.0 - ISC
60337
+ *
60338
+ * This source code is licensed under the ISC license.
60339
+ * See the LICENSE file in the root directory of this source tree.
60340
+ */
60341
+ const __iconNode$f = [
60342
+ ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
60343
+ ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
60344
+ ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
60345
+ ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
60346
+ ];
60347
+ const LayoutGrid = createLucideIcon("layout-grid", __iconNode$f);
60348
+ /**
60349
+ * @license lucide-react v0.575.0 - ISC
60350
+ *
60351
+ * This source code is licensed under the ISC license.
60352
+ * See the LICENSE file in the root directory of this source tree.
60353
+ */
60354
+ const __iconNode$e = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60355
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$e);
60356
+ /**
60357
+ * @license lucide-react v0.575.0 - ISC
60358
+ *
60359
+ * This source code is licensed under the ISC license.
60360
+ * See the LICENSE file in the root directory of this source tree.
60361
+ */
60362
+ const __iconNode$d = [
60252
60363
  ["path", { d: "M12 2v4", key: "3427ic" }],
60253
60364
  ["path", { d: "m16.2 7.8 2.9-2.9", key: "r700ao" }],
60254
60365
  ["path", { d: "M18 12h4", key: "wj9ykh" }],
@@ -60258,37 +60369,63 @@ const __iconNode$9 = [
60258
60369
  ["path", { d: "M2 12h4", key: "j09sii" }],
60259
60370
  ["path", { d: "m4.9 4.9 2.9 2.9", key: "giyufr" }]
60260
60371
  ];
60261
- const Loader = createLucideIcon("loader", __iconNode$9);
60372
+ const Loader = createLucideIcon("loader", __iconNode$d);
60262
60373
  /**
60263
60374
  * @license lucide-react v0.575.0 - ISC
60264
60375
  *
60265
60376
  * This source code is licensed under the ISC license.
60266
60377
  * See the LICENSE file in the root directory of this source tree.
60267
60378
  */
60268
- const __iconNode$8 = [
60379
+ const __iconNode$c = [
60269
60380
  ["path", { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7", key: "132q7q" }],
60270
60381
  ["rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", key: "izxlao" }]
60271
60382
  ];
60272
- const Mail = createLucideIcon("mail", __iconNode$8);
60383
+ const Mail = createLucideIcon("mail", __iconNode$c);
60273
60384
  /**
60274
60385
  * @license lucide-react v0.575.0 - ISC
60275
60386
  *
60276
60387
  * This source code is licensed under the ISC license.
60277
60388
  * See the LICENSE file in the root directory of this source tree.
60278
60389
  */
60279
- const __iconNode$7 = [
60390
+ const __iconNode$b = [
60391
+ ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60392
+ ["path", { d: "m21 3-7 7", key: "1l2asr" }],
60393
+ ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60394
+ ["path", { d: "M9 21H3v-6", key: "wtvkvv" }]
60395
+ ];
60396
+ const Maximize2 = createLucideIcon("maximize-2", __iconNode$b);
60397
+ /**
60398
+ * @license lucide-react v0.575.0 - ISC
60399
+ *
60400
+ * This source code is licensed under the ISC license.
60401
+ * See the LICENSE file in the root directory of this source tree.
60402
+ */
60403
+ const __iconNode$a = [
60404
+ ["path", { d: "m14 10 7-7", key: "oa77jy" }],
60405
+ ["path", { d: "M20 10h-6V4", key: "mjg0md" }],
60406
+ ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60407
+ ["path", { d: "M4 14h6v6", key: "rmj7iw" }]
60408
+ ];
60409
+ const Minimize2 = createLucideIcon("minimize-2", __iconNode$a);
60410
+ /**
60411
+ * @license lucide-react v0.575.0 - ISC
60412
+ *
60413
+ * This source code is licensed under the ISC license.
60414
+ * See the LICENSE file in the root directory of this source tree.
60415
+ */
60416
+ const __iconNode$9 = [
60280
60417
  ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
60281
60418
  ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
60282
60419
  ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
60283
60420
  ];
60284
- const Monitor = createLucideIcon("monitor", __iconNode$7);
60421
+ const Monitor = createLucideIcon("monitor", __iconNode$9);
60285
60422
  /**
60286
60423
  * @license lucide-react v0.575.0 - ISC
60287
60424
  *
60288
60425
  * This source code is licensed under the ISC license.
60289
60426
  * See the LICENSE file in the root directory of this source tree.
60290
60427
  */
60291
- const __iconNode$6 = [
60428
+ const __iconNode$8 = [
60292
60429
  ["path", { d: "M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4", key: "re6nr2" }],
60293
60430
  ["path", { d: "M2 6h4", key: "aawbzj" }],
60294
60431
  ["path", { d: "M2 10h4", key: "l0bgd4" }],
@@ -60302,14 +60439,14 @@ const __iconNode$6 = [
60302
60439
  }
60303
60440
  ]
60304
60441
  ];
60305
- const NotebookPen = createLucideIcon("notebook-pen", __iconNode$6);
60442
+ const NotebookPen = createLucideIcon("notebook-pen", __iconNode$8);
60306
60443
  /**
60307
60444
  * @license lucide-react v0.575.0 - ISC
60308
60445
  *
60309
60446
  * This source code is licensed under the ISC license.
60310
60447
  * See the LICENSE file in the root directory of this source tree.
60311
60448
  */
60312
- const __iconNode$5 = [
60449
+ const __iconNode$7 = [
60313
60450
  ["path", { d: "M13 21h8", key: "1jsn5i" }],
60314
60451
  [
60315
60452
  "path",
@@ -60319,38 +60456,50 @@ const __iconNode$5 = [
60319
60456
  }
60320
60457
  ]
60321
60458
  ];
60322
- const PenLine = createLucideIcon("pen-line", __iconNode$5);
60459
+ const PenLine = createLucideIcon("pen-line", __iconNode$7);
60323
60460
  /**
60324
60461
  * @license lucide-react v0.575.0 - ISC
60325
60462
  *
60326
60463
  * This source code is licensed under the ISC license.
60327
60464
  * See the LICENSE file in the root directory of this source tree.
60328
60465
  */
60329
- const __iconNode$4 = [
60466
+ const __iconNode$6 = [
60467
+ ["path", { d: "M2 3h20", key: "91anmk" }],
60468
+ ["path", { d: "M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3", key: "2k9sn8" }],
60469
+ ["path", { d: "m7 21 5-5 5 5", key: "bip4we" }]
60470
+ ];
60471
+ const Presentation = createLucideIcon("presentation", __iconNode$6);
60472
+ /**
60473
+ * @license lucide-react v0.575.0 - ISC
60474
+ *
60475
+ * This source code is licensed under the ISC license.
60476
+ * See the LICENSE file in the root directory of this source tree.
60477
+ */
60478
+ const __iconNode$5 = [
60330
60479
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
60331
60480
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
60332
60481
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
60333
60482
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
60334
60483
  ];
60335
- const RefreshCw = createLucideIcon("refresh-cw", __iconNode$4);
60484
+ const RefreshCw = createLucideIcon("refresh-cw", __iconNode$5);
60336
60485
  /**
60337
60486
  * @license lucide-react v0.575.0 - ISC
60338
60487
  *
60339
60488
  * This source code is licensed under the ISC license.
60340
60489
  * See the LICENSE file in the root directory of this source tree.
60341
60490
  */
60342
- const __iconNode$3 = [
60491
+ const __iconNode$4 = [
60343
60492
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
60344
60493
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
60345
60494
  ];
60346
- const Search = createLucideIcon("search", __iconNode$3);
60495
+ const Search = createLucideIcon("search", __iconNode$4);
60347
60496
  /**
60348
60497
  * @license lucide-react v0.575.0 - ISC
60349
60498
  *
60350
60499
  * This source code is licensed under the ISC license.
60351
60500
  * See the LICENSE file in the root directory of this source tree.
60352
60501
  */
60353
- const __iconNode$2 = [
60502
+ const __iconNode$3 = [
60354
60503
  [
60355
60504
  "path",
60356
60505
  {
@@ -60360,24 +60509,24 @@ const __iconNode$2 = [
60360
60509
  ],
60361
60510
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
60362
60511
  ];
60363
- const Settings = createLucideIcon("settings", __iconNode$2);
60512
+ const Settings = createLucideIcon("settings", __iconNode$3);
60364
60513
  /**
60365
60514
  * @license lucide-react v0.575.0 - ISC
60366
60515
  *
60367
60516
  * This source code is licensed under the ISC license.
60368
60517
  * See the LICENSE file in the root directory of this source tree.
60369
60518
  */
60370
- const __iconNode$1 = [
60519
+ const __iconNode$2 = [
60371
60520
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
60372
60521
  ];
60373
- const Square = createLucideIcon("square", __iconNode$1);
60522
+ const Square = createLucideIcon("square", __iconNode$2);
60374
60523
  /**
60375
60524
  * @license lucide-react v0.575.0 - ISC
60376
60525
  *
60377
60526
  * This source code is licensed under the ISC license.
60378
60527
  * See the LICENSE file in the root directory of this source tree.
60379
60528
  */
60380
- const __iconNode = [
60529
+ const __iconNode$1 = [
60381
60530
  [
60382
60531
  "path",
60383
60532
  {
@@ -60386,7 +60535,18 @@ const __iconNode = [
60386
60535
  }
60387
60536
  ]
60388
60537
  ];
60389
- const Wrench = createLucideIcon("wrench", __iconNode);
60538
+ const Wrench = createLucideIcon("wrench", __iconNode$1);
60539
+ /**
60540
+ * @license lucide-react v0.575.0 - ISC
60541
+ *
60542
+ * This source code is licensed under the ISC license.
60543
+ * See the LICENSE file in the root directory of this source tree.
60544
+ */
60545
+ const __iconNode = [
60546
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
60547
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
60548
+ ];
60549
+ const X = createLucideIcon("x", __iconNode);
60390
60550
  function Collapsible({ ...props }) {
60391
60551
  return /* @__PURE__ */ jsx(Root$2, { "data-slot": "collapsible", ...props });
60392
60552
  }
@@ -60396,6 +60556,41 @@ function CollapsibleTrigger({ ...props }) {
60396
60556
  function CollapsibleContent({ ...props }) {
60397
60557
  return /* @__PURE__ */ jsx(CollapsibleContent$1, { "data-slot": "collapsible-content", ...props });
60398
60558
  }
60559
+ const useAssetPanelStore = create((set2) => ({
60560
+ isOpen: false,
60561
+ tabs: [],
60562
+ activeTabId: null,
60563
+ viewMode: "tabs",
60564
+ isFullscreen: false,
60565
+ openAsset: (assetId, meta) => set2((s) => {
60566
+ const existing = s.tabs.find((t) => t.id === assetId);
60567
+ if (existing) {
60568
+ const tabs = meta ? s.tabs.map(
60569
+ (t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
60570
+ ) : s.tabs;
60571
+ return { isOpen: true, tabs, activeTabId: assetId };
60572
+ }
60573
+ const newTab = {
60574
+ id: assetId,
60575
+ name: (meta == null ? void 0 : meta.name) ?? null,
60576
+ type: (meta == null ? void 0 : meta.type) ?? "unknown"
60577
+ };
60578
+ return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
60579
+ }),
60580
+ closeTab: (assetId) => set2((s) => {
60581
+ var _a2;
60582
+ const tabs = s.tabs.filter((t) => t.id !== assetId);
60583
+ if (tabs.length === 0) {
60584
+ return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
60585
+ }
60586
+ const activeTabId = s.activeTabId === assetId ? ((_a2 = tabs[Math.min(s.tabs.findIndex((t) => t.id === assetId), tabs.length - 1)]) == null ? void 0 : _a2.id) ?? null : s.activeTabId;
60587
+ return { tabs, activeTabId };
60588
+ }),
60589
+ setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
60590
+ setViewMode: (mode) => set2({ viewMode: mode }),
60591
+ closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
60592
+ toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen }))
60593
+ }));
60399
60594
  const ANIMATION_DURATION = 200;
60400
60595
  const TOOL_META = {
60401
60596
  search: { displayName: "Web Search", icon: Search, describer: (a) => a.query ? `"${a.query}"` : "" },
@@ -60463,6 +60658,61 @@ function isResultSuccess(result) {
60463
60658
  }
60464
60659
  return false;
60465
60660
  }
60661
+ function extractAssetId$1(result) {
60662
+ if (!result) return null;
60663
+ try {
60664
+ const obj = typeof result === "string" ? JSON.parse(result) : result;
60665
+ if (typeof obj === "object" && obj !== null) {
60666
+ const id = obj.asset_id ?? obj.assetId ?? obj.id;
60667
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
60668
+ }
60669
+ } catch {
60670
+ }
60671
+ return null;
60672
+ }
60673
+ function toolMetaToAssetType(toolName) {
60674
+ const lower = toolName.toLowerCase();
60675
+ if (lower.includes("presentation") || lower.includes("pptx") || lower.includes("slide") || lower.includes("powerpoint"))
60676
+ return "presentation";
60677
+ if (lower.includes("sheet") || lower.includes("spreadsheet"))
60678
+ return "spreadsheet";
60679
+ if (lower.includes("document") || lower.includes("doc") || lower.includes("markdown"))
60680
+ return "document";
60681
+ return "unknown";
60682
+ }
60683
+ const CREATE_ASSET_TOOLS = [
60684
+ "create_powerpoint_deck",
60685
+ "create_document_from_markdown",
60686
+ "create_new_document",
60687
+ "create_new_sheet"
60688
+ ];
60689
+ function isAssetTool(toolName, result) {
60690
+ return CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) || extractAssetId$1(result) !== null;
60691
+ }
60692
+ function extractTitle(argsText, result) {
60693
+ if (argsText) {
60694
+ const args = tryParseJson$2(argsText);
60695
+ if (args) {
60696
+ const t = args.title ?? args.name ?? args.filename ?? args.sheet_name;
60697
+ if (t) return t;
60698
+ }
60699
+ }
60700
+ if (result) {
60701
+ try {
60702
+ const obj = typeof result === "string" ? JSON.parse(result) : result;
60703
+ if (typeof obj === "object" && obj !== null) {
60704
+ return obj.title ?? obj.name;
60705
+ }
60706
+ } catch {
60707
+ }
60708
+ }
60709
+ return null;
60710
+ }
60711
+ let assetGeneration$1 = 0;
60712
+ const autoOpenedAssets$1 = /* @__PURE__ */ new Map();
60713
+ function clearAutoOpenedAssets() {
60714
+ assetGeneration$1++;
60715
+ }
60466
60716
  function ToolFallbackRoot({
60467
60717
  className,
60468
60718
  open: controlledOpen,
@@ -60528,7 +60778,7 @@ function ToolFallbackTrigger({
60528
60778
  if (!parsed) return null;
60529
60779
  const desc = meta.describer(parsed);
60530
60780
  return desc || null;
60531
- }, [toolName, argsText, isRunning, meta]);
60781
+ }, [toolName, argsText, isRunning]);
60532
60782
  const resultMessage = useMemo(() => {
60533
60783
  if (!isComplete) return null;
60534
60784
  return extractResultMessage(result);
@@ -60692,6 +60942,97 @@ function ToolFallbackError({
60692
60942
  /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-destructive/80", children: errorText })
60693
60943
  ] });
60694
60944
  }
60945
+ function AssetToolCard({
60946
+ toolName,
60947
+ argsText,
60948
+ result,
60949
+ status
60950
+ }) {
60951
+ const [detailsOpen, setDetailsOpen] = useState(false);
60952
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
60953
+ const meta = getToolMeta(toolName);
60954
+ const ToolIcon = meta.icon;
60955
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
60956
+ const isRunning = (status == null ? void 0 : status.type) === "running";
60957
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
60958
+ const assetId = extractAssetId$1(result);
60959
+ const title = extractTitle(argsText, result);
60960
+ const assetType = toolMetaToAssetType(toolName);
60961
+ const wasCompleteAtMount = useRef(isComplete);
60962
+ useEffect(() => {
60963
+ if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current && autoOpenedAssets$1.get(assetId) !== assetGeneration$1) {
60964
+ autoOpenedAssets$1.set(assetId, assetGeneration$1);
60965
+ useAssetPanelStore.getState().openAsset(assetId, {
60966
+ name: title ?? void 0,
60967
+ type: assetType
60968
+ });
60969
+ }
60970
+ }, [isComplete, isCancelled, assetId, title, assetType]);
60971
+ const success = isComplete && isResultSuccess(result);
60972
+ return /* @__PURE__ */ jsxs("div", { className: cn(
60973
+ "aui-tool-fallback-root w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
60974
+ isCancelled && "border-muted-foreground/30 bg-muted/30"
60975
+ ), children: [
60976
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 px-3 text-sm", children: [
60977
+ /* @__PURE__ */ jsx(
60978
+ "div",
60979
+ {
60980
+ className: cn(
60981
+ "flex size-7 shrink-0 items-center justify-center rounded-lg",
60982
+ isRunning && "bg-blue-50 text-blue-600",
60983
+ isComplete && success && "bg-emerald-50 text-emerald-600",
60984
+ isComplete && !success && "bg-muted text-muted-foreground"
60985
+ ),
60986
+ children: isRunning ? /* @__PURE__ */ jsx(Loader, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx(ToolIcon, { className: "size-3.5" })
60987
+ }
60988
+ ),
60989
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 grow flex-col items-start gap-0.5 text-left", children: [
60990
+ /* @__PURE__ */ jsxs("span", { className: "leading-tight", children: [
60991
+ /* @__PURE__ */ jsx("b", { children: meta.displayName }),
60992
+ isRunning && "..."
60993
+ ] }),
60994
+ !isRunning && title && /* @__PURE__ */ jsx("span", { className: "max-w-full truncate text-xs leading-snug text-muted-foreground", children: title })
60995
+ ] }),
60996
+ assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxs(
60997
+ "button",
60998
+ {
60999
+ onClick: () => openAsset(assetId, { name: title ?? void 0, type: assetType }),
61000
+ className: "flex shrink-0 items-center gap-1 rounded-md border border-border/60 px-2 py-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
61001
+ children: [
61002
+ /* @__PURE__ */ jsx(ExternalLink, { className: "size-2.5" }),
61003
+ "Open"
61004
+ ]
61005
+ }
61006
+ ),
61007
+ isComplete && success && /* @__PURE__ */ jsx(CircleCheck, { className: "size-3.5 shrink-0 text-emerald-500" }),
61008
+ !isCancelled && /* @__PURE__ */ jsx(
61009
+ "button",
61010
+ {
61011
+ onClick: () => setDetailsOpen((o) => !o),
61012
+ className: cn(
61013
+ "flex size-5 shrink-0 items-center justify-center rounded transition-all",
61014
+ detailsOpen ? "bg-primary/5 text-primary" : "text-muted-foreground/40 hover:bg-muted/50 hover:text-muted-foreground"
61015
+ ),
61016
+ title: "Show details",
61017
+ children: /* @__PURE__ */ jsx(
61018
+ ChevronDown,
61019
+ {
61020
+ className: cn(
61021
+ "size-3 transition-transform duration-200",
61022
+ detailsOpen && "rotate-180"
61023
+ )
61024
+ }
61025
+ )
61026
+ }
61027
+ )
61028
+ ] }),
61029
+ (status == null ? void 0 : status.type) === "incomplete" && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsx(ToolFallbackError, { status }) }),
61030
+ detailsOpen && !isCancelled && /* @__PURE__ */ jsxs("div", { className: "mt-2.5 flex flex-col gap-2 border-t border-border/50 px-3 pt-2", children: [
61031
+ /* @__PURE__ */ jsx(ToolFallbackArgs, { argsText }),
61032
+ /* @__PURE__ */ jsx(ToolFallbackResult, { result })
61033
+ ] })
61034
+ ] });
61035
+ }
60695
61036
  const ToolFallbackImpl = ({
60696
61037
  toolName,
60697
61038
  argsText,
@@ -60699,6 +61040,17 @@ const ToolFallbackImpl = ({
60699
61040
  status
60700
61041
  }) => {
60701
61042
  const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
61043
+ if (isAssetTool(toolName, result)) {
61044
+ return /* @__PURE__ */ jsx(
61045
+ AssetToolCard,
61046
+ {
61047
+ toolName,
61048
+ argsText,
61049
+ result,
61050
+ status
61051
+ }
61052
+ );
61053
+ }
60702
61054
  return /* @__PURE__ */ jsxs(
60703
61055
  ToolFallbackRoot,
60704
61056
  {
@@ -61280,32 +61632,120 @@ const EmailSearchToolUI = memo(
61280
61632
  EmailSearchToolUIImpl
61281
61633
  );
61282
61634
  EmailSearchToolUI.displayName = "EmailSearchToolUI";
61283
- const CreateDocumentToolUIImpl = ({
61635
+ function extractAssetId(result) {
61636
+ const data = normalizeResult(result);
61637
+ if (!data) return null;
61638
+ const id = data.asset_id ?? data.assetId ?? data.id;
61639
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
61640
+ return null;
61641
+ }
61642
+ let assetGeneration = 0;
61643
+ const autoOpenedAssets = /* @__PURE__ */ new Map();
61644
+ function resetAssetAutoOpen() {
61645
+ assetGeneration++;
61646
+ }
61647
+ function CreateAssetToolUIImpl({
61648
+ icon: Icon2,
61649
+ assetType,
61650
+ runningLabel,
61651
+ doneLabel,
61284
61652
  args,
61285
61653
  result,
61286
61654
  status
61287
- }) => {
61655
+ }) {
61288
61656
  const typedArgs = args;
61289
- const docName = (typedArgs == null ? void 0 : typedArgs.name) ?? (typedArgs == null ? void 0 : typedArgs.title) ?? (typedArgs == null ? void 0 : typedArgs.document_name) ?? "";
61657
+ const name = (typedArgs == null ? void 0 : typedArgs.name) ?? (typedArgs == null ? void 0 : typedArgs.title) ?? (typedArgs == null ? void 0 : typedArgs.document_name) ?? (typedArgs == null ? void 0 : typedArgs.sheet_name) ?? "";
61290
61658
  const data = useMemo(() => normalizeResult(result), [result]);
61291
61659
  const createdName = (data == null ? void 0 : data.name) ?? (data == null ? void 0 : data.title) ?? (data == null ? void 0 : data.asset_name);
61660
+ const assetId = extractAssetId(result);
61292
61661
  const isRunning = (status == null ? void 0 : status.type) === "running";
61662
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
61663
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
61293
61664
  const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
61665
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
61666
+ const wasCompleteAtMount = useRef(isComplete);
61667
+ useEffect(() => {
61668
+ if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current && autoOpenedAssets.get(assetId) !== assetGeneration) {
61669
+ autoOpenedAssets.set(assetId, assetGeneration);
61670
+ useAssetPanelStore.getState().openAsset(assetId, {
61671
+ name: createdName || name || void 0,
61672
+ type: assetType
61673
+ });
61674
+ }
61675
+ }, [isComplete, isCancelled, assetId, createdName, name, assetType]);
61676
+ const handleOpen = () => {
61677
+ if (assetId) {
61678
+ openAsset(assetId, {
61679
+ name: createdName || name || void 0,
61680
+ type: assetType
61681
+ });
61682
+ }
61683
+ };
61294
61684
  return /* @__PURE__ */ jsx(
61295
61685
  ToolCard,
61296
61686
  {
61297
- icon: FilePlus,
61687
+ icon: Icon2,
61298
61688
  status: (status == null ? void 0 : status.type) ?? "complete",
61299
- title: isRunning ? "Creating document..." : "Created document",
61300
- subtitle: createdName || docName || void 0,
61301
- error: errorMsg
61689
+ title: isRunning ? runningLabel : doneLabel,
61690
+ subtitle: createdName || name || void 0,
61691
+ error: errorMsg,
61692
+ children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
61693
+ "button",
61694
+ {
61695
+ onClick: handleOpen,
61696
+ className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
61697
+ children: [
61698
+ /* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
61699
+ "Open ",
61700
+ assetType === "unknown" ? "asset" : assetType
61701
+ ]
61702
+ }
61703
+ ) })
61302
61704
  }
61303
61705
  );
61304
- };
61706
+ }
61707
+ const CreateDocumentToolUIImpl = (props) => /* @__PURE__ */ jsx(
61708
+ CreateAssetToolUIImpl,
61709
+ {
61710
+ icon: FilePlus,
61711
+ assetType: "document",
61712
+ runningLabel: "Creating document...",
61713
+ doneLabel: "Created document",
61714
+ ...props
61715
+ }
61716
+ );
61305
61717
  const CreateDocumentToolUI = memo(
61306
61718
  CreateDocumentToolUIImpl
61307
61719
  );
61308
61720
  CreateDocumentToolUI.displayName = "CreateDocumentToolUI";
61721
+ const CreateSheetToolUIImpl = (props) => /* @__PURE__ */ jsx(
61722
+ CreateAssetToolUIImpl,
61723
+ {
61724
+ icon: ChartColumn,
61725
+ assetType: "spreadsheet",
61726
+ runningLabel: "Creating spreadsheet...",
61727
+ doneLabel: "Created spreadsheet",
61728
+ ...props
61729
+ }
61730
+ );
61731
+ const CreateSheetToolUI = memo(
61732
+ CreateSheetToolUIImpl
61733
+ );
61734
+ CreateSheetToolUI.displayName = "CreateSheetToolUI";
61735
+ const CreatePresentationToolUIImpl = (props) => /* @__PURE__ */ jsx(
61736
+ CreateAssetToolUIImpl,
61737
+ {
61738
+ icon: Presentation,
61739
+ assetType: "presentation",
61740
+ runningLabel: "Creating presentation...",
61741
+ doneLabel: "Created presentation",
61742
+ ...props
61743
+ }
61744
+ );
61745
+ const CreatePresentationToolUI = memo(
61746
+ CreatePresentationToolUIImpl
61747
+ );
61748
+ CreatePresentationToolUI.displayName = "CreatePresentationToolUI";
61309
61749
  const CreateEmailDraftToolUIImpl = ({
61310
61750
  args,
61311
61751
  result,
@@ -61339,7 +61779,10 @@ const TOOL_UI_REGISTRY = {
61339
61779
  create_email_draft: CreateEmailDraftToolUI,
61340
61780
  unified_email_create_draft: CreateEmailDraftToolUI,
61341
61781
  create_new_document: CreateDocumentToolUI,
61342
- create_document_from_markdown: CreateDocumentToolUI
61782
+ create_document_from_markdown: CreateDocumentToolUI,
61783
+ create_new_sheet: CreateSheetToolUI,
61784
+ update_sheet_range: CreateSheetToolUI,
61785
+ create_powerpoint_deck: CreatePresentationToolUI
61343
61786
  };
61344
61787
  const falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
61345
61788
  const cx = clsx;
@@ -61451,14 +61894,7 @@ const TooltipIconButton = forwardRef(
61451
61894
  }
61452
61895
  );
61453
61896
  TooltipIconButton.displayName = "TooltipIconButton";
61454
- const SAMPLE_TOOLS = [
61455
- { id: "search_web", name: "Search Web", description: "Search the internet for information", icon: "🔍", type: "tool" },
61456
- { id: "read_file", name: "Read File", description: "Read contents of a file", icon: "📄", type: "tool" },
61457
- { id: "write_file", name: "Write File", description: "Write contents to a file", icon: "✏️", type: "tool" },
61458
- { id: "run_code", name: "Run Code", description: "Execute code in a sandbox", icon: "▶️", type: "tool" },
61459
- { id: "code_toolkit", name: "Code Toolkit", description: "Full suite of coding tools", icon: "🧰", type: "toolkit" },
61460
- { id: "research_toolkit", name: "Research Toolkit", description: "Research and analysis tools", icon: "📚", type: "toolkit" }
61461
- ];
61897
+ const EMPTY_MENTION_TOOLS = [];
61462
61898
  const AthenaChat = ({
61463
61899
  className,
61464
61900
  welcomeMessage = "Hello there!",
@@ -61467,13 +61903,17 @@ const AthenaChat = ({
61467
61903
  toolUIs,
61468
61904
  mentionTools
61469
61905
  }) => {
61470
- const tools = mentionTools ?? SAMPLE_TOOLS;
61471
- const mergedToolUIs = {
61906
+ const tools = mentionTools ?? EMPTY_MENTION_TOOLS;
61907
+ const mergedToolUIs = useMemo(() => ({
61472
61908
  append_markdown_to_athena_document: AppendDocumentToolUI,
61473
61909
  read_full_asset: ReadAssetToolUI,
61474
61910
  ...TOOL_UI_REGISTRY,
61475
61911
  ...toolUIs
61476
- };
61912
+ }), [toolUIs]);
61913
+ const AssistantMessageComponent = useMemo(
61914
+ () => () => /* @__PURE__ */ jsx(AssistantMessage, { toolUIs: mergedToolUIs }),
61915
+ [mergedToolUIs]
61916
+ );
61477
61917
  return /* @__PURE__ */ jsx(
61478
61918
  ThreadPrimitiveRoot,
61479
61919
  {
@@ -61494,7 +61934,7 @@ const AthenaChat = ({
61494
61934
  {
61495
61935
  components: {
61496
61936
  UserMessage,
61497
- AssistantMessage: () => /* @__PURE__ */ jsx(AssistantMessage, { toolUIs: mergedToolUIs })
61937
+ AssistantMessage: AssistantMessageComponent
61498
61938
  }
61499
61939
  }
61500
61940
  ),
@@ -61623,9 +62063,316 @@ const UserMessage = () => /* @__PURE__ */ jsx(
61623
62063
  children: /* @__PURE__ */ jsx("div", { className: "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground", children: /* @__PURE__ */ jsx(MessagePrimitiveParts, { components: { Text: TiptapText } }) })
61624
62064
  }
61625
62065
  );
62066
+ const embedCache = /* @__PURE__ */ new Map();
62067
+ function useAssetEmbed(assetId, options = {
62068
+ backendUrl: ""
62069
+ }) {
62070
+ const { readOnly = false, expiresInSeconds = 60 * 60 * 24 * 30, backendUrl, apiKey, token } = options;
62071
+ const [embedUrl, setEmbedUrl] = useState(null);
62072
+ const [isLoading, setIsLoading] = useState(false);
62073
+ const [error2, setError] = useState(null);
62074
+ const abortRef = useRef(null);
62075
+ useEffect(() => {
62076
+ var _a2;
62077
+ if (!assetId || !backendUrl) {
62078
+ setEmbedUrl(null);
62079
+ setIsLoading(false);
62080
+ setError(null);
62081
+ return;
62082
+ }
62083
+ const cached = embedCache.get(assetId);
62084
+ if (cached && cached.expiresAt > Date.now() / 1e3) {
62085
+ setEmbedUrl(cached.url);
62086
+ setIsLoading(false);
62087
+ setError(null);
62088
+ return;
62089
+ }
62090
+ const agoraBase = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
62091
+ const endpoint = `${agoraBase}/api/embed/generate-token`;
62092
+ (_a2 = abortRef.current) == null ? void 0 : _a2.abort();
62093
+ const controller = new AbortController();
62094
+ abortRef.current = controller;
62095
+ setIsLoading(true);
62096
+ setError(null);
62097
+ const headers = { "Content-Type": "application/json" };
62098
+ if (token) {
62099
+ headers["Authorization"] = `Bearer ${token}`;
62100
+ } else if (apiKey) {
62101
+ headers["X-API-KEY"] = apiKey;
62102
+ }
62103
+ fetch(endpoint, {
62104
+ method: "POST",
62105
+ headers,
62106
+ body: JSON.stringify({
62107
+ asset_id: assetId,
62108
+ read_only: readOnly,
62109
+ expires_in_seconds: expiresInSeconds
62110
+ }),
62111
+ signal: controller.signal
62112
+ }).then(async (res) => {
62113
+ if (!res.ok) {
62114
+ const text2 = await res.text().catch(() => "");
62115
+ throw new Error(`Failed to generate embed token (${res.status}): ${text2}`);
62116
+ }
62117
+ return res.json();
62118
+ }).then((data) => {
62119
+ embedCache.set(assetId, { url: data.embed_url, expiresAt: data.expires_at });
62120
+ setEmbedUrl(data.embed_url);
62121
+ setIsLoading(false);
62122
+ }).catch((err) => {
62123
+ if (err.name === "AbortError") return;
62124
+ setError(err.message);
62125
+ setIsLoading(false);
62126
+ });
62127
+ return () => controller.abort();
62128
+ }, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, token]);
62129
+ return { embedUrl, isLoading, error: error2 };
62130
+ }
62131
+ const ASSET_TYPE_CONFIG = {
62132
+ presentation: { icon: Presentation, label: "Presentation" },
62133
+ spreadsheet: { icon: FileSpreadsheet, label: "Spreadsheet" },
62134
+ document: { icon: FileText, label: "Document" },
62135
+ unknown: { icon: File$1, label: "Asset" }
62136
+ };
62137
+ const AssetIframe = memo(
62138
+ ({ tabId, tabName }) => {
62139
+ const { backendUrl, apiKey, token } = useAthenaConfig();
62140
+ const { embedUrl, isLoading, error: error2 } = useAssetEmbed(tabId, {
62141
+ backendUrl,
62142
+ apiKey,
62143
+ token
62144
+ });
62145
+ if (isLoading) {
62146
+ return /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
62147
+ /* @__PURE__ */ jsx(LoaderCircle, { className: "mx-auto size-6 animate-spin text-muted-foreground" }),
62148
+ /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: "Loading..." })
62149
+ ] }) });
62150
+ }
62151
+ if (error2) {
62152
+ return /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsxs("div", { className: "max-w-sm text-center", children: [
62153
+ /* @__PURE__ */ jsx(CircleAlert, { className: "mx-auto size-5 text-red-400" }),
62154
+ /* @__PURE__ */ jsx("p", { className: "mt-1.5 text-xs font-medium text-foreground", children: "Failed to load" }),
62155
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 line-clamp-2 break-words text-[10px] text-muted-foreground", children: error2 })
62156
+ ] }) });
62157
+ }
62158
+ if (!embedUrl) return null;
62159
+ return /* @__PURE__ */ jsx(
62160
+ "iframe",
62161
+ {
62162
+ src: embedUrl,
62163
+ width: "100%",
62164
+ height: "100%",
62165
+ frameBorder: "0",
62166
+ allow: "fullscreen",
62167
+ title: tabName ?? `Asset ${tabId}`,
62168
+ className: "h-full w-full"
62169
+ }
62170
+ );
62171
+ }
62172
+ );
62173
+ AssetIframe.displayName = "AssetIframe";
62174
+ const PanelContent = () => {
62175
+ const { tabs, activeTabId, viewMode, closeTab } = useAssetPanelStore();
62176
+ const isTiled = viewMode === "tiled" && tabs.length >= 2;
62177
+ const gridClass = useMemo(() => {
62178
+ const n = tabs.length;
62179
+ if (n <= 1) return "";
62180
+ if (n === 2) return "grid grid-cols-2 grid-rows-1";
62181
+ if (n <= 4) return "grid grid-cols-2 grid-rows-2";
62182
+ if (n <= 6) return "grid grid-cols-3 grid-rows-2";
62183
+ return "grid grid-cols-3 grid-rows-3";
62184
+ }, [tabs.length]);
62185
+ return /* @__PURE__ */ jsx(
62186
+ "div",
62187
+ {
62188
+ className: `flex-1 overflow-hidden ${isTiled ? `${gridClass} gap-px bg-border/60` : ""}`,
62189
+ children: tabs.map((tab) => {
62190
+ const isActive2 = tab.id === activeTabId;
62191
+ const config2 = ASSET_TYPE_CONFIG[tab.type];
62192
+ const TypeIcon = config2.icon;
62193
+ if (isTiled) {
62194
+ return /* @__PURE__ */ jsxs(
62195
+ "div",
62196
+ {
62197
+ className: "flex min-h-0 min-w-0 flex-col bg-background",
62198
+ children: [
62199
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5 border-b px-2 py-1", children: [
62200
+ /* @__PURE__ */ jsx(TypeIcon, { className: "size-3 shrink-0 text-muted-foreground" }),
62201
+ /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-[11px] font-medium text-foreground", children: tab.name ?? config2.label }),
62202
+ /* @__PURE__ */ jsx(
62203
+ "button",
62204
+ {
62205
+ onClick: () => closeTab(tab.id),
62206
+ className: "shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
62207
+ children: /* @__PURE__ */ jsx(X, { className: "size-2.5" })
62208
+ }
62209
+ )
62210
+ ] }),
62211
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(AssetIframe, { tabId: tab.id, tabName: tab.name }) })
62212
+ ]
62213
+ },
62214
+ tab.id
62215
+ );
62216
+ }
62217
+ return /* @__PURE__ */ jsx(
62218
+ "div",
62219
+ {
62220
+ className: isActive2 ? "h-full w-full" : "hidden",
62221
+ children: /* @__PURE__ */ jsx(AssetIframe, { tabId: tab.id, tabName: tab.name })
62222
+ },
62223
+ tab.id
62224
+ );
62225
+ })
62226
+ }
62227
+ );
62228
+ };
62229
+ const TabBar = () => {
62230
+ const { tabs, activeTabId, setActiveTab, closeTab, viewMode } = useAssetPanelStore();
62231
+ if (tabs.length <= 1 || viewMode === "tiled") return null;
62232
+ return /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-0 overflow-x-auto border-b bg-muted/30", children: tabs.map((tab) => {
62233
+ const config2 = ASSET_TYPE_CONFIG[tab.type];
62234
+ const TypeIcon = config2.icon;
62235
+ const isActive2 = tab.id === activeTabId;
62236
+ return /* @__PURE__ */ jsxs(
62237
+ "div",
62238
+ {
62239
+ 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"}`,
62240
+ onClick: () => setActiveTab(tab.id),
62241
+ children: [
62242
+ /* @__PURE__ */ jsx(TypeIcon, { className: "size-3 shrink-0" }),
62243
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: tab.name ?? config2.label }),
62244
+ /* @__PURE__ */ jsx(
62245
+ "button",
62246
+ {
62247
+ onClick: (e) => {
62248
+ e.stopPropagation();
62249
+ closeTab(tab.id);
62250
+ },
62251
+ className: "ml-auto shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:bg-muted group-hover:opacity-100",
62252
+ children: /* @__PURE__ */ jsx(X, { className: "size-2.5" })
62253
+ }
62254
+ )
62255
+ ]
62256
+ },
62257
+ tab.id
62258
+ );
62259
+ }) });
62260
+ };
62261
+ const PanelHeader = ({ fullscreen }) => {
62262
+ const {
62263
+ closePanel,
62264
+ toggleFullscreen,
62265
+ tabs,
62266
+ activeTabId,
62267
+ viewMode,
62268
+ setViewMode
62269
+ } = useAssetPanelStore();
62270
+ const activeTab = tabs.find((t) => t.id === activeTabId);
62271
+ const config2 = ASSET_TYPE_CONFIG[(activeTab == null ? void 0 : activeTab.type) ?? "unknown"];
62272
+ const TypeIcon = config2.icon;
62273
+ const isTiled = viewMode === "tiled";
62274
+ return /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2 border-b px-4 py-2.5", children: [
62275
+ !isTiled && /* @__PURE__ */ jsx(TypeIcon, { className: "size-4 shrink-0 text-muted-foreground" }),
62276
+ /* @__PURE__ */ jsx("p", { className: "flex-1 truncate text-sm font-semibold text-foreground", children: isTiled ? `${tabs.length} Assets` : (activeTab == null ? void 0 : activeTab.name) ?? config2.label }),
62277
+ tabs.length >= 2 && /* @__PURE__ */ jsx(
62278
+ "button",
62279
+ {
62280
+ onClick: () => setViewMode(isTiled ? "tabs" : "tiled"),
62281
+ 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"}`,
62282
+ title: isTiled ? "Switch to tabs" : "Tile all assets",
62283
+ children: isTiled ? /* @__PURE__ */ jsx(Layers, { className: "size-3.5" }) : /* @__PURE__ */ jsx(LayoutGrid, { className: "size-3.5" })
62284
+ }
62285
+ ),
62286
+ /* @__PURE__ */ jsx(
62287
+ "button",
62288
+ {
62289
+ onClick: toggleFullscreen,
62290
+ className: "flex size-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
62291
+ title: fullscreen ? "Exit fullscreen" : "Fullscreen",
62292
+ children: fullscreen ? /* @__PURE__ */ jsx(Minimize2, { className: "size-3.5" }) : /* @__PURE__ */ jsx(Maximize2, { className: "size-3.5" })
62293
+ }
62294
+ ),
62295
+ /* @__PURE__ */ jsx(
62296
+ "button",
62297
+ {
62298
+ onClick: closePanel,
62299
+ className: "flex size-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
62300
+ title: "Close all",
62301
+ children: /* @__PURE__ */ jsx(X, { className: "size-4" })
62302
+ }
62303
+ )
62304
+ ] });
62305
+ };
62306
+ const AssetPanel = () => {
62307
+ const isFullscreen = useAssetPanelStore((s) => s.isFullscreen);
62308
+ const content = /* @__PURE__ */ jsxs(Fragment$2, { children: [
62309
+ /* @__PURE__ */ jsx(PanelHeader, { fullscreen: isFullscreen }),
62310
+ /* @__PURE__ */ jsx(TabBar, {}),
62311
+ /* @__PURE__ */ jsx(PanelContent, {})
62312
+ ] });
62313
+ if (isFullscreen) {
62314
+ return /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-50 flex flex-col bg-background", children: content });
62315
+ }
62316
+ return /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col bg-background", children: content });
62317
+ };
62318
+ const AthenaLayout = ({
62319
+ children,
62320
+ defaultChatPercent = 50,
62321
+ minPercent = 25
62322
+ }) => {
62323
+ const isOpen = useAssetPanelStore((s) => s.isOpen);
62324
+ const [chatPercent, setChatPercent] = useState(defaultChatPercent);
62325
+ const containerRef = useRef(null);
62326
+ const dragging = useRef(false);
62327
+ const onPointerDown = useCallback(
62328
+ (e) => {
62329
+ e.preventDefault();
62330
+ dragging.current = true;
62331
+ e.target.setPointerCapture(e.pointerId);
62332
+ },
62333
+ []
62334
+ );
62335
+ const onPointerMove = useCallback(
62336
+ (e) => {
62337
+ if (!dragging.current || !containerRef.current) return;
62338
+ const rect = containerRef.current.getBoundingClientRect();
62339
+ const pct = (e.clientX - rect.left) / rect.width * 100;
62340
+ setChatPercent(Math.max(minPercent, Math.min(100 - minPercent, pct)));
62341
+ },
62342
+ [minPercent]
62343
+ );
62344
+ const onPointerUp = useCallback(() => {
62345
+ dragging.current = false;
62346
+ }, []);
62347
+ if (!isOpen) {
62348
+ return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full flex-col", children });
62349
+ }
62350
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "flex h-full w-full", children: [
62351
+ /* @__PURE__ */ jsx(
62352
+ "div",
62353
+ {
62354
+ className: "flex h-full flex-col overflow-hidden",
62355
+ style: { width: `${chatPercent}%` },
62356
+ children
62357
+ }
62358
+ ),
62359
+ /* @__PURE__ */ jsx(
62360
+ "div",
62361
+ {
62362
+ className: "flex h-full w-1 shrink-0 cursor-col-resize items-center bg-border/40 transition-colors hover:bg-border active:bg-primary/30",
62363
+ onPointerDown,
62364
+ onPointerMove,
62365
+ onPointerUp
62366
+ }
62367
+ ),
62368
+ /* @__PURE__ */ jsx("div", { className: "flex h-full flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx(AssetPanel, {}) })
62369
+ ] });
62370
+ };
61626
62371
  export {
61627
62372
  AppendDocumentToolUI,
62373
+ AssetPanel,
61628
62374
  AthenaChat,
62375
+ AthenaLayout,
61629
62376
  AthenaProvider,
61630
62377
  BrowseToolUI,
61631
62378
  Button,
@@ -61634,6 +62381,9 @@ export {
61634
62381
  CollapsibleTrigger,
61635
62382
  CreateDocumentToolUI,
61636
62383
  CreateEmailDraftToolUI,
62384
+ CreatePresentationToolUI,
62385
+ CreateSheetToolUI,
62386
+ DEFAULT_BACKEND_URL,
61637
62387
  EmailSearchToolUI,
61638
62388
  ReadAssetToolUI,
61639
62389
  TOOL_UI_REGISTRY,
@@ -61653,9 +62403,14 @@ export {
61653
62403
  TooltipTrigger,
61654
62404
  WebSearchToolUI,
61655
62405
  buttonVariants,
62406
+ clearAutoOpenedAssets,
61656
62407
  cn,
61657
62408
  getAssetInfo,
62409
+ resetAssetAutoOpen,
61658
62410
  tryParseJson$1 as tryParseJson,
62411
+ useAssetEmbed,
62412
+ useAssetPanelStore,
62413
+ useAthenaConfig,
61659
62414
  useAthenaRuntime,
61660
62415
  useMentionSuggestions,
61661
62416
  useParentAuth