@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.cjs CHANGED
@@ -16505,8 +16505,10 @@ function useParentBridge() {
16505
16505
  setState((prev) => ({
16506
16506
  ...prev,
16507
16507
  apiUrl: typeof event.data.apiUrl === "string" ? event.data.apiUrl : prev.apiUrl,
16508
- backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl,
16509
- ready: true
16508
+ backendUrl: typeof event.data.backendUrl === "string" ? event.data.backendUrl : prev.backendUrl
16509
+ // Don't set ready here — wait for athena-auth (token) or the timeout.
16510
+ // Setting ready on config alone causes a race: the thread list fires
16511
+ // before the token arrives, falling back to X-API-KEY.
16510
16512
  }));
16511
16513
  }
16512
16514
  if (event.data.type === "athena-auth" && typeof event.data.token === "string") {
@@ -16524,9 +16526,7 @@ function useParentBridge() {
16524
16526
  readySignalSent.current = true;
16525
16527
  }
16526
16528
  const timer = setTimeout(() => {
16527
- if (!configReceived.current) {
16528
- setState((prev) => ({ ...prev, ready: true }));
16529
- }
16529
+ setState((prev) => prev.ready ? prev : { ...prev, ready: true });
16530
16530
  }, BRIDGE_TIMEOUT_MS);
16531
16531
  return () => {
16532
16532
  window.removeEventListener("message", handler);
@@ -24314,6 +24314,9 @@ function useAthenaThreadListAdapter(config2) {
24314
24314
  );
24315
24315
  return React.useMemo(() => ({
24316
24316
  async list() {
24317
+ if (!auth.token) {
24318
+ return { threads: [] };
24319
+ }
24317
24320
  try {
24318
24321
  const { threads } = await listThreads(configRef.current.backendUrl, auth);
24319
24322
  return {
@@ -24355,6 +24358,10 @@ function useAthenaThreadListAdapter(config2) {
24355
24358
  unstable_Provider
24356
24359
  }), [auth, unstable_Provider]);
24357
24360
  }
24361
+ const ThreadListRefreshContext = React.createContext(null);
24362
+ function useRefreshThreadList() {
24363
+ return React.useContext(ThreadListRefreshContext);
24364
+ }
24358
24365
  const THEME_TO_CSS = {
24359
24366
  primary: "--primary",
24360
24367
  primaryForeground: "--primary-foreground",
@@ -24641,13 +24648,21 @@ function AthenaWithThreadList({
24641
24648
  runtimeHook,
24642
24649
  adapter
24643
24650
  });
24651
+ const handleRefresh = React.useCallback(() => {
24652
+ var _a2;
24653
+ const core = (_a2 = runtime == null ? void 0 : runtime._core) == null ? void 0 : _a2.threads;
24654
+ if (core) {
24655
+ core._loadThreadsPromise = void 0;
24656
+ core.__internal_load();
24657
+ }
24658
+ }, [runtime]);
24644
24659
  const auiTools = React.useMemo(() => Tools({ toolkit: frontendTools }), [frontendTools]);
24645
24660
  const aui = useAui({ tools: auiTools });
24646
24661
  const athenaConfig = React.useMemo(
24647
24662
  () => ({ backendUrl, apiKey, token }),
24648
24663
  [backendUrl, apiKey, token]
24649
24664
  );
24650
- return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) });
24665
+ return /* @__PURE__ */ jsxRuntime.jsx(AssistantRuntimeProvider, { aui, runtime, children: /* @__PURE__ */ jsxRuntime.jsx(AthenaContext.Provider, { value: athenaConfig, children: /* @__PURE__ */ jsxRuntime.jsx(ThreadListRefreshContext.Provider, { value: handleRefresh, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children }) }) }) });
24651
24666
  }
