@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.cjs CHANGED
@@ -6434,10 +6434,10 @@ class ThreadMessageConverter {
6434
6434
  constructor() {
6435
6435
  __publicField(this, "cache", /* @__PURE__ */ new WeakMap());
6436
6436
  }
6437
- convertMessages(messages, converter2) {
6437
+ convertMessages(messages, converter) {
6438
6438
  return messages.map((m, idx) => {
6439
6439
  const cached = this.cache.get(m);
6440
- const newMessage = converter2(cached, m, idx);
6440
+ const newMessage = converter(cached, m, idx);
6441
6441
  this.cache.set(m, newMessage);
6442
6442
  return newMessage;
6443
6443
  });
@@ -9091,8 +9091,8 @@ function useRunManager(config2) {
9091
9091
  cancel
9092
9092
  };
9093
9093
  }
9094
- function useConvertedState(converter2, agentState, pendingCommands, isSending, toolStatuses) {
9095
- return React.useMemo(() => converter2(agentState, { pendingCommands, isSending, toolStatuses }), [converter2, agentState, pendingCommands, isSending, toolStatuses]);
9094
+ function useConvertedState(converter, agentState, pendingCommands, isSending, toolStatuses) {
9095
+ return React.useMemo(() => converter(agentState, { pendingCommands, isSending, toolStatuses }), [converter, agentState, pendingCommands, isSending, toolStatuses]);
9096
9096
  }
9097
9097
  const convertAppendMessageToCommand = (message) => {
9098
9098
  var _a2;
@@ -20593,7 +20593,6 @@ const safeStringify = (value) => {
20593
20593
  return "[Unable to serialize tool result]";
20594
20594
  }
20595
20595
  };
20596
- const optimisticMessageCache = /* @__PURE__ */ new Map();
20597
20596
  const commandsToMessages = (commands) => {
20598
20597
  return commands.flatMap((c) => {
20599
20598
  if (c.type === "add-message") {
@@ -20638,7 +20637,7 @@ const getTrackingIdFromMessage = (msg) => {
20638
20637
  }
20639
20638
  return void 0;
20640
20639
  };
20641
- const converter = (state, connectionMetadata) => {
20640
+ const createConverter = (optimisticMessageCache) => (state, connectionMetadata) => {
20642
20641
  const validatedState = parseLangGraphState(state);
20643
20642
  const backendTrackingIds = /* @__PURE__ */ new Set();
20644
20643
  for (const msg of validatedState.messages) {
@@ -20755,6 +20754,8 @@ const useAthenaRuntime = (config2) => {
20755
20754
  () => Array.from(/* @__PURE__ */ new Set([...tools, ...frontendToolIds])),
20756
20755
  [tools, frontendToolIds]
20757
20756
  );
20757
+ const optimisticMessageCache = React.useRef(/* @__PURE__ */ new Map()).current;
20758
+ const converter = React.useMemo(() => createConverter(optimisticMessageCache), [optimisticMessageCache]);
20758
20759
  const tokenRef = React.useRef(token);
20759
20760
  tokenRef.current = token;
20760
20761
  const apiKeyRef = React.useRef(apiKey);
@@ -20770,49 +20771,57 @@ const useAthenaRuntime = (config2) => {
20770
20771
  Accept: "text/event-stream"
20771
20772
  }),
20772
20773
  onResponse: () => {
20773
- console.log("[AthenaSDK] Stream connected");
20774
+ if (process.env.NODE_ENV !== "production") {
20775
+ console.log("[AthenaSDK] Stream connected");
20776
+ }
20774
20777
  },
20775
20778
  onFinish: () => {
20776
- console.log("[AthenaSDK] Stream completed");
20779
+ if (process.env.NODE_ENV !== "production") {
20780
+ console.log("[AthenaSDK] Stream completed");
20781
+ }
20777
20782
  },
20778
20783
  onError: (error2, { commands, updateState }) => {
20779
20784
  const pendingCommands = commandsToMessages(commands);
20780
20785
  const isInvalidStringLength = error2 instanceof RangeError && /Invalid string length/i.test(error2.message);
20781
20786
  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;
20782
20787
  updateState((state) => {
20783
- const newState = {
20784
- ...state,
20785
- messages: [...state.messages, ...pendingCommands]
20786
- };
20787
- const lastAssistantMessage = newState.messages.filter((m) => m.type === "ai").at(-1);
20788
- if (lastAssistantMessage) {
20789
- lastAssistantMessage.status = {
20790
- type: "incomplete",
20791
- reason: "error",
20792
- error: userErrorMessage
20788
+ const messages = [...state.messages, ...pendingCommands];
20789
+ const lastAiIdx = messages.findLastIndex((m) => m.type === "ai");
20790
+ if (lastAiIdx !== -1) {
20791
+ messages[lastAiIdx] = {
20792
+ ...messages[lastAiIdx],
20793
+ status: {
20794
+ type: "incomplete",
20795
+ reason: "error",
20796
+ error: userErrorMessage
20797
+ }
20793
20798
  };
20794
20799
  }
20795
- return newState;
20800
+ return { ...state, messages };
20796
20801
  });
20797
- console.error("[AthenaSDK] Error:", error2.message);
20802
+ if (process.env.NODE_ENV !== "production") {
20803
+ console.error("[AthenaSDK] Error:", error2.message);
20804
+ }
20798
20805
  },
20799
20806
  onCancel: async ({ commands, updateState }) => {
20800
20807
  const pendingCommands = commandsToMessages(commands);
20801
20808
  updateState((state) => {
20802
- const newState = {
20803
- ...state,
20804
- messages: [...state.messages, ...pendingCommands]
20805
- };
20806
- const lastAssistantMessage = newState.messages.filter((m) => m.type === "ai").at(-1);
20807
- if (lastAssistantMessage) {
20808
- lastAssistantMessage.status = {
20809
- type: "incomplete",
20810
- reason: "cancelled"
20809
+ const messages = [...state.messages, ...pendingCommands];
20810
+ const lastAiIdx = messages.findLastIndex((m) => m.type === "ai");
20811
+ if (lastAiIdx !== -1) {
20812
+ messages[lastAiIdx] = {
20813
+ ...messages[lastAiIdx],
20814
+ status: {
20815
+ type: "incomplete",
20816
+ reason: "cancelled"
20817
+ }
20811
20818
  };
20812
20819
  }
20813
- return newState;
20820
+ return { ...state, messages };
20814
20821
  });
20815
- console.log("[AthenaSDK] Cancelled");
20822
+ if (process.env.NODE_ENV !== "production") {
20823
+ console.log("[AthenaSDK] Cancelled");
20824
+ }
20816
20825
  },
20817
20826
  capabilities: {
20818
20827
  edit: false
@@ -20857,10 +20866,7 @@ const useAthenaRuntime = (config2) => {
20857
20866
  },
20858
20867
  get threadId() {
20859
20868
  return threadId;
20860
- },
20861
- credentials: "include",
20862
- mode: "cors",
20863
- cache: "no-store"
20869
+ }
20864
20870
  }
20865
20871
  });
20866
20872
  return runtime;
@@ -24088,6 +24094,14 @@ function TooltipContent({
24088
24094
  }
24089
24095
  ) });
24090
24096
  }
24097
+ const AthenaContext = React.createContext(null);
24098
+ function useAthenaConfig() {
24099
+ const ctx = React.useContext(AthenaContext);
24100
+ if (!ctx) {
24101
+ throw new Error("[AthenaSDK] useAthenaConfig must be used within <AthenaProvider>");
24102
+ }
24103
+ return ctx;
24104
+ }
24091
24105
  function AthenaProvider({
24092
24106
  children,
24093
24107
  apiKey,
@@ -24103,15 +24117,16 @@ function AthenaProvider({
24103
24117
  systemPrompt,
24104
24118
  threadId
24105
24119
  }) {
24106
- const frontendToolNames = Object.keys(frontendTools);
24120
+ const frontendToolNames = React.useMemo(() => Object.keys(frontendTools), [frontendTools]);
24107
24121
  const aui = useAui({
24108
24122
  tools: Tools({ toolkit: frontendTools })
24109
24123
  });
24110
24124
  const parentAuthToken = useParentAuth();
24111
24125
  const effectiveToken = tokenProp ?? parentAuthToken;
24126
+ const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
24112
24127
  const runtime = useAthenaRuntime({
24113
24128
  apiUrl,
24114
- backendUrl,
24129
+ backendUrl: effectiveBackendUrl,
24115
24130
  apiKey,
24116
24131
  token: effectiveToken,
24117
24132
  model,
@@ -24123,7 +24138,11 @@ function AthenaProvider({
24123
24138
  systemPrompt,
24124
24139
  threadId
24125
24140
  });
24126
- return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) });
24141
+ const athenaConfig = React.useMemo(
24142
+ () => ({ backendUrl: effectiveBackendUrl, apiKey, token: effectiveToken }),
24143
+ [effectiveBackendUrl, apiKey, effectiveToken]
24144
+ );
24145
+ return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
24127
24146
  }
24128
24147
  function OrderedMap(content) {
24129
24148
  this.content = content;
@@ -59564,7 +59583,7 @@ function useMentionSuggestions(tools) {
59564
59583
  addItems(cache, items, "root");
59565
59584
  return new Store({ registry, cache });
59566
59585
  }, []);
59567
- React.useMemo(() => {
59586
+ React.useEffect(() => {
59568
59587
  const { cache } = store.state;
59569
59588
  for (const item of cache.items.values()) {
59570
59589
  item.visibleInScopes.delete("root");
@@ -59726,6 +59745,9 @@ const MentionSuggestionsExtension = Extension.create({
59726
59745
  };
59727
59746
  },
59728
59747
  addProseMirrorPlugins() {
59748
+ if (!this.options.store) {
59749
+ throw new Error("[MentionSuggestionsExtension] A `store` option is required.");
59750
+ }
59729
59751
  return [
59730
59752
  index_default({
59731
59753
  editor: this.editor,
@@ -60025,29 +60047,29 @@ const createLucideIcon = (iconName, iconNode) => {
60025
60047
  * This source code is licensed under the ISC license.
60026
60048
  * See the LICENSE file in the root directory of this source tree.
60027
60049
  */
60028
- const __iconNode$s = [
60050
+ const __iconNode$B = [
60029
60051
  ["path", { d: "M12 5v14", key: "s699le" }],
60030
60052
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
60031
60053
  ];
60032
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$s);
60054
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$B);
60033
60055
  /**
60034
60056
  * @license lucide-react v0.575.0 - ISC
60035
60057
  *
60036
60058
  * This source code is licensed under the ISC license.
60037
60059
  * See the LICENSE file in the root directory of this source tree.
60038
60060
  */
60039
- const __iconNode$r = [
60061
+ const __iconNode$A = [
60040
60062
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
60041
60063
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
60042
60064
  ];
60043
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$r);
60065
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$A);
60044
60066
  /**
60045
60067
  * @license lucide-react v0.575.0 - ISC
60046
60068
  *
60047
60069
  * This source code is licensed under the ISC license.
60048
60070
  * See the LICENSE file in the root directory of this source tree.
60049
60071
  */
60050
- const __iconNode$q = [
60072
+ const __iconNode$z = [
60051
60073
  ["path", { d: "M12 7v14", key: "1akyts" }],
60052
60074
  [
60053
60075
  "path",
@@ -60057,14 +60079,14 @@ const __iconNode$q = [
60057
60079
  }
60058
60080
  ]
60059
60081
  ];
60060
- const BookOpen = createLucideIcon("book-open", __iconNode$q);
60082
+ const BookOpen = createLucideIcon("book-open", __iconNode$z);
60061
60083
  /**
60062
60084
  * @license lucide-react v0.575.0 - ISC
60063
60085
  *
60064
60086
  * This source code is licensed under the ISC license.
60065
60087
  * See the LICENSE file in the root directory of this source tree.
60066
60088
  */
60067
- const __iconNode$p = [
60089
+ const __iconNode$y = [
60068
60090
  ["path", { d: "M12 18V5", key: "adv99a" }],
60069
60091
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
60070
60092
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -60074,148 +60096,148 @@ const __iconNode$p = [
60074
60096
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
60075
60097
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
60076
60098
  ];
60077
- const Brain = createLucideIcon("brain", __iconNode$p);
60099
+ const Brain = createLucideIcon("brain", __iconNode$y);
60078
60100
  /**
60079
60101
  * @license lucide-react v0.575.0 - ISC
60080
60102
  *
60081
60103
  * This source code is licensed under the ISC license.
60082
60104
  * See the LICENSE file in the root directory of this source tree.
60083
60105
  */
60084
- const __iconNode$o = [
60106
+ const __iconNode$x = [
60085
60107
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
60086
60108
  ["path", { d: "M18 17V9", key: "2bz60n" }],
60087
60109
  ["path", { d: "M13 17V5", key: "1frdt8" }],
60088
60110
  ["path", { d: "M8 17v-3", key: "17ska0" }]
60089
60111
  ];
60090
- const ChartColumn = createLucideIcon("chart-column", __iconNode$o);
60112
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$x);
60091
60113
  /**
60092
60114
  * @license lucide-react v0.575.0 - ISC
60093
60115
  *
60094
60116
  * This source code is licensed under the ISC license.
60095
60117
  * See the LICENSE file in the root directory of this source tree.
60096
60118
  */
60097
- const __iconNode$n = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60098
- const Check = createLucideIcon("check", __iconNode$n);
60119
+ const __iconNode$w = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60120
+ const Check = createLucideIcon("check", __iconNode$w);
60099
60121
  /**
60100
60122
  * @license lucide-react v0.575.0 - ISC
60101
60123
  *
60102
60124
  * This source code is licensed under the ISC license.
60103
60125
  * See the LICENSE file in the root directory of this source tree.
60104
60126
  */
60105
- const __iconNode$m = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60106
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$m);
60127
+ const __iconNode$v = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60128
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$v);
60107
60129
  /**
60108
60130
  * @license lucide-react v0.575.0 - ISC
60109
60131
  *
60110
60132
  * This source code is licensed under the ISC license.
60111
60133
  * See the LICENSE file in the root directory of this source tree.
60112
60134
  */
60113
- const __iconNode$l = [
60135
+ const __iconNode$u = [
60114
60136
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60115
60137
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
60116
60138
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
60117
60139
  ];
60118
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$l);
60140
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$u);
60119
60141
  /**
60120
60142
  * @license lucide-react v0.575.0 - ISC
60121
60143
  *
60122
60144
  * This source code is licensed under the ISC license.
60123
60145
  * See the LICENSE file in the root directory of this source tree.
60124
60146
  */
60125
- const __iconNode$k = [
60147
+ const __iconNode$t = [
60126
60148
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60127
60149
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
60128
60150
  ];
60129
- const CircleCheck = createLucideIcon("circle-check", __iconNode$k);
60151
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$t);
60130
60152
  /**
60131
60153
  * @license lucide-react v0.575.0 - ISC
60132
60154
  *
60133
60155
  * This source code is licensed under the ISC license.
60134
60156
  * See the LICENSE file in the root directory of this source tree.
60135
60157
  */
60136
- const __iconNode$j = [
60158
+ const __iconNode$s = [
60137
60159
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60138
60160
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
60139
60161
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
60140
60162
  ];
60141
- const CircleX = createLucideIcon("circle-x", __iconNode$j);
60163
+ const CircleX = createLucideIcon("circle-x", __iconNode$s);
60142
60164
  /**
60143
60165
  * @license lucide-react v0.575.0 - ISC
60144
60166
  *
60145
60167
  * This source code is licensed under the ISC license.
60146
60168
  * See the LICENSE file in the root directory of this source tree.
60147
60169
  */
60148
- const __iconNode$i = [
60170
+ const __iconNode$r = [
60149
60171
  ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
60150
60172
  ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
60151
60173
  ];
60152
- const Code = createLucideIcon("code", __iconNode$i);
60174
+ const Code = createLucideIcon("code", __iconNode$r);
60153
60175
  /**
60154
60176
  * @license lucide-react v0.575.0 - ISC
60155
60177
  *
60156
60178
  * This source code is licensed under the ISC license.
60157
60179
  * See the LICENSE file in the root directory of this source tree.
60158
60180
  */
60159
- const __iconNode$h = [
60181
+ const __iconNode$q = [
60160
60182
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
60161
60183
  ["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" }]
60162
60184
  ];
60163
- const Copy = createLucideIcon("copy", __iconNode$h);
60185
+ const Copy = createLucideIcon("copy", __iconNode$q);
60164
60186
  /**
60165
60187
  * @license lucide-react v0.575.0 - ISC
60166
60188
  *
60167
60189
  * This source code is licensed under the ISC license.
60168
60190
  * See the LICENSE file in the root directory of this source tree.
60169
60191
  */
60170
- const __iconNode$g = [
60192
+ const __iconNode$p = [
60171
60193
  ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
60172
60194
  ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
60173
60195
  ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
60174
60196
  ];
60175
- const Database = createLucideIcon("database", __iconNode$g);
60197
+ const Database = createLucideIcon("database", __iconNode$p);
60176
60198
  /**
60177
60199
  * @license lucide-react v0.575.0 - ISC
60178
60200
  *
60179
60201
  * This source code is licensed under the ISC license.
60180
60202
  * See the LICENSE file in the root directory of this source tree.
60181
60203
  */
60182
- const __iconNode$f = [
60204
+ const __iconNode$o = [
60183
60205
  ["path", { d: "M12 15V3", key: "m9g1x1" }],
60184
60206
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
60185
60207
  ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
60186
60208
  ];
60187
- const Download = createLucideIcon("download", __iconNode$f);
60209
+ const Download = createLucideIcon("download", __iconNode$o);
60188
60210
  /**
60189
60211
  * @license lucide-react v0.575.0 - ISC
60190
60212
  *
60191
60213
  * This source code is licensed under the ISC license.
60192
60214
  * See the LICENSE file in the root directory of this source tree.
60193
60215
  */
60194
- const __iconNode$e = [
60216
+ const __iconNode$n = [
60195
60217
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
60196
60218
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
60197
60219
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
60198
60220
  ];
60199
- const Ellipsis = createLucideIcon("ellipsis", __iconNode$e);
60221
+ const Ellipsis = createLucideIcon("ellipsis", __iconNode$n);
60200
60222
  /**
60201
60223
  * @license lucide-react v0.575.0 - ISC
60202
60224
  *
60203
60225
  * This source code is licensed under the ISC license.
60204
60226
  * See the LICENSE file in the root directory of this source tree.
60205
60227
  */
60206
- const __iconNode$d = [
60228
+ const __iconNode$m = [
60207
60229
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60208
60230
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
60209
60231
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
60210
60232
  ];
60211
- const ExternalLink = createLucideIcon("external-link", __iconNode$d);
60233
+ const ExternalLink = createLucideIcon("external-link", __iconNode$m);
60212
60234
  /**
60213
60235
  * @license lucide-react v0.575.0 - ISC
60214
60236
  *
60215
60237
  * This source code is licensed under the ISC license.
60216
60238
  * See the LICENSE file in the root directory of this source tree.
60217
60239
  */
60218
- const __iconNode$c = [
60240
+ const __iconNode$l = [
60219
60241
  [
60220
60242
  "path",
60221
60243
  {
@@ -60227,14 +60249,35 @@ const __iconNode$c = [
60227
60249
  ["path", { d: "M9 15h6", key: "cctwl0" }],
60228
60250
  ["path", { d: "M12 18v-6", key: "17g6i2" }]
60229
60251
  ];
60230
- const FilePlus = createLucideIcon("file-plus", __iconNode$c);
60252
+ const FilePlus = createLucideIcon("file-plus", __iconNode$l);
60231
60253
  /**
60232
60254
  * @license lucide-react v0.575.0 - ISC
60233
60255
  *
60234
60256
  * This source code is licensed under the ISC license.
60235
60257
  * See the LICENSE file in the root directory of this source tree.
60236
60258
  */
60237
- const __iconNode$b = [
60259
+ const __iconNode$k = [
60260
+ [
60261
+ "path",
60262
+ {
60263
+ 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",
60264
+ key: "1oefj6"
60265
+ }
60266
+ ],
60267
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
60268
+ ["path", { d: "M8 13h2", key: "yr2amv" }],
60269
+ ["path", { d: "M14 13h2", key: "un5t4a" }],
60270
+ ["path", { d: "M8 17h2", key: "2yhykz" }],
60271
+ ["path", { d: "M14 17h2", key: "10kma7" }]
60272
+ ];
60273
+ const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$k);
60274
+ /**
60275
+ * @license lucide-react v0.575.0 - ISC
60276
+ *
60277
+ * This source code is licensed under the ISC license.
60278
+ * See the LICENSE file in the root directory of this source tree.
60279
+ */
60280
+ const __iconNode$j = [
60238
60281
  [
60239
60282
  "path",
60240
60283
  {
@@ -60247,26 +60290,94 @@ const __iconNode$b = [
60247
60290
  ["path", { d: "M16 13H8", key: "t4e002" }],
60248
60291
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
60249
60292
  ];
60250
- const FileText = createLucideIcon("file-text", __iconNode$b);
60293
+ const FileText = createLucideIcon("file-text", __iconNode$j);
60251
60294
  /**
60252
60295
  * @license lucide-react v0.575.0 - ISC
60253
60296
  *
60254
60297
  * This source code is licensed under the ISC license.
60255
60298
  * See the LICENSE file in the root directory of this source tree.
60256
60299
  */
60257
- const __iconNode$a = [
60300
+ const __iconNode$i = [
60301
+ [
60302
+ "path",
60303
+ {
60304
+ 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",
60305
+ key: "1oefj6"
60306
+ }
60307
+ ],
60308
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
60309
+ ];
60310
+ const File$1 = createLucideIcon("file", __iconNode$i);
60311
+ /**
60312
+ * @license lucide-react v0.575.0 - ISC
60313
+ *
60314
+ * This source code is licensed under the ISC license.
60315
+ * See the LICENSE file in the root directory of this source tree.
60316
+ */
60317
+ const __iconNode$h = [
60258
60318
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60259
60319
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
60260
60320
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
60261
60321
  ];
60262
- const Globe = createLucideIcon("globe", __iconNode$a);
60322
+ const Globe = createLucideIcon("globe", __iconNode$h);
60263
60323
  /**
60264
60324
  * @license lucide-react v0.575.0 - ISC
60265
60325
  *
60266
60326
  * This source code is licensed under the ISC license.
60267
60327
  * See the LICENSE file in the root directory of this source tree.
60268
60328
  */
60269
- const __iconNode$9 = [
60329
+ const __iconNode$g = [
60330
+ [
60331
+ "path",
60332
+ {
60333
+ 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",
60334
+ key: "zw3jo"
60335
+ }
60336
+ ],
60337
+ [
60338
+ "path",
60339
+ {
60340
+ 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",
60341
+ key: "1wduqc"
60342
+ }
60343
+ ],
60344
+ [
60345
+ "path",
60346
+ {
60347
+ 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",
60348
+ key: "kqbvx6"
60349
+ }
60350
+ ]
60351
+ ];
60352
+ const Layers = createLucideIcon("layers", __iconNode$g);
60353
+ /**
60354
+ * @license lucide-react v0.575.0 - ISC
60355
+ *
60356
+ * This source code is licensed under the ISC license.
60357
+ * See the LICENSE file in the root directory of this source tree.
60358
+ */
60359
+ const __iconNode$f = [
60360
+ ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
60361
+ ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
60362
+ ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
60363
+ ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
60364
+ ];
60365
+ const LayoutGrid = createLucideIcon("layout-grid", __iconNode$f);
60366
+ /**
60367
+ * @license lucide-react v0.575.0 - ISC
60368
+ *
60369
+ * This source code is licensed under the ISC license.
60370
+ * See the LICENSE file in the root directory of this source tree.
60371
+ */
60372
+ const __iconNode$e = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60373
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$e);
60374
+ /**
60375
+ * @license lucide-react v0.575.0 - ISC
60376
+ *
60377
+ * This source code is licensed under the ISC license.
60378
+ * See the LICENSE file in the root directory of this source tree.
60379
+ */
60380
+ const __iconNode$d = [
60270
60381
  ["path", { d: "M12 2v4", key: "3427ic" }],
60271
60382
  ["path", { d: "m16.2 7.8 2.9-2.9", key: "r700ao" }],
60272
60383
  ["path", { d: "M18 12h4", key: "wj9ykh" }],
@@ -60276,37 +60387,63 @@ const __iconNode$9 = [
60276
60387
  ["path", { d: "M2 12h4", key: "j09sii" }],
60277
60388
  ["path", { d: "m4.9 4.9 2.9 2.9", key: "giyufr" }]
60278
60389
  ];
60279
- const Loader = createLucideIcon("loader", __iconNode$9);
60390
+ const Loader = createLucideIcon("loader", __iconNode$d);
60280
60391
  /**
60281
60392
  * @license lucide-react v0.575.0 - ISC
60282
60393
  *
60283
60394
  * This source code is licensed under the ISC license.
60284
60395
  * See the LICENSE file in the root directory of this source tree.
60285
60396
  */
60286
- const __iconNode$8 = [
60397
+ const __iconNode$c = [
60287
60398
  ["path", { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7", key: "132q7q" }],
60288
60399
  ["rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", key: "izxlao" }]
60289
60400
  ];
60290
- const Mail = createLucideIcon("mail", __iconNode$8);
60401
+ const Mail = createLucideIcon("mail", __iconNode$c);
60291
60402
  /**
60292
60403
  * @license lucide-react v0.575.0 - ISC
60293
60404
  *
60294
60405
  * This source code is licensed under the ISC license.
60295
60406
  * See the LICENSE file in the root directory of this source tree.
60296
60407
  */
60297
- const __iconNode$7 = [
60408
+ const __iconNode$b = [
60409
+ ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60410
+ ["path", { d: "m21 3-7 7", key: "1l2asr" }],
60411
+ ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60412
+ ["path", { d: "M9 21H3v-6", key: "wtvkvv" }]
60413
+ ];
60414
+ const Maximize2 = createLucideIcon("maximize-2", __iconNode$b);
60415
+ /**
60416
+ * @license lucide-react v0.575.0 - ISC
60417
+ *
60418
+ * This source code is licensed under the ISC license.
60419
+ * See the LICENSE file in the root directory of this source tree.
60420
+ */
60421
+ const __iconNode$a = [
60422
+ ["path", { d: "m14 10 7-7", key: "oa77jy" }],
60423
+ ["path", { d: "M20 10h-6V4", key: "mjg0md" }],
60424
+ ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60425
+ ["path", { d: "M4 14h6v6", key: "rmj7iw" }]
60426
+ ];
60427
+ const Minimize2 = createLucideIcon("minimize-2", __iconNode$a);
60428
+ /**
60429
+ * @license lucide-react v0.575.0 - ISC
60430
+ *
60431
+ * This source code is licensed under the ISC license.
60432
+ * See the LICENSE file in the root directory of this source tree.
60433
+ */
60434
+ const __iconNode$9 = [
60298
60435
  ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
60299
60436
  ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
60300
60437
  ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
60301
60438
  ];
60302
- const Monitor = createLucideIcon("monitor", __iconNode$7);
60439
+ const Monitor = createLucideIcon("monitor", __iconNode$9);
60303
60440
  /**
60304
60441
  * @license lucide-react v0.575.0 - ISC
60305
60442
  *
60306
60443
  * This source code is licensed under the ISC license.
60307
60444
  * See the LICENSE file in the root directory of this source tree.
60308
60445
  */
60309
- const __iconNode$6 = [
60446
+ const __iconNode$8 = [
60310
60447
  ["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" }],
60311
60448
  ["path", { d: "M2 6h4", key: "aawbzj" }],
60312
60449
  ["path", { d: "M2 10h4", key: "l0bgd4" }],
@@ -60320,14 +60457,14 @@ const __iconNode$6 = [
60320
60457
  }
60321
60458
  ]
60322
60459
  ];
60323
- const NotebookPen = createLucideIcon("notebook-pen", __iconNode$6);
60460
+ const NotebookPen = createLucideIcon("notebook-pen", __iconNode$8);
60324
60461
  /**
60325
60462
  * @license lucide-react v0.575.0 - ISC
60326
60463
  *
60327
60464
  * This source code is licensed under the ISC license.
60328
60465
  * See the LICENSE file in the root directory of this source tree.
60329
60466
  */
60330
- const __iconNode$5 = [
60467
+ const __iconNode$7 = [
60331
60468
  ["path", { d: "M13 21h8", key: "1jsn5i" }],
60332
60469
  [
60333
60470
  "path",
@@ -60337,38 +60474,50 @@ const __iconNode$5 = [
60337
60474
  }
60338
60475
  ]
60339
60476
  ];
60340
- const PenLine = createLucideIcon("pen-line", __iconNode$5);
60477
+ const PenLine = createLucideIcon("pen-line", __iconNode$7);
60341
60478
  /**
60342
60479
  * @license lucide-react v0.575.0 - ISC
60343
60480
  *
60344
60481
  * This source code is licensed under the ISC license.
60345
60482
  * See the LICENSE file in the root directory of this source tree.
60346
60483
  */
60347
- const __iconNode$4 = [
60484
+ const __iconNode$6 = [
60485
+ ["path", { d: "M2 3h20", key: "91anmk" }],
60486
+ ["path", { d: "M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3", key: "2k9sn8" }],
60487
+ ["path", { d: "m7 21 5-5 5 5", key: "bip4we" }]
60488
+ ];
60489
+ const Presentation = createLucideIcon("presentation", __iconNode$6);
60490
+ /**
60491
+ * @license lucide-react v0.575.0 - ISC
60492
+ *
60493
+ * This source code is licensed under the ISC license.
60494
+ * See the LICENSE file in the root directory of this source tree.
60495
+ */
60496
+ const __iconNode$5 = [
60348
60497
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
60349
60498
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
60350
60499
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
60351
60500
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
60352
60501
  ];
60353
- const RefreshCw = createLucideIcon("refresh-cw", __iconNode$4);
60502
+ const RefreshCw = createLucideIcon("refresh-cw", __iconNode$5);
60354
60503
  /**
60355
60504
  * @license lucide-react v0.575.0 - ISC
60356
60505
  *
60357
60506
  * This source code is licensed under the ISC license.
60358
60507
  * See the LICENSE file in the root directory of this source tree.
60359
60508
  */
60360
- const __iconNode$3 = [
60509
+ const __iconNode$4 = [
60361
60510
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
60362
60511
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
60363
60512
  ];
60364
- const Search = createLucideIcon("search", __iconNode$3);
60513
+ const Search = createLucideIcon("search", __iconNode$4);
60365
60514
  /**
60366
60515
  * @license lucide-react v0.575.0 - ISC
60367
60516
  *
60368
60517
  * This source code is licensed under the ISC license.
60369
60518
  * See the LICENSE file in the root directory of this source tree.
60370
60519
  */
60371
- const __iconNode$2 = [
60520
+ const __iconNode$3 = [
60372
60521
  [
60373
60522
  "path",
60374
60523
  {
@@ -60378,24 +60527,24 @@ const __iconNode$2 = [
60378
60527
  ],
60379
60528
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
60380
60529
  ];
60381
- const Settings = createLucideIcon("settings", __iconNode$2);
60530
+ const Settings = createLucideIcon("settings", __iconNode$3);
60382
60531
  /**
60383
60532
  * @license lucide-react v0.575.0 - ISC
60384
60533
  *
60385
60534
  * This source code is licensed under the ISC license.
60386
60535
  * See the LICENSE file in the root directory of this source tree.
60387
60536
  */
60388
- const __iconNode$1 = [
60537
+ const __iconNode$2 = [
60389
60538
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
60390
60539
  ];
60391
- const Square = createLucideIcon("square", __iconNode$1);
60540
+ const Square = createLucideIcon("square", __iconNode$2);
60392
60541
  /**
60393
60542
  * @license lucide-react v0.575.0 - ISC
60394
60543
  *
60395
60544
  * This source code is licensed under the ISC license.
60396
60545
  * See the LICENSE file in the root directory of this source tree.
60397
60546
  */
60398
- const __iconNode = [
60547
+ const __iconNode$1 = [
60399
60548
  [
60400
60549
  "path",
60401
60550
  {
@@ -60404,7 +60553,18 @@ const __iconNode = [
60404
60553
  }
60405
60554
  ]
60406
60555
  ];
60407
- const Wrench = createLucideIcon("wrench", __iconNode);
60556
+ const Wrench = createLucideIcon("wrench", __iconNode$1);
60557
+ /**
60558
+ * @license lucide-react v0.575.0 - ISC
60559
+ *
60560
+ * This source code is licensed under the ISC license.
60561
+ * See the LICENSE file in the root directory of this source tree.
60562
+ */
60563
+ const __iconNode = [
60564
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
60565
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
60566
+ ];
60567
+ const X = createLucideIcon("x", __iconNode);
60408
60568
  function Collapsible({ ...props }) {
60409
60569
  return /* @__PURE__ */ jsxRuntime.jsx(Root$2, { "data-slot": "collapsible", ...props });
60410
60570
  }
@@ -60414,6 +60574,41 @@ function CollapsibleTrigger({ ...props }) {
60414
60574
  function CollapsibleContent({ ...props }) {
60415
60575
  return /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent$1, { "data-slot": "collapsible-content", ...props });
60416
60576
  }
60577
+ const useAssetPanelStore = create((set2) => ({
60578
+ isOpen: false,
60579
+ tabs: [],
60580
+ activeTabId: null,
60581
+ viewMode: "tabs",
60582
+ isFullscreen: false,
60583
+ openAsset: (assetId, meta) => set2((s) => {
60584
+ const existing = s.tabs.find((t) => t.id === assetId);
60585
+ if (existing) {
60586
+ const tabs = meta ? s.tabs.map(
60587
+ (t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
60588
+ ) : s.tabs;
60589
+ return { isOpen: true, tabs, activeTabId: assetId };
60590
+ }
60591
+ const newTab = {
60592
+ id: assetId,
60593
+ name: (meta == null ? void 0 : meta.name) ?? null,
60594
+ type: (meta == null ? void 0 : meta.type) ?? "unknown"
60595
+ };
60596
+ return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
60597
+ }),
60598
+ closeTab: (assetId) => set2((s) => {
60599
+ var _a2;
60600
+ const tabs = s.tabs.filter((t) => t.id !== assetId);
60601
+ if (tabs.length === 0) {
60602
+ return { isOpen: false, tabs: [], activeTabId: null, isFullscreen: false };
60603
+ }
60604
+ 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;
60605
+ return { tabs, activeTabId };
60606
+ }),
60607
+ setActiveTab: (assetId) => set2({ activeTabId: assetId, viewMode: "tabs" }),
60608
+ setViewMode: (mode) => set2({ viewMode: mode }),
60609
+ closePanel: () => set2({ isOpen: false, tabs: [], activeTabId: null, viewMode: "tabs", isFullscreen: false }),
60610
+ toggleFullscreen: () => set2((s) => ({ isFullscreen: !s.isFullscreen }))
60611
+ }));
60417
60612
  const ANIMATION_DURATION = 200;
60418
60613
  const TOOL_META = {
60419
60614
  search: { displayName: "Web Search", icon: Search, describer: (a) => a.query ? `"${a.query}"` : "" },
@@ -60481,6 +60676,61 @@ function isResultSuccess(result) {
60481
60676
  }
60482
60677
  return false;
60483
60678
  }
60679
+ function extractAssetId$1(result) {
60680
+ if (!result) return null;
60681
+ try {
60682
+ const obj = typeof result === "string" ? JSON.parse(result) : result;
60683
+ if (typeof obj === "object" && obj !== null) {
60684
+ const id = obj.asset_id ?? obj.assetId ?? obj.id;
60685
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
60686
+ }
60687
+ } catch {
60688
+ }
60689
+ return null;
60690
+ }
60691
+ function toolMetaToAssetType(toolName) {
60692
+ const lower = toolName.toLowerCase();
60693
+ if (lower.includes("presentation") || lower.includes("pptx") || lower.includes("slide") || lower.includes("powerpoint"))
60694
+ return "presentation";
60695
+ if (lower.includes("sheet") || lower.includes("spreadsheet"))
60696
+ return "spreadsheet";
60697
+ if (lower.includes("document") || lower.includes("doc") || lower.includes("markdown"))
60698
+ return "document";
60699
+ return "unknown";
60700
+ }
60701
+ const CREATE_ASSET_TOOLS = [
60702
+ "create_powerpoint_deck",
60703
+ "create_document_from_markdown",
60704
+ "create_new_document",
60705
+ "create_new_sheet"
60706
+ ];
60707
+ function isAssetTool(toolName, result) {
60708
+ return CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) || extractAssetId$1(result) !== null;
60709
+ }
60710
+ function extractTitle(argsText, result) {
60711
+ if (argsText) {
60712
+ const args = tryParseJson$2(argsText);
60713
+ if (args) {
60714
+ const t = args.title ?? args.name ?? args.filename ?? args.sheet_name;
60715
+ if (t) return t;
60716
+ }
60717
+ }
60718
+ if (result) {
60719
+ try {
60720
+ const obj = typeof result === "string" ? JSON.parse(result) : result;
60721
+ if (typeof obj === "object" && obj !== null) {
60722
+ return obj.title ?? obj.name;
60723
+ }
60724
+ } catch {
60725
+ }
60726
+ }
60727
+ return null;
60728
+ }
60729
+ let assetGeneration$1 = 0;
60730
+ const autoOpenedAssets$1 = /* @__PURE__ */ new Map();
60731
+ function clearAutoOpenedAssets() {
60732
+ assetGeneration$1++;
60733
+ }
60484
60734
  function ToolFallbackRoot({
60485
60735
  className,
60486
60736
  open: controlledOpen,
@@ -60546,7 +60796,7 @@ function ToolFallbackTrigger({
60546
60796
  if (!parsed) return null;
60547
60797
  const desc = meta.describer(parsed);
60548
60798
  return desc || null;
60549
- }, [toolName, argsText, isRunning, meta]);
60799
+ }, [toolName, argsText, isRunning]);
60550
60800
  const resultMessage = React.useMemo(() => {
60551
60801
  if (!isComplete) return null;
60552
60802
  return extractResultMessage(result);
@@ -60710,6 +60960,97 @@ function ToolFallbackError({
60710
60960
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-xs text-destructive/80", children: errorText })
60711
60961
  ] });
60712
60962
  }
60963
+ function AssetToolCard({
60964
+ toolName,
60965
+ argsText,
60966
+ result,
60967
+ status
60968
+ }) {
60969
+ const [detailsOpen, setDetailsOpen] = React.useState(false);
60970
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
60971
+ const meta = getToolMeta(toolName);
60972
+ const ToolIcon = meta.icon;
60973
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
60974
+ const isRunning = (status == null ? void 0 : status.type) === "running";
60975
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
60976
+ const assetId = extractAssetId$1(result);
60977
+ const title = extractTitle(argsText, result);
60978
+ const assetType = toolMetaToAssetType(toolName);
60979
+ const wasCompleteAtMount = React.useRef(isComplete);
60980
+ React.useEffect(() => {
60981
+ if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current && autoOpenedAssets$1.get(assetId) !== assetGeneration$1) {
60982
+ autoOpenedAssets$1.set(assetId, assetGeneration$1);
60983
+ useAssetPanelStore.getState().openAsset(assetId, {
60984
+ name: title ?? void 0,
60985
+ type: assetType
60986
+ });
60987
+ }
60988
+ }, [isComplete, isCancelled, assetId, title, assetType]);
60989
+ const success = isComplete && isResultSuccess(result);
60990
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
60991
+ "aui-tool-fallback-root w-full rounded-xl border border-border/60 bg-background py-2.5 shadow-sm",
60992
+ isCancelled && "border-muted-foreground/30 bg-muted/30"
60993
+ ), children: [
60994
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5 px-3 text-sm", children: [
60995
+ /* @__PURE__ */ jsxRuntime.jsx(
60996
+ "div",
60997
+ {
60998
+ className: cn(
60999
+ "flex size-7 shrink-0 items-center justify-center rounded-lg",
61000
+ isRunning && "bg-blue-50 text-blue-600",
61001
+ isComplete && success && "bg-emerald-50 text-emerald-600",
61002
+ isComplete && !success && "bg-muted text-muted-foreground"
61003
+ ),
61004
+ children: isRunning ? /* @__PURE__ */ jsxRuntime.jsx(Loader, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(ToolIcon, { className: "size-3.5" })
61005
+ }
61006
+ ),
61007
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 grow flex-col items-start gap-0.5 text-left", children: [
61008
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "leading-tight", children: [
61009
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: meta.displayName }),
61010
+ isRunning && "..."
61011
+ ] }),
61012
+ !isRunning && title && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-full truncate text-xs leading-snug text-muted-foreground", children: title })
61013
+ ] }),
61014
+ assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsxs(
61015
+ "button",
61016
+ {
61017
+ onClick: () => openAsset(assetId, { name: title ?? void 0, type: assetType }),
61018
+ 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",
61019
+ children: [
61020
+ /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-2.5" }),
61021
+ "Open"
61022
+ ]
61023
+ }
61024
+ ),
61025
+ isComplete && success && /* @__PURE__ */ jsxRuntime.jsx(CircleCheck, { className: "size-3.5 shrink-0 text-emerald-500" }),
61026
+ !isCancelled && /* @__PURE__ */ jsxRuntime.jsx(
61027
+ "button",
61028
+ {
61029
+ onClick: () => setDetailsOpen((o) => !o),
61030
+ className: cn(
61031
+ "flex size-5 shrink-0 items-center justify-center rounded transition-all",
61032
+ detailsOpen ? "bg-primary/5 text-primary" : "text-muted-foreground/40 hover:bg-muted/50 hover:text-muted-foreground"
61033
+ ),
61034
+ title: "Show details",
61035
+ children: /* @__PURE__ */ jsxRuntime.jsx(
61036
+ ChevronDown,
61037
+ {
61038
+ className: cn(
61039
+ "size-3 transition-transform duration-200",
61040
+ detailsOpen && "rotate-180"
61041
+ )
61042
+ }
61043
+ )
61044
+ }
61045
+ )
61046
+ ] }),
61047
+ (status == null ? void 0 : status.type) === "incomplete" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackError, { status }) }),
61048
+ detailsOpen && !isCancelled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2.5 flex flex-col gap-2 border-t border-border/50 px-3 pt-2", children: [
61049
+ /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackArgs, { argsText }),
61050
+ /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackResult, { result })
61051
+ ] })
61052
+ ] });
61053
+ }
60713
61054
  const ToolFallbackImpl = ({
60714
61055
  toolName,
60715
61056
  argsText,
@@ -60717,6 +61058,17 @@ const ToolFallbackImpl = ({
60717
61058
  status
60718
61059
  }) => {
60719
61060
  const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
61061
+ if (isAssetTool(toolName, result)) {
61062
+ return /* @__PURE__ */ jsxRuntime.jsx(
61063
+ AssetToolCard,
61064
+ {
61065
+ toolName,
61066
+ argsText,
61067
+ result,
61068
+ status
61069
+ }
61070
+ );
61071
+ }
60720
61072
  return /* @__PURE__ */ jsxRuntime.jsxs(
60721
61073
  ToolFallbackRoot,
60722
61074
  {
@@ -61298,32 +61650,120 @@ const EmailSearchToolUI = React.memo(
61298
61650
  EmailSearchToolUIImpl
61299
61651
  );
61300
61652
  EmailSearchToolUI.displayName = "EmailSearchToolUI";
61301
- const CreateDocumentToolUIImpl = ({
61653
+ function extractAssetId(result) {
61654
+ const data = normalizeResult(result);
61655
+ if (!data) return null;
61656
+ const id = data.asset_id ?? data.assetId ?? data.id;
61657
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
61658
+ return null;
61659
+ }
61660
+ let assetGeneration = 0;
61661
+ const autoOpenedAssets = /* @__PURE__ */ new Map();
61662
+ function resetAssetAutoOpen() {
61663
+ assetGeneration++;
61664
+ }
61665
+ function CreateAssetToolUIImpl({
61666
+ icon: Icon2,
61667
+ assetType,
61668
+ runningLabel,
61669
+ doneLabel,
61302
61670
  args,
61303
61671
  result,
61304
61672
  status
61305
- }) => {
61673
+ }) {
61306
61674
  const typedArgs = args;
61307
- const docName = (typedArgs == null ? void 0 : typedArgs.name) ?? (typedArgs == null ? void 0 : typedArgs.title) ?? (typedArgs == null ? void 0 : typedArgs.document_name) ?? "";
61675
+ 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) ?? "";
61308
61676
  const data = React.useMemo(() => normalizeResult(result), [result]);
61309
61677
  const createdName = (data == null ? void 0 : data.name) ?? (data == null ? void 0 : data.title) ?? (data == null ? void 0 : data.asset_name);
61678
+ const assetId = extractAssetId(result);
61310
61679
  const isRunning = (status == null ? void 0 : status.type) === "running";
61680
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
61681
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
61311
61682
  const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
61683
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
61684
+ const wasCompleteAtMount = React.useRef(isComplete);
61685
+ React.useEffect(() => {
61686
+ if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current && autoOpenedAssets.get(assetId) !== assetGeneration) {
61687
+ autoOpenedAssets.set(assetId, assetGeneration);
61688
+ useAssetPanelStore.getState().openAsset(assetId, {
61689
+ name: createdName || name || void 0,
61690
+ type: assetType
61691
+ });
61692
+ }
61693
+ }, [isComplete, isCancelled, assetId, createdName, name, assetType]);
61694
+ const handleOpen = () => {
61695
+ if (assetId) {
61696
+ openAsset(assetId, {
61697
+ name: createdName || name || void 0,
61698
+ type: assetType
61699
+ });
61700
+ }
61701
+ };
61312
61702
  return /* @__PURE__ */ jsxRuntime.jsx(
61313
61703
  ToolCard,
61314
61704
  {
61315
- icon: FilePlus,
61705
+ icon: Icon2,
61316
61706
  status: (status == null ? void 0 : status.type) ?? "complete",
61317
- title: isRunning ? "Creating document..." : "Created document",
61318
- subtitle: createdName || docName || void 0,
61319
- error: errorMsg
61707
+ title: isRunning ? runningLabel : doneLabel,
61708
+ subtitle: createdName || name || void 0,
61709
+ error: errorMsg,
61710
+ children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
61711
+ "button",
61712
+ {
61713
+ onClick: handleOpen,
61714
+ 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",
61715
+ children: [
61716
+ /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-3" }),
61717
+ "Open ",
61718
+ assetType === "unknown" ? "asset" : assetType
61719
+ ]
61720
+ }
61721
+ ) })
61320
61722
  }
61321
61723
  );
61322
- };
61724
+ }
61725
+ const CreateDocumentToolUIImpl = (props) => /* @__PURE__ */ jsxRuntime.jsx(
61726
+ CreateAssetToolUIImpl,
61727
+ {
61728
+ icon: FilePlus,
61729
+ assetType: "document",
61730
+ runningLabel: "Creating document...",
61731
+ doneLabel: "Created document",
61732
+ ...props
61733
+ }
61734
+ );
61323
61735
  const CreateDocumentToolUI = React.memo(
61324
61736
  CreateDocumentToolUIImpl
61325
61737
  );
61326
61738
  CreateDocumentToolUI.displayName = "CreateDocumentToolUI";
61739
+ const CreateSheetToolUIImpl = (props) => /* @__PURE__ */ jsxRuntime.jsx(
61740
+ CreateAssetToolUIImpl,
61741
+ {
61742
+ icon: ChartColumn,
61743
+ assetType: "spreadsheet",
61744
+ runningLabel: "Creating spreadsheet...",
61745
+ doneLabel: "Created spreadsheet",
61746
+ ...props
61747
+ }
61748
+ );
61749
+ const CreateSheetToolUI = React.memo(
61750
+ CreateSheetToolUIImpl
61751
+ );
61752
+ CreateSheetToolUI.displayName = "CreateSheetToolUI";
61753
+ const CreatePresentationToolUIImpl = (props) => /* @__PURE__ */ jsxRuntime.jsx(
61754
+ CreateAssetToolUIImpl,
61755
+ {
61756
+ icon: Presentation,
61757
+ assetType: "presentation",
61758
+ runningLabel: "Creating presentation...",
61759
+ doneLabel: "Created presentation",
61760
+ ...props
61761
+ }
61762
+ );
61763
+ const CreatePresentationToolUI = React.memo(
61764
+ CreatePresentationToolUIImpl
61765
+ );
61766
+ CreatePresentationToolUI.displayName = "CreatePresentationToolUI";
61327
61767
  const CreateEmailDraftToolUIImpl = ({
61328
61768
  args,
61329
61769
  result,
@@ -61357,7 +61797,10 @@ const TOOL_UI_REGISTRY = {
61357
61797
  create_email_draft: CreateEmailDraftToolUI,
61358
61798
  unified_email_create_draft: CreateEmailDraftToolUI,
61359
61799
  create_new_document: CreateDocumentToolUI,
61360
- create_document_from_markdown: CreateDocumentToolUI
61800
+ create_document_from_markdown: CreateDocumentToolUI,
61801
+ create_new_sheet: CreateSheetToolUI,
61802
+ update_sheet_range: CreateSheetToolUI,
61803
+ create_powerpoint_deck: CreatePresentationToolUI
61361
61804
  };
61362
61805
  const falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
61363
61806
  const cx = clsx;
@@ -61469,14 +61912,7 @@ const TooltipIconButton = React.forwardRef(
61469
61912
  }
61470
61913
  );
61471
61914
  TooltipIconButton.displayName = "TooltipIconButton";
61472
- const SAMPLE_TOOLS = [
61473
- { id: "search_web", name: "Search Web", description: "Search the internet for information", icon: "🔍", type: "tool" },
61474
- { id: "read_file", name: "Read File", description: "Read contents of a file", icon: "📄", type: "tool" },
61475
- { id: "write_file", name: "Write File", description: "Write contents to a file", icon: "✏️", type: "tool" },
61476
- { id: "run_code", name: "Run Code", description: "Execute code in a sandbox", icon: "▶️", type: "tool" },
61477
- { id: "code_toolkit", name: "Code Toolkit", description: "Full suite of coding tools", icon: "🧰", type: "toolkit" },
61478
- { id: "research_toolkit", name: "Research Toolkit", description: "Research and analysis tools", icon: "📚", type: "toolkit" }
61479
- ];
61915
+ const EMPTY_MENTION_TOOLS = [];
61480
61916
  const AthenaChat = ({
61481
61917
  className,
61482
61918
  welcomeMessage = "Hello there!",
@@ -61485,13 +61921,17 @@ const AthenaChat = ({
61485
61921
  toolUIs,
61486
61922
  mentionTools
61487
61923
  }) => {
61488
- const tools = mentionTools ?? SAMPLE_TOOLS;
61489
- const mergedToolUIs = {
61924
+ const tools = mentionTools ?? EMPTY_MENTION_TOOLS;
61925
+ const mergedToolUIs = React.useMemo(() => ({
61490
61926
  append_markdown_to_athena_document: AppendDocumentToolUI,
61491
61927
  read_full_asset: ReadAssetToolUI,
61492
61928
  ...TOOL_UI_REGISTRY,
61493
61929
  ...toolUIs
61494
- };
61930
+ }), [toolUIs]);
61931
+ const AssistantMessageComponent = React.useMemo(
61932
+ () => () => /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { toolUIs: mergedToolUIs }),
61933
+ [mergedToolUIs]
61934
+ );
61495
61935
  return /* @__PURE__ */ jsxRuntime.jsx(
61496
61936
  ThreadPrimitiveRoot,
61497
61937
  {
@@ -61512,7 +61952,7 @@ const AthenaChat = ({
61512
61952
  {
61513
61953
  components: {
61514
61954
  UserMessage,
61515
- AssistantMessage: () => /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { toolUIs: mergedToolUIs })
61955
+ AssistantMessage: AssistantMessageComponent
61516
61956
  }
61517
61957
  }
61518
61958
  ),
@@ -61641,8 +62081,315 @@ const UserMessage = () => /* @__PURE__ */ jsxRuntime.jsx(
61641
62081
  children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(MessagePrimitiveParts, { components: { Text: TiptapText } }) })
61642
62082
  }
61643
62083
  );
62084
+ const embedCache = /* @__PURE__ */ new Map();
62085
+ function useAssetEmbed(assetId, options = {
62086
+ backendUrl: ""
62087
+ }) {
62088
+ const { readOnly = false, expiresInSeconds = 60 * 60 * 24 * 30, backendUrl, apiKey, token } = options;
62089
+ const [embedUrl, setEmbedUrl] = React.useState(null);
62090
+ const [isLoading, setIsLoading] = React.useState(false);
62091
+ const [error2, setError] = React.useState(null);
62092
+ const abortRef = React.useRef(null);
62093
+ React.useEffect(() => {
62094
+ var _a2;
62095
+ if (!assetId || !backendUrl) {
62096
+ setEmbedUrl(null);
62097
+ setIsLoading(false);
62098
+ setError(null);
62099
+ return;
62100
+ }
62101
+ const cached = embedCache.get(assetId);
62102
+ if (cached && cached.expiresAt > Date.now() / 1e3) {
62103
+ setEmbedUrl(cached.url);
62104
+ setIsLoading(false);
62105
+ setError(null);
62106
+ return;
62107
+ }
62108
+ const agoraBase = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
62109
+ const endpoint = `${agoraBase}/api/embed/generate-token`;
62110
+ (_a2 = abortRef.current) == null ? void 0 : _a2.abort();
62111
+ const controller = new AbortController();
62112
+ abortRef.current = controller;
62113
+ setIsLoading(true);
62114
+ setError(null);
62115
+ const headers = { "Content-Type": "application/json" };
62116
+ if (token) {
62117
+ headers["Authorization"] = `Bearer ${token}`;
62118
+ } else if (apiKey) {
62119
+ headers["X-API-KEY"] = apiKey;
62120
+ }
62121
+ fetch(endpoint, {
62122
+ method: "POST",
62123
+ headers,
62124
+ body: JSON.stringify({
62125
+ asset_id: assetId,
62126
+ read_only: readOnly,
62127
+ expires_in_seconds: expiresInSeconds
62128
+ }),
62129
+ signal: controller.signal
62130
+ }).then(async (res) => {
62131
+ if (!res.ok) {
62132
+ const text2 = await res.text().catch(() => "");
62133
+ throw new Error(`Failed to generate embed token (${res.status}): ${text2}`);
62134
+ }
62135
+ return res.json();
62136
+ }).then((data) => {
62137
+ embedCache.set(assetId, { url: data.embed_url, expiresAt: data.expires_at });
62138
+ setEmbedUrl(data.embed_url);
62139
+ setIsLoading(false);
62140
+ }).catch((err) => {
62141
+ if (err.name === "AbortError") return;
62142
+ setError(err.message);
62143
+ setIsLoading(false);
62144
+ });
62145
+ return () => controller.abort();
62146
+ }, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, token]);
62147
+ return { embedUrl, isLoading, error: error2 };
62148
+ }
62149
+ const ASSET_TYPE_CONFIG = {
62150
+ presentation: { icon: Presentation, label: "Presentation" },
62151
+ spreadsheet: { icon: FileSpreadsheet, label: "Spreadsheet" },
62152
+ document: { icon: FileText, label: "Document" },
62153
+ unknown: { icon: File$1, label: "Asset" }
62154
+ };
62155
+ const AssetIframe = React.memo(
62156
+ ({ tabId, tabName }) => {
62157
+ const { backendUrl, apiKey, token } = useAthenaConfig();
62158
+ const { embedUrl, isLoading, error: error2 } = useAssetEmbed(tabId, {
62159
+ backendUrl,
62160
+ apiKey,
62161
+ token
62162
+ });
62163
+ if (isLoading) {
62164
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
62165
+ /* @__PURE__ */ jsxRuntime.jsx(LoaderCircle, { className: "mx-auto size-6 animate-spin text-muted-foreground" }),
62166
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: "Loading..." })
62167
+ ] }) });
62168
+ }
62169
+ if (error2) {
62170
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-sm text-center", children: [
62171
+ /* @__PURE__ */ jsxRuntime.jsx(CircleAlert, { className: "mx-auto size-5 text-red-400" }),
62172
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1.5 text-xs font-medium text-foreground", children: "Failed to load" }),
62173
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 line-clamp-2 break-words text-[10px] text-muted-foreground", children: error2 })
62174
+ ] }) });
62175
+ }
62176
+ if (!embedUrl) return null;
62177
+ return /* @__PURE__ */ jsxRuntime.jsx(
62178
+ "iframe",
62179
+ {
62180
+ src: embedUrl,
62181
+ width: "100%",
62182
+ height: "100%",
62183
+ frameBorder: "0",
62184
+ allow: "fullscreen",
62185
+ title: tabName ?? `Asset ${tabId}`,
62186
+ className: "h-full w-full"
62187
+ }
62188
+ );
62189
+ }
62190
+ );
62191
+ AssetIframe.displayName = "AssetIframe";
62192
+ const PanelContent = () => {
62193
+ const { tabs, activeTabId, viewMode, closeTab } = useAssetPanelStore();
62194
+ const isTiled = viewMode === "tiled" && tabs.length >= 2;
62195
+ const gridClass = React.useMemo(() => {
62196
+ const n = tabs.length;
62197
+ if (n <= 1) return "";
62198
+ if (n === 2) return "grid grid-cols-2 grid-rows-1";
62199
+ if (n <= 4) return "grid grid-cols-2 grid-rows-2";
62200
+ if (n <= 6) return "grid grid-cols-3 grid-rows-2";
62201
+ return "grid grid-cols-3 grid-rows-3";
62202
+ }, [tabs.length]);
62203
+ return /* @__PURE__ */ jsxRuntime.jsx(
62204
+ "div",
62205
+ {
62206
+ className: `flex-1 overflow-hidden ${isTiled ? `${gridClass} gap-px bg-border/60` : ""}`,
62207
+ children: tabs.map((tab) => {
62208
+ const isActive2 = tab.id === activeTabId;
62209
+ const config2 = ASSET_TYPE_CONFIG[tab.type];
62210
+ const TypeIcon = config2.icon;
62211
+ if (isTiled) {
62212
+ return /* @__PURE__ */ jsxRuntime.jsxs(
62213
+ "div",
62214
+ {
62215
+ className: "flex min-h-0 min-w-0 flex-col bg-background",
62216
+ children: [
62217
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-1.5 border-b px-2 py-1", children: [
62218
+ /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { className: "size-3 shrink-0 text-muted-foreground" }),
62219
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate text-[11px] font-medium text-foreground", children: tab.name ?? config2.label }),
62220
+ /* @__PURE__ */ jsxRuntime.jsx(
62221
+ "button",
62222
+ {
62223
+ onClick: () => closeTab(tab.id),
62224
+ className: "shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
62225
+ children: /* @__PURE__ */ jsxRuntime.jsx(X, { className: "size-2.5" })
62226
+ }
62227
+ )
62228
+ ] }),
62229
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, { tabId: tab.id, tabName: tab.name }) })
62230
+ ]
62231
+ },
62232
+ tab.id
62233
+ );
62234
+ }
62235
+ return /* @__PURE__ */ jsxRuntime.jsx(
62236
+ "div",
62237
+ {
62238
+ className: isActive2 ? "h-full w-full" : "hidden",
62239
+ children: /* @__PURE__ */ jsxRuntime.jsx(AssetIframe, { tabId: tab.id, tabName: tab.name })
62240
+ },
62241
+ tab.id
62242
+ );
62243
+ })
62244
+ }
62245
+ );
62246
+ };
62247
+ const TabBar = () => {
62248
+ const { tabs, activeTabId, setActiveTab, closeTab, viewMode } = useAssetPanelStore();
62249
+ if (tabs.length <= 1 || viewMode === "tiled") return null;
62250
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-0 overflow-x-auto border-b bg-muted/30", children: tabs.map((tab) => {
62251
+ const config2 = ASSET_TYPE_CONFIG[tab.type];
62252
+ const TypeIcon = config2.icon;
62253
+ const isActive2 = tab.id === activeTabId;
62254
+ return /* @__PURE__ */ jsxRuntime.jsxs(
62255
+ "div",
62256
+ {
62257
+ 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"}`,
62258
+ onClick: () => setActiveTab(tab.id),
62259
+ children: [
62260
+ /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { className: "size-3 shrink-0" }),
62261
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: tab.name ?? config2.label }),
62262
+ /* @__PURE__ */ jsxRuntime.jsx(
62263
+ "button",
62264
+ {
62265
+ onClick: (e) => {
62266
+ e.stopPropagation();
62267
+ closeTab(tab.id);
62268
+ },
62269
+ className: "ml-auto shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:bg-muted group-hover:opacity-100",
62270
+ children: /* @__PURE__ */ jsxRuntime.jsx(X, { className: "size-2.5" })
62271
+ }
62272
+ )
62273
+ ]
62274
+ },
62275
+ tab.id
62276
+ );
62277
+ }) });
62278
+ };
62279
+ const PanelHeader = ({ fullscreen }) => {
62280
+ const {
62281
+ closePanel,
62282
+ toggleFullscreen,
62283
+ tabs,
62284
+ activeTabId,
62285
+ viewMode,
62286
+ setViewMode
62287
+ } = useAssetPanelStore();
62288
+ const activeTab = tabs.find((t) => t.id === activeTabId);
62289
+ const config2 = ASSET_TYPE_CONFIG[(activeTab == null ? void 0 : activeTab.type) ?? "unknown"];
62290
+ const TypeIcon = config2.icon;
62291
+ const isTiled = viewMode === "tiled";
62292
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-2 border-b px-4 py-2.5", children: [
62293
+ !isTiled && /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { className: "size-4 shrink-0 text-muted-foreground" }),
62294
+ /* @__PURE__ */ jsxRuntime.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 }),
62295
+ tabs.length >= 2 && /* @__PURE__ */ jsxRuntime.jsx(
62296
+ "button",
62297
+ {
62298
+ onClick: () => setViewMode(isTiled ? "tabs" : "tiled"),
62299
+ 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"}`,
62300
+ title: isTiled ? "Switch to tabs" : "Tile all assets",
62301
+ children: isTiled ? /* @__PURE__ */ jsxRuntime.jsx(Layers, { className: "size-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(LayoutGrid, { className: "size-3.5" })
62302
+ }
62303
+ ),
62304
+ /* @__PURE__ */ jsxRuntime.jsx(
62305
+ "button",
62306
+ {
62307
+ onClick: toggleFullscreen,
62308
+ className: "flex size-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
62309
+ title: fullscreen ? "Exit fullscreen" : "Fullscreen",
62310
+ children: fullscreen ? /* @__PURE__ */ jsxRuntime.jsx(Minimize2, { className: "size-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(Maximize2, { className: "size-3.5" })
62311
+ }
62312
+ ),
62313
+ /* @__PURE__ */ jsxRuntime.jsx(
62314
+ "button",
62315
+ {
62316
+ onClick: closePanel,
62317
+ className: "flex size-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
62318
+ title: "Close all",
62319
+ children: /* @__PURE__ */ jsxRuntime.jsx(X, { className: "size-4" })
62320
+ }
62321
+ )
62322
+ ] });
62323
+ };
62324
+ const AssetPanel = () => {
62325
+ const isFullscreen = useAssetPanelStore((s) => s.isFullscreen);
62326
+ const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
62327
+ /* @__PURE__ */ jsxRuntime.jsx(PanelHeader, { fullscreen: isFullscreen }),
62328
+ /* @__PURE__ */ jsxRuntime.jsx(TabBar, {}),
62329
+ /* @__PURE__ */ jsxRuntime.jsx(PanelContent, {})
62330
+ ] });
62331
+ if (isFullscreen) {
62332
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 z-50 flex flex-col bg-background", children: content });
62333
+ }
62334
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full flex-col bg-background", children: content });
62335
+ };
62336
+ const AthenaLayout = ({
62337
+ children,
62338
+ defaultChatPercent = 50,
62339
+ minPercent = 25
62340
+ }) => {
62341
+ const isOpen = useAssetPanelStore((s) => s.isOpen);
62342
+ const [chatPercent, setChatPercent] = React.useState(defaultChatPercent);
62343
+ const containerRef = React.useRef(null);
62344
+ const dragging = React.useRef(false);
62345
+ const onPointerDown = React.useCallback(
62346
+ (e) => {
62347
+ e.preventDefault();
62348
+ dragging.current = true;
62349
+ e.target.setPointerCapture(e.pointerId);
62350
+ },
62351
+ []
62352
+ );
62353
+ const onPointerMove = React.useCallback(
62354
+ (e) => {
62355
+ if (!dragging.current || !containerRef.current) return;
62356
+ const rect = containerRef.current.getBoundingClientRect();
62357
+ const pct = (e.clientX - rect.left) / rect.width * 100;
62358
+ setChatPercent(Math.max(minPercent, Math.min(100 - minPercent, pct)));
62359
+ },
62360
+ [minPercent]
62361
+ );
62362
+ const onPointerUp = React.useCallback(() => {
62363
+ dragging.current = false;
62364
+ }, []);
62365
+ if (!isOpen) {
62366
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full flex-col", children });
62367
+ }
62368
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "flex h-full w-full", children: [
62369
+ /* @__PURE__ */ jsxRuntime.jsx(
62370
+ "div",
62371
+ {
62372
+ className: "flex h-full flex-col overflow-hidden",
62373
+ style: { width: `${chatPercent}%` },
62374
+ children
62375
+ }
62376
+ ),
62377
+ /* @__PURE__ */ jsxRuntime.jsx(
62378
+ "div",
62379
+ {
62380
+ 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",
62381
+ onPointerDown,
62382
+ onPointerMove,
62383
+ onPointerUp
62384
+ }
62385
+ ),
62386
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(AssetPanel, {}) })
62387
+ ] });
62388
+ };
61644
62389
  exports.AppendDocumentToolUI = AppendDocumentToolUI;
