@athenaintel/react 0.3.0 → 0.4.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
@@ -16417,16 +16417,45 @@ function useParentAuth() {
16417
16417
  const [authToken, setAuthToken] = useState(null);
16418
16418
  const readySignalSent = useRef(false);
16419
16419
  useEffect(() => {
16420
+ const isInIframe = window.parent !== window;
16421
+ if (process.env.NODE_ENV !== "production") {
16422
+ console.log("[AthenaAuth] useParentAuth mounted", {
16423
+ isInIframe,
16424
+ currentOrigin: window.location.origin,
16425
+ currentUrl: window.location.href
16426
+ });
16427
+ }
16420
16428
  const handler = (event) => {
16421
- if (!isTrustedOrigin(event.origin)) return;
16429
+ var _a2;
16430
+ if (process.env.NODE_ENV !== "production") {
16431
+ console.log("[AthenaAuth] Received PostMessage", {
16432
+ type: (_a2 = event.data) == null ? void 0 : _a2.type,
16433
+ origin: event.origin,
16434
+ isTrusted: isTrustedOrigin(event.origin)
16435
+ });
16436
+ }
16437
+ if (!isTrustedOrigin(event.origin)) {
16438
+ if (process.env.NODE_ENV !== "production") {
16439
+ console.warn("[AthenaAuth] Rejected PostMessage — untrusted origin:", event.origin);
16440
+ }
16441
+ return;
16442
+ }
16422
16443
  if (event.data && typeof event.data === "object" && event.data.type === "athena-auth" && typeof event.data.token === "string") {
16444
+ if (process.env.NODE_ENV !== "production") {
16445
+ console.log("[AthenaAuth] PropelAuth token received via PostMessage, length:", event.data.token.length);
16446
+ }
16423
16447
  setAuthToken(event.data.token);
16424
16448
  }
16425
16449
  };
16426
16450
  window.addEventListener("message", handler);
16427
- if (!readySignalSent.current && window.parent !== window) {
16451
+ if (!readySignalSent.current && isInIframe) {
16452
+ if (process.env.NODE_ENV !== "production") {
16453
+ console.log("[AthenaAuth] Sending athena-auth-ready signal to parent");
16454
+ }
16428
16455
  window.parent.postMessage({ type: "athena-auth-ready" }, "*");
16429
16456
  readySignalSent.current = true;
16457
+ } else if (!isInIframe && process.env.NODE_ENV !== "production") {
16458
+ console.log("[AthenaAuth] Not in iframe — skipping parent auth (standalone mode)");
16430
16459
  }
16431
16460
  return () => window.removeEventListener("message", handler);
16432
16461
  }, []);
@@ -20750,12 +20779,24 @@ const useAthenaRuntime = (config2) => {
20750
20779
  initialState: { messages: [] },
20751
20780
  converter,
20752
20781
  api: apiUrl,
20753
- headers: async () => ({
20754
- // Prefer parent-injected PropelAuth token over hardcoded API key
20755
- ...tokenRef.current ? { Authorization: `Bearer ${tokenRef.current}` } : apiKeyRef.current ? { "X-API-KEY": apiKeyRef.current } : {},
20756
- "Accept-Encoding": "identity",
20757
- Accept: "text/event-stream"
20758
- }),
20782
+ headers: async () => {
20783
+ const authHeaders = tokenRef.current ? { Authorization: `Bearer ${tokenRef.current}` } : apiKeyRef.current ? { "X-API-KEY": apiKeyRef.current } : {};
20784
+ if (process.env.NODE_ENV !== "production") {
20785
+ console.log("[AthenaAuth] Request headers", {
20786
+ authMethod: tokenRef.current ? "Bearer token" : apiKeyRef.current ? "X-API-KEY" : "NONE",
20787
+ hasToken: !!tokenRef.current,
20788
+ tokenPrefix: tokenRef.current ? tokenRef.current.substring(0, 20) + "..." : void 0,
20789
+ apiKeyPrefix: apiKeyRef.current ? apiKeyRef.current.substring(0, 10) + "..." : void 0,
20790
+ apiUrl
20791
+ });
20792
+ }
20793
+ return {
20794
+ // Prefer parent-injected PropelAuth token over hardcoded API key
20795
+ ...authHeaders,
20796
+ "Accept-Encoding": "identity",
20797
+ Accept: "text/event-stream"
20798
+ };
20799
+ },
20759
20800
  onResponse: () => {
20760
20801
  if (process.env.NODE_ENV !== "production") {
20761
20802
  console.log("[AthenaSDK] Stream connected");
@@ -24088,49 +24129,200 @@ function useAthenaConfig() {
24088
24129
  }
24089
24130
  return ctx;
24090
24131
  }
24091
- function AthenaProvider({
24132
+ const ThreadListContext = createContext(null);
24133
+ function useThreadListStore() {
24134
+ const store = useContext(ThreadListContext);
24135
+ if (!store) {
24136
+ throw new Error(
24137
+ "[AthenaSDK] useThreadList must be used within an <AthenaProvider> that has thread management enabled."
24138
+ );
24139
+ }
24140
+ return store;
24141
+ }
24142
+ function getAuthHeaders(auth) {
24143
+ if (auth.token) {
24144
+ return { Authorization: `Bearer ${auth.token}` };
24145
+ }
24146
+ if (auth.apiKey) {
24147
+ return { "X-API-KEY": auth.apiKey };
24148
+ }
24149
+ return {};
24150
+ }
24151
+ function getAgoraBaseUrl(backendUrl) {
24152
+ return backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
24153
+ }
24154
+ async function listThreads(backendUrl, auth, opts = {}) {
24155
+ const base2 = getAgoraBaseUrl(backendUrl);
24156
+ const res = await fetch(`${base2}/api/conversations/threads/list`, {
24157
+ method: "POST",
24158
+ headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
24159
+ body: JSON.stringify({ limit: opts.limit ?? 50, offset: opts.offset ?? 0 })
24160
+ });
24161
+ if (!res.ok) {
24162
+ throw new Error(`[AthenaSDK] Failed to list threads: ${res.status}`);
24163
+ }
24164
+ return res.json();
24165
+ }
24166
+ async function archiveThread(backendUrl, auth, threadId) {
24167
+ const base2 = getAgoraBaseUrl(backendUrl);
24168
+ const res = await fetch(`${base2}/api/conversations/threads/archive`, {
24169
+ method: "POST",
24170
+ headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
24171
+ body: JSON.stringify({ thread_id: threadId })
24172
+ });
24173
+ if (!res.ok) {
24174
+ throw new Error(`[AthenaSDK] Failed to archive thread: ${res.status}`);
24175
+ }
24176
+ }
24177
+ function createThreadListStore(config2) {
24178
+ const auth = { apiKey: config2.apiKey, token: config2.token };
24179
+ return create((set2, get2) => ({
24180
+ threads: [],
24181
+ activeThreadId: null,
24182
+ isLoading: false,
24183
+ error: null,
24184
+ fetchThreads: async () => {
24185
+ set2({ isLoading: true, error: null });
24186
+ try {
24187
+ const { threads } = await listThreads(config2.backendUrl, auth);
24188
+ const sorted = [...threads].sort(
24189
+ (a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime()
24190
+ );
24191
+ set2({ threads: sorted, isLoading: false });
24192
+ } catch (e) {
24193
+ set2({ error: e.message, isLoading: false });
24194
+ }
24195
+ },
24196
+ switchThread: (threadId) => {
24197
+ set2({ activeThreadId: threadId });
24198
+ },
24199
+ newThread: async () => {
24200
+ const localThreadId = `thread_${crypto.randomUUID()}`;
24201
+ set2({ activeThreadId: localThreadId });
24202
+ return localThreadId;
24203
+ },
24204
+ archiveThread: async (threadId) => {
24205
+ var _a2;
24206
+ try {
24207
+ await archiveThread(config2.backendUrl, auth, threadId);
24208
+ const { threads, activeThreadId } = get2();
24209
+ const remaining = threads.filter((t) => t.thread_id !== threadId);
24210
+ set2({
24211
+ threads: remaining,
24212
+ activeThreadId: activeThreadId === threadId ? ((_a2 = remaining[0]) == null ? void 0 : _a2.thread_id) ?? null : activeThreadId
24213
+ });
24214
+ } catch (e) {
24215
+ set2({ error: e.message });
24216
+ }
24217
+ }
24218
+ }));
24219
+ }
24220
+ function AthenaRuntimeInner({
24092
24221
  children,
24093
- apiKey,
24094
- token: tokenProp,
24095
- agent: agent2,
24096
- model,
24097
- tools = [],
24098
- frontendTools = {},
24099
24222
  apiUrl,
24100
24223
  backendUrl,
24224
+ apiKey,
24225
+ token,
24226
+ model,
24227
+ agent: agent2,
24228
+ tools,
24229
+ frontendToolIds,
24230
+ frontendTools,
24101
24231
  workbench,
24102
24232
  knowledgeBase,
24103
24233
  systemPrompt,
24104
24234
  threadId
24105
24235
  }) {
24106
- const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
24107
24236
  const auiTools = useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
24108
- const aui = useAui({
24109
- tools: auiTools
24110
- });
24111
- const parentAuthToken = useParentAuth();
24112
- const effectiveToken = tokenProp ?? parentAuthToken;
24113
- const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
24237
+ const aui = useAui({ tools: auiTools });
24114
24238
  const runtime = useAthenaRuntime({
24115
24239
  apiUrl,
24116
- backendUrl: effectiveBackendUrl,
24240
+ backendUrl,
24117
24241
  apiKey,
24118
- token: effectiveToken,
24242
+ token,
24119
24243
  model,
24120
24244
  agent: agent2,
24121
24245
  tools,
24122
- frontendToolIds: frontendToolNames,
24246
+ frontendToolIds,
24123
24247
  workbench,
24124
24248
  knowledgeBase,
24125
24249
  systemPrompt,
24126
24250
  threadId
24127
24251
  });
24128
24252
  const athenaConfig = useMemo(
24129
- () => ({ backendUrl: effectiveBackendUrl, apiKey, token: effectiveToken }),
24130
- [effectiveBackendUrl, apiKey, effectiveToken]
24253
+ () => ({ backendUrl, apiKey, token }),
24254
+ [backendUrl, apiKey, token]
24131
24255
  );
24132
24256
  return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
24133
24257
  }
24258
+ function useActiveThreadFromStore(store) {
24259
+ return useSyncExternalStore(
24260
+ (cb) => {
24261
+ if (!store) return () => {
24262
+ };
24263
+ return store.subscribe(cb);
24264
+ },
24265
+ () => (store == null ? void 0 : store.getState().activeThreadId) ?? null,
24266
+ () => null
24267
+ );
24268
+ }
24269
+ function AthenaProvider({
24270
+ children,
24271
+ apiKey,
24272
+ token: tokenProp,
24273
+ agent: agent2,
24274
+ model,
24275
+ tools = [],
24276
+ frontendTools = {},
24277
+ apiUrl,
24278
+ backendUrl,
24279
+ workbench,
24280
+ knowledgeBase,
24281
+ systemPrompt,
24282
+ threadId: threadIdProp,
24283
+ enableThreadList = false
24284
+ }) {
24285
+ const frontendToolNames = useMemo(() => Object.keys(frontendTools), [frontendTools]);
24286
+ const parentAuthToken = useParentAuth();
24287
+ const effectiveToken = tokenProp ?? parentAuthToken;
24288
+ const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
24289
+ const threadListStoreRef = useRef(null);
24290
+ if (enableThreadList && !threadListStoreRef.current) {
24291
+ threadListStoreRef.current = createThreadListStore({
24292
+ backendUrl: effectiveBackendUrl,
24293
+ apiKey,
24294
+ token: effectiveToken
24295
+ });
24296
+ }
24297
+ const activeThreadId = useActiveThreadFromStore(
24298
+ enableThreadList ? threadListStoreRef.current : null
24299
+ );
24300
+ const resolvedThreadId = threadIdProp ?? activeThreadId ?? void 0;
24301
+ const inner = /* @__PURE__ */ jsx(
24302
+ AthenaRuntimeInner,
24303
+ {
24304
+ apiUrl,
24305
+ backendUrl: effectiveBackendUrl,
24306
+ apiKey,
24307
+ token: effectiveToken,
24308
+ model,
24309
+ agent: agent2,
24310
+ tools,
24311
+ frontendToolIds: frontendToolNames,
24312
+ frontendTools,
24313
+ workbench,
24314
+ knowledgeBase,
24315
+ systemPrompt,
24316
+ threadId: resolvedThreadId,
24317
+ children
24318
+ },
24319
+ resolvedThreadId ?? "__new__"
24320
+ );
24321
+ if (enableThreadList && threadListStoreRef.current) {
24322
+ return /* @__PURE__ */ jsx(ThreadListContext.Provider, { value: threadListStoreRef.current, children: inner });
24323
+ }
24324
+ return inner;
24325
+ }
24134
24326
  function OrderedMap(content) {
24135
24327
  this.content = content;
24136
24328
  }
@@ -60062,29 +60254,41 @@ const createLucideIcon = (iconName, iconNode) => {
60062
60254
  * This source code is licensed under the ISC license.
60063
60255
  * See the LICENSE file in the root directory of this source tree.
60064
60256
  */
60065
- const __iconNode$B = [
60257
+ const __iconNode$E = [
60258
+ ["rect", { width: "20", height: "5", x: "2", y: "3", rx: "1", key: "1wp1u1" }],
60259
+ ["path", { d: "M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8", key: "1s80jp" }],
60260
+ ["path", { d: "M10 12h4", key: "a56b0p" }]
60261
+ ];
60262
+ const Archive = createLucideIcon("archive", __iconNode$E);
60263
+ /**
60264
+ * @license lucide-react v0.575.0 - ISC
60265
+ *
60266
+ * This source code is licensed under the ISC license.
60267
+ * See the LICENSE file in the root directory of this source tree.
60268
+ */
60269
+ const __iconNode$D = [
60066
60270
  ["path", { d: "M12 5v14", key: "s699le" }],
60067
60271
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
60068
60272
  ];
60069
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$B);
60273
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$D);
60070
60274
  /**
60071
60275
  * @license lucide-react v0.575.0 - ISC
60072
60276
  *
60073
60277
  * This source code is licensed under the ISC license.
60074
60278
  * See the LICENSE file in the root directory of this source tree.
60075
60279
  */
60076
- const __iconNode$A = [
60280
+ const __iconNode$C = [
60077
60281
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
60078
60282
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
60079
60283
  ];
60080
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$A);
60284
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$C);
60081
60285
  /**
60082
60286
  * @license lucide-react v0.575.0 - ISC
60083
60287
  *
60084
60288
  * This source code is licensed under the ISC license.
60085
60289
  * See the LICENSE file in the root directory of this source tree.
60086
60290
  */
60087
- const __iconNode$z = [
60291
+ const __iconNode$B = [
60088
60292
  ["path", { d: "M12 7v14", key: "1akyts" }],
60089
60293
  [
60090
60294
  "path",
@@ -60094,14 +60298,14 @@ const __iconNode$z = [
60094
60298
  }
60095
60299
  ]
60096
60300
  ];
60097
- const BookOpen = createLucideIcon("book-open", __iconNode$z);
60301
+ const BookOpen = createLucideIcon("book-open", __iconNode$B);
60098
60302
  /**
60099
60303
  * @license lucide-react v0.575.0 - ISC
60100
60304
  *
60101
60305
  * This source code is licensed under the ISC license.
60102
60306
  * See the LICENSE file in the root directory of this source tree.
60103
60307
  */
60104
- const __iconNode$y = [
60308
+ const __iconNode$A = [
60105
60309
  ["path", { d: "M12 18V5", key: "adv99a" }],
60106
60310
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
60107
60311
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -60111,148 +60315,148 @@ const __iconNode$y = [
60111
60315
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
60112
60316
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
60113
60317
  ];
60114
- const Brain = createLucideIcon("brain", __iconNode$y);
60318
+ const Brain = createLucideIcon("brain", __iconNode$A);
60115
60319
  /**
60116
60320
  * @license lucide-react v0.575.0 - ISC
60117
60321
  *
60118
60322
  * This source code is licensed under the ISC license.
60119
60323
  * See the LICENSE file in the root directory of this source tree.
60120
60324
  */
60121
- const __iconNode$x = [
60325
+ const __iconNode$z = [
60122
60326
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
60123
60327
  ["path", { d: "M18 17V9", key: "2bz60n" }],
60124
60328
  ["path", { d: "M13 17V5", key: "1frdt8" }],
60125
60329
  ["path", { d: "M8 17v-3", key: "17ska0" }]
60126
60330
  ];
60127
- const ChartColumn = createLucideIcon("chart-column", __iconNode$x);
60331
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$z);
60128
60332
  /**
60129
60333
  * @license lucide-react v0.575.0 - ISC
60130
60334
  *
60131
60335
  * This source code is licensed under the ISC license.
60132
60336
  * See the LICENSE file in the root directory of this source tree.
60133
60337
  */
60134
- const __iconNode$w = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60135
- const Check = createLucideIcon("check", __iconNode$w);
60338
+ const __iconNode$y = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60339
+ const Check = createLucideIcon("check", __iconNode$y);
60136
60340
  /**
60137
60341
  * @license lucide-react v0.575.0 - ISC
60138
60342
  *
60139
60343
  * This source code is licensed under the ISC license.
60140
60344
  * See the LICENSE file in the root directory of this source tree.
60141
60345
  */
60142
- const __iconNode$v = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60143
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$v);
60346
+ const __iconNode$x = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60347
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$x);
60144
60348
  /**
60145
60349
  * @license lucide-react v0.575.0 - ISC
60146
60350
  *
60147
60351
  * This source code is licensed under the ISC license.
60148
60352
  * See the LICENSE file in the root directory of this source tree.
60149
60353
  */
60150
- const __iconNode$u = [
60354
+ const __iconNode$w = [
60151
60355
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60152
60356
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
60153
60357
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
60154
60358
  ];
60155
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$u);
60359
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$w);
60156
60360
  /**
60157
60361
  * @license lucide-react v0.575.0 - ISC
60158
60362
  *
60159
60363
  * This source code is licensed under the ISC license.
60160
60364
  * See the LICENSE file in the root directory of this source tree.
60161
60365
  */
60162
- const __iconNode$t = [
60366
+ const __iconNode$v = [
60163
60367
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60164
60368
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
60165
60369
  ];
60166
- const CircleCheck = createLucideIcon("circle-check", __iconNode$t);
60370
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$v);
60167
60371
  /**
60168
60372
  * @license lucide-react v0.575.0 - ISC
60169
60373
  *
60170
60374
  * This source code is licensed under the ISC license.
60171
60375
  * See the LICENSE file in the root directory of this source tree.
60172
60376
  */
60173
- const __iconNode$s = [
60377
+ const __iconNode$u = [
60174
60378
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60175
60379
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
60176
60380
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
60177
60381
  ];
60178
- const CircleX = createLucideIcon("circle-x", __iconNode$s);
60382
+ const CircleX = createLucideIcon("circle-x", __iconNode$u);
60179
60383
  /**
60180
60384
  * @license lucide-react v0.575.0 - ISC
60181
60385
  *
60182
60386
  * This source code is licensed under the ISC license.
60183
60387
  * See the LICENSE file in the root directory of this source tree.
60184
60388
  */
60185
- const __iconNode$r = [
60389
+ const __iconNode$t = [
60186
60390
  ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
60187
60391
  ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
60188
60392
  ];
60189
- const Code = createLucideIcon("code", __iconNode$r);
60393
+ const Code = createLucideIcon("code", __iconNode$t);
60190
60394
  /**
60191
60395
  * @license lucide-react v0.575.0 - ISC
60192
60396
  *
60193
60397
  * This source code is licensed under the ISC license.
60194
60398
  * See the LICENSE file in the root directory of this source tree.
60195
60399
  */
60196
- const __iconNode$q = [
60400
+ const __iconNode$s = [
60197
60401
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
60198
60402
  ["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" }]
60199
60403
  ];
60200
- const Copy = createLucideIcon("copy", __iconNode$q);
60404
+ const Copy = createLucideIcon("copy", __iconNode$s);
60201
60405
  /**
60202
60406
  * @license lucide-react v0.575.0 - ISC
60203
60407
  *
60204
60408
  * This source code is licensed under the ISC license.
60205
60409
  * See the LICENSE file in the root directory of this source tree.
60206
60410
  */
60207
- const __iconNode$p = [
60411
+ const __iconNode$r = [
60208
60412
  ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
60209
60413
  ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
60210
60414
  ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
60211
60415
  ];
60212
- const Database = createLucideIcon("database", __iconNode$p);
60416
+ const Database = createLucideIcon("database", __iconNode$r);
60213
60417
  /**
60214
60418
  * @license lucide-react v0.575.0 - ISC
60215
60419
  *
60216
60420
  * This source code is licensed under the ISC license.
60217
60421
  * See the LICENSE file in the root directory of this source tree.
60218
60422
  */
60219
- const __iconNode$o = [
60423
+ const __iconNode$q = [
60220
60424
  ["path", { d: "M12 15V3", key: "m9g1x1" }],
60221
60425
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
60222
60426
  ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
60223
60427
  ];
60224
- const Download = createLucideIcon("download", __iconNode$o);
60428
+ const Download = createLucideIcon("download", __iconNode$q);
60225
60429
  /**
60226
60430
  * @license lucide-react v0.575.0 - ISC
60227
60431
  *
60228
60432
  * This source code is licensed under the ISC license.
60229
60433
  * See the LICENSE file in the root directory of this source tree.
60230
60434
  */
60231
- const __iconNode$n = [
60435
+ const __iconNode$p = [
60232
60436
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
60233
60437
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
60234
60438
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
60235
60439
  ];
60236
- const Ellipsis = createLucideIcon("ellipsis", __iconNode$n);
60440
+ const Ellipsis = createLucideIcon("ellipsis", __iconNode$p);
60237
60441
  /**
60238
60442
  * @license lucide-react v0.575.0 - ISC
60239
60443
  *
60240
60444
  * This source code is licensed under the ISC license.
60241
60445
  * See the LICENSE file in the root directory of this source tree.
60242
60446
  */
60243
- const __iconNode$m = [
60447
+ const __iconNode$o = [
60244
60448
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60245
60449
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
60246
60450
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
60247
60451
  ];
60248
- const ExternalLink = createLucideIcon("external-link", __iconNode$m);
60452
+ const ExternalLink = createLucideIcon("external-link", __iconNode$o);
60249
60453
  /**
60250
60454
  * @license lucide-react v0.575.0 - ISC
60251
60455
  *
60252
60456
  * This source code is licensed under the ISC license.
60253
60457
  * See the LICENSE file in the root directory of this source tree.
60254
60458
  */
60255
- const __iconNode$l = [
60459
+ const __iconNode$n = [
60256
60460
  [
60257
60461
  "path",
60258
60462
  {
@@ -60264,14 +60468,14 @@ const __iconNode$l = [
60264
60468
  ["path", { d: "M9 15h6", key: "cctwl0" }],
60265
60469
  ["path", { d: "M12 18v-6", key: "17g6i2" }]
60266
60470
  ];
60267
- const FilePlus = createLucideIcon("file-plus", __iconNode$l);
60471
+ const FilePlus = createLucideIcon("file-plus", __iconNode$n);
60268
60472
  /**
60269
60473
  * @license lucide-react v0.575.0 - ISC
60270
60474
  *
60271
60475
  * This source code is licensed under the ISC license.
60272
60476
  * See the LICENSE file in the root directory of this source tree.
60273
60477
  */
60274
- const __iconNode$k = [
60478
+ const __iconNode$m = [
60275
60479
  [
60276
60480
  "path",
60277
60481
  {
@@ -60285,14 +60489,14 @@ const __iconNode$k = [
60285
60489
  ["path", { d: "M8 17h2", key: "2yhykz" }],
60286
60490
  ["path", { d: "M14 17h2", key: "10kma7" }]
60287
60491
  ];
60288
- const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$k);
60492
+ const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode$m);
60289
60493
  /**
60290
60494
  * @license lucide-react v0.575.0 - ISC
60291
60495
  *
60292
60496
  * This source code is licensed under the ISC license.
60293
60497
  * See the LICENSE file in the root directory of this source tree.
60294
60498
  */
60295
- const __iconNode$j = [
60499
+ const __iconNode$l = [
60296
60500
  [
60297
60501
  "path",
60298
60502
  {
@@ -60305,14 +60509,14 @@ const __iconNode$j = [
60305
60509
  ["path", { d: "M16 13H8", key: "t4e002" }],
60306
60510
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
60307
60511
  ];
60308
- const FileText = createLucideIcon("file-text", __iconNode$j);
60512
+ const FileText = createLucideIcon("file-text", __iconNode$l);
60309
60513
  /**
60310
60514
  * @license lucide-react v0.575.0 - ISC
60311
60515
  *
60312
60516
  * This source code is licensed under the ISC license.
60313
60517
  * See the LICENSE file in the root directory of this source tree.
60314
60518
  */
60315
- const __iconNode$i = [
60519
+ const __iconNode$k = [
60316
60520
  [
60317
60521
  "path",
60318
60522
  {
@@ -60322,26 +60526,26 @@ const __iconNode$i = [
60322
60526
  ],
60323
60527
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
60324
60528
  ];
60325
- const File$1 = createLucideIcon("file", __iconNode$i);
60529
+ const File$1 = createLucideIcon("file", __iconNode$k);
60326
60530
  /**
60327
60531
  * @license lucide-react v0.575.0 - ISC
60328
60532
  *
60329
60533
  * This source code is licensed under the ISC license.
60330
60534
  * See the LICENSE file in the root directory of this source tree.
60331
60535
  */
60332
- const __iconNode$h = [
60536
+ const __iconNode$j = [
60333
60537
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60334
60538
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
60335
60539
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
60336
60540
  ];
60337
- const Globe = createLucideIcon("globe", __iconNode$h);
60541
+ const Globe = createLucideIcon("globe", __iconNode$j);
60338
60542
  /**
60339
60543
  * @license lucide-react v0.575.0 - ISC
60340
60544
  *
60341
60545
  * This source code is licensed under the ISC license.
60342
60546
  * See the LICENSE file in the root directory of this source tree.
60343
60547
  */
60344
- const __iconNode$g = [
60548
+ const __iconNode$i = [
60345
60549
  [
60346
60550
  "path",
60347
60551
  {
@@ -60364,35 +60568,35 @@ const __iconNode$g = [
60364
60568
  }
60365
60569
  ]
60366
60570
  ];
60367
- const Layers = createLucideIcon("layers", __iconNode$g);
60571
+ const Layers = createLucideIcon("layers", __iconNode$i);
60368
60572
  /**
60369
60573
  * @license lucide-react v0.575.0 - ISC
60370
60574
  *
60371
60575
  * This source code is licensed under the ISC license.
60372
60576
  * See the LICENSE file in the root directory of this source tree.
60373
60577
  */
60374
- const __iconNode$f = [
60578
+ const __iconNode$h = [
60375
60579
  ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
60376
60580
  ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
60377
60581
  ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
60378
60582
  ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
60379
60583
  ];
60380
- const LayoutGrid = createLucideIcon("layout-grid", __iconNode$f);
60584
+ const LayoutGrid = createLucideIcon("layout-grid", __iconNode$h);
60381
60585
  /**
60382
60586
  * @license lucide-react v0.575.0 - ISC
60383
60587
  *
60384
60588
  * This source code is licensed under the ISC license.
60385
60589
  * See the LICENSE file in the root directory of this source tree.
60386
60590
  */
60387
- const __iconNode$e = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60388
- const LoaderCircle = createLucideIcon("loader-circle", __iconNode$e);
60591
+ const __iconNode$g = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
60592
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$g);
60389
60593
  /**
60390
60594
  * @license lucide-react v0.575.0 - ISC
60391
60595
  *
60392
60596
  * This source code is licensed under the ISC license.
60393
60597
  * See the LICENSE file in the root directory of this source tree.
60394
60598
  */
60395
- const __iconNode$d = [
60599
+ const __iconNode$f = [
60396
60600
  ["path", { d: "M12 2v4", key: "3427ic" }],
60397
60601
  ["path", { d: "m16.2 7.8 2.9-2.9", key: "r700ao" }],
60398
60602
  ["path", { d: "M18 12h4", key: "wj9ykh" }],
@@ -60402,63 +60606,79 @@ const __iconNode$d = [
60402
60606
  ["path", { d: "M2 12h4", key: "j09sii" }],
60403
60607
  ["path", { d: "m4.9 4.9 2.9 2.9", key: "giyufr" }]
60404
60608
  ];
60405
- const Loader = createLucideIcon("loader", __iconNode$d);
60609
+ const Loader = createLucideIcon("loader", __iconNode$f);
60406
60610
  /**
60407
60611
  * @license lucide-react v0.575.0 - ISC
60408
60612
  *
60409
60613
  * This source code is licensed under the ISC license.
60410
60614
  * See the LICENSE file in the root directory of this source tree.
60411
60615
  */
60412
- const __iconNode$c = [
60616
+ const __iconNode$e = [
60413
60617
  ["path", { d: "m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7", key: "132q7q" }],
60414
60618
  ["rect", { x: "2", y: "4", width: "20", height: "16", rx: "2", key: "izxlao" }]
60415
60619
  ];
60416
- const Mail = createLucideIcon("mail", __iconNode$c);
60620
+ const Mail = createLucideIcon("mail", __iconNode$e);
60417
60621
  /**
60418
60622
  * @license lucide-react v0.575.0 - ISC
60419
60623
  *
60420
60624
  * This source code is licensed under the ISC license.
60421
60625
  * See the LICENSE file in the root directory of this source tree.
60422
60626
  */
60423
- const __iconNode$b = [
60627
+ const __iconNode$d = [
60424
60628
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
60425
60629
  ["path", { d: "m21 3-7 7", key: "1l2asr" }],
60426
60630
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60427
60631
  ["path", { d: "M9 21H3v-6", key: "wtvkvv" }]
60428
60632
  ];
60429
- const Maximize2 = createLucideIcon("maximize-2", __iconNode$b);
60633
+ const Maximize2 = createLucideIcon("maximize-2", __iconNode$d);
60430
60634
  /**
60431
60635
  * @license lucide-react v0.575.0 - ISC
60432
60636
  *
60433
60637
  * This source code is licensed under the ISC license.
60434
60638
  * See the LICENSE file in the root directory of this source tree.
60435
60639
  */
60436
- const __iconNode$a = [
60640
+ const __iconNode$c = [
60641
+ [
60642
+ "path",
60643
+ {
60644
+ d: "M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",
60645
+ key: "18887p"
60646
+ }
60647
+ ]
60648
+ ];
60649
+ const MessageSquare = createLucideIcon("message-square", __iconNode$c);
60650
+ /**
60651
+ * @license lucide-react v0.575.0 - ISC
60652
+ *
60653
+ * This source code is licensed under the ISC license.
60654
+ * See the LICENSE file in the root directory of this source tree.
60655
+ */
60656
+ const __iconNode$b = [
60437
60657
  ["path", { d: "m14 10 7-7", key: "oa77jy" }],
60438
60658
  ["path", { d: "M20 10h-6V4", key: "mjg0md" }],
60439
60659
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
60440
60660
  ["path", { d: "M4 14h6v6", key: "rmj7iw" }]
60441
60661
  ];
60442
- const Minimize2 = createLucideIcon("minimize-2", __iconNode$a);
60662
+ const Minimize2 = createLucideIcon("minimize-2", __iconNode$b);
60443
60663
  /**
60444
60664
  * @license lucide-react v0.575.0 - ISC
60445
60665
  *
60446
60666
  * This source code is licensed under the ISC license.
60447
60667
  * See the LICENSE file in the root directory of this source tree.
60448
60668
  */
60449
- const __iconNode$9 = [
60669
+ const __iconNode$a = [
60450
60670
  ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
60451
60671
  ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
60452
60672
  ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
60453
60673
  ];
60454
- const Monitor = createLucideIcon("monitor", __iconNode$9);
60674
+ const Monitor = createLucideIcon("monitor", __iconNode$a);
60455
60675
  /**
60456
60676
  * @license lucide-react v0.575.0 - ISC
60457
60677
  *
60458
60678
  * This source code is licensed under the ISC license.
60459
60679
  * See the LICENSE file in the root directory of this source tree.
60460
60680
  */
60461
- const __iconNode$8 = [
60681
+ const __iconNode$9 = [
60462
60682
  ["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" }],
60463
60683
  ["path", { d: "M2 6h4", key: "aawbzj" }],
60464
60684
  ["path", { d: "M2 10h4", key: "l0bgd4" }],
@@ -60472,14 +60692,14 @@ const __iconNode$8 = [
60472
60692
  }
60473
60693
  ]
60474
60694
  ];
60475
- const NotebookPen = createLucideIcon("notebook-pen", __iconNode$8);
60695
+ const NotebookPen = createLucideIcon("notebook-pen", __iconNode$9);
60476
60696
  /**
60477
60697
  * @license lucide-react v0.575.0 - ISC
60478
60698
  *
60479
60699
  * This source code is licensed under the ISC license.
60480
60700
  * See the LICENSE file in the root directory of this source tree.
60481
60701
  */
60482
- const __iconNode$7 = [
60702
+ const __iconNode$8 = [
60483
60703
  ["path", { d: "M13 21h8", key: "1jsn5i" }],
60484
60704
  [
60485
60705
  "path",
@@ -60489,7 +60709,18 @@ const __iconNode$7 = [
60489
60709
  }
60490
60710
  ]
60491
60711
  ];
60492
- const PenLine = createLucideIcon("pen-line", __iconNode$7);
60712
+ const PenLine = createLucideIcon("pen-line", __iconNode$8);
60713
+ /**
60714
+ * @license lucide-react v0.575.0 - ISC
60715
+ *
60716
+ * This source code is licensed under the ISC license.
60717
+ * See the LICENSE file in the root directory of this source tree.
60718
+ */
60719
+ const __iconNode$7 = [
60720
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
60721
+ ["path", { d: "M12 5v14", key: "s699le" }]
60722
+ ];
60723
+ const Plus = createLucideIcon("plus", __iconNode$7);
60493
60724
  /**
60494
60725
  * @license lucide-react v0.575.0 - ISC
60495
60726
  *
@@ -62438,6 +62669,103 @@ const AthenaLayout = ({
62438
62669
  /* @__PURE__ */ jsx("div", { className: "flex h-full flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx(AssetPanel, {}) })
62439
62670
  ] });
62440
62671
  };
62672
+ function useThreadList() {
62673
+ const store = useThreadListStore();
62674
+ return useStore$1(store);
62675
+ }
62676
+ function useActiveThreadId() {
62677
+ const store = useThreadListStore();
62678
+ return useStore$1(store, (s) => s.activeThreadId);
62679
+ }
62680
+ function ThreadList({ className }) {
62681
+ const {
62682
+ threads,
62683
+ activeThreadId,
62684
+ isLoading,
62685
+ fetchThreads,
62686
+ switchThread,
62687
+ newThread,
62688
+ archiveThread: archiveThread2
62689
+ } = useThreadList();
62690
+ useEffect(() => {
62691
+ fetchThreads();
62692
+ }, [fetchThreads]);
62693
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1", className), children: [
62694
+ /* @__PURE__ */ jsxs(
62695
+ "button",
62696
+ {
62697
+ onClick: () => newThread(),
62698
+ 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",
62699
+ children: [
62700
+ /* @__PURE__ */ jsx(Plus, { className: "size-4" }),
62701
+ "New Chat"
62702
+ ]
62703
+ }
62704
+ ),
62705
+ 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(
62706
+ "div",
62707
+ {
62708
+ className: cn(
62709
+ "group flex items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors cursor-pointer",
62710
+ activeThreadId === thread.thread_id ? "bg-muted/50 text-foreground" : "text-muted-foreground hover:bg-muted/30 hover:text-foreground"
62711
+ ),
62712
+ onClick: () => switchThread(thread.thread_id),
62713
+ children: [
62714
+ /* @__PURE__ */ jsx(MessageSquare, { className: "size-3.5 shrink-0" }),
62715
+ /* @__PURE__ */ jsx("span", { className: "flex-1 truncate", children: thread.title || "Untitled" }),
62716
+ /* @__PURE__ */ jsx(
62717
+ "button",
62718
+ {
62719
+ onClick: (e) => {
62720
+ e.stopPropagation();
62721
+ archiveThread2(thread.thread_id);
62722
+ },
62723
+ className: "hidden size-5 items-center justify-center rounded text-muted-foreground/60 transition-colors hover:bg-muted hover:text-foreground group-hover:flex",
62724
+ title: "Archive",
62725
+ children: /* @__PURE__ */ jsx(Archive, { className: "size-3" })
62726
+ }
62727
+ )
62728
+ ]
62729
+ },
62730
+ thread.thread_id
62731
+ )) })
62732
+ ] });
62733
+ }
62734
+ function useAppendToComposer() {
62735
+ const aui = useAui();
62736
+ return useCallback(
62737
+ (text2, opts) => {
62738
+ const composer = aui.composer();
62739
+ if (opts == null ? void 0 : opts.replace) {
62740
+ composer.setText(text2);
62741
+ } else {
62742
+ const current = composer.getState().text;
62743
+ composer.setText(current ? `${current}
62744
+ ${text2}` : text2);
62745
+ }
62746
+ },
62747
+ [aui]
62748
+ );
62749
+ }
62750
+ function useComposerAttachment() {
62751
+ const aui = useAui();
62752
+ const addFile = useCallback(
62753
+ (file) => {
62754
+ aui.composer().addAttachment(file);
62755
+ },
62756
+ [aui]
62757
+ );
62758
+ const addContent = useCallback(
62759
+ (name, content) => {
62760
+ aui.composer().addAttachment({ name, content });
62761
+ },
62762
+ [aui]
62763
+ );
62764
+ const clear = useCallback(() => {
62765
+ aui.composer().clearAttachments();
62766
+ }, [aui]);
62767
+ return { addFile, addContent, clear };
62768
+ }
62441
62769
  export {
62442
62770
  AppendDocumentToolUI,
62443
62771
  AssetPanel,
@@ -62457,6 +62785,7 @@ export {
62457
62785
  EmailSearchToolUI,
62458
62786
  ReadAssetToolUI,
62459
62787
  TOOL_UI_REGISTRY,
62788
+ ThreadList,
62460
62789
  TiptapComposer,
62461
62790
  TiptapText,
62462
62791
  ToolFallback,
@@ -62475,14 +62804,19 @@ export {
62475
62804
  buttonVariants,
62476
62805
  clearAutoOpenedAssets,
62477
62806
  cn,
62807
+ createThreadListStore,
62478
62808
  getAssetInfo,
62479
62809
  resetAssetAutoOpen,
62480
62810
  tryParseJson$1 as tryParseJson,
62811
+ useActiveThreadId,
62812
+ useAppendToComposer,
62481
62813
  useAssetEmbed,
62482
62814
  useAssetPanelStore,
62483
62815
  useAthenaConfig,
62484
62816
  useAthenaRuntime,
62817
+ useComposerAttachment,
62485
62818
  useMentionSuggestions,
62486
- useParentAuth
62819
+ useParentAuth,
62820
+ useThreadList
62487
62821
  };
62488
62822
  //# sourceMappingURL=index.js.map