@athenaintel/react 0.3.0 → 0.4.0

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