62390
+ exports.AssetPanel = AssetPanel;
61645
62391
  exports.AthenaChat = AthenaChat;
62392
+ exports.AthenaLayout = AthenaLayout;
61646
62393
  exports.AthenaProvider = AthenaProvider;
61647
62394
  exports.BrowseToolUI = BrowseToolUI;
61648
62395
  exports.Button = Button;
@@ -61651,6 +62398,9 @@ exports.CollapsibleContent = CollapsibleContent;
61651
62398
  exports.CollapsibleTrigger = CollapsibleTrigger;
61652
62399
  exports.CreateDocumentToolUI = CreateDocumentToolUI;
61653
62400
  exports.CreateEmailDraftToolUI = CreateEmailDraftToolUI;
62401
+ exports.CreatePresentationToolUI = CreatePresentationToolUI;
62402
+ exports.CreateSheetToolUI = CreateSheetToolUI;
62403
+ exports.DEFAULT_BACKEND_URL = DEFAULT_BACKEND_URL;
61654
62404
  exports.EmailSearchToolUI = EmailSearchToolUI;
61655
62405
  exports.ReadAssetToolUI = ReadAssetToolUI;
61656
62406
  exports.TOOL_UI_REGISTRY = TOOL_UI_REGISTRY;
@@ -61670,9 +62420,14 @@ exports.TooltipProvider = TooltipProvider;
61670
62420
  exports.TooltipTrigger = TooltipTrigger;
61671
62421
  exports.WebSearchToolUI = WebSearchToolUI;
61672
62422
  exports.buttonVariants = buttonVariants;
62423
+ exports.clearAutoOpenedAssets = clearAutoOpenedAssets;
61673
62424
  exports.cn = cn;
61674
62425
  exports.getAssetInfo = getAssetInfo;
62426
+ exports.resetAssetAutoOpen = resetAssetAutoOpen;
61675
62427
  exports.tryParseJson = tryParseJson$1;
62428
+ exports.useAssetEmbed = useAssetEmbed;
62429
+ exports.useAssetPanelStore = useAssetPanelStore;
62430
+ exports.useAthenaConfig = useAthenaConfig;
61676
62431
  exports.useAthenaRuntime = useAthenaRuntime;
61677
62432
  exports.useMentionSuggestions = useMentionSuggestions;
61678
62433
  exports.useParentAuth = useParentAuth;