@athenaintel/react 0.5.0 → 0.6.1

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
@@ -4561,6 +4561,16 @@ const ChainOfThoughtByIndicesProvider = ({ startIndex, endIndex, children }) =>
4561
4561
  });
4562
4562
  return jsxRuntime.jsx(AuiProvider, { value: aui, children });
4563
4563
  };
4564
+ const ThreadListItemByIndexProvider = ({ index: index2, archived, children }) => {
4565
+ const aui = useAui({
4566
+ threadListItem: Derived({
4567
+ source: "threads",
4568
+ query: { type: "index", index: index2, archived },
4569
+ get: (aui2) => aui2.threads().item({ index: index2, archived })
4570
+ })
4571
+ });
4572
+ return jsxRuntime.jsx(AuiProvider, { value: aui, children });
4573
+ };
4564
4574
  const RuntimeAdapter = resource((runtime) => tapResource(RuntimeAdapterResource(runtime)));
4565
4575
  attachTransformScopes(RuntimeAdapter, (scopes, parent) => {
4566
4576
  const result = baseRuntimeAdapterTransformScopes(scopes, parent);
@@ -8930,6 +8940,24 @@ const MessagePrimitiveParts$1 = ({ components, unstable_showEmptyOnNonTextEnd =
8930
8940
  return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [partsElements, jsxRuntime.jsx(ConditionalEmpty, { components, enabled: unstable_showEmptyOnNonTextEnd })] });
8931
8941
  };
8932
8942
  MessagePrimitiveParts$1.displayName = "MessagePrimitive.Parts";
8943
+ const ThreadListPrimitiveItemByIndex = React.memo(({ index: index2, archived = false, components }) => {
8944
+ const ThreadListItemComponent = components.ThreadListItem;
8945
+ return jsxRuntime.jsx(ThreadListItemByIndexProvider, { index: index2, archived, children: jsxRuntime.jsx(ThreadListItemComponent, {}) });
8946
+ }, (prev, next) => prev.index === next.index && prev.archived === next.archived && prev.components.ThreadListItem === next.components.ThreadListItem);
8947
+ ThreadListPrimitiveItemByIndex.displayName = "ThreadListPrimitive.ItemByIndex";
8948
+ const ThreadListPrimitiveItems = ({ archived = false, components }) => {
8949
+ const contentLength = useAuiState((s) => archived ? s.threads.archivedThreadIds.length : s.threads.threadIds.length);
8950
+ const listElements = React.useMemo(() => {
8951
+ return Array.from({ length: contentLength }, (_, index2) => jsxRuntime.jsx(ThreadListPrimitiveItemByIndex, { index: index2, archived, components }, index2));
8952
+ }, [contentLength, archived, components]);
8953
+ return listElements;
8954
+ };
8955
+ ThreadListPrimitiveItems.displayName = "ThreadListPrimitive.Items";
8956
+ const ThreadListItemPrimitiveTitle = ({ fallback }) => {
8957
+ const title = useAuiState((s) => s.threadListItem.title);
8958
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: title || fallback });
8959
+ };
8960
+ ThreadListItemPrimitiveTitle.displayName = "ThreadListItemPrimitive.Title";
8933
8961
  const useComposerSend$1 = () => {
8934
8962
  const aui = useAui();
8935
8963
  const disabled = useAuiState((s) => s.thread.isRunning || !s.composer.isEditing || s.composer.isEmpty);
@@ -16362,6 +16390,37 @@ const useThreadScrollToBottom = ({ behavior } = {}) => {
16362
16390
  return handleScrollToBottom;
16363
16391
  };
16364
16392
  const ThreadPrimitiveScrollToBottom = createActionButton("ThreadPrimitive.ScrollToBottom", useThreadScrollToBottom, ["behavior"]);
16393
+ const ThreadListPrimitiveNew = React.forwardRef(({ onClick, disabled, ...props }, forwardedRef) => {
16394
+ const isMain = useAuiState((s) => s.threads.newThreadId === s.threads.mainThreadId);
16395
+ const aui = useAui();
16396
+ return jsxRuntime.jsx(Primitive$1.button, { type: "button", ...isMain ? { "data-active": "true", "aria-current": "true" } : null, ...props, ref: forwardedRef, disabled, onClick: composeEventHandlers(onClick, () => {
16397
+ aui.threads().switchToNewThread();
16398
+ }) });
16399
+ });
16400
+ ThreadListPrimitiveNew.displayName = "ThreadListPrimitive.New";
16401
+ const ThreadListPrimitiveRoot = React.forwardRef((props, ref) => {
16402
+ return jsxRuntime.jsx(Primitive$1.div, { ...props, ref });
16403
+ });
16404
+ ThreadListPrimitiveRoot.displayName = "ThreadListPrimitive.Root";
16405
+ const ThreadListItemPrimitiveRoot = React.forwardRef((props, ref) => {
16406
+ const isMain = useAuiState((s) => s.threads.mainThreadId === s.threadListItem.id);
16407
+ return jsxRuntime.jsx(Primitive$1.div, { ...isMain ? { "data-active": "true", "aria-current": "true" } : null, ...props, ref });
16408
+ });
16409
+ ThreadListItemPrimitiveRoot.displayName = "ThreadListItemPrimitive.Root";
16410
+ const useThreadListItemArchive = () => {
16411
+ const aui = useAui();
16412
+ return React.useCallback(() => {
16413
+ aui.threadListItem().archive();
16414
+ }, [aui]);
16415
+ };
16416
+ const ThreadListItemPrimitiveArchive = createActionButton("ThreadListItemPrimitive.Archive", useThreadListItemArchive);
16417
+ const useThreadListItemTrigger = () => {
16418
+ const aui = useAui();
16419
+ return React.useCallback(() => {
16420
+ aui.threadListItem().switchTo();
16421
+ }, [aui]);
16422
+ };
16423
+ const ThreadListItemPrimitiveTrigger = createActionButton("ThreadListItemPrimitive.Trigger", useThreadListItemTrigger);
16365
16424
  const useScrollLock = (animatedElementRef, animationDuration) => {
16366
16425
  const scrollContainerRef = React.useRef(null);
16367
16426
  const cleanupRef = React.useRef(null);
@@ -20578,6 +20637,73 @@ const parseLangGraphState = (state) => {
20578
20637
  }
20579
20638
  return result;
20580
20639
  };
20640
+ function getAuthHeaders(auth) {
20641
+ if (auth.token) {
20642
+ return { Authorization: `Bearer ${auth.token}` };
20643
+ }
20644
+ if (auth.apiKey) {
20645
+ return { "X-API-KEY": auth.apiKey };
20646
+ }
20647
+ return {};
20648
+ }
20649
+ function getAgoraBaseUrl(backendUrl) {
20650
+ const stripped = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
20651
+ if (stripped === backendUrl) {
20652
+ return backendUrl.replace(/\/$/, "");
20653
+ }
20654
+ return stripped;
20655
+ }
20656
+ async function listThreads(backendUrl, auth, opts = {}) {
20657
+ const base2 = getAgoraBaseUrl(backendUrl);
20658
+ const res = await fetch(`${base2}/api/conversations/threads/list`, {
20659
+ method: "POST",
20660
+ headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
20661
+ body: JSON.stringify({ limit: opts.limit ?? 50, offset: opts.offset ?? 0 })
20662
+ });
20663
+ if (!res.ok) {
20664
+ throw new Error(`[AthenaSDK] Failed to list threads: ${res.status}`);
20665
+ }
20666
+ return res.json();
20667
+ }
20668
+ function deserializeMessage(msg) {
20669
+ if (msg && typeof msg === "object" && "lc" in msg && "kwargs" in msg && msg.type === "constructor") {
20670
+ const kwargs = msg.kwargs;
20671
+ const deserializedToolCalls = Array.isArray(kwargs.tool_calls) ? kwargs.tool_calls.map((tc) => {
20672
+ if (tc && typeof tc === "object" && "lc" in tc && "kwargs" in tc) {
20673
+ return tc.kwargs;
20674
+ }
20675
+ return tc;
20676
+ }) : kwargs.tool_calls;
20677
+ return { ...kwargs, tool_calls: deserializedToolCalls };
20678
+ }
20679
+ return msg;
20680
+ }
20681
+ async function getThreadState(backendUrl, auth, threadId) {
20682
+ const base2 = getAgoraBaseUrl(backendUrl);
20683
+ const res = await fetch(`${base2}/api/unstable/threads/${threadId}`, {
20684
+ method: "GET",
20685
+ headers: { ...getAuthHeaders(auth) }
20686
+ });
20687
+ if (!res.ok) {
20688
+ throw new Error(`[AthenaSDK] Failed to get thread state: ${res.status}`);
20689
+ }
20690
+ const data = await res.json();
20691
+ if (Array.isArray(data.messages)) {
20692
+ data.messages = data.messages.map(deserializeMessage);
20693
+ }
20694
+ return data;
20695
+ }
20696
+ async function archiveThread(backendUrl, auth, threadId) {
20697
+ const base2 = getAgoraBaseUrl(backendUrl);
20698
+ const res = await fetch(`${base2}/api/conversations/threads/archive`, {
20699
+ method: "POST",
20700
+ headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
20701
+ body: JSON.stringify({ thread_id: threadId })
20702
+ });
20703
+ if (!res.ok) {
20704
+ throw new Error(`[AthenaSDK] Failed to archive thread: ${res.status}`);
20705
+ }
20706
+ }
20581
20707
  const DEFAULT_API_URL = "https://sync.athenaintel.com/api/chat";
20582
20708
  const DEFAULT_BACKEND_URL = "https://api.athenaintel.com/api/assistant-ui";
20583
20709
  const DEFAULT_MODEL = "claude-sonnet-4-6-low";
@@ -20737,6 +20863,7 @@ const createConverter = (optimisticMessageCache) => (state, connectionMetadata)
20737
20863
  const useAthenaRuntime = (config2) => {
20738
20864
  const {
20739
20865
  apiUrl = DEFAULT_API_URL,
20866
+ resumeApiUrl,
20740
20867
  backendUrl = DEFAULT_BACKEND_URL,
20741
20868
  apiKey,
20742
20869
  token,
@@ -20747,9 +20874,9 @@ const useAthenaRuntime = (config2) => {
20747
20874
  workbench = [],
20748
20875
  knowledgeBase = [],
20749
20876
  systemPrompt,
20750
- threadId: threadIdProp,
20751
- initialMessages
20877
+ threadId: threadIdProp
20752
20878
  } = config2;
20879
+ const resolvedResumeApiUrl = resumeApiUrl ?? apiUrl.replace(/\/api\/chat$/, "/api/resume");
20753
20880
  const generatedIdRef = React.useRef(null);
20754
20881
  if (generatedIdRef.current === null) {
20755
20882
  generatedIdRef.current = crypto.randomUUID();
@@ -20765,10 +20892,12 @@ const useAthenaRuntime = (config2) => {
20765
20892
  tokenRef.current = token;
20766
20893
  const apiKeyRef = React.useRef(apiKey);
20767
20894
  apiKeyRef.current = apiKey;
20895
+ const isExistingThread = !!threadIdProp;
20768
20896
  const runtime = useAssistantTransportRuntime({
20769
- initialState: { messages: initialMessages ?? [] },
20897
+ initialState: { messages: [] },
20770
20898
  converter,
20771
20899
  api: apiUrl,
20900
+ resumeApi: resolvedResumeApiUrl,
20772
20901
  headers: async () => ({
20773
20902
  // Prefer parent-injected PropelAuth token over hardcoded API key
20774
20903
  ...tokenRef.current ? { Authorization: `Bearer ${tokenRef.current}` } : apiKeyRef.current ? { "X-API-KEY": apiKeyRef.current } : {},
@@ -20874,6 +21003,34 @@ const useAthenaRuntime = (config2) => {
20874
21003
  }
20875
21004
  }
20876
21005
  });
21006
+ const hasResumedRef = React.useRef(false);
21007
+ const prevThreadIdRef = React.useRef(threadId);
21008
+ if (prevThreadIdRef.current !== threadId) {
21009
+ prevThreadIdRef.current = threadId;
21010
+ hasResumedRef.current = false;
21011
+ }
21012
+ React.useEffect(() => {
21013
+ if (isExistingThread && !hasResumedRef.current) {
21014
+ hasResumedRef.current = true;
21015
+ (async () => {
21016
+ try {
21017
+ const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
21018
+ const state = await getThreadState(backendUrl, auth, threadId);
21019
+ runtime.thread.importExternalState({
21020
+ messages: state.messages
21021
+ });
21022
+ } catch (err) {
21023
+ if (process.env.NODE_ENV !== "production") {
21024
+ console.error("[AthenaSDK] Failed to load thread state:", err);
21025
+ }
21026
+ try {
21027
+ runtime.thread.unstable_resumeRun({ parentId: null });
21028
+ } catch {
21029
+ }
21030
+ }
21031
+ })();
21032
+ }
21033
+ }, [isExistingThread, runtime, threadId, backendUrl]);
20877
21034
  return runtime;
20878
21035
  };
20879
21036
  function r(e) {
@@ -24107,132 +24264,67 @@ function useAthenaConfig() {
24107
24264
  }
24108
24265
  return ctx;
24109
24266
  }
24110
- const ThreadLoadingContext = React.createContext(false);
24111
- function useThreadLoading() {
24112
- return React.useContext(ThreadLoadingContext);
24113
- }
24114
- const ThreadListContext = React.createContext(null);
24115
- function useThreadListStore() {
24116
- const store = React.useContext(ThreadListContext);
24117
- if (!store) {
24118
- throw new Error(
24119
- "[AthenaSDK] useThreadList must be used within an <AthenaProvider> that has thread management enabled."
24120
- );
24121
- }
24122
- return store;
24267
+ const AthenaThreadIdContext = React.createContext(void 0);
24268
+ function useAthenaThreadId() {
24269
+ return React.useContext(AthenaThreadIdContext);
24123
24270
  }
24124
- function getAuthHeaders(auth) {
24125
- if (auth.token) {
24126
- return { Authorization: `Bearer ${auth.token}` };
24127
- }
24128
- if (auth.apiKey) {
24129
- return { "X-API-KEY": auth.apiKey };
24130
- }
24131
- return {};
24132
- }
24133
- function getAgoraBaseUrl(backendUrl) {
24134
- return backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
24135
- }
24136
- async function listThreads(backendUrl, auth, opts = {}) {
24137
- const base2 = getAgoraBaseUrl(backendUrl);
24138
- const res = await fetch(`${base2}/api/conversations/threads/list`, {
24139
- method: "POST",
24140
- headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
24141
- body: JSON.stringify({ limit: opts.limit ?? 50, offset: opts.offset ?? 0 })
24142
- });
24143
- if (!res.ok) {
24144
- throw new Error(`[AthenaSDK] Failed to list threads: ${res.status}`);
24145
- }
24146
- return res.json();
24147
- }
24148
- function deserializeMessage(msg) {
24149
- if (msg && typeof msg === "object" && "lc" in msg && "kwargs" in msg && msg.type === "constructor") {
24150
- const kwargs = msg.kwargs;
24151
- if (Array.isArray(kwargs.tool_calls)) {
24152
- kwargs.tool_calls = kwargs.tool_calls.map((tc) => {
24153
- if (tc && typeof tc === "object" && "lc" in tc && "kwargs" in tc) {
24154
- return tc.kwargs;
24155
- }
24156
- return tc;
24157
- });
24158
- }
24159
- return kwargs;
24160
- }
24161
- return msg;
24162
- }
24163
- async function getThreadState(backendUrl, auth, threadId) {
24164
- const base2 = getAgoraBaseUrl(backendUrl);
24165
- const res = await fetch(`${base2}/api/unstable/threads/${threadId}`, {
24166
- method: "GET",
24167
- headers: { ...getAuthHeaders(auth) }
24168
- });
24169
- if (!res.ok) {
24170
- throw new Error(`[AthenaSDK] Failed to get thread state: ${res.status}`);
24171
- }
24172
- const data = await res.json();
24173
- if (Array.isArray(data.messages)) {
24174
- data.messages = data.messages.map(deserializeMessage);
24175
- }
24176
- return data;
24177
- }
24178
- async function archiveThread(backendUrl, auth, threadId) {
24179
- const base2 = getAgoraBaseUrl(backendUrl);
24180
- const res = await fetch(`${base2}/api/conversations/threads/archive`, {
24181
- method: "POST",
24182
- headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
24183
- body: JSON.stringify({ thread_id: threadId })
24184
- });
24185
- if (!res.ok) {
24186
- throw new Error(`[AthenaSDK] Failed to archive thread: ${res.status}`);
24187
- }
24188
- }
24189
- function createThreadListStore(config2) {
24190
- const auth = { apiKey: config2.apiKey, token: config2.token };
24191
- const store = create((set2, get2) => ({
24192
- threads: [],
24193
- activeThreadId: null,
24194
- isLoading: false,
24195
- error: null,
24196
- fetchThreads: async () => {
24197
- set2({ isLoading: true, error: null });
24271
+ function useAthenaThreadListAdapter(config2) {
24272
+ const configRef = React.useRef(config2);
24273
+ configRef.current = config2;
24274
+ const auth = React.useMemo(
24275
+ () => ({ apiKey: config2.apiKey, token: config2.token }),
24276
+ [config2.apiKey, config2.token]
24277
+ );
24278
+ const unstable_Provider = React.useCallback(
24279
+ function AthenaThreadProvider({ children }) {
24280
+ const aui = useAui();
24281
+ const remoteId = aui.threadListItem().getState().remoteId;
24282
+ return /* @__PURE__ */ jsxRuntime.jsx(AthenaThreadIdContext.Provider, { value: remoteId, children });
24283
+ },
24284
+ []
24285
+ );
24286
+ return React.useMemo(() => ({
24287
+ async list() {
24198
24288
  try {
24199
- const { threads } = await listThreads(config2.backendUrl, auth);
24200
- const sorted = [...threads].sort(
24201
- (a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
24202
- );
24203
- set2({ threads: sorted, isLoading: false });
24204
- } catch (e) {
24205
- set2({ error: e.message, isLoading: false });
24289
+ const { threads } = await listThreads(configRef.current.backendUrl, auth);
24290
+ return {
24291
+ threads: threads.map((t) => ({
24292
+ status: "regular",
24293
+ remoteId: t.thread_id,
24294
+ title: t.title || void 0
24295
+ }))
24296
+ };
24297
+ } catch (err) {
24298
+ console.error("[AthenaSDK] adapter.list() failed:", err);
24299
+ return { threads: [] };
24206
24300
  }
24207
24301
  },
24208
- switchThread: (threadId) => {
24209
- if (process.env.NODE_ENV !== "production") {
24210
- console.log("[AthenaThreads] switchThread called", { threadId, prev: get2().activeThreadId });
24211
- }
24212
- set2({ activeThreadId: threadId });
24302
+ async initialize(threadId) {
24303
+ return { remoteId: threadId, externalId: void 0 };
24213
24304
  },
24214
- newThread: async () => {
24215
- const localThreadId = `thread_${crypto.randomUUID()}`;
24216
- set2({ activeThreadId: localThreadId });
24217
- return localThreadId;
24305
+ async rename(_remoteId, _newTitle) {
24218
24306
  },
24219
- archiveThread: async (threadId) => {
24220
- var _a2;
24221
- try {
24222
- await archiveThread(config2.backendUrl, auth, threadId);
24223
- const { threads, activeThreadId } = get2();
24224
- const remaining = threads.filter((t) => t.thread_id !== threadId);
24225
- set2({
24226
- threads: remaining,
24227
- activeThreadId: activeThreadId === threadId ? ((_a2 = remaining[0]) == null ? void 0 : _a2.thread_id) ?? null : activeThreadId
24228
- });
24229
- } catch (e) {
24230
- set2({ error: e.message });
24231
- }
24232
- }
24233
- }));
24234
- store.getState().fetchThreads();
24235
- return store;
24307
+ async archive(remoteId) {
24308
+ await archiveThread(configRef.current.backendUrl, auth, remoteId);
24309
+ },
24310
+ async unarchive(_remoteId) {
24311
+ },
24312
+ async delete(remoteId) {
24313
+ await archiveThread(configRef.current.backendUrl, auth, remoteId);
24314
+ },
24315
+ async generateTitle(_remoteId, _messages) {
24316
+ return new ReadableStream({ start(c) {
24317
+ c.close();
24318
+ } });
24319
+ },
24320
+ async fetch(remoteId) {
24321
+ return {
24322
+ status: "regular",
24323
+ remoteId
24324
+ };
24325
+ },
24326
+ unstable_Provider
24327
+ }), [auth, unstable_Provider]);
24236
24328
  }
24237
24329
  const THEME_TO_CSS = {
24238
24330
  primary: "--primary",
@@ -24406,7 +24498,7 @@ const themes = {
24406
24498
  radius: "0.625rem"
24407
24499
  }
24408
24500
  };
24409
- function AthenaRuntimeInner({
24501
+ function AthenaStandalone({
24410
24502
  children,
24411
24503
  apiUrl,
24412
24504
  backendUrl,
@@ -24420,13 +24512,10 @@ function AthenaRuntimeInner({
24420
24512
  workbench,
24421
24513
  knowledgeBase,
24422
24514
  systemPrompt,
24423
- threadId,
24424
- initialMessages
24515
+ threadId
24425
24516
  }) {
24426
24517
  const auiTools = React.useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
24427
- const aui = useAui({
24428
- tools: auiTools
24429
- });
24518
+ const aui = useAui({ tools: auiTools });
24430
24519
  const runtime = useAthenaRuntime({
24431
24520
  apiUrl,
24432
24521
  backendUrl,
@@ -24439,8 +24528,7 @@ function AthenaRuntimeInner({
24439
24528
  workbench,
24440
24529
  knowledgeBase,
24441
24530
  systemPrompt,
24442
- threadId,
24443
- initialMessages
24531
+ threadId
24444
24532
  });
24445
24533
  const athenaConfig = React.useMemo(
24446
24534
  () => ({ backendUrl, apiKey, token }),
@@ -24448,6 +24536,85 @@ function AthenaRuntimeInner({
24448
24536
  );
24449
24537
  return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
24450
24538
  }
24539
+ function useAthenaRuntimeHook(config2) {
24540
+ const remoteId = useAthenaThreadId();
24541
+ return useAthenaRuntime({
24542
+ apiUrl: config2.apiUrl,
24543
+ backendUrl: config2.backendUrl,
24544
+ apiKey: config2.apiKey,
24545
+ token: config2.token,
24546
+ model: config2.model,
24547
+ agent: config2.agent,
24548
+ tools: config2.tools,
24549
+ frontendToolIds: config2.frontendToolIds,
24550
+ workbench: config2.workbench,
24551
+ knowledgeBase: config2.knowledgeBase,
24552
+ systemPrompt: config2.systemPrompt,
24553
+ threadId: remoteId
24554
+ });
24555
+ }
24556
+ function AthenaWithThreadList({
24557
+ children,
24558
+ apiUrl,
24559
+ backendUrl,
24560
+ apiKey,
24561
+ token,
24562
+ model,
24563
+ agent: agent2,
24564
+ tools,
24565
+ frontendToolIds,
24566
+ frontendTools,
24567
+ workbench,
24568
+ knowledgeBase,
24569
+ systemPrompt
24570
+ }) {
24571
+ const adapter = useAthenaThreadListAdapter({
24572
+ backendUrl,
24573
+ apiKey,
24574
+ token
24575
+ });
24576
+ const runtimeConfigRef = React.useRef({
24577
+ apiUrl,
24578
+ backendUrl,
24579
+ apiKey,
24580
+ token,
24581
+ model,
24582
+ agent: agent2,
24583
+ tools,
24584
+ frontendToolIds,
24585
+ workbench,
24586
+ knowledgeBase,
24587
+ systemPrompt
24588
+ });
24589
+ runtimeConfigRef.current = {
24590
+ apiUrl,
24591
+ backendUrl,
24592
+ apiKey,
24593
+ token,
24594
+ model,
24595
+ agent: agent2,
24596
+ tools,
24597
+ frontendToolIds,
24598
+ workbench,
24599
+ knowledgeBase,
24600
+ systemPrompt
24601
+ };
24602
+ const runtimeHook = React.useCallback(
24603
+ () => useAthenaRuntimeHook(runtimeConfigRef.current),
24604
+ []
24605
+ );
24606
+ const runtime = useRemoteThreadListRuntime({
24607
+ runtimeHook,
24608
+ adapter
24609
+ });
24610
+ const auiTools = React.useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
24611
+ const aui = useAui({ tools: auiTools });
24612
+ const athenaConfig = React.useMemo(
24613
+ () => ({ backendUrl, apiKey, token }),
24614
+ [backendUrl, apiKey, token]
24615
+ );
24616
+ return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
24617
+ }
24451
24618
  function AthenaProvider({
24452
24619
  children,
24453
24620
  apiKey,
@@ -24470,75 +24637,46 @@ function AthenaProvider({
24470
24637
  const parentAuthToken = useParentAuth();
24471
24638
  const effectiveToken = tokenProp ?? parentAuthToken;
24472
24639
  const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
24473
- const threadListStoreRef = React.useRef(null);
24474
- if (enableThreadList && !threadListStoreRef.current) {
24475
- threadListStoreRef.current = createThreadListStore({
24476
- backendUrl: effectiveBackendUrl,
24477
- apiKey,
24478
- token: effectiveToken
24479
- });
24480
- }
24481
- const activeThreadId = threadListStoreRef.current ? useStore$1(threadListStoreRef.current, (s) => s.activeThreadId) : null;
24482
- const [displayedThreadId, setDisplayedThreadId] = React.useState(null);
24483
- const [loadedMessages, setLoadedMessages] = React.useState(void 0);
24484
- const [isLoadingThread, setIsLoadingThread] = React.useState(false);
24485
- React.useEffect(() => {
24486
- var _a2;
24487
- if (!enableThreadList) return;
24488
- if (activeThreadId === displayedThreadId) return;
24489
- const threads = ((_a2 = threadListStoreRef.current) == null ? void 0 : _a2.getState().threads) ?? [];
24490
- const isExistingThread = threads.some((t) => t.thread_id === activeThreadId);
24491
- if (!isExistingThread) {
24492
- setLoadedMessages(void 0);
24493
- setDisplayedThreadId(activeThreadId);
24494
- setIsLoadingThread(false);
24495
- return;
24496
- }
24497
- let cancelled = false;
24498
- setIsLoadingThread(true);
24499
- getThreadState(effectiveBackendUrl, { apiKey, token: effectiveToken }, activeThreadId).then((state) => {
24500
- if (cancelled) return;
24501
- setLoadedMessages(state.messages ?? []);
24502
- setDisplayedThreadId(activeThreadId);
24503
- setIsLoadingThread(false);
24504
- }).catch((err) => {
24505
- if (cancelled) return;
24506
- if (process.env.NODE_ENV !== "production") {
24507
- console.error("[AthenaSDK] Failed to load thread state:", err);
24640
+ let inner;
24641
+ if (enableThreadList) {
24642
+ inner = /* @__PURE__ */ jsxRuntime.jsx(
24643
+ AthenaWithThreadList,
24644
+ {
24645
+ apiUrl,
24646
+ backendUrl: effectiveBackendUrl,
24647
+ apiKey,
24648
+ token: effectiveToken,
24649
+ model,
24650
+ agent: agent2,
24651
+ tools,
24652
+ frontendToolIds: frontendToolNames,
24653
+ frontendTools,
24654
+ workbench,
24655
+ knowledgeBase,
24656
+ systemPrompt,
24657
+ children
24508
24658
  }
24509
- setLoadedMessages(void 0);
24510
- setDisplayedThreadId(activeThreadId);
24511
- setIsLoadingThread(false);
24512
- });
24513
- return () => {
24514
- cancelled = true;
24515
- };
24516
- }, [activeThreadId, displayedThreadId, enableThreadList, effectiveBackendUrl, apiKey, effectiveToken]);
24517
- const resolvedThreadId = threadIdProp ?? displayedThreadId ?? void 0;
24518
- const runtimeContent = /* @__PURE__ */ jsxRuntime.jsx(ThreadLoadingContext.Provider, { value: isLoadingThread, children: /* @__PURE__ */ jsxRuntime.jsx(
24519
- AthenaRuntimeInner,
24520
- {
24521
- apiUrl,
24522
- backendUrl: effectiveBackendUrl,
24523
- apiKey,
24524
- token: effectiveToken,
24525
- model,
24526
- agent: agent2,
24527
- tools,
24528
- frontendToolIds: frontendToolNames,
24529
- frontendTools,
24530
- workbench,
24531
- knowledgeBase,
24532
- systemPrompt,
24533
- threadId: resolvedThreadId,
24534
- initialMessages: loadedMessages,
24535
- children
24536
- },
24537
- resolvedThreadId ?? "__new__"
24538
- ) });
24539
- let inner = runtimeContent;
24540
- if (enableThreadList && threadListStoreRef.current) {
24541
- inner = /* @__PURE__ */ jsxRuntime.jsx(ThreadListContext.Provider, { value: threadListStoreRef.current, children: inner });
24659
+ );
24660
+ } else {
24661
+ inner = /* @__PURE__ */ jsxRuntime.jsx(
24662
+ AthenaStandalone,
24663
+ {
24664
+ apiUrl,
24665
+ backendUrl: effectiveBackendUrl,
24666
+ apiKey,
24667
+ token: effectiveToken,
24668
+ model,
24669
+ agent: agent2,
24670
+ tools,
24671
+ frontendToolIds: frontendToolNames,
24672
+ frontendTools,
24673
+ workbench,
24674
+ knowledgeBase,
24675
+ systemPrompt,
24676
+ threadId: threadIdProp,
24677
+ children
24678
+ }
24679
+ );
24542
24680
  }
24543
24681
  if (themeStyleVars) {
24544
24682
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "athena-themed", style: themeStyleVars, children: inner });
@@ -57336,10 +57474,10 @@ const HorizontalRule$1 = HorizontalRule.extend({
57336
57474
  };
57337
57475
  }
57338
57476
  });
57339
- const Image = Node3.create({
57477
+ const Image$1 = Node3.create({
57340
57478
  name: "image"
57341
57479
  });
57342
- const Image$1 = Image.extend({
57480
+ const Image$1$1 = Image$1.extend({
57343
57481
  /**
57344
57482
  * @return {{markdown: MarkdownNodeSpec}}
57345
57483
  */
@@ -57623,10 +57761,10 @@ const Italic$1 = Italic.extend({
57623
57761
  };
57624
57762
  }
57625
57763
  });
57626
- const Link = Mark2.create({
57764
+ const Link$1 = Mark2.create({
57627
57765
  name: "link"
57628
57766
  });
57629
- const Link$1 = Link.extend({
57767
+ const Link$1$1 = Link$1.extend({
57630
57768
  /**
57631
57769
  * @return {{markdown: MarkdownMarkSpec}}
57632
57770
  */
@@ -57663,7 +57801,7 @@ const Strike$1 = Strike.extend({
57663
57801
  };
57664
57802
  }
57665
57803
  });
57666
- const markdownExtensions = [Blockquote$1, BulletList$1, CodeBlock$1, HardBreak$1, Heading$1, HorizontalRule$1, HTMLNode, Image$1, ListItem$1, OrderedList$1, Paragraph$1, Table$1, TaskItem$1, TaskList$1, Text$1, Bold$1, Code$1$1, HTMLMark, Italic$1, Link$1, Strike$1];
57804
+ const markdownExtensions = [Blockquote$1, BulletList$1, CodeBlock$1, HardBreak$1, Heading$1, HorizontalRule$1, HTMLNode, Image$1$1, ListItem$1, OrderedList$1, Paragraph$1, Table$1, TaskItem$1, TaskList$1, Text$1, Bold$1, Code$1$1, HTMLMark, Italic$1, Link$1$1, Strike$1];
57667
57805
  function getMarkdownSpec(extension) {
57668
57806
  var _extension$storage, _markdownExtensions$f;
57669
57807
  const markdownSpec = (_extension$storage = extension.storage) === null || _extension$storage === void 0 ? void 0 : _extension$storage.markdown;
@@ -60476,41 +60614,41 @@ const createLucideIcon = (iconName, iconNode) => {
60476
60614
  * This source code is licensed under the ISC license.
60477
60615
  * See the LICENSE file in the root directory of this source tree.
60478
60616
  */
60479
- const __iconNode$E = [
60617
+ const __iconNode$J = [
60480
60618
  ["rect", { width: "20", height: "5", x: "2", y: "3", rx: "1", key: "1wp1u1" }],
60481
60619
  ["path", { d: "M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8", key: "1s80jp" }],
60482
60620
  ["path", { d: "M10 12h4", key: "a56b0p" }]
60483
60621
  ];
60484
- const Archive = createLucideIcon("archive", __iconNode$E);
60622
+ const Archive = createLucideIcon("archive", __iconNode$J);
60485
60623
  /**
60486
60624
  * @license lucide-react v0.575.0 - ISC
60487
60625
  *
60488
60626
  * This source code is licensed under the ISC license.
60489
60627
  * See the LICENSE file in the root directory of this source tree.
60490
60628
  */
60491
- const __iconNode$D = [
60629
+ const __iconNode$I = [
60492
60630
  ["path", { d: "M12 5v14", key: "s699le" }],
60493
60631
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
60494
60632
  ];
60495
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$D);
60633
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$I);
60496
60634
  /**
60497
60635
  * @license lucide-react v0.575.0 - ISC
60498
60636
  *
60499
60637
  * This source code is licensed under the ISC license.
60500
60638
  * See the LICENSE file in the root directory of this source tree.
60501
60639
  */
60502
- const __iconNode$C = [
60640
+ const __iconNode$H = [
60503
60641
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
60504
60642
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
60505
60643
  ];
60506
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$C);
60644
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$H);
60507
60645
  /**
60508
60646
  * @license lucide-react v0.575.0 - ISC
60509
60647
  *
60510
60648
  * This source code is licensed under the ISC license.
60511
60649
  * See the LICENSE file in the root directory of this source tree.
60512
60650
  */
60513
- const __iconNode$B = [
60651
+ const __iconNode$G = [
60514
60652
  ["path", { d: "M12 7v14", key: "1akyts" }],
60515
60653
  [
60516
60654
  "path",
@@ -60520,14 +60658,14 @@ const __iconNode$B = [
60520
60658
  }
60521
60659
  ]
60522
60660
  ];
60523
- const BookOpen = createLucideIcon("book-open", __iconNode$B);
60661
+ const BookOpen = createLucideIcon("book-open", __iconNode$G);
60524
60662
  /**
60525
60663
  * @license lucide-react v0.575.0 - ISC
60526
60664
  *
60527
60665
  * This source code is licensed under the ISC license.
60528
60666
  * See the LICENSE file in the root directory of this source tree.
60529
60667
  */
60530
- const __iconNode$A = [
60668
+ const __iconNode$F = [
60531
60669
  ["path", { d: "M12 18V5", key: "adv99a" }],
60532
60670
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
60533
60671
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -60537,148 +60675,148 @@ const __iconNode$A = [
60537
60675
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
60538
60676
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
60539
60677
  ];
60540
- const Brain = createLucideIcon("brain", __iconNode$A);
60678
+ const Brain = createLucideIcon("brain", __iconNode$F);
60541
60679
  /**
60542
60680
  * @license lucide-react v0.575.0 - ISC
60543
60681
  *
60544
60682
  * This source code is licensed under the ISC license.
60545
60683
  * See the LICENSE file in the root directory of this source tree.
60546
60684
  */
60547
- const __iconNode$z = [
60685
+ const __iconNode$E = [
60548
60686
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
60549
60687
  ["path", { d: "M18 17V9", key: "2bz60n" }],
60550
60688
  ["path", { d: "M13 17V5", key: "1frdt8" }],
60551
60689
  ["path", { d: "M8 17v-3", key: "17ska0" }]
60552
60690
  ];
60553
- const ChartColumn = createLucideIcon("chart-column", __iconNode$z);
60691
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$E);
60554
60692
  /**
60555
60693
  * @license lucide-react v0.575.0 - ISC
60556
60694
  *
60557
60695
  * This source code is licensed under the ISC license.
60558
60696
  * See the LICENSE file in the root directory of this source tree.
60559
60697
  */
60560
- const __iconNode$y = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60561
- const Check = createLucideIcon("check", __iconNode$y);
60698
+ const __iconNode$D = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60699
+ const Check = createLucideIcon("check", __iconNode$D);
60562
60700
  /**
60563
60701
  * @license lucide-react v0.575.0 - ISC
60564
60702
  *
60565
60703
  * This source code is licensed under the ISC license.
60566
60704
  * See the LICENSE file in the root directory of this source tree.
60567
60705
  */
60568
- const __iconNode$x = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60569
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$x);
60706
+ const __iconNode$C = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60707
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$C);
60570
60708
  /**
60571
60709
  * @license lucide-react v0.575.0 - ISC
60572
60710
  *
60573
60711
  * This source code is licensed under the ISC license.
60574
60712
  * See the LICENSE file in the root directory of this source tree.
60575
60713
  */
60576
- const __iconNode$w = [
60714
+ const __iconNode$B = [
60577
60715
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60578
60716
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
60579
60717
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
60580
60718
  ];
60581
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$w);
60719
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$B);
60582
60720
  /**
60583
60721
  * @license lucide-react v0.575.0 - ISC
60584
60722
  *
60585
60723
  * This source code is licensed under the ISC license.
60586
60724
  * See the LICENSE file in the root directory of this source tree.
60587
60725
  */
60588
- const __iconNode$v = [
60726
+ const __iconNode$A = [
60589
60727
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60590
60728
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
60591
60729
  ];
60592
- const CircleCheck = createLucideIcon("circle-check", __iconNode$v);
60730
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$A);
60593
60731
  /**
60594
60732
  * @license lucide-react v0.575.0 - ISC
60595
60733
  *
60596
60734
  * This source code is licensed under the ISC license.
60597
60735
  * See the LICENSE file in the root directory of this source tree.
60598
60736
  */
60599
- const __iconNode$u = [
60737
+ const __iconNode$z = [
60600
60738
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60601
60739
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
60602
60740
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
60603
60741
  ];
60604
- const CircleX = createLucideIcon("circle-x", __iconNode$u);
60742
+ const CircleX = createLucideIcon("circle-x", __iconNode$z);
60605
60743
  /**
60606
60744
  * @license lucide-react v0.575.0 - ISC
60607
60745
  *
60608
60746
  * This source code is licensed under the ISC license.
60609
60747
  * See the LICENSE file in the root directory of this source tree.
60610
60748
  */
60611
- const __iconNode$t = [
60749
+ const __iconNode$y = [
60612
60750
  ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
60613
60751
  ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
60614
60752
  ];
60615
- const Code = createLucideIcon("code", __iconNode$t);
60753
+ const Code = createLucideIcon("code", __iconNode$y);
60616
60754
  /**
60617
60755
  * @license lucide-react v0.575.0 - ISC
60618
60756
  *
60619
60757
  * This source code is licensed under the ISC license.
60620
60758
  * See the LICENSE file in the root directory of this source tree.
60621
60759
  */
60622
- const __iconNode$s = [
60760
+ const __iconNode$x = [
60623
60761
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
60624
60762
  ["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" }]
60625
60763
  ];
60626
- const Copy = createLucideIcon("copy", __iconNode$s);
60764
+ const Copy = createLucideIcon("copy", __iconNode$x);
60627
60765
  /**
60628
60766
  * @license lucide-react v0.575.0 - ISC
60629
60767
  *
60630
60768
  * This source code is licensed under the ISC license.
60631
60769
  * See the LICENSE file in the root directory of this source tree.
60632
60770
  */
60633
- const __iconNode$r = [
60771
+ const __iconNode$w = [
60634
60772
  ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
60635
60773
  ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
60636
60774
  ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
60637
60775
  ];
60638
- const Database = createLucideIcon("database", __iconNode$r);
60776
+ const Database = createLucideIcon("database", __iconNode$w);
60639
60777
  /**
60640
60778
  * @license lucide-react v0.575.0 - ISC
60641
60779
  *
60642
60780
  * This source code is licensed under the ISC license.
60643
60781
  * See the LICENSE file in the root directory of this source tree.
60644
60782
  */
60645
- const __iconNode$q = [
60783
+ const __iconNode$v = [
60646
60784
  ["path", { d: "M12 15V3", key: "m9g1x1" }],
60647
60785
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
60648
60786
  ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
60649
60787
  ];
60650
- const Download = createLucideIcon("download", __iconNode$q);
60788
+ const Download = createLucideIcon("download", __iconNode$v);
60651
60789
  /**
60652
60790
  * @license lucide-react v0.575.0 - ISC
60653
60791
  *
60654
60792
  * This source code is licensed under the ISC license.
60655
60793
  * See the LICENSE file in the root directory of this source tree.
60656
60794
  */
60657
- const __iconNode$p = [
60795
+ const __iconNode$u = [
60658
60796
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
60659
60797
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
60660
60798
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
60661
60799
  ];
60662
- const Ellipsis = createLucideIcon("ellipsis", __iconNode$p);
60800
+ const Ellipsis = createLucideIcon("ellipsis", __iconNode$u);
60663
60801
  /**
60664
60802
  * @license lucide-react v0.575.0 - ISC
60665
60803
  *
60666
60804
  * This source code is licensed under the ISC license.
60667
60805
  * See the LICENSE file in the root directory of this source tree.
60668
60806
  */
60669
- const __iconNode$o = [
60807
+ const __iconNode$t = [
60670
60808
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60671
60809
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
60672
60810
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
60673
60811
  ];
60674
- const ExternalLink = createLucideIcon("external-link", __iconNode$o);
60812
+ const ExternalLink = createLucideIcon("external-link", __iconNode$t);
60675
60813
  /**
60676
60814
  * @license lucide-react v0.575.0 - ISC
60677
60815
  *
60678
60816
  * This source code is licensed under the ISC license.
60679
60817
  * See the LICENSE file in the root directory of this source tree.
60680
60818
  */
60681
- const __iconNode$n = [
60819
+ const __iconNode$s = [
60682
60820
  [
60683
60821
  "path",
60684
60822
  {
@@ -60690,14 +60828,14 @@ const __iconNode$n = [
60690
60828
  ["path", { d: "M9 15h6", key: "cctwl0" }],
60691
60829
  ["path", { d: "M12 18v-6", key: "17g6i2" }]
60692
60830
  ];
60693
- const FilePlus = createLucideIcon("file-plus", __iconNode$n);
60831
+ const FilePlus = createLucideIcon("file-plus", __iconNode$s);
60694
60832
  /**
60695
60833
  * @license lucide-react v0.575.0 - ISC
60696
60834
  *
60697
60835
  * This source code is licensed under the ISC license.
60698
60836
  * See the LICENSE file in the root directory of this source tree.
60699
60837
  */
60700
- const __iconNode$m = [
60838
+ const __iconNode$r = [
60701
60839
  [
60702
60840
  "path",
60703
60841
  {
@@ -60711,14 +60849,14 @@ const __iconNode$m = [
60711
60849
  ["path", { d: "M8 17h2", key: "2yhykz" }],
60712
60850
  ["path", { d: "M14 17h2", key: "10kma7" }]
60713
60851
  ];
60714
- const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$m);
60852
+ const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$r);
60715
60853
  /**
60716
60854
  * @license lucide-react v0.575.0 - ISC
60717
60855
  *
60718
60856
  * This source code is licensed under the ISC license.
60719
60857
  * See the LICENSE file in the root directory of this source tree.
60720
60858
  */
60721
- const __iconNode$l = [
60859
+ const __iconNode$q = [
60722
60860
  [
60723
60861
  "path",
60724
60862
  {
@@ -60731,14 +60869,14 @@ const __iconNode$l = [
60731
60869
  ["path", { d: "M16 13H8", key: "t4e002" }],
60732
60870
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
60733
60871
  ];
60734
- const FileText = createLucideIcon("file-text", __iconNode$l);
60872
+ const FileText = createLucideIcon("file-text", __iconNode$q);
60735
60873
  /**
60736
60874
  * @license lucide-react v0.575.0 - ISC
60737
60875
  *
60738
60876
  * This source code is licensed under the ISC license.
60739
60877
  * See the LICENSE file in the root directory of this source tree.
60740
60878
  */
60741
- const __iconNode$k = [
60879
+ const __iconNode$p = [
60742
60880
  [
60743
60881
  "path",
60744
60882
  {
@@ -60748,26 +60886,54 @@ const __iconNode$k = [
60748
60886
  ],
60749
60887
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
60750
60888
  ];
60751
- const File$1 = createLucideIcon("file", __iconNode$k);
60889
+ const File$1 = createLucideIcon("file", __iconNode$p);
60752
60890
  /**
60753
60891
  * @license lucide-react v0.575.0 - ISC
60754
60892
  *
60755
60893
  * This source code is licensed under the ISC license.
60756
60894
  * See the LICENSE file in the root directory of this source tree.
60757
60895
  */
60758
- const __iconNode$j = [
60896
+ const __iconNode$o = [
60897
+ [
60898
+ "path",
60899
+ {
60900
+ d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",
60901
+ key: "usdka0"
60902
+ }
60903
+ ]
60904
+ ];
60905
+ const FolderOpen = createLucideIcon("folder-open", __iconNode$o);
60906
+ /**
60907
+ * @license lucide-react v0.575.0 - ISC
60908
+ *
60909
+ * This source code is licensed under the ISC license.
60910
+ * See the LICENSE file in the root directory of this source tree.
60911
+ */
60912
+ const __iconNode$n = [
60759
60913
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60760
60914
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
60761
60915
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
60762
60916
  ];
60763
- const Globe = createLucideIcon("globe", __iconNode$j);
60917
+ const Globe = createLucideIcon("globe", __iconNode$n);
60764
60918
  /**
60765
60919
  * @license lucide-react v0.575.0 - ISC
60766
60920
  *
60767
60921
  * This source code is licensed under the ISC license.
60768
60922
  * See the LICENSE file in the root directory of this source tree.
60769
60923
  */
60770
- const __iconNode$i = [
60924
+ const __iconNode$m = [
60925
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
60926
+ ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
60927
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
60928
+ ];
60929
+ const Image = createLucideIcon("image", __iconNode$m);
60930
+ /**
60931
+ * @license lucide-react v0.575.0 - ISC
60932
+ *
60933
+ * This source code is licensed under the ISC license.
60934
+ * See the LICENSE file in the root directory of this source tree.
60935
+ */
60936
+ const __iconNode$l = [
60771
60937
  [
60772
60938
  "path",
60773
60939
  {
@@ -60790,35 +60956,46 @@ const __iconNode$i = [
60790
60956
  }
60791
60957
  ]
60792
60958
  ];
60793
- const Layers = createLucideIcon("layers", __iconNode$i);
60959
+ const Layers = createLucideIcon("layers", __iconNode$l);
60794
60960
  /**
60795
60961
  * @license lucide-react v0.575.0 - ISC
60796
60962
  *
60797
60963
  * This source code is licensed under the ISC license.
60798
60964
  * See the LICENSE file in the root directory of this source tree.
60799
60965
  */
60800
- const __iconNode$h = [
60966
+ const __iconNode$k = [
60801
60967
  ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
60802
60968
  ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
60803
60969
  ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
60804
60970
  ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
60805
60971
  ];
60806
- const LayoutGrid = createLucideIcon("layout-grid", __iconNode$h);
60972
+ const LayoutGrid = createLucideIcon("layout-grid", __iconNode$k);
60807
60973
  /**
60808
60974
  * @license lucide-react v0.575.0 - ISC
60809
60975
  *
60810
60976
  * This source code is licensed under the ISC license.
60811
60977
  * See the LICENSE file in the root directory of this source tree.
60812
60978
  */
60813
- const __iconNode$g = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60814
- const LoaderCircle = createLucideIcon("loader-circle", __iconNode$g);
60979
+ const __iconNode$j = [
60980
+ ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
60981
+ ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
60982
+ ];
60983
+ const Link = createLucideIcon("link", __iconNode$j);
60815
60984
  /**
60816
60985
  * @license lucide-react v0.575.0 - ISC
60817
60986
  *
60818
60987
  * This source code is licensed under the ISC license.
60819
60988
  * See the LICENSE file in the root directory of this source tree.
60820
60989
  */
60821
- const __iconNode$f = [
60990
+ const __iconNode$i = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60991
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$i);
60992
+ /**
60993
+ * @license lucide-react v0.575.0 - ISC
60994
+ *
60995
+ * This source code is licensed under the ISC license.
60996
+ * See the LICENSE file in the root directory of this source tree.
60997
+ */
60998
+ const __iconNode$h = [
60822
60999
  ["path", { d: "M12 2v4", key: "3427ic" }],
60823
61000
  ["path", { d: "m16.2 7.8 2.9-2.9", key: "r700ao" }],
60824
61001
  ["path", { d: "M18 12h4", key: "wj9ykh" }],
@@ -60828,38 +61005,38 @@ const __iconNode$f = [
60828
61005
  ["path", { d: "M2 12h4", key: "j09sii" }],
60829
61006
  ["path", { d: "m4.9 4.9 2.9 2.9", key: "giyufr" }]
60830
61007
  ];
60831
- const Loader = createLucideIcon("loader", __iconNode$f);
61008
+ const Loader = createLucideIcon("loader", __iconNode$h);
60832
61009
  /**
60833
61010
  * @license lucide-react v0.575.0 - ISC
60834
61011
  *
60835
61012
  * This source code is licensed under the ISC license.
60836
61013
  * See the LICENSE file in the root directory of this source tree.
60837
61014
  */
60838
- const __iconNode$e = [
61015
+ const __iconNode$g = [
60839
61016
  ["path", { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7", key: "132q7q" }],
60840
61017
  ["rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", key: "izxlao" }]
60841
61018
  ];
60842
- const Mail = createLucideIcon("mail", __iconNode$e);
61019
+ const Mail = createLucideIcon("mail", __iconNode$g);
60843
61020
  /**
60844
61021
  * @license lucide-react v0.575.0 - ISC
60845
61022
  *
60846
61023
  * This source code is licensed under the ISC license.
60847
61024
  * See the LICENSE file in the root directory of this source tree.
60848
61025
  */
60849
- const __iconNode$d = [
61026
+ const __iconNode$f = [
60850
61027
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60851
61028
  ["path", { d: "m21 3-7 7", key: "1l2asr" }],
60852
61029
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60853
61030
  ["path", { d: "M9 21H3v-6", key: "wtvkvv" }]
60854
61031
  ];
60855
- const Maximize2 = createLucideIcon("maximize-2", __iconNode$d);
61032
+ const Maximize2 = createLucideIcon("maximize-2", __iconNode$f);
60856
61033
  /**
60857
61034
  * @license lucide-react v0.575.0 - ISC
60858
61035
  *
60859
61036
  * This source code is licensed under the ISC license.
60860
61037
  * See the LICENSE file in the root directory of this source tree.
60861
61038
  */
60862
- const __iconNode$c = [
61039
+ const __iconNode$e = [
60863
61040
  [
60864
61041
  "path",
60865
61042
  {
@@ -60868,39 +61045,39 @@ const __iconNode$c = [
60868
61045
  }
60869
61046
  ]
60870
61047
  ];
60871
- const MessageSquare = createLucideIcon("message-square", __iconNode$c);
61048
+ const MessageSquare = createLucideIcon("message-square", __iconNode$e);
60872
61049
  /**
60873
61050
  * @license lucide-react v0.575.0 - ISC
60874
61051
  *
60875
61052
  * This source code is licensed under the ISC license.
60876
61053
  * See the LICENSE file in the root directory of this source tree.
60877
61054
  */
60878
- const __iconNode$b = [
61055
+ const __iconNode$d = [
60879
61056
  ["path", { d: "m14 10 7-7", key: "oa77jy" }],
60880
61057
  ["path", { d: "M20 10h-6V4", key: "mjg0md" }],
60881
61058
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60882
61059
  ["path", { d: "M4 14h6v6", key: "rmj7iw" }]
60883
61060
  ];
60884
- const Minimize2 = createLucideIcon("minimize-2", __iconNode$b);
61061
+ const Minimize2 = createLucideIcon("minimize-2", __iconNode$d);
60885
61062
  /**
60886
61063
  * @license lucide-react v0.575.0 - ISC
60887
61064
  *
60888
61065
  * This source code is licensed under the ISC license.
60889
61066
  * See the LICENSE file in the root directory of this source tree.
60890
61067
  */
60891
- const __iconNode$a = [
61068
+ const __iconNode$c = [
60892
61069
  ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
60893
61070
  ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
60894
61071
  ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
60895
61072
  ];
60896
- const Monitor = createLucideIcon("monitor", __iconNode$a);
61073
+ const Monitor = createLucideIcon("monitor", __iconNode$c);
60897
61074
  /**
60898
61075
  * @license lucide-react v0.575.0 - ISC
60899
61076
  *
60900
61077
  * This source code is licensed under the ISC license.
60901
61078
  * See the LICENSE file in the root directory of this source tree.
60902
61079
  */
60903
- const __iconNode$9 = [
61080
+ const __iconNode$b = [
60904
61081
  ["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" }],
60905
61082
  ["path", { d: "M2 6h4", key: "aawbzj" }],
60906
61083
  ["path", { d: "M2 10h4", key: "l0bgd4" }],
@@ -60914,14 +61091,14 @@ const __iconNode$9 = [
60914
61091
  }
60915
61092
  ]
60916
61093
  ];
60917
- const NotebookPen = createLucideIcon("notebook-pen", __iconNode$9);
61094
+ const NotebookPen = createLucideIcon("notebook-pen", __iconNode$b);
60918
61095
  /**
60919
61096
  * @license lucide-react v0.575.0 - ISC
60920
61097
  *
60921
61098
  * This source code is licensed under the ISC license.
60922
61099
  * See the LICENSE file in the root directory of this source tree.
60923
61100
  */
60924
- const __iconNode$8 = [
61101
+ const __iconNode$a = [
60925
61102
  ["path", { d: "M13 21h8", key: "1jsn5i" }],
60926
61103
  [
60927
61104
  "path",
@@ -60931,61 +61108,61 @@ const __iconNode$8 = [
60931
61108
  }
60932
61109
  ]
60933
61110
  ];
60934
- const PenLine = createLucideIcon("pen-line", __iconNode$8);
61111
+ const PenLine = createLucideIcon("pen-line", __iconNode$a);
60935
61112
  /**
60936
61113
  * @license lucide-react v0.575.0 - ISC
60937
61114
  *
60938
61115
  * This source code is licensed under the ISC license.
60939
61116
  * See the LICENSE file in the root directory of this source tree.
60940
61117
  */
60941
- const __iconNode$7 = [
61118
+ const __iconNode$9 = [
60942
61119
  ["path", { d: "M5 12h14", key: "1ays0h" }],
60943
61120
  ["path", { d: "M12 5v14", key: "s699le" }]
60944
61121
  ];
60945
- const Plus = createLucideIcon("plus", __iconNode$7);
61122
+ const Plus = createLucideIcon("plus", __iconNode$9);
60946
61123
  /**
60947
61124
  * @license lucide-react v0.575.0 - ISC
60948
61125
  *
60949
61126
  * This source code is licensed under the ISC license.
60950
61127
  * See the LICENSE file in the root directory of this source tree.
60951
61128
  */
60952
- const __iconNode$6 = [
61129
+ const __iconNode$8 = [
60953
61130
  ["path", { d: "M2 3h20", key: "91anmk" }],
60954
61131
  ["path", { d: "M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3", key: "2k9sn8" }],
60955
61132
  ["path", { d: "m7 21 5-5 5 5", key: "bip4we" }]
60956
61133
  ];
60957
- const Presentation = createLucideIcon("presentation", __iconNode$6);
61134
+ const Presentation = createLucideIcon("presentation", __iconNode$8);
60958
61135
  /**
60959
61136
  * @license lucide-react v0.575.0 - ISC
60960
61137
  *
60961
61138
  * This source code is licensed under the ISC license.
60962
61139
  * See the LICENSE file in the root directory of this source tree.
60963
61140
  */
60964
- const __iconNode$5 = [
61141
+ const __iconNode$7 = [
60965
61142
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
60966
61143
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
60967
61144
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
60968
61145
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
60969
61146
  ];
60970
- const RefreshCw = createLucideIcon("refresh-cw", __iconNode$5);
61147
+ const RefreshCw = createLucideIcon("refresh-cw", __iconNode$7);
60971
61148
  /**
60972
61149
  * @license lucide-react v0.575.0 - ISC
60973
61150
  *
60974
61151
  * This source code is licensed under the ISC license.
60975
61152
  * See the LICENSE file in the root directory of this source tree.
60976
61153
  */
60977
- const __iconNode$4 = [
61154
+ const __iconNode$6 = [
60978
61155
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
60979
61156
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
60980
61157
  ];
60981
- const Search = createLucideIcon("search", __iconNode$4);
61158
+ const Search = createLucideIcon("search", __iconNode$6);
60982
61159
  /**
60983
61160
  * @license lucide-react v0.575.0 - ISC
60984
61161
  *
60985
61162
  * This source code is licensed under the ISC license.
60986
61163
  * See the LICENSE file in the root directory of this source tree.
60987
61164
  */
60988
- const __iconNode$3 = [
61165
+ const __iconNode$5 = [
60989
61166
  [
60990
61167
  "path",
60991
61168
  {
@@ -60995,17 +61172,46 @@ const __iconNode$3 = [
60995
61172
  ],
60996
61173
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
60997
61174
  ];
60998
- const Settings = createLucideIcon("settings", __iconNode$3);
61175
+ const Settings = createLucideIcon("settings", __iconNode$5);
60999
61176
  /**
61000
61177
  * @license lucide-react v0.575.0 - ISC
61001
61178
  *
61002
61179
  * This source code is licensed under the ISC license.
61003
61180
  * See the LICENSE file in the root directory of this source tree.
61004
61181
  */
61005
- const __iconNode$2 = [
61182
+ const __iconNode$4 = [
61006
61183
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
61007
61184
  ];
61008
- const Square = createLucideIcon("square", __iconNode$2);
61185
+ const Square = createLucideIcon("square", __iconNode$4);
61186
+ /**
61187
+ * @license lucide-react v0.575.0 - ISC
61188
+ *
61189
+ * This source code is licensed under the ISC license.
61190
+ * See the LICENSE file in the root directory of this source tree.
61191
+ */
61192
+ const __iconNode$3 = [
61193
+ ["path", { d: "M12 19h8", key: "baeox8" }],
61194
+ ["path", { d: "m4 17 6-6-6-6", key: "1yngyt" }]
61195
+ ];
61196
+ const Terminal = createLucideIcon("terminal", __iconNode$3);
61197
+ /**
61198
+ * @license lucide-react v0.575.0 - ISC
61199
+ *
61200
+ * This source code is licensed under the ISC license.
61201
+ * See the LICENSE file in the root directory of this source tree.
61202
+ */
61203
+ const __iconNode$2 = [
61204
+ [
61205
+ "path",
61206
+ {
61207
+ d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
61208
+ key: "wmoenq"
61209
+ }
61210
+ ],
61211
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
61212
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
61213
+ ];
61214
+ const TriangleAlert = createLucideIcon("triangle-alert", __iconNode$2);
61009
61215
  /**
61010
61216
  * @license lucide-react v0.575.0 - ISC
61011
61217
  *
@@ -61128,6 +61334,8 @@ const TOOL_META = {
61128
61334
  // Workflows
61129
61335
  create_new_aop: { displayName: "Creating workflow", icon: Brain },
61130
61336
  execute_aop: { displayName: "Running workflow", icon: Brain },
61337
+ // Drive / Assets
61338
+ open_asset_in_workspace: { displayName: "Opening asset", icon: FolderOpen },
61131
61339
  // Preferences
61132
61340
  save_preference_as_memory: { displayName: "Saving preference", icon: Settings }
61133
61341
  };
@@ -61178,6 +61386,14 @@ function extractAssetId$1(result) {
61178
61386
  }
61179
61387
  return null;
61180
61388
  }
61389
+ function extractAssetIdFromArgs(argsText) {
61390
+ if (!argsText) return null;
61391
+ const parsed = tryParseJson$2(argsText);
61392
+ if (!parsed) return null;
61393
+ const id = parsed.asset_id ?? parsed.assetId;
61394
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
61395
+ return null;
61396
+ }
61181
61397
  function toolMetaToAssetType(toolName) {
61182
61398
  const lower = toolName.toLowerCase();
61183
61399
  if (lower.includes("presentation") || lower.includes("pptx") || lower.includes("slide") || lower.includes("powerpoint"))
@@ -61186,13 +61402,16 @@ function toolMetaToAssetType(toolName) {
61186
61402
  return "spreadsheet";
61187
61403
  if (lower.includes("document") || lower.includes("doc") || lower.includes("markdown"))
61188
61404
  return "document";
61405
+ if (lower.includes("notebook"))
61406
+ return "notebook";
61189
61407
  return "unknown";
61190
61408
  }
61191
61409
  const CREATE_ASSET_TOOLS = [
61192
61410
  "create_powerpoint_deck",
61193
61411
  "create_document_from_markdown",
61194
61412
  "create_new_document",
61195
- "create_new_sheet"
61413
+ "create_new_sheet",
61414
+ "create_new_notebook"
61196
61415
  ];
61197
61416
  function isAssetTool(toolName, result) {
61198
61417
  return CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) || extractAssetId$1(result) !== null;
@@ -61504,6 +61723,7 @@ function AssetToolCard({
61504
61723
  assetId && isComplete && !isCancelled && CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) && /* @__PURE__ */ jsxRuntime.jsxs(
61505
61724
  "button",
61506
61725
  {
61726
+ type: "button",
61507
61727
  onClick: () => openAsset(assetId, { name: title ?? void 0, type: assetType }),
61508
61728
  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",
61509
61729
  children: [
@@ -61516,6 +61736,7 @@ function AssetToolCard({
61516
61736
  !isCancelled && /* @__PURE__ */ jsxRuntime.jsx(
61517
61737
  "button",
61518
61738
  {
61739
+ type: "button",
61519
61740
  onClick: () => setDetailsOpen((o) => !o),
61520
61741
  className: cn(
61521
61742
  "flex size-5 shrink-0 items-center justify-center rounded transition-all",
@@ -61541,6 +61762,23 @@ function AssetToolCard({
61541
61762
  ] })
61542
61763
  ] });
61543
61764
  }
61765
+ function AssetOpenLink({ assetId, toolName }) {
61766
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
61767
+ const assetType = toolMetaToAssetType(toolName);
61768
+ return /* @__PURE__ */ jsxRuntime.jsx(
61769
+ "button",
61770
+ {
61771
+ type: "button",
61772
+ onClick: (e) => {
61773
+ e.stopPropagation();
61774
+ openAsset(assetId, { type: assetType });
61775
+ },
61776
+ className: "flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-colors hover:bg-muted/50 hover:text-foreground",
61777
+ title: "Open asset",
61778
+ children: /* @__PURE__ */ jsxRuntime.jsx(Link, { className: "size-3" })
61779
+ }
61780
+ );
61781
+ }
61544
61782
  const ToolFallbackImpl = ({
61545
61783
  toolName,
61546
61784
  argsText,
@@ -61559,12 +61797,19 @@ const ToolFallbackImpl = ({
61559
61797
  }
61560
61798
  );
61561
61799
  }
61800
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
61801
+ const resultAssetId = extractAssetId$1(result);
61802
+ const argsAssetId = extractAssetIdFromArgs(argsText);
61803
+ const fallbackAssetId = resultAssetId ?? argsAssetId;
61562
61804
  return /* @__PURE__ */ jsxRuntime.jsxs(
61563
61805
  ToolFallbackRoot,
61564
61806
  {
61565
61807
  className: cn(isCancelled && "border-muted-foreground/30 bg-muted/30"),
61566
61808
  children: [
61567
- /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackTrigger, { toolName, argsText, result, status }),
61809
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
61810
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackTrigger, { toolName, argsText, result, status }) }),
61811
+ fallbackAssetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0 pr-2", children: /* @__PURE__ */ jsxRuntime.jsx(AssetOpenLink, { assetId: fallbackAssetId, toolName }) })
61812
+ ] }),
61568
61813
  /* @__PURE__ */ jsxRuntime.jsxs(ToolFallbackContent, { children: [
61569
61814
  /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackError, { status }),
61570
61815
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -61948,7 +62193,7 @@ function ToolCard({
61948
62193
  "flex size-8 shrink-0 items-center justify-center rounded-lg",
61949
62194
  isRunning && "bg-blue-50 text-blue-600",
61950
62195
  isComplete && "bg-emerald-50 text-emerald-600",
61951
- isError && "bg-red-50 text-red-500"
62196
+ isError && "bg-destructive/10 text-destructive"
61952
62197
  ),
61953
62198
  children: isRunning ? /* @__PURE__ */ jsxRuntime.jsx(Loader, { className: "size-4 animate-spin" }) : isError ? /* @__PURE__ */ jsxRuntime.jsx(CircleAlert, { className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(Icon2, { className: "size-4" })
61954
62199
  }
@@ -61967,7 +62212,7 @@ function ToolCard({
61967
62212
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-1.5 w-6 animate-pulse rounded-full bg-blue-100" })
61968
62213
  ] })
61969
62214
  ] }),
61970
- error2 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 bg-red-50/50 px-4 py-2.5", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[12px] leading-relaxed text-red-600", children: error2 }) }),
62215
+ error2 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 bg-destructive/10 px-4 py-2.5", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[12px] leading-relaxed text-destructive", children: error2 }) }),
61971
62216
  children
61972
62217
  ] });
61973
62218
  }
@@ -62213,6 +62458,7 @@ function CreateAssetToolUIImpl({
62213
62458
  children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
62214
62459
  "button",
62215
62460
  {
62461
+ type: "button",
62216
62462
  onClick: handleOpen,
62217
62463
  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",
62218
62464
  children: [
@@ -62294,6 +62540,192 @@ const CreateEmailDraftToolUI = React.memo(
62294
62540
  CreateEmailDraftToolUIImpl
62295
62541
  );
62296
62542
  CreateEmailDraftToolUI.displayName = "CreateEmailDraftToolUI";
62543
+ const CreateNotebookToolUIImpl = (props) => /* @__PURE__ */ jsxRuntime.jsx(
62544
+ CreateAssetToolUIImpl,
62545
+ {
62546
+ icon: BookOpen,
62547
+ assetType: "notebook",
62548
+ runningLabel: "Creating notebook...",
62549
+ doneLabel: "Created notebook",
62550
+ ...props
62551
+ }
62552
+ );
62553
+ const CreateNotebookToolUI = React.memo(
62554
+ CreateNotebookToolUIImpl
62555
+ );
62556
+ CreateNotebookToolUI.displayName = "CreateNotebookToolUI";
62557
+ function parsePythonResult(result) {
62558
+ const data = normalizeResult(result);
62559
+ if (!data) return { stdout: null, stderr: null, value: null, error: null, exception: null, imagePng: null, createdAssets: [] };
62560
+ const inner = typeof data.result === "object" && data.result !== null ? data.result : data;
62561
+ const stdout = inner.stdout ?? null;
62562
+ const stderr = inner.stderr ?? null;
62563
+ const value = inner.value ?? null;
62564
+ const error2 = inner.error ?? null;
62565
+ let exception = null;
62566
+ if (inner.exception && typeof inner.exception === "object") {
62567
+ const exc = inner.exception;
62568
+ exception = {
62569
+ name: exc.name ?? "Error",
62570
+ value: exc.value ?? "",
62571
+ traceback: exc.traceback ?? ""
62572
+ };
62573
+ }
62574
+ let imagePng = null;
62575
+ if (inner.data && typeof inner.data === "object") {
62576
+ imagePng = inner.data.png ?? null;
62577
+ }
62578
+ const createdAssets = Array.isArray(data.created_assets) ? data.created_assets : [];
62579
+ return { stdout, stderr, value, error: error2, exception, imagePng, createdAssets };
62580
+ }
62581
+ const RunPythonCodeToolUIImpl = ({
62582
+ toolName,
62583
+ args,
62584
+ result,
62585
+ status
62586
+ }) => {
62587
+ var _a2;
62588
+ const typedArgs = args;
62589
+ const code2 = (typedArgs == null ? void 0 : typedArgs.code) ?? "";
62590
+ const summary = (typedArgs == null ? void 0 : typedArgs.summary) ?? null;
62591
+ const lines = code2 ? code2.split("\n").length : 0;
62592
+ const isRunning = (status == null ? void 0 : status.type) === "running";
62593
+ const isComplete = (status == null ? void 0 : status.type) === "complete";
62594
+ const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
62595
+ const parsed = React.useMemo(() => isComplete ? parsePythonResult(result) : null, [result, isComplete]);
62596
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
62597
+ const hasOutput = parsed && (parsed.stdout || parsed.stderr || parsed.value);
62598
+ const hasError = parsed && (parsed.error || parsed.exception);
62599
+ const hasImage = parsed == null ? void 0 : parsed.imagePng;
62600
+ return /* @__PURE__ */ jsxRuntime.jsxs(
62601
+ ToolCard,
62602
+ {
62603
+ icon: Code,
62604
+ status: (status == null ? void 0 : status.type) ?? "complete",
62605
+ title: isRunning ? "Running code..." : summary || `Executed ${lines} ${lines !== 1 ? "lines" : "line"}`,
62606
+ toolName,
62607
+ error: errorMsg,
62608
+ children: [
62609
+ code2 && /* @__PURE__ */ jsxRuntime.jsx(ExpandableSection, { label: "Show code", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap break-words text-[11px] leading-relaxed font-mono text-foreground/80", children: code2 }) }),
62610
+ isComplete && hasOutput && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
62611
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 mb-1", children: [
62612
+ /* @__PURE__ */ jsxRuntime.jsx(Terminal, { className: "size-3 text-muted-foreground" }),
62613
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Output" })
62614
+ ] }),
62615
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/30 p-2 text-[11px] leading-relaxed font-mono text-foreground/80", children: [parsed.value, parsed.stdout, parsed.stderr].filter(Boolean).join("\n") })
62616
+ ] }),
62617
+ isComplete && hasError && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 bg-destructive/10 px-4 py-2.5", children: [
62618
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 mb-1", children: [
62619
+ /* @__PURE__ */ jsxRuntime.jsx(TriangleAlert, { className: "size-3 text-destructive" }),
62620
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-medium text-destructive", children: parsed.exception ? `${parsed.exception.name}: ${parsed.exception.value}` : "Error" })
62621
+ ] }),
62622
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md bg-destructive/5 p-2 text-[11px] leading-relaxed font-mono text-destructive/80", children: ((_a2 = parsed.exception) == null ? void 0 : _a2.traceback) ?? parsed.error })
62623
+ ] }),
62624
+ isComplete && hasImage && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
62625
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 mb-1.5", children: [
62626
+ /* @__PURE__ */ jsxRuntime.jsx(Image, { className: "size-3 text-muted-foreground" }),
62627
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Generated image" })
62628
+ ] }),
62629
+ /* @__PURE__ */ jsxRuntime.jsx(
62630
+ "img",
62631
+ {
62632
+ src: `data:image/png;base64,${parsed.imagePng}`,
62633
+ alt: "Python output",
62634
+ className: "max-w-full rounded-md border border-border/40"
62635
+ }
62636
+ )
62637
+ ] }),
62638
+ isComplete && parsed && parsed.createdAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t border-border/40 px-4 py-2", children: [
62639
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Created assets" }),
62640
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 flex flex-wrap gap-1.5", children: parsed.createdAssets.map((a) => /* @__PURE__ */ jsxRuntime.jsxs(
62641
+ "button",
62642
+ {
62643
+ type: "button",
62644
+ onClick: () => openAsset(a.asset_id),
62645
+ className: "flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
62646
+ children: [
62647
+ /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-2.5" }),
62648
+ truncate(a.asset_id, 20)
62649
+ ]
62650
+ },
62651
+ a.asset_id
62652
+ )) })
62653
+ ] })
62654
+ ]
62655
+ }
62656
+ );
62657
+ };
62658
+ const RunPythonCodeToolUI = React.memo(
62659
+ RunPythonCodeToolUIImpl
62660
+ );
62661
+ RunPythonCodeToolUI.displayName = "RunPythonCodeToolUI";
62662
+ const OpenAssetToolUIImpl = ({
62663
+ toolName,
62664
+ args,
62665
+ result,
62666
+ status
62667
+ }) => {
62668
+ const typedArgs = args;
62669
+ const argsAssetId = (typedArgs == null ? void 0 : typedArgs.asset_id) ?? (typedArgs == null ? void 0 : typedArgs.assetId) ?? "";
62670
+ const resultAssetId = extractAssetId(result);
62671
+ const assetId = resultAssetId ?? (argsAssetId.startsWith("asset_") ? argsAssetId : null);
62672
+ const isRunning = (status == null ? void 0 : status.type) === "running";
62673
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
62674
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
62675
+ const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
62676
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
62677
+ const wasCompleteAtMount = React.useRef(isComplete);
62678
+ React.useEffect(() => {
62679
+ if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
62680
+ const store = useAssetPanelStore.getState();
62681
+ if (store.markAutoOpened(assetId)) {
62682
+ store.openAsset(assetId);
62683
+ }
62684
+ }
62685
+ }, [isComplete, isCancelled, assetId]);
62686
+ return /* @__PURE__ */ jsxRuntime.jsx(
62687
+ ToolCard,
62688
+ {
62689
+ icon: FolderOpen,
62690
+ status: (status == null ? void 0 : status.type) ?? "complete",
62691
+ title: isRunning ? "Opening asset..." : "Asset opened",
62692
+ subtitle: assetId ? truncate(assetId, 30) : void 0,
62693
+ toolName,
62694
+ error: errorMsg,
62695
+ children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs(
62696
+ "button",
62697
+ {
62698
+ type: "button",
62699
+ onClick: () => openAsset(assetId),
62700
+ 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",
62701
+ children: [
62702
+ /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, { className: "size-3" }),
62703
+ "Open asset"
62704
+ ]
62705
+ }
62706
+ ) })
62707
+ }
62708
+ );
62709
+ };
62710
+ const OpenAssetToolUI = React.memo(
62711
+ OpenAssetToolUIImpl
62712
+ );
62713
+ OpenAssetToolUI.displayName = "OpenAssetToolUI";
62714
+ function createAssetToolUI(config2) {
62715
+ const Component = (props) => /* @__PURE__ */ jsxRuntime.jsx(
62716
+ CreateAssetToolUIImpl,
62717
+ {
62718
+ icon: config2.icon,
62719
+ assetType: config2.assetType,
62720
+ runningLabel: config2.runningLabel,
62721
+ doneLabel: config2.doneLabel,
62722
+ ...props
62723
+ }
62724
+ );
62725
+ const Memoized = React.memo(Component);
62726
+ Memoized.displayName = `CreateAssetToolUI(${config2.assetType})`;
62727
+ return Memoized;
62728
+ }
62297
62729
  const TOOL_UI_REGISTRY = {
62298
62730
  search: WebSearchToolUI,
62299
62731
  browse: BrowseToolUI,
@@ -62304,7 +62736,10 @@ const TOOL_UI_REGISTRY = {
62304
62736
  create_new_document: CreateDocumentToolUI,
62305
62737
  create_document_from_markdown: CreateDocumentToolUI,
62306
62738
  create_new_sheet: CreateSheetToolUI,
62307
- create_powerpoint_deck: CreatePresentationToolUI
62739
+ create_powerpoint_deck: CreatePresentationToolUI,
62740
+ create_new_notebook: CreateNotebookToolUI,
62741
+ run_python_code: RunPythonCodeToolUI,
62742
+ open_asset_in_workspace: OpenAssetToolUI
62308
62743
  };
62309
62744
  const falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
62310
62745
  const cx = clsx;
@@ -62425,7 +62860,6 @@ const AthenaChat = ({
62425
62860
  toolUIs,
62426
62861
  mentionTools
62427
62862
  }) => {
62428
- const isLoadingThread = useThreadLoading();
62429
62863
  const tools = mentionTools ?? EMPTY_MENTION_TOOLS;
62430
62864
  const mergedToolUIs = React.useMemo(() => ({
62431
62865
  append_markdown_to_athena_document: AppendDocumentToolUI,
@@ -62437,43 +62871,40 @@ const AthenaChat = ({
62437
62871
  () => () => /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { toolUIs: mergedToolUIs }),
62438
62872
  [mergedToolUIs]
62439
62873
  );
62440
- return /* @__PURE__ */ jsxRuntime.jsxs(
62874
+ return /* @__PURE__ */ jsxRuntime.jsx(
62441
62875
  ThreadPrimitiveRoot,
62442
62876
  {
62443
62877
  className: `aui-root aui-thread-root @container flex h-full flex-col bg-background ${className ?? ""}`,
62444
62878
  style: { ["--thread-max-width"]: maxWidth, position: "relative" },
62445
- children: [
62446
- isLoadingThread && /* @__PURE__ */ jsxRuntime.jsx(ThreadLoadingOverlay, {}),
62447
- /* @__PURE__ */ jsxRuntime.jsxs(
62448
- ThreadPrimitiveViewport,
62449
- {
62450
- turnAnchor: "top",
62451
- className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
62452
- children: [
62453
- /* @__PURE__ */ jsxRuntime.jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "aui-thread-welcome-message flex size-full flex-col justify-center px-4", children: [
62454
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both font-semibold text-2xl duration-200", children: welcomeMessage }),
62455
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-muted-foreground text-xl delay-75 duration-200", children: welcomeSubtext })
62456
- ] }) }) }) }),
62457
- /* @__PURE__ */ jsxRuntime.jsx(
62458
- ThreadPrimitiveMessages,
62459
- {
62460
- components: {
62461
- UserMessage,
62462
- AssistantMessage: AssistantMessageComponent
62463
- }
62879
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
62880
+ ThreadPrimitiveViewport,
62881
+ {
62882
+ turnAnchor: "top",
62883
+ className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
62884
+ children: [
62885
+ /* @__PURE__ */ jsxRuntime.jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "aui-thread-welcome-message flex size-full flex-col justify-center px-4", children: [
62886
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both font-semibold text-2xl duration-200", children: welcomeMessage }),
62887
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-muted-foreground text-xl delay-75 duration-200", children: welcomeSubtext })
62888
+ ] }) }) }) }),
62889
+ /* @__PURE__ */ jsxRuntime.jsx(
62890
+ ThreadPrimitiveMessages,
62891
+ {
62892
+ components: {
62893
+ UserMessage,
62894
+ AssistantMessage: AssistantMessageComponent
62464
62895
  }
62465
- ),
62466
- /* @__PURE__ */ jsxRuntime.jsxs(ThreadPrimitiveViewportFooter, { className: "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-auto flex w-full max-w-(--thread-max-width) flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6", children: [
62467
- /* @__PURE__ */ jsxRuntime.jsx(ThreadScrollToBottom, {}),
62468
- /* @__PURE__ */ jsxRuntime.jsxs(ComposerPrimitiveRoot, { className: "aui-composer-root relative flex w-full flex-col rounded-2xl border border-input bg-background px-1 pt-2 outline-none transition-shadow focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20", children: [
62469
- /* @__PURE__ */ jsxRuntime.jsx(TiptapComposer, { tools }),
62470
- /* @__PURE__ */ jsxRuntime.jsx(ComposerAction, {})
62471
- ] })
62896
+ }
62897
+ ),
62898
+ /* @__PURE__ */ jsxRuntime.jsxs(ThreadPrimitiveViewportFooter, { className: "aui-thread-viewport-footer sticky bottom-0 mx-auto mt-auto flex w-full max-w-(--thread-max-width) flex-col gap-4 overflow-visible rounded-t-3xl bg-background pb-4 md:pb-6", children: [
62899
+ /* @__PURE__ */ jsxRuntime.jsx(ThreadScrollToBottom, {}),
62900
+ /* @__PURE__ */ jsxRuntime.jsxs(ComposerPrimitiveRoot, { className: "aui-composer-root relative flex w-full flex-col rounded-2xl border border-input bg-background px-1 pt-2 outline-none transition-shadow focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20", children: [
62901
+ /* @__PURE__ */ jsxRuntime.jsx(TiptapComposer, { tools }),
62902
+ /* @__PURE__ */ jsxRuntime.jsx(ComposerAction, {})
62472
62903
  ] })
62473
- ]
62474
- }
62475
- )
62476
- ]
62904
+ ] })
62905
+ ]
62906
+ }
62907
+ )
62477
62908
  }
62478
62909
  );
62479
62910
  };
@@ -62589,53 +63020,6 @@ const UserMessage = () => /* @__PURE__ */ jsxRuntime.jsx(
62589
63020
  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 } }) })
62590
63021
  }
62591
63022
  );
62592
- const ThreadLoadingOverlay = () => /* @__PURE__ */ jsxRuntime.jsxs(
62593
- "div",
62594
- {
62595
- className: "aui-thread-loading-overlay",
62596
- style: {
62597
- position: "absolute",
62598
- inset: 0,
62599
- zIndex: 50,
62600
- display: "flex",
62601
- flexDirection: "column",
62602
- alignItems: "center",
62603
- justifyContent: "center",
62604
- gap: 12,
62605
- background: "color-mix(in srgb, var(--background, #fff) 80%, transparent)",
62606
- backdropFilter: "blur(4px)",
62607
- WebkitBackdropFilter: "blur(4px)",
62608
- animation: "aui-overlay-in 0.2s ease-out"
62609
- },
62610
- children: [
62611
- /* @__PURE__ */ jsxRuntime.jsx(
62612
- "div",
62613
- {
62614
- style: {
62615
- width: 28,
62616
- height: 28,
62617
- border: "2.5px solid var(--border, #e5e5e5)",
62618
- borderTopColor: "var(--primary, #2563eb)",
62619
- borderRadius: "50%",
62620
- animation: "aui-spin 0.7s linear infinite"
62621
- }
62622
- }
62623
- ),
62624
- /* @__PURE__ */ jsxRuntime.jsx(
62625
- "span",
62626
- {
62627
- style: {
62628
- fontSize: 13,
62629
- fontWeight: 500,
62630
- color: "var(--muted-foreground, #888)"
62631
- },
62632
- children: "Loading conversation…"
62633
- }
62634
- ),
62635
- /* @__PURE__ */ jsxRuntime.jsx("style", { children: `@keyframes aui-spin { to { transform: rotate(360deg); } } @keyframes aui-overlay-in { from { opacity: 0; } to { opacity: 1; } }` })
62636
- ]
62637
- }
62638
- );
62639
63023
  const embedCache = /* @__PURE__ */ new Map();
62640
63024
  function useAssetEmbed(assetId, options = {
62641
63025
  backendUrl: ""
@@ -62706,6 +63090,7 @@ const ASSET_TYPE_CONFIG = {
62706
63090
  presentation: { icon: Presentation, label: "Presentation" },
62707
63091
  spreadsheet: { icon: FileSpreadsheet, label: "Spreadsheet" },
62708
63092
  document: { icon: FileText, label: "Document" },
63093
+ notebook: { icon: BookOpen, label: "Notebook" },
62709
63094
  unknown: { icon: File$1, label: "Asset" }
62710
63095
  };
62711
63096
  const AssetIframe = React.memo(
@@ -62942,66 +63327,29 @@ const AthenaLayout = ({
62942
63327
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(AssetPanel, {}) })
62943
63328
  ] });
62944
63329
  };
62945
- function useThreadList() {
62946
- const store = useThreadListStore();
62947
- return useStore$1(store);
62948
- }
62949
- function useActiveThreadId() {
62950
- const store = useThreadListStore();
62951
- return useStore$1(store, (s) => s.activeThreadId);
62952
- }
62953
63330
  function ThreadList({ className }) {
62954
- const {
62955
- threads,
62956
- activeThreadId,
62957
- isLoading,
62958
- fetchThreads,
62959
- switchThread,
62960
- newThread,
62961
- archiveThread: archiveThread2
62962
- } = useThreadList();
62963
- React.useEffect(() => {
62964
- fetchThreads();
62965
- }, [fetchThreads]);
62966
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col gap-1", className), children: [
62967
- /* @__PURE__ */ jsxRuntime.jsxs(
62968
- "button",
63331
+ return /* @__PURE__ */ jsxRuntime.jsxs(ThreadListPrimitiveRoot, { className: cn("flex flex-col gap-1", className), children: [
63332
+ /* @__PURE__ */ jsxRuntime.jsxs(ThreadListPrimitiveNew, { className: "flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground", children: [
63333
+ /* @__PURE__ */ jsxRuntime.jsx(Plus, { className: "size-4" }),
63334
+ "New Chat"
63335
+ ] }),
63336
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(
63337
+ ThreadListPrimitiveItems,
62969
63338
  {
62970
- onClick: () => newThread(),
62971
- className: "flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
62972
- children: [
62973
- /* @__PURE__ */ jsxRuntime.jsx(Plus, { className: "size-4" }),
62974
- "New Chat"
62975
- ]
63339
+ components: {
63340
+ ThreadListItem
63341
+ }
62976
63342
  }
62977
- ),
62978
- isLoading && threads.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-4 text-muted-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(LoaderCircle, { className: "size-4 animate-spin" }) }) : threads.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "px-2 py-4 text-center text-xs text-muted-foreground/60", children: "No conversations yet" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: threads.map((thread) => /* @__PURE__ */ jsxRuntime.jsxs(
62979
- "div",
62980
- {
62981
- className: cn(
62982
- "group flex items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors cursor-pointer",
62983
- activeThreadId === thread.thread_id ? "bg-muted/50 text-foreground" : "text-muted-foreground hover:bg-muted/30 hover:text-foreground"
62984
- ),
62985
- onClick: () => switchThread(thread.thread_id),
62986
- children: [
62987
- /* @__PURE__ */ jsxRuntime.jsx(MessageSquare, { className: "size-3.5 shrink-0" }),
62988
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate", children: thread.title || "Untitled" }),
62989
- /* @__PURE__ */ jsxRuntime.jsx(
62990
- "button",
62991
- {
62992
- onClick: (e) => {
62993
- e.stopPropagation();
62994
- archiveThread2(thread.thread_id);
62995
- },
62996
- className: "hidden size-5 items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-muted hover:text-foreground group-hover:flex",
62997
- title: "Archive",
62998
- children: /* @__PURE__ */ jsxRuntime.jsx(Archive, { className: "size-3" })
62999
- }
63000
- )
63001
- ]
63002
- },
63003
- thread.thread_id
63004
- )) })
63343
+ ) })
63344
+ ] });
63345
+ }
63346
+ function ThreadListItem() {
63347
+ return /* @__PURE__ */ jsxRuntime.jsxs(ThreadListItemPrimitiveRoot, { className: "group", children: [
63348
+ /* @__PURE__ */ jsxRuntime.jsxs(ThreadListItemPrimitiveTrigger, { className: "flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors cursor-pointer text-muted-foreground hover:bg-muted/30 hover:text-foreground data-[active]:bg-muted/50 data-[active]:text-foreground", children: [
63349
+ /* @__PURE__ */ jsxRuntime.jsx(MessageSquare, { className: "size-3.5 shrink-0" }),
63350
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate text-left", children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListItemPrimitiveTitle, { fallback: "Untitled" }) })
63351
+ ] }),
63352
+ /* @__PURE__ */ jsxRuntime.jsx(ThreadListItemPrimitiveArchive, { className: "hidden size-5 items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-muted hover:text-foreground group-hover:flex", children: /* @__PURE__ */ jsxRuntime.jsx(Archive, { className: "size-3" }) })
63005
63353
  ] });
63006
63354
  }
63007
63355
  function useAppendToComposer() {
@@ -63119,11 +63467,14 @@ exports.CollapsibleContent = CollapsibleContent;
63119
63467
  exports.CollapsibleTrigger = CollapsibleTrigger;
63120
63468
  exports.CreateDocumentToolUI = CreateDocumentToolUI;
63121
63469
  exports.CreateEmailDraftToolUI = CreateEmailDraftToolUI;
63470
+ exports.CreateNotebookToolUI = CreateNotebookToolUI;
63122
63471
  exports.CreatePresentationToolUI = CreatePresentationToolUI;
63123
63472
  exports.CreateSheetToolUI = CreateSheetToolUI;
63124
63473
  exports.DEFAULT_BACKEND_URL = DEFAULT_BACKEND_URL;
63125
63474
  exports.EmailSearchToolUI = EmailSearchToolUI;
63475
+ exports.OpenAssetToolUI = OpenAssetToolUI;
63126
63476
  exports.ReadAssetToolUI = ReadAssetToolUI;
63477
+ exports.RunPythonCodeToolUI = RunPythonCodeToolUI;
63127
63478
  exports.TOOL_UI_REGISTRY = TOOL_UI_REGISTRY;
63128
63479
  exports.ThreadList = ThreadList;
63129
63480
  exports.TiptapComposer = TiptapComposer;
@@ -63145,13 +63496,12 @@ exports.WebSearchToolUI = WebSearchToolUI;
63145
63496
  exports.buttonVariants = buttonVariants;
63146
63497
  exports.clearAutoOpenedAssets = clearAutoOpenedAssets;
63147
63498
  exports.cn = cn;
63148
- exports.createThreadListStore = createThreadListStore;
63499
+ exports.createAssetToolUI = createAssetToolUI;
63149
63500
  exports.getAssetInfo = getAssetInfo;
63150
63501
  exports.resetAssetAutoOpen = resetAssetAutoOpen;
63151
63502
  exports.themeToStyleVars = themeToStyleVars;
63152
63503
  exports.themes = themes;
63153
63504
  exports.tryParseJson = tryParseJson$1;
63154
- exports.useActiveThreadId = useActiveThreadId;
63155
63505
  exports.useAppendToComposer = useAppendToComposer;
63156
63506
  exports.useAssetEmbed = useAssetEmbed;
63157
63507
  exports.useAssetPanelStore = useAssetPanelStore;
@@ -63160,6 +63510,4 @@ exports.useAthenaRuntime = useAthenaRuntime;
63160
63510
  exports.useComposerAttachment = useComposerAttachment;
63161
63511
  exports.useMentionSuggestions = useMentionSuggestions;
63162
63512
  exports.useParentAuth = useParentAuth;
63163
- exports.useThreadList = useThreadList;
63164
- exports.useThreadLoading = useThreadLoading;
63165
63513
  //# sourceMappingURL=index.cjs.map