@athenaintel/react 0.9.0 → 0.9.2

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.d.ts CHANGED
@@ -907,6 +907,9 @@ export declare function useParentBridge(): ParentBridgeState;
907
907
 
908
908
  export declare function useQuote(): QuoteContextValue;
909
909
 
910
+ /** Trigger a re-fetch of the thread list. No-op outside of thread list mode. */
911
+ export declare function useRefreshThreadList(): (() => void) | null;
912
+
910
913
  export declare type ViewMode = 'tabs' | 'tiled';
911
914
 
912
915
  export declare const WebSearchToolUI: ToolCallMessagePartComponent;
package/dist/index.js CHANGED
@@ -16487,8 +16487,10 @@ function useParentBridge() {
16487
16487
  setState((prev) => ({
16488
16488
  ...prev,
16489
16489
  apiUrl: typeof event.data.apiUrl === "string" ? event.data.apiUrl : prev.apiUrl,
16490
- backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl,
16491
- ready: true
16490
+ backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl
16491
+ // Don't set ready here — wait for athena-auth (token) or the timeout.
16492
+ // Setting ready on config alone causes a race: the thread list fires
16493
+ // before the token arrives, falling back to X-API-KEY.
16492
16494
  }));
16493
16495
  }
16494
16496
  if (event.data.type === "athena-auth" && typeof event.data.token === "string") {
@@ -16506,9 +16508,7 @@ function useParentBridge() {
16506
16508
  readySignalSent.current = true;
16507
16509
  }
16508
16510
  const timer = setTimeout(() => {
16509
- if (!configReceived.current) {
16510
- setState((prev) => ({ ...prev, ready: true }));
16511
- }
16511
+ setState((prev) => prev.ready ? prev : { ...prev, ready: true });
16512
16512
  }, BRIDGE_TIMEOUT_MS);
16513
16513
  return () => {
16514
16514
  window.removeEventListener("message", handler);
@@ -24296,6 +24296,9 @@ function useAthenaThreadListAdapter(config2) {
24296
24296
  );
24297
24297
  return useMemo(() => ({
24298
24298
  async list() {
24299
+ if (!auth.token) {
24300
+ return { threads: [] };
24301
+ }
24299
24302
  try {
24300
24303
  const { threads } = await listThreads(configRef.current.backendUrl, auth);
24301
24304
  return {
@@ -24337,6 +24340,10 @@ function useAthenaThreadListAdapter(config2) {
24337
24340
  unstable_Provider
24338
24341
  }), [auth, unstable_Provider]);
24339
24342
  }
24343
+ const ThreadListRefreshContext = createContext(null);
24344
+ function useRefreshThreadList() {
24345
+ return useContext(ThreadListRefreshContext);
24346
+ }
24340
24347
  const THEME_TO_CSS = {
24341
24348
  primary: "--primary",
24342
24349
  primaryForeground: "--primary-foreground",
@@ -24623,13 +24630,21 @@ function AthenaWithThreadList({
24623
24630
  runtimeHook,
24624
24631
  adapter
24625
24632
  });
24633
+ const handleRefresh = useCallback(() => {
24634
+ var _a2;
24635
+ const core = (_a2 = runtime == null ? void 0 : runtime._core) == null ? void 0 : _a2.threads;
24636
+ if (core) {
24637
+ core._loadThreadsPromise = void 0;
24638
+ core.__internal_load();
24639
+ }
24640
+ }, [runtime]);
24626
24641
  const auiTools = useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
24627
24642
  const aui = useAui({ tools: auiTools });
24628
24643
  const athenaConfig = useMemo(
24629
24644
  () => ({ backendUrl, apiKey, token }),
24630
24645
  [backendUrl, apiKey, token]
24631
24646
  );
24632
- return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) });
24647
+ return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsx(TooltipProvider, { children }) }) }) });
24633
24648
  }
