@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.js CHANGED
@@ -4543,6 +4543,16 @@ const ChainOfThoughtByIndicesProvider = ({ startIndex, endIndex, children }) =>
4543
4543
  });
4544
4544
  return jsx(AuiProvider, { value: aui, children });
4545
4545
  };
4546
+ const ThreadListItemByIndexProvider = ({ index: index2, archived, children }) => {
4547
+ const aui = useAui({
4548
+ threadListItem: Derived({
4549
+ source: "threads",
4550
+ query: { type: "index", index: index2, archived },
4551
+ get: (aui2) => aui2.threads().item({ index: index2, archived })
4552
+ })
4553
+ });
4554
+ return jsx(AuiProvider, { value: aui, children });
4555
+ };
4546
4556
  const RuntimeAdapter = resource((runtime) => tapResource(RuntimeAdapterResource(runtime)));
4547
4557
  attachTransformScopes(RuntimeAdapter, (scopes, parent) => {
4548
4558
  const result = baseRuntimeAdapterTransformScopes(scopes, parent);
@@ -8912,6 +8922,24 @@ const MessagePrimitiveParts$1 = ({ components, unstable_showEmptyOnNonTextEnd =
8912
8922
  return jsxs(Fragment$2, { children: [partsElements, jsx(ConditionalEmpty, { components, enabled: unstable_showEmptyOnNonTextEnd })] });
8913
8923
  };
8914
8924
  MessagePrimitiveParts$1.displayName = "MessagePrimitive.Parts";
8925
+ const ThreadListPrimitiveItemByIndex = memo(({ index: index2, archived = false, components }) => {
8926
+ const ThreadListItemComponent = components.ThreadListItem;
8927
+ return jsx(ThreadListItemByIndexProvider, { index: index2, archived, children: jsx(ThreadListItemComponent, {}) });
8928
+ }, (prev, next) => prev.index === next.index && prev.archived === next.archived && prev.components.ThreadListItem === next.components.ThreadListItem);
8929
+ ThreadListPrimitiveItemByIndex.displayName = "ThreadListPrimitive.ItemByIndex";
8930
+ const ThreadListPrimitiveItems = ({ archived = false, components }) => {
8931
+ const contentLength = useAuiState((s) => archived ? s.threads.archivedThreadIds.length : s.threads.threadIds.length);
8932
+ const listElements = useMemo(() => {
8933
+ return Array.from({ length: contentLength }, (_, index2) => jsx(ThreadListPrimitiveItemByIndex, { index: index2, archived, components }, index2));
8934
+ }, [contentLength, archived, components]);
8935
+ return listElements;
8936
+ };
8937
+ ThreadListPrimitiveItems.displayName = "ThreadListPrimitive.Items";
8938
+ const ThreadListItemPrimitiveTitle = ({ fallback }) => {
8939
+ const title = useAuiState((s) => s.threadListItem.title);
8940
+ return jsx(Fragment$2, { children: title || fallback });
8941
+ };
8942
+ ThreadListItemPrimitiveTitle.displayName = "ThreadListItemPrimitive.Title";
8915
8943
  const useComposerSend$1 = () => {
8916
8944
  const aui = useAui();
8917
8945
  const disabled = useAuiState((s) => s.thread.isRunning || !s.composer.isEditing || s.composer.isEmpty);
@@ -16344,6 +16372,37 @@ const useThreadScrollToBottom = ({ behavior } = {}) => {
16344
16372
  return handleScrollToBottom;
16345
16373
  };
16346
16374
  const ThreadPrimitiveScrollToBottom = createActionButton("ThreadPrimitive.ScrollToBottom", useThreadScrollToBottom, ["behavior"]);
16375
+ const ThreadListPrimitiveNew = forwardRef(({ onClick, disabled, ...props }, forwardedRef) => {
16376
+ const isMain = useAuiState((s) => s.threads.newThreadId === s.threads.mainThreadId);
16377
+ const aui = useAui();
16378
+ return jsx(Primitive$1.button, { type: "button", ...isMain ? { "data-active": "true", "aria-current": "true" } : null, ...props, ref: forwardedRef, disabled, onClick: composeEventHandlers(onClick, () => {
16379
+ aui.threads().switchToNewThread();
16380
+ }) });
16381
+ });
16382
+ ThreadListPrimitiveNew.displayName = "ThreadListPrimitive.New";
16383
+ const ThreadListPrimitiveRoot = forwardRef((props, ref) => {
16384
+ return jsx(Primitive$1.div, { ...props, ref });
16385
+ });
16386
+ ThreadListPrimitiveRoot.displayName = "ThreadListPrimitive.Root";
16387
+ const ThreadListItemPrimitiveRoot = forwardRef((props, ref) => {
16388
+ const isMain = useAuiState((s) => s.threads.mainThreadId === s.threadListItem.id);
16389
+ return jsx(Primitive$1.div, { ...isMain ? { "data-active": "true", "aria-current": "true" } : null, ...props, ref });
16390
+ });
16391
+ ThreadListItemPrimitiveRoot.displayName = "ThreadListItemPrimitive.Root";
16392
+ const useThreadListItemArchive = () => {
16393
+ const aui = useAui();
16394
+ return useCallback(() => {
16395
+ aui.threadListItem().archive();
16396
+ }, [aui]);
16397
+ };
16398
+ const ThreadListItemPrimitiveArchive = createActionButton("ThreadListItemPrimitive.Archive", useThreadListItemArchive);
16399
+ const useThreadListItemTrigger = () => {
16400
+ const aui = useAui();
16401
+ return useCallback(() => {
16402
+ aui.threadListItem().switchTo();
16403
+ }, [aui]);
16404
+ };
16405
+ const ThreadListItemPrimitiveTrigger = createActionButton("ThreadListItemPrimitive.Trigger", useThreadListItemTrigger);
16347
16406
  const useScrollLock = (animatedElementRef, animationDuration) => {
16348
16407
  const scrollContainerRef = useRef(null);
16349
16408
  const cleanupRef = useRef(null);
@@ -20560,6 +20619,73 @@ const parseLangGraphState = (state) => {
20560
20619
  }
20561
20620
  return result;
20562
20621
  };
20622
+ function getAuthHeaders(auth) {
20623
+ if (auth.token) {
20624
+ return { Authorization: `Bearer ${auth.token}` };
20625
+ }
20626
+ if (auth.apiKey) {
20627
+ return { "X-API-KEY": auth.apiKey };
20628
+ }
20629
+ return {};
20630
+ }
20631
+ function getAgoraBaseUrl(backendUrl) {
20632
+ const stripped = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
20633
+ if (stripped === backendUrl) {
20634
+ return backendUrl.replace(/\/$/, "");
20635
+ }
20636
+ return stripped;
20637
+ }
20638
+ async function listThreads(backendUrl, auth, opts = {}) {
20639
+ const base2 = getAgoraBaseUrl(backendUrl);
20640
+ const res = await fetch(`${base2}/api/conversations/threads/list`, {
20641
+ method: "POST",
20642
+ headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
20643
+ body: JSON.stringify({ limit: opts.limit ?? 50, offset: opts.offset ?? 0 })
20644
+ });
20645
+ if (!res.ok) {
20646
+ throw new Error(`[AthenaSDK] Failed to list threads: ${res.status}`);
20647
+ }
20648
+ return res.json();
20649
+ }
20650
+ function deserializeMessage(msg) {
20651
+ if (msg && typeof msg === "object" && "lc" in msg && "kwargs" in msg && msg.type === "constructor") {
20652
+ const kwargs = msg.kwargs;
20653
+ const deserializedToolCalls = Array.isArray(kwargs.tool_calls) ? kwargs.tool_calls.map((tc) => {
20654
+ if (tc && typeof tc === "object" && "lc" in tc && "kwargs" in tc) {
20655
+ return tc.kwargs;
20656
+ }
20657
+ return tc;
20658
+ }) : kwargs.tool_calls;
20659
+ return { ...kwargs, tool_calls: deserializedToolCalls };
20660
+ }
20661
+ return msg;
20662
+ }
20663
+ async function getThreadState(backendUrl, auth, threadId) {
20664
+ const base2 = getAgoraBaseUrl(backendUrl);
20665
+ const res = await fetch(`${base2}/api/unstable/threads/${threadId}`, {
20666
+ method: "GET",
20667
+ headers: { ...getAuthHeaders(auth) }
20668
+ });
20669
+ if (!res.ok) {
20670
+ throw new Error(`[AthenaSDK] Failed to get thread state: ${res.status}`);
20671
+ }
20672
+ const data = await res.json();
20673
+ if (Array.isArray(data.messages)) {
20674
+ data.messages = data.messages.map(deserializeMessage);
20675
+ }
20676
+ return data;
20677
+ }
20678
+ async function archiveThread(backendUrl, auth, threadId) {
20679
+ const base2 = getAgoraBaseUrl(backendUrl);
20680
+ const res = await fetch(`${base2}/api/conversations/threads/archive`, {
20681
+ method: "POST",
20682
+ headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
20683
+ body: JSON.stringify({ thread_id: threadId })
20684
+ });
20685
+ if (!res.ok) {
20686
+ throw new Error(`[AthenaSDK] Failed to archive thread: ${res.status}`);
20687
+ }
20688
+ }
20563
20689
  const DEFAULT_API_URL = "https://sync.athenaintel.com/api/chat";
20564
20690
  const DEFAULT_BACKEND_URL = "https://api.athenaintel.com/api/assistant-ui";
20565
20691
  const DEFAULT_MODEL = "claude-sonnet-4-6-low";
@@ -20719,6 +20845,7 @@ const createConverter = (optimisticMessageCache) => (state, connectionMetadata)
20719
20845
  const useAthenaRuntime = (config2) => {
20720
20846
  const {
20721
20847
  apiUrl = DEFAULT_API_URL,
20848
+ resumeApiUrl,
20722
20849
  backendUrl = DEFAULT_BACKEND_URL,
20723
20850
  apiKey,
20724
20851
  token,
@@ -20729,9 +20856,9 @@ const useAthenaRuntime = (config2) => {
20729
20856
  workbench = [],
20730
20857
  knowledgeBase = [],
20731
20858
  systemPrompt,
20732
- threadId: threadIdProp,
20733
- initialMessages
20859
+ threadId: threadIdProp
20734
20860
  } = config2;
20861
+ const resolvedResumeApiUrl = resumeApiUrl ?? apiUrl.replace(/\/api\/chat$/, "/api/resume");
20735
20862
  const generatedIdRef = useRef(null);
20736
20863
  if (generatedIdRef.current === null) {
20737
20864
  generatedIdRef.current = crypto.randomUUID();
@@ -20747,10 +20874,12 @@ const useAthenaRuntime = (config2) => {
20747
20874
  tokenRef.current = token;
20748
20875
  const apiKeyRef = useRef(apiKey);
20749
20876
  apiKeyRef.current = apiKey;
20877
+ const isExistingThread = !!threadIdProp;
20750
20878
  const runtime = useAssistantTransportRuntime({
20751
- initialState: { messages: initialMessages ?? [] },
20879
+ initialState: { messages: [] },
20752
20880
  converter,
20753
20881
  api: apiUrl,
20882
+ resumeApi: resolvedResumeApiUrl,
20754
20883
  headers: async () => ({
20755
20884
  // Prefer parent-injected PropelAuth token over hardcoded API key
20756
20885
  ...tokenRef.current ? { Authorization: `Bearer ${tokenRef.current}` } : apiKeyRef.current ? { "X-API-KEY": apiKeyRef.current } : {},
@@ -20856,6 +20985,34 @@ const useAthenaRuntime = (config2) => {
20856
20985
  }
20857
20986
  }
20858
20987
  });
20988
+ const hasResumedRef = useRef(false);
20989
+ const prevThreadIdRef = useRef(threadId);
20990
+ if (prevThreadIdRef.current !== threadId) {
20991
+ prevThreadIdRef.current = threadId;
20992
+ hasResumedRef.current = false;
20993
+ }
20994
+ useEffect(() => {
20995
+ if (isExistingThread && !hasResumedRef.current) {
20996
+ hasResumedRef.current = true;
20997
+ (async () => {
20998
+ try {
20999
+ const auth = { apiKey: apiKeyRef.current, token: tokenRef.current };
21000
+ const state = await getThreadState(backendUrl, auth, threadId);
21001
+ runtime.thread.importExternalState({
21002
+ messages: state.messages
21003
+ });
21004
+ } catch (err) {
21005
+ if (process.env.NODE_ENV !== "production") {
21006
+ console.error("[AthenaSDK] Failed to load thread state:", err);
21007
+ }
21008
+ try {
21009
+ runtime.thread.unstable_resumeRun({ parentId: null });
21010
+ } catch {
21011
+ }
21012
+ }
21013
+ })();
21014
+ }
21015
+ }, [isExistingThread, runtime, threadId, backendUrl]);
20859
21016
  return runtime;
20860
21017
  };
20861
21018
  function r(e) {
@@ -24089,132 +24246,67 @@ function useAthenaConfig() {
24089
24246
  }
24090
24247
  return ctx;
24091
24248
  }
24092
- const ThreadLoadingContext = createContext(false);
24093
- function useThreadLoading() {
24094
- return useContext(ThreadLoadingContext);
24095
- }
24096
- const ThreadListContext = createContext(null);
24097
- function useThreadListStore() {
24098
- const store = useContext(ThreadListContext);
24099
- if (!store) {
24100
- throw new Error(
24101
- "[AthenaSDK] useThreadList must be used within an <AthenaProvider> that has thread management enabled."
24102
- );
24103
- }
24104
- return store;
24249
+ const AthenaThreadIdContext = createContext(void 0);
24250
+ function useAthenaThreadId() {
24251
+ return useContext(AthenaThreadIdContext);
24105
24252
  }
24106
- function getAuthHeaders(auth) {
24107
- if (auth.token) {
24108
- return { Authorization: `Bearer ${auth.token}` };
24109
- }
24110
- if (auth.apiKey) {
24111
- return { "X-API-KEY": auth.apiKey };
24112
- }
24113
- return {};
24114
- }
24115
- function getAgoraBaseUrl(backendUrl) {
24116
- return backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
24117
- }
24118
- async function listThreads(backendUrl, auth, opts = {}) {
24119
- const base2 = getAgoraBaseUrl(backendUrl);
24120
- const res = await fetch(`${base2}/api/conversations/threads/list`, {
24121
- method: "POST",
24122
- headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
24123
- body: JSON.stringify({ limit: opts.limit ?? 50, offset: opts.offset ?? 0 })
24124
- });
24125
- if (!res.ok) {
24126
- throw new Error(`[AthenaSDK] Failed to list threads: ${res.status}`);
24127
- }
24128
- return res.json();
24129
- }
24130
- function deserializeMessage(msg) {
24131
- if (msg && typeof msg === "object" && "lc" in msg && "kwargs" in msg && msg.type === "constructor") {
24132
- const kwargs = msg.kwargs;
24133
- if (Array.isArray(kwargs.tool_calls)) {
24134
- kwargs.tool_calls = kwargs.tool_calls.map((tc) => {
24135
- if (tc && typeof tc === "object" && "lc" in tc && "kwargs" in tc) {
24136
- return tc.kwargs;
24137
- }
24138
- return tc;
24139
- });
24140
- }
24141
- return kwargs;
24142
- }
24143
- return msg;
24144
- }
24145
- async function getThreadState(backendUrl, auth, threadId) {
24146
- const base2 = getAgoraBaseUrl(backendUrl);
24147
- const res = await fetch(`${base2}/api/unstable/threads/${threadId}`, {
24148
- method: "GET",
24149
- headers: { ...getAuthHeaders(auth) }
24150
- });
24151
- if (!res.ok) {
24152
- throw new Error(`[AthenaSDK] Failed to get thread state: ${res.status}`);
24153
- }
24154
- const data = await res.json();
24155
- if (Array.isArray(data.messages)) {
24156
- data.messages = data.messages.map(deserializeMessage);
24157
- }
24158
- return data;
24159
- }
24160
- async function archiveThread(backendUrl, auth, threadId) {
24161
- const base2 = getAgoraBaseUrl(backendUrl);
24162
- const res = await fetch(`${base2}/api/conversations/threads/archive`, {
24163
- method: "POST",
24164
- headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
24165
- body: JSON.stringify({ thread_id: threadId })
24166
- });
24167
- if (!res.ok) {
24168
- throw new Error(`[AthenaSDK] Failed to archive thread: ${res.status}`);
24169
- }
24170
- }
24171
- function createThreadListStore(config2) {
24172
- const auth = { apiKey: config2.apiKey, token: config2.token };
24173
- const store = create((set2, get2) => ({
24174
- threads: [],
24175
- activeThreadId: null,
24176
- isLoading: false,
24177
- error: null,
24178
- fetchThreads: async () => {
24179
- set2({ isLoading: true, error: null });
24253
+ function useAthenaThreadListAdapter(config2) {
24254
+ const configRef = useRef(config2);
24255
+ configRef.current = config2;
24256
+ const auth = useMemo(
24257
+ () => ({ apiKey: config2.apiKey, token: config2.token }),
24258
+ [config2.apiKey, config2.token]
24259
+ );
24260
+ const unstable_Provider = useCallback(
24261
+ function AthenaThreadProvider({ children }) {
24262
+ const aui = useAui();
24263
+ const remoteId = aui.threadListItem().getState().remoteId;
24264
+ return /* @__PURE__ */ jsx(AthenaThreadIdContext.Provider, { value: remoteId, children });
24265
+ },
24266
+ []
24267
+ );
24268
+ return useMemo(() => ({
24269
+ async list() {
24180
24270
  try {
24181
- const { threads } = await listThreads(config2.backendUrl, auth);
24182
- const sorted = [...threads].sort(
24183
- (a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
24184
- );
24185
- set2({ threads: sorted, isLoading: false });
24186
- } catch (e) {
24187
- set2({ error: e.message, isLoading: false });
24271
+ const { threads } = await listThreads(configRef.current.backendUrl, auth);
24272
+ return {
24273
+ threads: threads.map((t) => ({
24274
+ status: "regular",
24275
+ remoteId: t.thread_id,
24276
+ title: t.title || void 0
24277
+ }))
24278
+ };
24279
+ } catch (err) {
24280
+ console.error("[AthenaSDK] adapter.list() failed:", err);
24281
+ return { threads: [] };
24188
24282
  }
24189
24283
  },
24190
- switchThread: (threadId) => {
24191
- if (process.env.NODE_ENV !== "production") {
24192
- console.log("[AthenaThreads] switchThread called", { threadId, prev: get2().activeThreadId });
24193
- }
24194
- set2({ activeThreadId: threadId });
24284
+ async initialize(threadId) {
24285
+ return { remoteId: threadId, externalId: void 0 };
24195
24286
  },
24196
- newThread: async () => {
24197
- const localThreadId = `thread_${crypto.randomUUID()}`;
24198
- set2({ activeThreadId: localThreadId });
24199
- return localThreadId;
24287
+ async rename(_remoteId, _newTitle) {
24200
24288
  },
24201
- archiveThread: async (threadId) => {
24202
- var _a2;
24203
- try {
24204
- await archiveThread(config2.backendUrl, auth, threadId);
24205
- const { threads, activeThreadId } = get2();
24206
- const remaining = threads.filter((t) => t.thread_id !== threadId);
24207
- set2({
24208
- threads: remaining,
24209
- activeThreadId: activeThreadId === threadId ? ((_a2 = remaining[0]) == null ? void 0 : _a2.thread_id) ?? null : activeThreadId
24210
- });
24211
- } catch (e) {
24212
- set2({ error: e.message });
24213
- }
24214
- }
24215
- }));
24216
- store.getState().fetchThreads();
24217
- return store;
24289
+ async archive(remoteId) {
24290
+ await archiveThread(configRef.current.backendUrl, auth, remoteId);
24291
+ },
24292
+ async unarchive(_remoteId) {
24293
+ },
24294
+ async delete(remoteId) {
24295
+ await archiveThread(configRef.current.backendUrl, auth, remoteId);
24296
+ },
24297
+ async generateTitle(_remoteId, _messages) {
24298
+ return new ReadableStream({ start(c) {
24299
+ c.close();
24300
+ } });
24301
+ },
24302
+ async fetch(remoteId) {
24303
+ return {
24304
+ status: "regular",
24305
+ remoteId
24306
+ };
24307
+ },
24308
+ unstable_Provider
24309
+ }), [auth, unstable_Provider]);
24218
24310
  }
24219
24311
  const THEME_TO_CSS = {
24220
24312
  primary: "--primary",
@@ -24388,7 +24480,7 @@ const themes = {
24388
24480
  radius: "0.625rem"
24389
24481
  }
24390
24482
  };
24391
- function AthenaRuntimeInner({
24483
+ function AthenaStandalone({
24392
24484
  children,
24393
24485
  apiUrl,
24394
24486
  backendUrl,
@@ -24402,13 +24494,10 @@ function AthenaRuntimeInner({
24402
24494
  workbench,
24403
24495
  knowledgeBase,
24404
24496
  systemPrompt,
24405
- threadId,
24406
- initialMessages
24497
+ threadId
24407
24498
  }) {
24408
24499
  const auiTools = useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
24409
- const aui = useAui({
24410
- tools: auiTools
24411
- });
24500
+ const aui = useAui({ tools: auiTools });
24412
24501
  const runtime = useAthenaRuntime({
24413
24502
  apiUrl,
24414
24503
  backendUrl,
@@ -24421,8 +24510,7 @@ function AthenaRuntimeInner({
24421
24510
  workbench,
24422
24511
  knowledgeBase,
24423
24512
  systemPrompt,
24424
- threadId,
24425
- initialMessages
24513
+ threadId
24426
24514
  });
24427
24515
  const athenaConfig = useMemo(
24428
24516
  () => ({ backendUrl, apiKey, token }),
@@ -24430,6 +24518,85 @@ function AthenaRuntimeInner({
24430
24518
  );
24431
24519
  return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
24432
24520
  }
24521
+ function useAthenaRuntimeHook(config2) {
24522
+ const remoteId = useAthenaThreadId();
24523
+ return useAthenaRuntime({
24524
+ apiUrl: config2.apiUrl,
24525
+ backendUrl: config2.backendUrl,
24526
+ apiKey: config2.apiKey,
24527
+ token: config2.token,
24528
+ model: config2.model,
24529
+ agent: config2.agent,
24530
+ tools: config2.tools,
24531
+ frontendToolIds: config2.frontendToolIds,
24532
+ workbench: config2.workbench,
24533
+ knowledgeBase: config2.knowledgeBase,
24534
+ systemPrompt: config2.systemPrompt,
24535
+ threadId: remoteId
24536
+ });
24537
+ }
24538
+ function AthenaWithThreadList({
24539
+ children,
24540
+ apiUrl,
24541
+ backendUrl,
24542
+ apiKey,
24543
+ token,
24544
+ model,
24545
+ agent: agent2,
24546
+ tools,
24547
+ frontendToolIds,
24548
+ frontendTools,
24549
+ workbench,
24550
+ knowledgeBase,
24551
+ systemPrompt
24552
+ }) {
24553
+ const adapter = useAthenaThreadListAdapter({
24554
+ backendUrl,
24555
+ apiKey,
24556
+ token
24557
+ });
24558
+ const runtimeConfigRef = useRef({
24559
+ apiUrl,
24560
+ backendUrl,
24561
+ apiKey,
24562
+ token,
24563
+ model,
24564
+ agent: agent2,
24565
+ tools,
24566
+ frontendToolIds,
24567
+ workbench,
24568
+ knowledgeBase,
24569
+ systemPrompt
24570
+ });
24571
+ runtimeConfigRef.current = {
24572
+ apiUrl,
24573
+ backendUrl,
24574
+ apiKey,
24575
+ token,
24576
+ model,
24577
+ agent: agent2,
24578
+ tools,
24579
+ frontendToolIds,
24580
+ workbench,
24581
+ knowledgeBase,
24582
+ systemPrompt
24583
+ };
24584
+ const runtimeHook = useCallback(
24585
+ () => useAthenaRuntimeHook(runtimeConfigRef.current),
24586
+ []
24587
+ );
24588
+ const runtime = useRemoteThreadListRuntime({
24589
+ runtimeHook,
24590
+ adapter
24591
+ });
24592
+ const auiTools = useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
24593
+ const aui = useAui({ tools: auiTools });
24594
+ const athenaConfig = useMemo(
24595
+ () => ({ backendUrl, apiKey, token }),
24596
+ [backendUrl, apiKey, token]
24597
+ );
24598
+ return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
24599
+ }
24433
24600
  function AthenaProvider({
24434
24601
  children,
24435
24602
  apiKey,
@@ -24452,75 +24619,46 @@ function AthenaProvider({
24452
24619
  const parentAuthToken = useParentAuth();
24453
24620
  const effectiveToken = tokenProp ?? parentAuthToken;
24454
24621
  const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
24455
- const threadListStoreRef = useRef(null);
24456
- if (enableThreadList && !threadListStoreRef.current) {
24457
- threadListStoreRef.current = createThreadListStore({
24458
- backendUrl: effectiveBackendUrl,
24459
- apiKey,
24460
- token: effectiveToken
24461
- });
24462
- }
24463
- const activeThreadId = threadListStoreRef.current ? useStore$1(threadListStoreRef.current, (s) => s.activeThreadId) : null;
24464
- const [displayedThreadId, setDisplayedThreadId] = useState(null);
24465
- const [loadedMessages, setLoadedMessages] = useState(void 0);
24466
- const [isLoadingThread, setIsLoadingThread] = useState(false);
24467
- useEffect(() => {
24468
- var _a2;
24469
- if (!enableThreadList) return;
24470
- if (activeThreadId === displayedThreadId) return;
24471
- const threads = ((_a2 = threadListStoreRef.current) == null ? void 0 : _a2.getState().threads) ?? [];
24472
- const isExistingThread = threads.some((t) => t.thread_id === activeThreadId);
24473
- if (!isExistingThread) {
24474
- setLoadedMessages(void 0);
24475
- setDisplayedThreadId(activeThreadId);
24476
- setIsLoadingThread(false);
24477
- return;
24478
- }
24479
- let cancelled = false;
24480
- setIsLoadingThread(true);
24481
- getThreadState(effectiveBackendUrl, { apiKey, token: effectiveToken }, activeThreadId).then((state) => {
24482
- if (cancelled) return;
24483
- setLoadedMessages(state.messages ?? []);
24484
- setDisplayedThreadId(activeThreadId);
24485
- setIsLoadingThread(false);
24486
- }).catch((err) => {
24487
- if (cancelled) return;
24488
- if (process.env.NODE_ENV !== "production") {
24489
- console.error("[AthenaSDK] Failed to load thread state:", err);
24622
+ let inner;
24623
+ if (enableThreadList) {
24624
+ inner = /* @__PURE__ */ jsx(
24625
+ AthenaWithThreadList,
24626
+ {
24627
+ apiUrl,
24628
+ backendUrl: effectiveBackendUrl,
24629
+ apiKey,
24630
+ token: effectiveToken,
24631
+ model,
24632
+ agent: agent2,
24633
+ tools,
24634
+ frontendToolIds: frontendToolNames,
24635
+ frontendTools,
24636
+ workbench,
24637
+ knowledgeBase,
24638
+ systemPrompt,
24639
+ children
24490
24640
  }
24491
- setLoadedMessages(void 0);
24492
- setDisplayedThreadId(activeThreadId);
24493
- setIsLoadingThread(false);
24494
- });
24495
- return () => {
24496
- cancelled = true;
24497
- };
24498
- }, [activeThreadId, displayedThreadId, enableThreadList, effectiveBackendUrl, apiKey, effectiveToken]);
24499
- const resolvedThreadId = threadIdProp ?? displayedThreadId ?? void 0;
24500
- const runtimeContent = /* @__PURE__ */ jsx(ThreadLoadingContext.Provider, { value: isLoadingThread, children: /* @__PURE__ */ jsx(
24501
- AthenaRuntimeInner,
24502
- {
24503
- apiUrl,
24504
- backendUrl: effectiveBackendUrl,
24505
- apiKey,
24506
- token: effectiveToken,
24507
- model,
24508
- agent: agent2,
24509
- tools,
24510
- frontendToolIds: frontendToolNames,
24511
- frontendTools,
24512
- workbench,
24513
- knowledgeBase,
24514
- systemPrompt,
24515
- threadId: resolvedThreadId,
24516
- initialMessages: loadedMessages,
24517
- children
24518
- },
24519
- resolvedThreadId ?? "__new__"
24520
- ) });
24521
- let inner = runtimeContent;
24522
- if (enableThreadList && threadListStoreRef.current) {
24523
- inner = /* @__PURE__ */ jsx(ThreadListContext.Provider, { value: threadListStoreRef.current, children: inner });
24641
+ );
24642
+ } else {
24643
+ inner = /* @__PURE__ */ jsx(
24644
+ AthenaStandalone,
24645
+ {
24646
+ apiUrl,
24647
+ backendUrl: effectiveBackendUrl,
24648
+ apiKey,
24649
+ token: effectiveToken,
24650
+ model,
24651
+ agent: agent2,
24652
+ tools,
24653
+ frontendToolIds: frontendToolNames,
24654
+ frontendTools,
24655
+ workbench,
24656
+ knowledgeBase,
24657
+ systemPrompt,
24658
+ threadId: threadIdProp,
24659
+ children
24660
+ }
24661
+ );
24524
24662
  }
24525
24663
  if (themeStyleVars) {
24526
24664
  return /* @__PURE__ */ jsx("div", { className: "athena-themed", style: themeStyleVars, children: inner });
@@ -57318,10 +57456,10 @@ const HorizontalRule$1 = HorizontalRule.extend({
57318
57456
  };
57319
57457
  }
57320
57458
  });
57321
- const Image = Node3.create({
57459
+ const Image$1 = Node3.create({
57322
57460
  name: "image"
57323
57461
  });
57324
- const Image$1 = Image.extend({
57462
+ const Image$1$1 = Image$1.extend({
57325
57463
  /**
57326
57464
  * @return {{markdown: MarkdownNodeSpec}}
57327
57465
  */
@@ -57605,10 +57743,10 @@ const Italic$1 = Italic.extend({
57605
57743
  };
57606
57744
  }
57607
57745
  });
57608
- const Link = Mark2.create({
57746
+ const Link$1 = Mark2.create({
57609
57747
  name: "link"
57610
57748
  });
57611
- const Link$1 = Link.extend({
57749
+ const Link$1$1 = Link$1.extend({
57612
57750
  /**
57613
57751
  * @return {{markdown: MarkdownMarkSpec}}
57614
57752
  */
@@ -57645,7 +57783,7 @@ const Strike$1 = Strike.extend({
57645
57783
  };
57646
57784
  }
57647
57785
  });
57648
- 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];
57786
+ 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];
57649
57787
  function getMarkdownSpec(extension) {
57650
57788
  var _extension$storage, _markdownExtensions$f;
57651
57789
  const markdownSpec = (_extension$storage = extension.storage) === null || _extension$storage === void 0 ? void 0 : _extension$storage.markdown;
@@ -60458,41 +60596,41 @@ const createLucideIcon = (iconName, iconNode) => {
60458
60596
  * This source code is licensed under the ISC license.
60459
60597
  * See the LICENSE file in the root directory of this source tree.
60460
60598
  */
60461
- const __iconNode$E = [
60599
+ const __iconNode$J = [
60462
60600
  ["rect", { width: "20", height: "5", x: "2", y: "3", rx: "1", key: "1wp1u1" }],
60463
60601
  ["path", { d: "M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8", key: "1s80jp" }],
60464
60602
  ["path", { d: "M10 12h4", key: "a56b0p" }]
60465
60603
  ];
60466
- const Archive = createLucideIcon("archive", __iconNode$E);
60604
+ const Archive = createLucideIcon("archive", __iconNode$J);
60467
60605
  /**
60468
60606
  * @license lucide-react v0.575.0 - ISC
60469
60607
  *
60470
60608
  * This source code is licensed under the ISC license.
60471
60609
  * See the LICENSE file in the root directory of this source tree.
60472
60610
  */
60473
- const __iconNode$D = [
60611
+ const __iconNode$I = [
60474
60612
  ["path", { d: "M12 5v14", key: "s699le" }],
60475
60613
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
60476
60614
  ];
60477
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$D);
60615
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$I);
60478
60616
  /**
60479
60617
  * @license lucide-react v0.575.0 - ISC
60480
60618
  *
60481
60619
  * This source code is licensed under the ISC license.
60482
60620
  * See the LICENSE file in the root directory of this source tree.
60483
60621
  */
60484
- const __iconNode$C = [
60622
+ const __iconNode$H = [
60485
60623
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
60486
60624
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
60487
60625
  ];
60488
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$C);
60626
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$H);
60489
60627
  /**
60490
60628
  * @license lucide-react v0.575.0 - ISC
60491
60629
  *
60492
60630
  * This source code is licensed under the ISC license.
60493
60631
  * See the LICENSE file in the root directory of this source tree.
60494
60632
  */
60495
- const __iconNode$B = [
60633
+ const __iconNode$G = [
60496
60634
  ["path", { d: "M12 7v14", key: "1akyts" }],
60497
60635
  [
60498
60636
  "path",
@@ -60502,14 +60640,14 @@ const __iconNode$B = [
60502
60640
  }
60503
60641
  ]
60504
60642
  ];
60505
- const BookOpen = createLucideIcon("book-open", __iconNode$B);
60643
+ const BookOpen = createLucideIcon("book-open", __iconNode$G);
60506
60644
  /**
60507
60645
  * @license lucide-react v0.575.0 - ISC
60508
60646
  *
60509
60647
  * This source code is licensed under the ISC license.
60510
60648
  * See the LICENSE file in the root directory of this source tree.
60511
60649
  */
60512
- const __iconNode$A = [
60650
+ const __iconNode$F = [
60513
60651
  ["path", { d: "M12 18V5", key: "adv99a" }],
60514
60652
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
60515
60653
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -60519,148 +60657,148 @@ const __iconNode$A = [
60519
60657
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
60520
60658
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
60521
60659
  ];
60522
- const Brain = createLucideIcon("brain", __iconNode$A);
60660
+ const Brain = createLucideIcon("brain", __iconNode$F);
60523
60661
  /**
60524
60662
  * @license lucide-react v0.575.0 - ISC
60525
60663
  *
60526
60664
  * This source code is licensed under the ISC license.
60527
60665
  * See the LICENSE file in the root directory of this source tree.
60528
60666
  */
60529
- const __iconNode$z = [
60667
+ const __iconNode$E = [
60530
60668
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
60531
60669
  ["path", { d: "M18 17V9", key: "2bz60n" }],
60532
60670
  ["path", { d: "M13 17V5", key: "1frdt8" }],
60533
60671
  ["path", { d: "M8 17v-3", key: "17ska0" }]
60534
60672
  ];
60535
- const ChartColumn = createLucideIcon("chart-column", __iconNode$z);
60673
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$E);
60536
60674
  /**
60537
60675
  * @license lucide-react v0.575.0 - ISC
60538
60676
  *
60539
60677
  * This source code is licensed under the ISC license.
60540
60678
  * See the LICENSE file in the root directory of this source tree.
60541
60679
  */
60542
- const __iconNode$y = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60543
- const Check = createLucideIcon("check", __iconNode$y);
60680
+ const __iconNode$D = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60681
+ const Check = createLucideIcon("check", __iconNode$D);
60544
60682
  /**
60545
60683
  * @license lucide-react v0.575.0 - ISC
60546
60684
  *
60547
60685
  * This source code is licensed under the ISC license.
60548
60686
  * See the LICENSE file in the root directory of this source tree.
60549
60687
  */
60550
- const __iconNode$x = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60551
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$x);
60688
+ const __iconNode$C = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60689
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$C);
60552
60690
  /**
60553
60691
  * @license lucide-react v0.575.0 - ISC
60554
60692
  *
60555
60693
  * This source code is licensed under the ISC license.
60556
60694
  * See the LICENSE file in the root directory of this source tree.
60557
60695
  */
60558
- const __iconNode$w = [
60696
+ const __iconNode$B = [
60559
60697
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60560
60698
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
60561
60699
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
60562
60700
  ];
60563
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$w);
60701
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$B);
60564
60702
  /**
60565
60703
  * @license lucide-react v0.575.0 - ISC
60566
60704
  *
60567
60705
  * This source code is licensed under the ISC license.
60568
60706
  * See the LICENSE file in the root directory of this source tree.
60569
60707
  */
60570
- const __iconNode$v = [
60708
+ const __iconNode$A = [
60571
60709
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60572
60710
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
60573
60711
  ];
60574
- const CircleCheck = createLucideIcon("circle-check", __iconNode$v);
60712
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$A);
60575
60713
  /**
60576
60714
  * @license lucide-react v0.575.0 - ISC
60577
60715
  *
60578
60716
  * This source code is licensed under the ISC license.
60579
60717
  * See the LICENSE file in the root directory of this source tree.
60580
60718
  */
60581
- const __iconNode$u = [
60719
+ const __iconNode$z = [
60582
60720
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60583
60721
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
60584
60722
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
60585
60723
  ];
60586
- const CircleX = createLucideIcon("circle-x", __iconNode$u);
60724
+ const CircleX = createLucideIcon("circle-x", __iconNode$z);
60587
60725
  /**
60588
60726
  * @license lucide-react v0.575.0 - ISC
60589
60727
  *
60590
60728
  * This source code is licensed under the ISC license.
60591
60729
  * See the LICENSE file in the root directory of this source tree.
60592
60730
  */
60593
- const __iconNode$t = [
60731
+ const __iconNode$y = [
60594
60732
  ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
60595
60733
  ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
60596
60734
  ];
60597
- const Code = createLucideIcon("code", __iconNode$t);
60735
+ const Code = createLucideIcon("code", __iconNode$y);
60598
60736
  /**
60599
60737
  * @license lucide-react v0.575.0 - ISC
60600
60738
  *
60601
60739
  * This source code is licensed under the ISC license.
60602
60740
  * See the LICENSE file in the root directory of this source tree.
60603
60741
  */
60604
- const __iconNode$s = [
60742
+ const __iconNode$x = [
60605
60743
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
60606
60744
  ["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" }]
60607
60745
  ];
60608
- const Copy = createLucideIcon("copy", __iconNode$s);
60746
+ const Copy = createLucideIcon("copy", __iconNode$x);
60609
60747
  /**
60610
60748
  * @license lucide-react v0.575.0 - ISC
60611
60749
  *
60612
60750
  * This source code is licensed under the ISC license.
60613
60751
  * See the LICENSE file in the root directory of this source tree.
60614
60752
  */
60615
- const __iconNode$r = [
60753
+ const __iconNode$w = [
60616
60754
  ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
60617
60755
  ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
60618
60756
  ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
60619
60757
  ];
60620
- const Database = createLucideIcon("database", __iconNode$r);
60758
+ const Database = createLucideIcon("database", __iconNode$w);
60621
60759
  /**
60622
60760
  * @license lucide-react v0.575.0 - ISC
60623
60761
  *
60624
60762
  * This source code is licensed under the ISC license.
60625
60763
  * See the LICENSE file in the root directory of this source tree.
60626
60764
  */
60627
- const __iconNode$q = [
60765
+ const __iconNode$v = [
60628
60766
  ["path", { d: "M12 15V3", key: "m9g1x1" }],
60629
60767
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
60630
60768
  ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
60631
60769
  ];
60632
- const Download = createLucideIcon("download", __iconNode$q);
60770
+ const Download = createLucideIcon("download", __iconNode$v);
60633
60771
  /**
60634
60772
  * @license lucide-react v0.575.0 - ISC
60635
60773
  *
60636
60774
  * This source code is licensed under the ISC license.
60637
60775
  * See the LICENSE file in the root directory of this source tree.
60638
60776
  */
60639
- const __iconNode$p = [
60777
+ const __iconNode$u = [
60640
60778
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
60641
60779
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
60642
60780
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
60643
60781
  ];
60644
- const Ellipsis = createLucideIcon("ellipsis", __iconNode$p);
60782
+ const Ellipsis = createLucideIcon("ellipsis", __iconNode$u);
60645
60783
  /**
60646
60784
  * @license lucide-react v0.575.0 - ISC
60647
60785
  *
60648
60786
  * This source code is licensed under the ISC license.
60649
60787
  * See the LICENSE file in the root directory of this source tree.
60650
60788
  */
60651
- const __iconNode$o = [
60789
+ const __iconNode$t = [
60652
60790
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60653
60791
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
60654
60792
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
60655
60793
  ];
60656
- const ExternalLink = createLucideIcon("external-link", __iconNode$o);
60794
+ const ExternalLink = createLucideIcon("external-link", __iconNode$t);
60657
60795
  /**
60658
60796
  * @license lucide-react v0.575.0 - ISC
60659
60797
  *
60660
60798
  * This source code is licensed under the ISC license.
60661
60799
  * See the LICENSE file in the root directory of this source tree.
60662
60800
  */
60663
- const __iconNode$n = [
60801
+ const __iconNode$s = [
60664
60802
  [
60665
60803
  "path",
60666
60804
  {
@@ -60672,14 +60810,14 @@ const __iconNode$n = [
60672
60810
  ["path", { d: "M9 15h6", key: "cctwl0" }],
60673
60811
  ["path", { d: "M12 18v-6", key: "17g6i2" }]
60674
60812
  ];
60675
- const FilePlus = createLucideIcon("file-plus", __iconNode$n);
60813
+ const FilePlus = createLucideIcon("file-plus", __iconNode$s);
60676
60814
  /**
60677
60815
  * @license lucide-react v0.575.0 - ISC
60678
60816
  *
60679
60817
  * This source code is licensed under the ISC license.
60680
60818
  * See the LICENSE file in the root directory of this source tree.
60681
60819
  */
60682
- const __iconNode$m = [
60820
+ const __iconNode$r = [
60683
60821
  [
60684
60822
  "path",
60685
60823
  {
@@ -60693,14 +60831,14 @@ const __iconNode$m = [
60693
60831
  ["path", { d: "M8 17h2", key: "2yhykz" }],
60694
60832
  ["path", { d: "M14 17h2", key: "10kma7" }]
60695
60833
  ];
60696
- const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$m);
60834
+ const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$r);
60697
60835
  /**
60698
60836
  * @license lucide-react v0.575.0 - ISC
60699
60837
  *
60700
60838
  * This source code is licensed under the ISC license.
60701
60839
  * See the LICENSE file in the root directory of this source tree.
60702
60840
  */
60703
- const __iconNode$l = [
60841
+ const __iconNode$q = [
60704
60842
  [
60705
60843
  "path",
60706
60844
  {
@@ -60713,14 +60851,14 @@ const __iconNode$l = [
60713
60851
  ["path", { d: "M16 13H8", key: "t4e002" }],
60714
60852
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
60715
60853
  ];
60716
- const FileText = createLucideIcon("file-text", __iconNode$l);
60854
+ const FileText = createLucideIcon("file-text", __iconNode$q);
60717
60855
  /**
60718
60856
  * @license lucide-react v0.575.0 - ISC
60719
60857
  *
60720
60858
  * This source code is licensed under the ISC license.
60721
60859
  * See the LICENSE file in the root directory of this source tree.
60722
60860
  */
60723
- const __iconNode$k = [
60861
+ const __iconNode$p = [
60724
60862
  [
60725
60863
  "path",
60726
60864
  {
@@ -60730,26 +60868,54 @@ const __iconNode$k = [
60730
60868
  ],
60731
60869
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
60732
60870
  ];
60733
- const File$1 = createLucideIcon("file", __iconNode$k);
60871
+ const File$1 = createLucideIcon("file", __iconNode$p);
60734
60872
  /**
60735
60873
  * @license lucide-react v0.575.0 - ISC
60736
60874
  *
60737
60875
  * This source code is licensed under the ISC license.
60738
60876
  * See the LICENSE file in the root directory of this source tree.
60739
60877
  */
60740
- const __iconNode$j = [
60878
+ const __iconNode$o = [
60879
+ [
60880
+ "path",
60881
+ {
60882
+ 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",
60883
+ key: "usdka0"
60884
+ }
60885
+ ]
60886
+ ];
60887
+ const FolderOpen = createLucideIcon("folder-open", __iconNode$o);
60888
+ /**
60889
+ * @license lucide-react v0.575.0 - ISC
60890
+ *
60891
+ * This source code is licensed under the ISC license.
60892
+ * See the LICENSE file in the root directory of this source tree.
60893
+ */
60894
+ const __iconNode$n = [
60741
60895
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60742
60896
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
60743
60897
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
60744
60898
  ];
60745
- const Globe = createLucideIcon("globe", __iconNode$j);
60899
+ const Globe = createLucideIcon("globe", __iconNode$n);
60746
60900
  /**
60747
60901
  * @license lucide-react v0.575.0 - ISC
60748
60902
  *
60749
60903
  * This source code is licensed under the ISC license.
60750
60904
  * See the LICENSE file in the root directory of this source tree.
60751
60905
  */
60752
- const __iconNode$i = [
60906
+ const __iconNode$m = [
60907
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
60908
+ ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
60909
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
60910
+ ];
60911
+ const Image = createLucideIcon("image", __iconNode$m);
60912
+ /**
60913
+ * @license lucide-react v0.575.0 - ISC
60914
+ *
60915
+ * This source code is licensed under the ISC license.
60916
+ * See the LICENSE file in the root directory of this source tree.
60917
+ */
60918
+ const __iconNode$l = [
60753
60919
  [
60754
60920
  "path",
60755
60921
  {
@@ -60772,35 +60938,46 @@ const __iconNode$i = [
60772
60938
  }
60773
60939
  ]
60774
60940
  ];
60775
- const Layers = createLucideIcon("layers", __iconNode$i);
60941
+ const Layers = createLucideIcon("layers", __iconNode$l);
60776
60942
  /**
60777
60943
  * @license lucide-react v0.575.0 - ISC
60778
60944
  *
60779
60945
  * This source code is licensed under the ISC license.
60780
60946
  * See the LICENSE file in the root directory of this source tree.
60781
60947
  */
60782
- const __iconNode$h = [
60948
+ const __iconNode$k = [
60783
60949
  ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
60784
60950
  ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
60785
60951
  ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
60786
60952
  ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
60787
60953
  ];
60788
- const LayoutGrid = createLucideIcon("layout-grid", __iconNode$h);
60954
+ const LayoutGrid = createLucideIcon("layout-grid", __iconNode$k);
60789
60955
  /**
60790
60956
  * @license lucide-react v0.575.0 - ISC
60791
60957
  *
60792
60958
  * This source code is licensed under the ISC license.
60793
60959
  * See the LICENSE file in the root directory of this source tree.
60794
60960
  */
60795
- const __iconNode$g = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60796
- const LoaderCircle = createLucideIcon("loader-circle", __iconNode$g);
60961
+ const __iconNode$j = [
60962
+ ["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" }],
60963
+ ["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" }]
60964
+ ];
60965
+ const Link = createLucideIcon("link", __iconNode$j);
60797
60966
  /**
60798
60967
  * @license lucide-react v0.575.0 - ISC
60799
60968
  *
60800
60969
  * This source code is licensed under the ISC license.
60801
60970
  * See the LICENSE file in the root directory of this source tree.
60802
60971
  */
60803
- const __iconNode$f = [
60972
+ const __iconNode$i = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60973
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$i);
60974
+ /**
60975
+ * @license lucide-react v0.575.0 - ISC
60976
+ *
60977
+ * This source code is licensed under the ISC license.
60978
+ * See the LICENSE file in the root directory of this source tree.
60979
+ */
60980
+ const __iconNode$h = [
60804
60981
  ["path", { d: "M12 2v4", key: "3427ic" }],
60805
60982
  ["path", { d: "m16.2 7.8 2.9-2.9", key: "r700ao" }],
60806
60983
  ["path", { d: "M18 12h4", key: "wj9ykh" }],
@@ -60810,38 +60987,38 @@ const __iconNode$f = [
60810
60987
  ["path", { d: "M2 12h4", key: "j09sii" }],
60811
60988
  ["path", { d: "m4.9 4.9 2.9 2.9", key: "giyufr" }]
60812
60989
  ];
60813
- const Loader = createLucideIcon("loader", __iconNode$f);
60990
+ const Loader = createLucideIcon("loader", __iconNode$h);
60814
60991
  /**
60815
60992
  * @license lucide-react v0.575.0 - ISC
60816
60993
  *
60817
60994
  * This source code is licensed under the ISC license.
60818
60995
  * See the LICENSE file in the root directory of this source tree.
60819
60996
  */
60820
- const __iconNode$e = [
60997
+ const __iconNode$g = [
60821
60998
  ["path", { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7", key: "132q7q" }],
60822
60999
  ["rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", key: "izxlao" }]
60823
61000
  ];
60824
- const Mail = createLucideIcon("mail", __iconNode$e);
61001
+ const Mail = createLucideIcon("mail", __iconNode$g);
60825
61002
  /**
60826
61003
  * @license lucide-react v0.575.0 - ISC
60827
61004
  *
60828
61005
  * This source code is licensed under the ISC license.
60829
61006
  * See the LICENSE file in the root directory of this source tree.
60830
61007
  */
60831
- const __iconNode$d = [
61008
+ const __iconNode$f = [
60832
61009
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60833
61010
  ["path", { d: "m21 3-7 7", key: "1l2asr" }],
60834
61011
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60835
61012
  ["path", { d: "M9 21H3v-6", key: "wtvkvv" }]
60836
61013
  ];
60837
- const Maximize2 = createLucideIcon("maximize-2", __iconNode$d);
61014
+ const Maximize2 = createLucideIcon("maximize-2", __iconNode$f);
60838
61015
  /**
60839
61016
  * @license lucide-react v0.575.0 - ISC
60840
61017
  *
60841
61018
  * This source code is licensed under the ISC license.
60842
61019
  * See the LICENSE file in the root directory of this source tree.
60843
61020
  */
60844
- const __iconNode$c = [
61021
+ const __iconNode$e = [
60845
61022
  [
60846
61023
  "path",
60847
61024
  {
@@ -60850,39 +61027,39 @@ const __iconNode$c = [
60850
61027
  }
60851
61028
  ]
60852
61029
  ];
60853
- const MessageSquare = createLucideIcon("message-square", __iconNode$c);
61030
+ const MessageSquare = createLucideIcon("message-square", __iconNode$e);
60854
61031
  /**
60855
61032
  * @license lucide-react v0.575.0 - ISC
60856
61033
  *
60857
61034
  * This source code is licensed under the ISC license.
60858
61035
  * See the LICENSE file in the root directory of this source tree.
60859
61036
  */
60860
- const __iconNode$b = [
61037
+ const __iconNode$d = [
60861
61038
  ["path", { d: "m14 10 7-7", key: "oa77jy" }],
60862
61039
  ["path", { d: "M20 10h-6V4", key: "mjg0md" }],
60863
61040
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60864
61041
  ["path", { d: "M4 14h6v6", key: "rmj7iw" }]
60865
61042
  ];
60866
- const Minimize2 = createLucideIcon("minimize-2", __iconNode$b);
61043
+ const Minimize2 = createLucideIcon("minimize-2", __iconNode$d);
60867
61044
  /**
60868
61045
  * @license lucide-react v0.575.0 - ISC
60869
61046
  *
60870
61047
  * This source code is licensed under the ISC license.
60871
61048
  * See the LICENSE file in the root directory of this source tree.
60872
61049
  */
60873
- const __iconNode$a = [
61050
+ const __iconNode$c = [
60874
61051
  ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
60875
61052
  ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
60876
61053
  ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
60877
61054
  ];
60878
- const Monitor = createLucideIcon("monitor", __iconNode$a);
61055
+ const Monitor = createLucideIcon("monitor", __iconNode$c);
60879
61056
  /**
60880
61057
  * @license lucide-react v0.575.0 - ISC
60881
61058
  *
60882
61059
  * This source code is licensed under the ISC license.
60883
61060
  * See the LICENSE file in the root directory of this source tree.
60884
61061
  */
60885
- const __iconNode$9 = [
61062
+ const __iconNode$b = [
60886
61063
  ["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" }],
60887
61064
  ["path", { d: "M2 6h4", key: "aawbzj" }],
60888
61065
  ["path", { d: "M2 10h4", key: "l0bgd4" }],
@@ -60896,14 +61073,14 @@ const __iconNode$9 = [
60896
61073
  }
60897
61074
  ]
60898
61075
  ];
60899
- const NotebookPen = createLucideIcon("notebook-pen", __iconNode$9);
61076
+ const NotebookPen = createLucideIcon("notebook-pen", __iconNode$b);
60900
61077
  /**
60901
61078
  * @license lucide-react v0.575.0 - ISC
60902
61079
  *
60903
61080
  * This source code is licensed under the ISC license.
60904
61081
  * See the LICENSE file in the root directory of this source tree.
60905
61082
  */
60906
- const __iconNode$8 = [
61083
+ const __iconNode$a = [
60907
61084
  ["path", { d: "M13 21h8", key: "1jsn5i" }],
60908
61085
  [
60909
61086
  "path",
@@ -60913,61 +61090,61 @@ const __iconNode$8 = [
60913
61090
  }
60914
61091
  ]
60915
61092
  ];
60916
- const PenLine = createLucideIcon("pen-line", __iconNode$8);
61093
+ const PenLine = createLucideIcon("pen-line", __iconNode$a);
60917
61094
  /**
60918
61095
  * @license lucide-react v0.575.0 - ISC
60919
61096
  *
60920
61097
  * This source code is licensed under the ISC license.
60921
61098
  * See the LICENSE file in the root directory of this source tree.
60922
61099
  */
60923
- const __iconNode$7 = [
61100
+ const __iconNode$9 = [
60924
61101
  ["path", { d: "M5 12h14", key: "1ays0h" }],
60925
61102
  ["path", { d: "M12 5v14", key: "s699le" }]
60926
61103
  ];
60927
- const Plus = createLucideIcon("plus", __iconNode$7);
61104
+ const Plus = createLucideIcon("plus", __iconNode$9);
60928
61105
  /**
60929
61106
  * @license lucide-react v0.575.0 - ISC
60930
61107
  *
60931
61108
  * This source code is licensed under the ISC license.
60932
61109
  * See the LICENSE file in the root directory of this source tree.
60933
61110
  */
60934
- const __iconNode$6 = [
61111
+ const __iconNode$8 = [
60935
61112
  ["path", { d: "M2 3h20", key: "91anmk" }],
60936
61113
  ["path", { d: "M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3", key: "2k9sn8" }],
60937
61114
  ["path", { d: "m7 21 5-5 5 5", key: "bip4we" }]
60938
61115
  ];
60939
- const Presentation = createLucideIcon("presentation", __iconNode$6);
61116
+ const Presentation = createLucideIcon("presentation", __iconNode$8);
60940
61117
  /**
60941
61118
  * @license lucide-react v0.575.0 - ISC
60942
61119
  *
60943
61120
  * This source code is licensed under the ISC license.
60944
61121
  * See the LICENSE file in the root directory of this source tree.
60945
61122
  */
60946
- const __iconNode$5 = [
61123
+ const __iconNode$7 = [
60947
61124
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
60948
61125
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
60949
61126
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
60950
61127
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
60951
61128
  ];
60952
- const RefreshCw = createLucideIcon("refresh-cw", __iconNode$5);
61129
+ const RefreshCw = createLucideIcon("refresh-cw", __iconNode$7);
60953
61130
  /**
60954
61131
  * @license lucide-react v0.575.0 - ISC
60955
61132
  *
60956
61133
  * This source code is licensed under the ISC license.
60957
61134
  * See the LICENSE file in the root directory of this source tree.
60958
61135
  */
60959
- const __iconNode$4 = [
61136
+ const __iconNode$6 = [
60960
61137
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
60961
61138
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
60962
61139
  ];
60963
- const Search = createLucideIcon("search", __iconNode$4);
61140
+ const Search = createLucideIcon("search", __iconNode$6);
60964
61141
  /**
60965
61142
  * @license lucide-react v0.575.0 - ISC
60966
61143
  *
60967
61144
  * This source code is licensed under the ISC license.
60968
61145
  * See the LICENSE file in the root directory of this source tree.
60969
61146
  */
60970
- const __iconNode$3 = [
61147
+ const __iconNode$5 = [
60971
61148
  [
60972
61149
  "path",
60973
61150
  {
@@ -60977,17 +61154,46 @@ const __iconNode$3 = [
60977
61154
  ],
60978
61155
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
60979
61156
  ];
60980
- const Settings = createLucideIcon("settings", __iconNode$3);
61157
+ const Settings = createLucideIcon("settings", __iconNode$5);
60981
61158
  /**
60982
61159
  * @license lucide-react v0.575.0 - ISC
60983
61160
  *
60984
61161
  * This source code is licensed under the ISC license.
60985
61162
  * See the LICENSE file in the root directory of this source tree.
60986
61163
  */
60987
- const __iconNode$2 = [
61164
+ const __iconNode$4 = [
60988
61165
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
60989
61166
  ];
60990
- const Square = createLucideIcon("square", __iconNode$2);
61167
+ const Square = createLucideIcon("square", __iconNode$4);
61168
+ /**
61169
+ * @license lucide-react v0.575.0 - ISC
61170
+ *
61171
+ * This source code is licensed under the ISC license.
61172
+ * See the LICENSE file in the root directory of this source tree.
61173
+ */
61174
+ const __iconNode$3 = [
61175
+ ["path", { d: "M12 19h8", key: "baeox8" }],
61176
+ ["path", { d: "m4 17 6-6-6-6", key: "1yngyt" }]
61177
+ ];
61178
+ const Terminal = createLucideIcon("terminal", __iconNode$3);
61179
+ /**
61180
+ * @license lucide-react v0.575.0 - ISC
61181
+ *
61182
+ * This source code is licensed under the ISC license.
61183
+ * See the LICENSE file in the root directory of this source tree.
61184
+ */
61185
+ const __iconNode$2 = [
61186
+ [
61187
+ "path",
61188
+ {
61189
+ 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",
61190
+ key: "wmoenq"
61191
+ }
61192
+ ],
61193
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
61194
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
61195
+ ];
61196
+ const TriangleAlert = createLucideIcon("triangle-alert", __iconNode$2);
60991
61197
  /**
60992
61198
  * @license lucide-react v0.575.0 - ISC
60993
61199
  *
@@ -61110,6 +61316,8 @@ const TOOL_META = {
61110
61316
  // Workflows
61111
61317
  create_new_aop: { displayName: "Creating workflow", icon: Brain },
61112
61318
  execute_aop: { displayName: "Running workflow", icon: Brain },
61319
+ // Drive / Assets
61320
+ open_asset_in_workspace: { displayName: "Opening asset", icon: FolderOpen },
61113
61321
  // Preferences
61114
61322
  save_preference_as_memory: { displayName: "Saving preference", icon: Settings }
61115
61323
  };
@@ -61160,6 +61368,14 @@ function extractAssetId$1(result) {
61160
61368
  }
61161
61369
  return null;
61162
61370
  }
61371
+ function extractAssetIdFromArgs(argsText) {
61372
+ if (!argsText) return null;
61373
+ const parsed = tryParseJson$2(argsText);
61374
+ if (!parsed) return null;
61375
+ const id = parsed.asset_id ?? parsed.assetId;
61376
+ if (typeof id === "string" && id.startsWith("asset_")) return id;
61377
+ return null;
61378
+ }
61163
61379
  function toolMetaToAssetType(toolName) {
61164
61380
  const lower = toolName.toLowerCase();
61165
61381
  if (lower.includes("presentation") || lower.includes("pptx") || lower.includes("slide") || lower.includes("powerpoint"))
@@ -61168,13 +61384,16 @@ function toolMetaToAssetType(toolName) {
61168
61384
  return "spreadsheet";
61169
61385
  if (lower.includes("document") || lower.includes("doc") || lower.includes("markdown"))
61170
61386
  return "document";
61387
+ if (lower.includes("notebook"))
61388
+ return "notebook";
61171
61389
  return "unknown";
61172
61390
  }
61173
61391
  const CREATE_ASSET_TOOLS = [
61174
61392
  "create_powerpoint_deck",
61175
61393
  "create_document_from_markdown",
61176
61394
  "create_new_document",
61177
- "create_new_sheet"
61395
+ "create_new_sheet",
61396
+ "create_new_notebook"
61178
61397
  ];
61179
61398
  function isAssetTool(toolName, result) {
61180
61399
  return CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) || extractAssetId$1(result) !== null;
@@ -61486,6 +61705,7 @@ function AssetToolCard({
61486
61705
  assetId && isComplete && !isCancelled && CREATE_ASSET_TOOLS.includes(toolName.toLowerCase()) && /* @__PURE__ */ jsxs(
61487
61706
  "button",
61488
61707
  {
61708
+ type: "button",
61489
61709
  onClick: () => openAsset(assetId, { name: title ?? void 0, type: assetType }),
61490
61710
  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",
61491
61711
  children: [
@@ -61498,6 +61718,7 @@ function AssetToolCard({
61498
61718
  !isCancelled && /* @__PURE__ */ jsx(
61499
61719
  "button",
61500
61720
  {
61721
+ type: "button",
61501
61722
  onClick: () => setDetailsOpen((o) => !o),
61502
61723
  className: cn(
61503
61724
  "flex size-5 shrink-0 items-center justify-center rounded transition-all",
@@ -61523,6 +61744,23 @@ function AssetToolCard({
61523
61744
  ] })
61524
61745
  ] });
61525
61746
  }
61747
+ function AssetOpenLink({ assetId, toolName }) {
61748
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
61749
+ const assetType = toolMetaToAssetType(toolName);
61750
+ return /* @__PURE__ */ jsx(
61751
+ "button",
61752
+ {
61753
+ type: "button",
61754
+ onClick: (e) => {
61755
+ e.stopPropagation();
61756
+ openAsset(assetId, { type: assetType });
61757
+ },
61758
+ className: "flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground/50 transition-colors hover:bg-muted/50 hover:text-foreground",
61759
+ title: "Open asset",
61760
+ children: /* @__PURE__ */ jsx(Link, { className: "size-3" })
61761
+ }
61762
+ );
61763
+ }
61526
61764
  const ToolFallbackImpl = ({
61527
61765
  toolName,
61528
61766
  argsText,
@@ -61541,12 +61779,19 @@ const ToolFallbackImpl = ({
61541
61779
  }
61542
61780
  );
61543
61781
  }
61782
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
61783
+ const resultAssetId = extractAssetId$1(result);
61784
+ const argsAssetId = extractAssetIdFromArgs(argsText);
61785
+ const fallbackAssetId = resultAssetId ?? argsAssetId;
61544
61786
  return /* @__PURE__ */ jsxs(
61545
61787
  ToolFallbackRoot,
61546
61788
  {
61547
61789
  className: cn(isCancelled && "border-muted-foreground/30 bg-muted/30"),
61548
61790
  children: [
61549
- /* @__PURE__ */ jsx(ToolFallbackTrigger, { toolName, argsText, result, status }),
61791
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
61792
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx(ToolFallbackTrigger, { toolName, argsText, result, status }) }),
61793
+ fallbackAssetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "shrink-0 pr-2", children: /* @__PURE__ */ jsx(AssetOpenLink, { assetId: fallbackAssetId, toolName }) })
61794
+ ] }),
61550
61795
  /* @__PURE__ */ jsxs(ToolFallbackContent, { children: [
61551
61796
  /* @__PURE__ */ jsx(ToolFallbackError, { status }),
61552
61797
  /* @__PURE__ */ jsx(
@@ -61930,7 +62175,7 @@ function ToolCard({
61930
62175
  "flex size-8 shrink-0 items-center justify-center rounded-lg",
61931
62176
  isRunning && "bg-blue-50 text-blue-600",
61932
62177
  isComplete && "bg-emerald-50 text-emerald-600",
61933
- isError && "bg-red-50 text-red-500"
62178
+ isError && "bg-destructive/10 text-destructive"
61934
62179
  ),
61935
62180
  children: isRunning ? /* @__PURE__ */ jsx(Loader, { className: "size-4 animate-spin" }) : isError ? /* @__PURE__ */ jsx(CircleAlert, { className: "size-4" }) : /* @__PURE__ */ jsx(Icon2, { className: "size-4" })
61936
62181
  }
@@ -61949,7 +62194,7 @@ function ToolCard({
61949
62194
  /* @__PURE__ */ jsx("div", { className: "h-1.5 w-6 animate-pulse rounded-full bg-blue-100" })
61950
62195
  ] })
61951
62196
  ] }),
61952
- error2 && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 bg-red-50/50 px-4 py-2.5", children: /* @__PURE__ */ jsx("p", { className: "text-[12px] leading-relaxed text-red-600", children: error2 }) }),
62197
+ error2 && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 bg-destructive/10 px-4 py-2.5", children: /* @__PURE__ */ jsx("p", { className: "text-[12px] leading-relaxed text-destructive", children: error2 }) }),
61953
62198
  children
61954
62199
  ] });
61955
62200
  }
@@ -62195,6 +62440,7 @@ function CreateAssetToolUIImpl({
62195
62440
  children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
62196
62441
  "button",
62197
62442
  {
62443
+ type: "button",
62198
62444
  onClick: handleOpen,
62199
62445
  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",
62200
62446
  children: [
@@ -62276,6 +62522,192 @@ const CreateEmailDraftToolUI = memo(
62276
62522
  CreateEmailDraftToolUIImpl
62277
62523
  );
62278
62524
  CreateEmailDraftToolUI.displayName = "CreateEmailDraftToolUI";
62525
+ const CreateNotebookToolUIImpl = (props) => /* @__PURE__ */ jsx(
62526
+ CreateAssetToolUIImpl,
62527
+ {
62528
+ icon: BookOpen,
62529
+ assetType: "notebook",
62530
+ runningLabel: "Creating notebook...",
62531
+ doneLabel: "Created notebook",
62532
+ ...props
62533
+ }
62534
+ );
62535
+ const CreateNotebookToolUI = memo(
62536
+ CreateNotebookToolUIImpl
62537
+ );
62538
+ CreateNotebookToolUI.displayName = "CreateNotebookToolUI";
62539
+ function parsePythonResult(result) {
62540
+ const data = normalizeResult(result);
62541
+ if (!data) return { stdout: null, stderr: null, value: null, error: null, exception: null, imagePng: null, createdAssets: [] };
62542
+ const inner = typeof data.result === "object" && data.result !== null ? data.result : data;
62543
+ const stdout = inner.stdout ?? null;
62544
+ const stderr = inner.stderr ?? null;
62545
+ const value = inner.value ?? null;
62546
+ const error2 = inner.error ?? null;
62547
+ let exception = null;
62548
+ if (inner.exception && typeof inner.exception === "object") {
62549
+ const exc = inner.exception;
62550
+ exception = {
62551
+ name: exc.name ?? "Error",
62552
+ value: exc.value ?? "",
62553
+ traceback: exc.traceback ?? ""
62554
+ };
62555
+ }
62556
+ let imagePng = null;
62557
+ if (inner.data && typeof inner.data === "object") {
62558
+ imagePng = inner.data.png ?? null;
62559
+ }
62560
+ const createdAssets = Array.isArray(data.created_assets) ? data.created_assets : [];
62561
+ return { stdout, stderr, value, error: error2, exception, imagePng, createdAssets };
62562
+ }
62563
+ const RunPythonCodeToolUIImpl = ({
62564
+ toolName,
62565
+ args,
62566
+ result,
62567
+ status
62568
+ }) => {
62569
+ var _a2;
62570
+ const typedArgs = args;
62571
+ const code2 = (typedArgs == null ? void 0 : typedArgs.code) ?? "";
62572
+ const summary = (typedArgs == null ? void 0 : typedArgs.summary) ?? null;
62573
+ const lines = code2 ? code2.split("\n").length : 0;
62574
+ const isRunning = (status == null ? void 0 : status.type) === "running";
62575
+ const isComplete = (status == null ? void 0 : status.type) === "complete";
62576
+ const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
62577
+ const parsed = useMemo(() => isComplete ? parsePythonResult(result) : null, [result, isComplete]);
62578
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
62579
+ const hasOutput = parsed && (parsed.stdout || parsed.stderr || parsed.value);
62580
+ const hasError = parsed && (parsed.error || parsed.exception);
62581
+ const hasImage = parsed == null ? void 0 : parsed.imagePng;
62582
+ return /* @__PURE__ */ jsxs(
62583
+ ToolCard,
62584
+ {
62585
+ icon: Code,
62586
+ status: (status == null ? void 0 : status.type) ?? "complete",
62587
+ title: isRunning ? "Running code..." : summary || `Executed ${lines} ${lines !== 1 ? "lines" : "line"}`,
62588
+ toolName,
62589
+ error: errorMsg,
62590
+ children: [
62591
+ code2 && /* @__PURE__ */ jsx(ExpandableSection, { label: "Show code", children: /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap break-words text-[11px] leading-relaxed font-mono text-foreground/80", children: code2 }) }),
62592
+ isComplete && hasOutput && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
62593
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 mb-1", children: [
62594
+ /* @__PURE__ */ jsx(Terminal, { className: "size-3 text-muted-foreground" }),
62595
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Output" })
62596
+ ] }),
62597
+ /* @__PURE__ */ 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") })
62598
+ ] }),
62599
+ isComplete && hasError && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 bg-destructive/10 px-4 py-2.5", children: [
62600
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 mb-1", children: [
62601
+ /* @__PURE__ */ jsx(TriangleAlert, { className: "size-3 text-destructive" }),
62602
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-destructive", children: parsed.exception ? `${parsed.exception.name}: ${parsed.exception.value}` : "Error" })
62603
+ ] }),
62604
+ /* @__PURE__ */ 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 })
62605
+ ] }),
62606
+ isComplete && hasImage && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2.5", children: [
62607
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 mb-1.5", children: [
62608
+ /* @__PURE__ */ jsx(Image, { className: "size-3 text-muted-foreground" }),
62609
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Generated image" })
62610
+ ] }),
62611
+ /* @__PURE__ */ jsx(
62612
+ "img",
62613
+ {
62614
+ src: `data:image/png;base64,${parsed.imagePng}`,
62615
+ alt: "Python output",
62616
+ className: "max-w-full rounded-md border border-border/40"
62617
+ }
62618
+ )
62619
+ ] }),
62620
+ isComplete && parsed && parsed.createdAssets.length > 0 && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-4 py-2", children: [
62621
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: "Created assets" }),
62622
+ /* @__PURE__ */ jsx("div", { className: "mt-1 flex flex-wrap gap-1.5", children: parsed.createdAssets.map((a) => /* @__PURE__ */ jsxs(
62623
+ "button",
62624
+ {
62625
+ type: "button",
62626
+ onClick: () => openAsset(a.asset_id),
62627
+ 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",
62628
+ children: [
62629
+ /* @__PURE__ */ jsx(ExternalLink, { className: "size-2.5" }),
62630
+ truncate(a.asset_id, 20)
62631
+ ]
62632
+ },
62633
+ a.asset_id
62634
+ )) })
62635
+ ] })
62636
+ ]
62637
+ }
62638
+ );
62639
+ };
62640
+ const RunPythonCodeToolUI = memo(
62641
+ RunPythonCodeToolUIImpl
62642
+ );
62643
+ RunPythonCodeToolUI.displayName = "RunPythonCodeToolUI";
62644
+ const OpenAssetToolUIImpl = ({
62645
+ toolName,
62646
+ args,
62647
+ result,
62648
+ status
62649
+ }) => {
62650
+ const typedArgs = args;
62651
+ const argsAssetId = (typedArgs == null ? void 0 : typedArgs.asset_id) ?? (typedArgs == null ? void 0 : typedArgs.assetId) ?? "";
62652
+ const resultAssetId = extractAssetId(result);
62653
+ const assetId = resultAssetId ?? (argsAssetId.startsWith("asset_") ? argsAssetId : null);
62654
+ const isRunning = (status == null ? void 0 : status.type) === "running";
62655
+ const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
62656
+ const isCancelled = (status == null ? void 0 : status.type) === "incomplete" && status.reason === "cancelled";
62657
+ const errorMsg = (status == null ? void 0 : status.type) === "incomplete" ? status.error : null;
62658
+ const openAsset = useAssetPanelStore((s) => s.openAsset);
62659
+ const wasCompleteAtMount = useRef(isComplete);
62660
+ useEffect(() => {
62661
+ if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
62662
+ const store = useAssetPanelStore.getState();
62663
+ if (store.markAutoOpened(assetId)) {
62664
+ store.openAsset(assetId);
62665
+ }
62666
+ }
62667
+ }, [isComplete, isCancelled, assetId]);
62668
+ return /* @__PURE__ */ jsx(
62669
+ ToolCard,
62670
+ {
62671
+ icon: FolderOpen,
62672
+ status: (status == null ? void 0 : status.type) ?? "complete",
62673
+ title: isRunning ? "Opening asset..." : "Asset opened",
62674
+ subtitle: assetId ? truncate(assetId, 30) : void 0,
62675
+ toolName,
62676
+ error: errorMsg,
62677
+ children: assetId && isComplete && !isCancelled && /* @__PURE__ */ jsx("div", { className: "border-t border-border/40 px-4 py-2", children: /* @__PURE__ */ jsxs(
62678
+ "button",
62679
+ {
62680
+ type: "button",
62681
+ onClick: () => openAsset(assetId),
62682
+ 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",
62683
+ children: [
62684
+ /* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
62685
+ "Open asset"
62686
+ ]
62687
+ }
62688
+ ) })
62689
+ }
62690
+ );
62691
+ };
62692
+ const OpenAssetToolUI = memo(
62693
+ OpenAssetToolUIImpl
62694
+ );
62695
+ OpenAssetToolUI.displayName = "OpenAssetToolUI";
62696
+ function createAssetToolUI(config2) {
62697
+ const Component = (props) => /* @__PURE__ */ jsx(
62698
+ CreateAssetToolUIImpl,
62699
+ {
62700
+ icon: config2.icon,
62701
+ assetType: config2.assetType,
62702
+ runningLabel: config2.runningLabel,
62703
+ doneLabel: config2.doneLabel,
62704
+ ...props
62705
+ }
62706
+ );
62707
+ const Memoized = memo(Component);
62708
+ Memoized.displayName = `CreateAssetToolUI(${config2.assetType})`;
62709
+ return Memoized;
62710
+ }
62279
62711
  const TOOL_UI_REGISTRY = {
62280
62712
  search: WebSearchToolUI,
62281
62713
  browse: BrowseToolUI,
@@ -62286,7 +62718,10 @@ const TOOL_UI_REGISTRY = {
62286
62718
  create_new_document: CreateDocumentToolUI,
62287
62719
  create_document_from_markdown: CreateDocumentToolUI,
62288
62720
  create_new_sheet: CreateSheetToolUI,
62289
- create_powerpoint_deck: CreatePresentationToolUI
62721
+ create_powerpoint_deck: CreatePresentationToolUI,
62722
+ create_new_notebook: CreateNotebookToolUI,
62723
+ run_python_code: RunPythonCodeToolUI,
62724
+ open_asset_in_workspace: OpenAssetToolUI
62290
62725
  };
62291
62726
  const falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
62292
62727
  const cx = clsx;
@@ -62407,7 +62842,6 @@ const AthenaChat = ({
62407
62842
  toolUIs,
62408
62843
  mentionTools
62409
62844
  }) => {
62410
- const isLoadingThread = useThreadLoading();
62411
62845
  const tools = mentionTools ?? EMPTY_MENTION_TOOLS;
62412
62846
  const mergedToolUIs = useMemo(() => ({
62413
62847
  append_markdown_to_athena_document: AppendDocumentToolUI,
@@ -62419,43 +62853,40 @@ const AthenaChat = ({
62419
62853
  () => () => /* @__PURE__ */ jsx(AssistantMessage, { toolUIs: mergedToolUIs }),
62420
62854
  [mergedToolUIs]
62421
62855
  );
62422
- return /* @__PURE__ */ jsxs(
62856
+ return /* @__PURE__ */ jsx(
62423
62857
  ThreadPrimitiveRoot,
62424
62858
  {
62425
62859
  className: `aui-root aui-thread-root @container flex h-full flex-col bg-background ${className ?? ""}`,
62426
62860
  style: { ["--thread-max-width"]: maxWidth, position: "relative" },
62427
- children: [
62428
- isLoadingThread && /* @__PURE__ */ jsx(ThreadLoadingOverlay, {}),
62429
- /* @__PURE__ */ jsxs(
62430
- ThreadPrimitiveViewport,
62431
- {
62432
- turnAnchor: "top",
62433
- className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
62434
- children: [
62435
- /* @__PURE__ */ jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsx("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ jsx("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "aui-thread-welcome-message flex size-full flex-col justify-center px-4", children: [
62436
- /* @__PURE__ */ 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 }),
62437
- /* @__PURE__ */ 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 })
62438
- ] }) }) }) }),
62439
- /* @__PURE__ */ jsx(
62440
- ThreadPrimitiveMessages,
62441
- {
62442
- components: {
62443
- UserMessage,
62444
- AssistantMessage: AssistantMessageComponent
62445
- }
62861
+ children: /* @__PURE__ */ jsxs(
62862
+ ThreadPrimitiveViewport,
62863
+ {
62864
+ turnAnchor: "top",
62865
+ className: "aui-thread-viewport relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4",
62866
+ children: [
62867
+ /* @__PURE__ */ jsx(AuiIf, { condition: (s) => s.thread.isEmpty, children: /* @__PURE__ */ jsx("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ jsx("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "aui-thread-welcome-message flex size-full flex-col justify-center px-4", children: [
62868
+ /* @__PURE__ */ 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 }),
62869
+ /* @__PURE__ */ 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 })
62870
+ ] }) }) }) }),
62871
+ /* @__PURE__ */ jsx(
62872
+ ThreadPrimitiveMessages,
62873
+ {
62874
+ components: {
62875
+ UserMessage,
62876
+ AssistantMessage: AssistantMessageComponent
62446
62877
  }
62447
- ),
62448
- /* @__PURE__ */ 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: [
62449
- /* @__PURE__ */ jsx(ThreadScrollToBottom, {}),
62450
- /* @__PURE__ */ 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: [
62451
- /* @__PURE__ */ jsx(TiptapComposer, { tools }),
62452
- /* @__PURE__ */ jsx(ComposerAction, {})
62453
- ] })
62878
+ }
62879
+ ),
62880
+ /* @__PURE__ */ 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: [
62881
+ /* @__PURE__ */ jsx(ThreadScrollToBottom, {}),
62882
+ /* @__PURE__ */ 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: [
62883
+ /* @__PURE__ */ jsx(TiptapComposer, { tools }),
62884
+ /* @__PURE__ */ jsx(ComposerAction, {})
62454
62885
  ] })
62455
- ]
62456
- }
62457
- )
62458
- ]
62886
+ ] })
62887
+ ]
62888
+ }
62889
+ )
62459
62890
  }
62460
62891
  );
62461
62892
  };
@@ -62571,53 +63002,6 @@ const UserMessage = () => /* @__PURE__ */ jsx(
62571
63002
  children: /* @__PURE__ */ jsx("div", { className: "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground", children: /* @__PURE__ */ jsx(MessagePrimitiveParts, { components: { Text: TiptapText } }) })
62572
63003
  }
62573
63004
  );
62574
- const ThreadLoadingOverlay = () => /* @__PURE__ */ jsxs(
62575
- "div",
62576
- {
62577
- className: "aui-thread-loading-overlay",
62578
- style: {
62579
- position: "absolute",
62580
- inset: 0,
62581
- zIndex: 50,
62582
- display: "flex",
62583
- flexDirection: "column",
62584
- alignItems: "center",
62585
- justifyContent: "center",
62586
- gap: 12,
62587
- background: "color-mix(in srgb, var(--background, #fff) 80%, transparent)",
62588
- backdropFilter: "blur(4px)",
62589
- WebkitBackdropFilter: "blur(4px)",
62590
- animation: "aui-overlay-in 0.2s ease-out"
62591
- },
62592
- children: [
62593
- /* @__PURE__ */ jsx(
62594
- "div",
62595
- {
62596
- style: {
62597
- width: 28,
62598
- height: 28,
62599
- border: "2.5px solid var(--border, #e5e5e5)",
62600
- borderTopColor: "var(--primary, #2563eb)",
62601
- borderRadius: "50%",
62602
- animation: "aui-spin 0.7s linear infinite"
62603
- }
62604
- }
62605
- ),
62606
- /* @__PURE__ */ jsx(
62607
- "span",
62608
- {
62609
- style: {
62610
- fontSize: 13,
62611
- fontWeight: 500,
62612
- color: "var(--muted-foreground, #888)"
62613
- },
62614
- children: "Loading conversation…"
62615
- }
62616
- ),
62617
- /* @__PURE__ */ jsx("style", { children: `@keyframes aui-spin { to { transform: rotate(360deg); } } @keyframes aui-overlay-in { from { opacity: 0; } to { opacity: 1; } }` })
62618
- ]
62619
- }
62620
- );
62621
63005
  const embedCache = /* @__PURE__ */ new Map();
62622
63006
  function useAssetEmbed(assetId, options = {
62623
63007
  backendUrl: ""
@@ -62688,6 +63072,7 @@ const ASSET_TYPE_CONFIG = {
62688
63072
  presentation: { icon: Presentation, label: "Presentation" },
62689
63073
  spreadsheet: { icon: FileSpreadsheet, label: "Spreadsheet" },
62690
63074
  document: { icon: FileText, label: "Document" },
63075
+ notebook: { icon: BookOpen, label: "Notebook" },
62691
63076
  unknown: { icon: File$1, label: "Asset" }
62692
63077
  };
62693
63078
  const AssetIframe = memo(
@@ -62924,66 +63309,29 @@ const AthenaLayout = ({
62924
63309
  /* @__PURE__ */ jsx("div", { className: "flex h-full flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx(AssetPanel, {}) })
62925
63310
  ] });
62926
63311
  };
62927
- function useThreadList() {
62928
- const store = useThreadListStore();
62929
- return useStore$1(store);
62930
- }
62931
- function useActiveThreadId() {
62932
- const store = useThreadListStore();
62933
- return useStore$1(store, (s) => s.activeThreadId);
62934
- }
62935
63312
  function ThreadList({ className }) {
62936
- const {
62937
- threads,
62938
- activeThreadId,
62939
- isLoading,
62940
- fetchThreads,
62941
- switchThread,
62942
- newThread,
62943
- archiveThread: archiveThread2
62944
- } = useThreadList();
62945
- useEffect(() => {
62946
- fetchThreads();
62947
- }, [fetchThreads]);
62948
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1", className), children: [
62949
- /* @__PURE__ */ jsxs(
62950
- "button",
63313
+ return /* @__PURE__ */ jsxs(ThreadListPrimitiveRoot, { className: cn("flex flex-col gap-1", className), children: [
63314
+ /* @__PURE__ */ 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: [
63315
+ /* @__PURE__ */ jsx(Plus, { className: "size-4" }),
63316
+ "New Chat"
63317
+ ] }),
63318
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsx(
63319
+ ThreadListPrimitiveItems,
62951
63320
  {
62952
- onClick: () => newThread(),
62953
- 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",
62954
- children: [
62955
- /* @__PURE__ */ jsx(Plus, { className: "size-4" }),
62956
- "New Chat"
62957
- ]
63321
+ components: {
63322
+ ThreadListItem
63323
+ }
62958
63324
  }
62959
- ),
62960
- isLoading && threads.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-4 text-muted-foreground", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }) }) : threads.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-2 py-4 text-center text-xs text-muted-foreground/60", children: "No conversations yet" }) : /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: threads.map((thread) => /* @__PURE__ */ jsxs(
62961
- "div",
62962
- {
62963
- className: cn(
62964
- "group flex items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors cursor-pointer",
62965
- activeThreadId === thread.thread_id ? "bg-muted/50 text-foreground" : "text-muted-foreground hover:bg-muted/30 hover:text-foreground"
62966
- ),
62967
- onClick: () => switchThread(thread.thread_id),
62968
- children: [
62969
- /* @__PURE__ */ jsx(MessageSquare, { className: "size-3.5 shrink-0" }),
62970
- /* @__PURE__ */ jsx("span", { className: "flex-1 truncate", children: thread.title || "Untitled" }),
62971
- /* @__PURE__ */ jsx(
62972
- "button",
62973
- {
62974
- onClick: (e) => {
62975
- e.stopPropagation();
62976
- archiveThread2(thread.thread_id);
62977
- },
62978
- className: "hidden size-5 items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-muted hover:text-foreground group-hover:flex",
62979
- title: "Archive",
62980
- children: /* @__PURE__ */ jsx(Archive, { className: "size-3" })
62981
- }
62982
- )
62983
- ]
62984
- },
62985
- thread.thread_id
62986
- )) })
63325
+ ) })
63326
+ ] });
63327
+ }
63328
+ function ThreadListItem() {
63329
+ return /* @__PURE__ */ jsxs(ThreadListItemPrimitiveRoot, { className: "group", children: [
63330
+ /* @__PURE__ */ 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: [
63331
+ /* @__PURE__ */ jsx(MessageSquare, { className: "size-3.5 shrink-0" }),
63332
+ /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-left", children: /* @__PURE__ */ jsx(ThreadListItemPrimitiveTitle, { fallback: "Untitled" }) })
63333
+ ] }),
63334
+ /* @__PURE__ */ 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__ */ jsx(Archive, { className: "size-3" }) })
62987
63335
  ] });
62988
63336
  }
62989
63337
  function useAppendToComposer() {
@@ -63102,11 +63450,14 @@ export {
63102
63450
  CollapsibleTrigger,
63103
63451
  CreateDocumentToolUI,
63104
63452
  CreateEmailDraftToolUI,
63453
+ CreateNotebookToolUI,
63105
63454
  CreatePresentationToolUI,
63106
63455
  CreateSheetToolUI,
63107
63456
  DEFAULT_BACKEND_URL,
63108
63457
  EmailSearchToolUI,
63458
+ OpenAssetToolUI,
63109
63459
  ReadAssetToolUI,
63460
+ RunPythonCodeToolUI,
63110
63461
  TOOL_UI_REGISTRY,
63111
63462
  ThreadList,
63112
63463
  TiptapComposer,
@@ -63128,13 +63479,12 @@ export {
63128
63479
  buttonVariants,
63129
63480
  clearAutoOpenedAssets,
63130
63481
  cn,
63131
- createThreadListStore,
63482
+ createAssetToolUI,
63132
63483
  getAssetInfo,
63133
63484
  resetAssetAutoOpen,
63134
63485
  themeToStyleVars,
63135
63486
  themes,
63136
63487
  tryParseJson$1 as tryParseJson,
63137
- useActiveThreadId,
63138
63488
  useAppendToComposer,
63139
63489
  useAssetEmbed,
63140
63490
  useAssetPanelStore,
@@ -63142,8 +63492,6 @@ export {
63142
63492
  useAthenaRuntime,
63143
63493
  useComposerAttachment,
63144
63494
  useMentionSuggestions,
63145
- useParentAuth,
63146
- useThreadList,
63147
- useThreadLoading
63495
+ useParentAuth
63148
63496
  };
63149
63497
  //# sourceMappingURL=index.js.map