24652
24667
  function AthenaProvider({
24653
24668
  children,
@@ -60811,40 +60826,40 @@ const createLucideIcon = (iconName, iconNode) => {
60811
60826
  * This source code is licensed under the ISC license.
60812
60827
  * See the LICENSE file in the root directory of this source tree.
60813
60828
  */
60814
- const __iconNode$L = [
60829
+ const __iconNode$M = [
60815
60830
  ["path", { d: "M12 5v14", key: "s699le" }],
60816
60831
  ["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
60817
60832
  ];
60818
- const ArrowDown = createLucideIcon("arrow-down", __iconNode$L);
60833
+ const ArrowDown = createLucideIcon("arrow-down", __iconNode$M);
60819
60834
  /**
60820
60835
  * @license lucide-react v0.575.0 - ISC
60821
60836
  *
60822
60837
  * This source code is licensed under the ISC license.
60823
60838
  * See the LICENSE file in the root directory of this source tree.
60824
60839
  */
60825
- const __iconNode$K = [
60840
+ const __iconNode$L = [
60826
60841
  ["path", { d: "M5 12h14", key: "1ays0h" }],
60827
60842
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
60828
60843
  ];
60829
- const ArrowRight = createLucideIcon("arrow-right", __iconNode$K);
60844
+ const ArrowRight = createLucideIcon("arrow-right", __iconNode$L);
60830
60845
  /**
60831
60846
  * @license lucide-react v0.575.0 - ISC
60832
60847
  *
60833
60848
  * This source code is licensed under the ISC license.
60834
60849
  * See the LICENSE file in the root directory of this source tree.
60835
60850
  */
60836
- const __iconNode$J = [
60851
+ const __iconNode$K = [
60837
60852
  ["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
60838
60853
  ["path", { d: "M12 19V5", key: "x0mq9r" }]
60839
60854
  ];
60840
- const ArrowUp = createLucideIcon("arrow-up", __iconNode$J);
60855
+ const ArrowUp = createLucideIcon("arrow-up", __iconNode$K);
60841
60856
  /**
60842
60857
  * @license lucide-react v0.575.0 - ISC
60843
60858
  *
60844
60859
  * This source code is licensed under the ISC license.
60845
60860
  * See the LICENSE file in the root directory of this source tree.
60846
60861
  */
60847
- const __iconNode$I = [
60862
+ const __iconNode$J = [
60848
60863
  ["path", { d: "M12 7v14", key: "1akyts" }],
60849
60864
  [
60850
60865
  "path",
@@ -60854,14 +60869,14 @@ const __iconNode$I = [
60854
60869
  }
60855
60870
  ]
60856
60871
  ];
60857
- const BookOpen = createLucideIcon("book-open", __iconNode$I);
60872
+ const BookOpen = createLucideIcon("book-open", __iconNode$J);
60858
60873
  /**
60859
60874
  * @license lucide-react v0.575.0 - ISC
60860
60875
  *
60861
60876
  * This source code is licensed under the ISC license.
60862
60877
  * See the LICENSE file in the root directory of this source tree.
60863
60878
  */
60864
- const __iconNode$H = [
60879
+ const __iconNode$I = [
60865
60880
  ["path", { d: "M12 18V5", key: "adv99a" }],
60866
60881
  ["path", { d: "M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4", key: "1e3is1" }],
60867
60882
  ["path", { d: "M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5", key: "1gqd8o" }],
@@ -60871,71 +60886,85 @@ const __iconNode$H = [
60871
60886
  ["path", { d: "M6 18a4 4 0 0 1-2-7.464", key: "k1g0md" }],
60872
60887
  ["path", { d: "M6.003 5.125a4 4 0 0 0-2.526 5.77", key: "q97ue3" }]
60873
60888
  ];
60874
- const Brain = createLucideIcon("brain", __iconNode$H);
60889
+ const Brain = createLucideIcon("brain", __iconNode$I);
60875
60890
  /**
60876
60891
  * @license lucide-react v0.575.0 - ISC
60877
60892
  *
60878
60893
  * This source code is licensed under the ISC license.
60879
60894
  * See the LICENSE file in the root directory of this source tree.
60880
60895
  */
60881
- const __iconNode$G = [
60896
+ const __iconNode$H = [
60882
60897
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
60883
60898
  ["path", { d: "M18 17V9", key: "2bz60n" }],
60884
60899
  ["path", { d: "M13 17V5", key: "1frdt8" }],
60885
60900
  ["path", { d: "M8 17v-3", key: "17ska0" }]
60886
60901
  ];
60887
- const ChartColumn = createLucideIcon("chart-column", __iconNode$G);
60902
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$H);
60888
60903
  /**
60889
60904
  * @license lucide-react v0.575.0 - ISC
60890
60905
  *
60891
60906
  * This source code is licensed under the ISC license.
60892
60907
  * See the LICENSE file in the root directory of this source tree.
60893
60908
  */
60894
- const __iconNode$F = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60895
- const Check = createLucideIcon("check", __iconNode$F);
60909
+ const __iconNode$G = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
60910
+ const Check = createLucideIcon("check", __iconNode$G);
60896
60911
  /**
60897
60912
  * @license lucide-react v0.575.0 - ISC
60898
60913
  *
60899
60914
  * This source code is licensed under the ISC license.
60900
60915
  * See the LICENSE file in the root directory of this source tree.
60901
60916
  */
60902
- const __iconNode$E = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60903
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$E);
60917
+ const __iconNode$F = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
60918
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$F);
60904
60919
  /**
60905
60920
  * @license lucide-react v0.575.0 - ISC
60906
60921
  *
60907
60922
  * This source code is licensed under the ISC license.
60908
60923
  * See the LICENSE file in the root directory of this source tree.
60909
60924
  */
60910
- const __iconNode$D = [
60925
+ const __iconNode$E = [
60911
60926
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60912
60927
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
60913
60928
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
60914
60929
  ];
60915
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$D);
60930
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$E);
60916
60931
  /**
60917
60932
  * @license lucide-react v0.575.0 - ISC
60918
60933
  *
60919
60934
  * This source code is licensed under the ISC license.
60920
60935
  * See the LICENSE file in the root directory of this source tree.
60921
60936
  */
60922
- const __iconNode$C = [
60937
+ const __iconNode$D = [
60923
60938
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60924
60939
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
60925
60940
  ];
60926
- const CircleCheck = createLucideIcon("circle-check", __iconNode$C);
60941
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$D);
60927
60942
  /**
60928
60943
  * @license lucide-react v0.575.0 - ISC
60929
60944
  *
60930
60945
  * This source code is licensed under the ISC license.
60931
60946
  * See the LICENSE file in the root directory of this source tree.
60932
60947
  */
60933
- const __iconNode$B = [
60948
+ const __iconNode$C = [
60934
60949
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
60935
60950
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
60936
60951
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
60937
60952
  ];
60938
- const CircleX = createLucideIcon("circle-x", __iconNode$B);
60953
+ const CircleX = createLucideIcon("circle-x", __iconNode$C);
60954
+ /**
60955
+ * @license lucide-react v0.575.0 - ISC
60956
+ *
60957
+ * This source code is licensed under the ISC license.
60958
+ * See the LICENSE file in the root directory of this source tree.
60959
+ */
60960
+ const __iconNode$B = [
60961
+ ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
60962
+ ["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" }],
60963
+ ["path", { d: "M16 4h2a2 2 0 0 1 2 2v4", key: "3hqy98" }],
60964
+ ["path", { d: "M21 14H11", key: "1bme5i" }],
60965
+ ["path", { d: "m15 10-4 4 4 4", key: "5dvupr" }]
60966
+ ];
60967
+ const ClipboardCopy = createLucideIcon("clipboard-copy", __iconNode$B);
60939
60968
  /**
60940
60969
  * @license lucide-react v0.575.0 - ISC
60941
60970
  *
@@ -61902,6 +61931,46 @@ function ToolFallbackError({
61902
61931
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-xs text-destructive/80", children: errorText })
61903
61932
  ] });
61904
61933
  }
61934
+ function CopyToolSpec({
61935
+ toolName,
61936
+ argsText,
61937
+ result
61938
+ }) {
61939
+ const [copied, setCopied] = React.useState(false);
61940
+ const handleCopy = React.useCallback(() => {
61941
+ const spec = { tool_name: toolName };
61942
+ if (argsText) {
61943
+ const parsed = tryParseJson$2(argsText);
61944
+ spec.arguments = parsed ?? argsText;
61945
+ }
61946
+ if (result !== void 0) {
61947
+ if (typeof result === "string") {
61948
+ const parsed = tryParseJson$2(result);
61949
+ spec.result = parsed ?? result;
61950
+ } else {
61951
+ spec.result = result;
61952
+ }
61953
+ }
61954
+ const text2 = JSON.stringify(spec, null, 2);
61955
+ navigator.clipboard.writeText(text2).then(() => {
61956
+ setCopied(true);
61957
+ setTimeout(() => setCopied(false), 2e3);
61958
+ });
61959
+ }, [toolName, argsText, result]);
61960
+ return /* @__PURE__ */ jsxRuntime.jsxs(
61961
+ "button",
61962
+ {
61963
+ type: "button",
61964
+ onClick: handleCopy,
61965
+ 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",
61966
+ title: "Copy tool name, arguments, and result as JSON",
61967
+ children: [
61968
+ /* @__PURE__ */ jsxRuntime.jsx(ClipboardCopy, { className: "size-2.5" }),
61969
+ copied ? "Copied" : toolName
61970
+ ]
61971
+ }
61972
+ );
61973
+ }
61905
61974
  function AssetToolCard({
61906
61975
  toolName,
61907
61976
  argsText,
@@ -61993,7 +62062,8 @@ function AssetToolCard({
61993
62062
  (status == null ? void 0 : status.type) === "incomplete" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackError, { status }) }),
61994
62063
  detailsOpen && !isCancelled && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2.5 flex flex-col gap-2 border-t border-border/50 px-3 pt-2", children: [
61995
62064
  /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackArgs, { argsText }),
61996
- /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackResult, { result })
62065
+ /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackResult, { result }),
62066
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(CopyToolSpec, { toolName, argsText, result }) })
61997
62067
  ] })