24634
24649
  function AthenaProvider({
24635
24650
  children,
@@ -60793,40 +60808,40 @@ const createLucideIcon = (iconName, iconNode) => {
60793
60808
  * This source code is licensed under the ISC license.
60794
60809
  * See the LICENSE file in the root directory of this source tree.
60795
60810
  */
60796
- const __iconNode$L = [
60811
+ const __iconNode$M = [
60797
60812
  ["path", { d: "M12 5v14", key: "s699le" }],
60798
60813
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
60799
60814
  ];
60800
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$L);
60815
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$M);
60801
60816
  /**
60802
60817
  * @license lucide-react v0.575.0 - ISC
60803
60818
  *
60804
60819
  * This source code is licensed under the ISC license.
60805
60820
  * See the LICENSE file in the root directory of this source tree.
60806
60821
  */
60807
- const __iconNode$K = [
60822
+ const __iconNode$L = [
60808
60823
  ["path", { d: "M5 12h14", key: "1ays0h" }],
60809
60824
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
60810
60825
  ];
60811
- const ArrowRight = createLucideIcon("arrow-right", __iconNode$K);
60826
+ const ArrowRight = createLucideIcon("arrow-right", __iconNode$L);
60812
60827
  /**
60813
60828
  * @license lucide-react v0.575.0 - ISC
60814
60829
  *
60815
60830
  * This source code is licensed under the ISC license.
60816
60831
  * See the LICENSE file in the root directory of this source tree.
60817
60832
  */
60818
- const __iconNode$J = [
60833
+ const __iconNode$K = [
60819
60834
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
60820
60835
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
60821
60836
  ];
60822
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$J);
60837
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$K);
60823
60838
  /**
60824
60839
  * @license lucide-react v0.575.0 - ISC
60825
60840
  *
60826
60841
  * This source code is licensed under the ISC license.
60827
60842
  * See the LICENSE file in the root directory of this source tree.
60828
60843
  */
60829
- const __iconNode$I = [
60844
+ const __iconNode$J = [
60830
60845
  ["path", { d: "M12 7v14", key: "1akyts" }],
60831
60846
  [
60832
60847
  "path",
@@ -60836,14 +60851,14 @@ const __iconNode$I = [
60836
60851
  }
60837
60852
  ]
60838
60853
  ];
60839
- const BookOpen = createLucideIcon("book-open", __iconNode$I);
60854
+ const BookOpen = createLucideIcon("book-open", __iconNode$J);
60840
60855
  /**
60841
60856
  * @license lucide-react v0.575.0 - ISC
60842
60857
  *
60843
60858
  * This source code is licensed under the ISC license.
60844
60859
  * See the LICENSE file in the root directory of this source tree.
60845
60860
  */
60846
- const __iconNode$H = [
60861
+ const __iconNode$I = [
60847
60862
  ["path", { d: "M12 18V5", key: "adv99a" }],
60848
60863
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
60849
60864
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -60853,71 +60868,85 @@ const __iconNode$H = [
60853
60868
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
60854
60869
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
60855
60870
  ];
60856
- const Brain = createLucideIcon("brain", __iconNode$H);
60871
+ const Brain = createLucideIcon("brain", __iconNode$I);
60857
60872
  /**
60858
60873
  * @license lucide-react v0.575.0 - ISC
60859
60874
  *
60860
60875
  * This source code is licensed under the ISC license.
60861
60876
  * See the LICENSE file in the root directory of this source tree.
60862
60877
  */
60863
- const __iconNode$G = [
60878
+ const __iconNode$H = [
60864
60879
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
60865
60880
  ["path", { d: "M18 17V9", key: "2bz60n" }],
60866
60881
  ["path", { d: "M13 17V5", key: "1frdt8" }],
60867
60882
  ["path", { d: "M8 17v-3", key: "17ska0" }]
60868
60883
  ];
60869
- const ChartColumn = createLucideIcon("chart-column", __iconNode$G);
60884
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$H);
60870
60885
  /**
60871
60886
  * @license lucide-react v0.575.0 - ISC
60872
60887
  *
60873
60888
  * This source code is licensed under the ISC license.
60874
60889
  * See the LICENSE file in the root directory of this source tree.
60875
60890
  */
60876
- const __iconNode$F = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60877
- const Check = createLucideIcon("check", __iconNode$F);
60891
+ const __iconNode$G = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60892
+ const Check = createLucideIcon("check", __iconNode$G);
60878
60893
  /**
60879
60894
  * @license lucide-react v0.575.0 - ISC
60880
60895
  *
60881
60896
  * This source code is licensed under the ISC license.
60882
60897
  * See the LICENSE file in the root directory of this source tree.
60883
60898
  */
60884
- const __iconNode$E = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60885
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$E);
60899
+ const __iconNode$F = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60900
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$F);
60886
60901
  /**
60887
60902
  * @license lucide-react v0.575.0 - ISC
60888
60903
  *
60889
60904
  * This source code is licensed under the ISC license.
60890
60905
  * See the LICENSE file in the root directory of this source tree.
60891
60906
  */
60892
- const __iconNode$D = [
60907
+ const __iconNode$E = [
60893
60908
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60894
60909
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
60895
60910
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
60896
60911
  ];
60897
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$D);
60912
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$E);
60898
60913
  /**
60899
60914
  * @license lucide-react v0.575.0 - ISC
60900
60915
  *
60901
60916
  * This source code is licensed under the ISC license.
60902
60917
  * See the LICENSE file in the root directory of this source tree.
60903
60918
  */
60904
- const __iconNode$C = [
60919
+ const __iconNode$D = [
60905
60920
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60906
60921
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
60907
60922
  ];
60908
- const CircleCheck = createLucideIcon("circle-check", __iconNode$C);
60923
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$D);
60909
60924
  /**
60910
60925
  * @license lucide-react v0.575.0 - ISC
60911
60926
  *
60912
60927
  * This source code is licensed under the ISC license.
60913
60928
  * See the LICENSE file in the root directory of this source tree.
60914
60929
  */
60915
- const __iconNode$B = [
60930
+ const __iconNode$C = [
60916
60931
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60917
60932
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
60918
60933
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
60919
60934
  ];
60920
- const CircleX = createLucideIcon("circle-x", __iconNode$B);
60935
+ const CircleX = createLucideIcon("circle-x", __iconNode$C);
60936
+ /**
60937
+ * @license lucide-react v0.575.0 - ISC
60938
+ *
60939
+ * This source code is licensed under the ISC license.
60940
+ * See the LICENSE file in the root directory of this source tree.
60941
+ */
60942
+ const __iconNode$B = [
60943
+ ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
60944
+ ["path", { d: "M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2", key: "4jdomd" }],
60945
+ ["path", { d: "M16 4h2a2 2 0 0 1 2 2v4", key: "3hqy98" }],
60946
+ ["path", { d: "M21 14H11", key: "1bme5i" }],
60947
+ ["path", { d: "m15 10-4 4 4 4", key: "5dvupr" }]
60948
+ ];
60949
+ const ClipboardCopy = createLucideIcon("clipboard-copy", __iconNode$B);
60921
60950
  /**
60922
60951
  * @license lucide-react v0.575.0 - ISC
60923
60952
  *
@@ -61884,6 +61913,46 @@ function ToolFallbackError({
61884
61913
  /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-destructive/80", children: errorText })
61885
61914
  ] });
61886
61915
  }
61916
+ function CopyToolSpec({
61917
+ toolName,
61918
+ argsText,
61919
+ result
61920
+ }) {
61921
+ const [copied, setCopied] = useState(false);
61922
+ const handleCopy = useCallback(() => {
61923
+ const spec = { tool_name: toolName };
61924
+ if (argsText) {
61925
+ const parsed = tryParseJson$2(argsText);
61926
+ spec.arguments = parsed ?? argsText;
61927
+ }
61928
+ if (result !== void 0) {
61929
+ if (typeof result === "string") {
61930
+ const parsed = tryParseJson$2(result);
61931
+ spec.result = parsed ?? result;
61932
+ } else {
61933
+ spec.result = result;
61934
+ }
61935
+ }
61936
+ const text2 = JSON.stringify(spec, null, 2);
61937
+ navigator.clipboard.writeText(text2).then(() => {
61938
+ setCopied(true);
61939
+ setTimeout(() => setCopied(false), 2e3);
61940
+ });
61941
+ }, [toolName, argsText, result]);
61942
+ return /* @__PURE__ */ jsxs(
61943
+ "button",
61944
+ {
61945
+ type: "button",
61946
+ onClick: handleCopy,
61947
+ className: "flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground/50 transition-colors hover:bg-muted/50 hover:text-muted-foreground",
61948
+ title: "Copy tool name, arguments, and result as JSON",
61949
+ children: [
61950
+ /* @__PURE__ */ jsx(ClipboardCopy, { className: "size-2.5" }),
61951
+ copied ? "Copied" : toolName
61952
+ ]
61953
+ }
61954
+ );
61955
+ }
61887
61956
  function AssetToolCard({
61888
61957
  toolName,
61889
61958
  argsText,
@@ -61975,7 +62044,8 @@ function AssetToolCard({
61975
62044
  (status == null ? void 0 : status.type) === "incomplete" && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsx(ToolFallbackError, { status }) }),
61976
62045
  detailsOpen && !isCancelled && /* @__PURE__ */ jsxs("div", { className: "mt-2.5 flex flex-col gap-2 border-t border-border/50 px-3 pt-2", children: [
61977
62046
  /* @__PURE__ */ jsx(ToolFallbackArgs, { argsText }),
61978
- /* @__PURE__ */ jsx(ToolFallbackResult, { result })
62047
+ /* @__PURE__ */ jsx(ToolFallbackResult, { result }),
62048
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsx(CopyToolSpec, { toolName, argsText, result }) })
61979
62049
  ] })
61980
62050
  ] });
