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