61998
62068
  ] });
61999
62069
  }
@@ -62054,7 +62124,8 @@ const ToolFallbackImpl = ({
62054
62124
  className: cn(isCancelled && "opacity-60")
62055
62125
  }
62056
62126
  ),
62057
- !isCancelled && /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackResult, { result })
62127
+ !isCancelled && /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackResult, { result }),
62128
+ !isCancelled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end px-3 pt-1", children: /* @__PURE__ */ jsxRuntime.jsx(CopyToolSpec, { toolName, argsText, result }) })
62058
62129
  ] })
62059
62130
  ]
62060
62131
  }
@@ -64309,10 +64380,23 @@ const AthenaLayout = ({
64309
64380
  ] });
64310
64381
  };
64311
64382
  function ThreadList({ className }) {
64383
+ const refresh = useRefreshThreadList();
64312
64384
  return /* @__PURE__ */ jsxRuntime.jsxs(ThreadListPrimitiveRoot, { className: cn("flex flex-col gap-1", className), children: [
64313
- /* @__PURE__ */ jsxRuntime.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: [
64314
- /* @__PURE__ */ jsxRuntime.jsx(Plus, { className: "size-4" }),
64315
- "New Chat"
64385
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
64386
+ /* @__PURE__ */ jsxRuntime.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: [
64387
+ /* @__PURE__ */ jsxRuntime.jsx(Plus, { className: "size-4" }),
64388
+ "New Chat"
64389
+ ] }),
64390
+ refresh && /* @__PURE__ */ jsxRuntime.jsx(
64391
+ "button",
64392
+ {
64393
+ type: "button",
64394
+ onClick: refresh,
64395
+ 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",
64396
+ title: "Refresh threads",
64397
+ children: /* @__PURE__ */ jsxRuntime.jsx(RefreshCw, { className: "size-4" })
64398
+ }
64399
+ )
64316
64400
  ] }),
64317
64401
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(
64318
64402
  ThreadListPrimitiveItems,
@@ -64500,4 +64584,5 @@ exports.useMentionSuggestions = useMentionSuggestions;
64500
64584
  exports.useParentAuth = useParentAuth;
64501
64585
  exports.useParentBridge = useParentBridge;
64502
64586
  exports.useQuote = useQuote;
64587
+ exports.useRefreshThreadList = useRefreshThreadList;
64503
64588
  //# sourceMappingURL=index.cjs.map