61981
62051
  }
@@ -62036,7 +62106,8 @@ const ToolFallbackImpl = ({
62036
62106
  className: cn(isCancelled && "opacity-60")
62037
62107
  }
62038
62108
  ),
62039
- !isCancelled && /* @__PURE__ */ jsx(ToolFallbackResult, { result })
62109
+ !isCancelled && /* @__PURE__ */ jsx(ToolFallbackResult, { result }),
62110
+ !isCancelled && /* @__PURE__ */ jsx("div", { className: "flex justify-end px-3 pt-1", children: /* @__PURE__ */ jsx(CopyToolSpec, { toolName, argsText, result }) })
62040
62111
  ] })
62041
62112
  ]
62042
62113
  }
@@ -64291,10 +64362,23 @@ const AthenaLayout = ({
64291
64362
  ] });
64292
64363
  };
64293
64364
  function ThreadList({ className }) {
64365
+ const refresh = useRefreshThreadList();
64294
64366
  return /* @__PURE__ */ jsxs(ThreadListPrimitiveRoot, { className: cn("flex flex-col gap-1", className), children: [
64295
- /* @__PURE__ */ jsxs(ThreadListPrimitiveNew, { className: "flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground", children: [
64296
- /* @__PURE__ */ jsx(Plus, { className: "size-4" }),
64297
- "New Chat"
64367
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
64368
+ /* @__PURE__ */ jsxs(ThreadListPrimitiveNew, { className: "flex flex-1 items-center gap-2 rounded-lg border border-border/60 px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground", children: [
64369
+ /* @__PURE__ */ jsx(Plus, { className: "size-4" }),
64370
+ "New Chat"
64371
+ ] }),
64372
+ refresh && /* @__PURE__ */ jsx(
64373
+ "button",
64374
+ {
64375
+ type: "button",
64376
+ onClick: refresh,
64377
+ className: "flex items-center justify-center rounded-lg border border-border/60 p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
64378
+ title: "Refresh threads",
64379
+ children: /* @__PURE__ */ jsx(RefreshCw, { className: "size-4" })
64380
+ }
64381
+ )
64298
64382
  ] }),
64299
64383
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsx(
64300
64384
  ThreadListPrimitiveItems,
@@ -64482,6 +64566,7 @@ export {
64482
64566
  useMentionSuggestions,
64483
64567
  useParentAuth,
64484
64568
  useParentBridge,
64485
- useQuote
64569
+ useQuote,
64570
+ useRefreshThreadList
64486
64571
  };
64487
64572
  //# sourceMappingURL=index.js.map