@athenaintel/react 0.9.7 → 0.9.8
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/README.md +20 -0
- package/dist/index.cjs +43 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +34 -6
- package/dist/index.js +44 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,6 +68,26 @@ Preset themes: `light`, `dark`, `midnight`, `warm`, `purple`, `green`.
|
|
|
68
68
|
- **`<ThreadList>`** — Conversation history sidebar
|
|
69
69
|
- **`Toolkits`** — Constants for all available backend toolkits
|
|
70
70
|
|
|
71
|
+
## Composer Hooks
|
|
72
|
+
|
|
73
|
+
Use `useAppendToComposer()` when you want to prefill a draft without sending it.
|
|
74
|
+
|
|
75
|
+
Use `useSendMessage()` for workflow buttons, sidebar shortcuts, and other UI that lives outside `<AthenaChat>` but still needs to submit a prompt.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { useSendMessage } from '@athenaintel/react';
|
|
79
|
+
|
|
80
|
+
function WorkflowButton() {
|
|
81
|
+
const sendMessage = useSendMessage();
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<button onClick={() => void sendMessage('Run the quarterly workflow')}>
|
|
85
|
+
Run workflow
|
|
86
|
+
</button>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
71
91
|
## License
|
|
72
92
|
|
|
73
93
|
Proprietary. For licensed enterprise customers only.
|
package/dist/index.cjs
CHANGED
|
@@ -16491,8 +16491,16 @@ const DEFAULT_ATHENA_ENVIRONMENT = "production";
|
|
|
16491
16491
|
const DEFAULT_API_URL = ATHENA_ENVIRONMENT_URLS.production.apiUrl;
|
|
16492
16492
|
const DEFAULT_BACKEND_URL = ATHENA_ENVIRONMENT_URLS.production.backendUrl;
|
|
16493
16493
|
const DEFAULT_APP_URL = ATHENA_ENVIRONMENT_URLS.production.appUrl;
|
|
16494
|
-
const
|
|
16494
|
+
const MARATHON_APP_PORT = "8082";
|
|
16495
|
+
const SPACES_PATHNAME = "dashboard/spaces/";
|
|
16495
16496
|
const normalizeBaseUrl = (url) => url.replace(/\/+$/, "");
|
|
16497
|
+
const createUrlWithFallback = (url, fallbackUrl) => {
|
|
16498
|
+
try {
|
|
16499
|
+
return new URL(`${normalizeBaseUrl(url)}/`);
|
|
16500
|
+
} catch {
|
|
16501
|
+
return new URL(`${normalizeBaseUrl(fallbackUrl)}/`);
|
|
16502
|
+
}
|
|
16503
|
+
};
|
|
16496
16504
|
const getHostname = (value) => {
|
|
16497
16505
|
if (!value) return null;
|
|
16498
16506
|
try {
|
|
@@ -16514,7 +16522,7 @@ const deriveWorkspaceAppUrl = ({
|
|
|
16514
16522
|
if (!((_a2 = match2 == null ? void 0 : match2.groups) == null ? void 0 : _a2.prefix) || !match2.groups.domain) {
|
|
16515
16523
|
return null;
|
|
16516
16524
|
}
|
|
16517
|
-
return `${parsedUrl.protocol}//${match2.groups.prefix}
|
|
16525
|
+
return `${parsedUrl.protocol}//${match2.groups.prefix}--${MARATHON_APP_PORT}.${match2.groups.domain}`;
|
|
16518
16526
|
} catch {
|
|
16519
16527
|
return null;
|
|
16520
16528
|
}
|
|
@@ -16563,7 +16571,7 @@ function createAthenaSpacesUrl({
|
|
|
16563
16571
|
assetIds,
|
|
16564
16572
|
sessionId
|
|
16565
16573
|
}) {
|
|
16566
|
-
const url = new URL(SPACES_PATHNAME,
|
|
16574
|
+
const url = new URL(SPACES_PATHNAME, createUrlWithFallback(appUrl, DEFAULT_APP_URL));
|
|
16567
16575
|
if (assetIds) {
|
|
16568
16576
|
const normalizedAssetIds = (Array.isArray(assetIds) ? assetIds : [assetIds]).map((assetId) => assetId.trim()).filter((assetId) => assetId.length > 0);
|
|
16569
16577
|
if (normalizedAssetIds.length > 0) {
|
|
@@ -20625,7 +20633,9 @@ const toolMessageSchema = objectType({
|
|
|
20625
20633
|
type: literalType("tool"),
|
|
20626
20634
|
content: toolMessageContentSchema,
|
|
20627
20635
|
tool_call_id: stringType(),
|
|
20628
|
-
name
|
|
20636
|
+
// Some backend/tool result flows omit the tool name entirely.
|
|
20637
|
+
// The converter already treats toolName as optional, so accept that shape.
|
|
20638
|
+
name: nullableToOptionalString,
|
|
20629
20639
|
artifact: anyType().optional(),
|
|
20630
20640
|
status: enumType(["success", "error"]),
|
|
20631
20641
|
additional_kwargs: recordType(stringType(), unknownType()).optional()
|
|
@@ -20792,7 +20802,9 @@ async function listThreads(backendUrl, auth, opts = {}) {
|
|
|
20792
20802
|
body: JSON.stringify({
|
|
20793
20803
|
limit: opts.limit ?? 50,
|
|
20794
20804
|
offset: opts.offset ?? 0,
|
|
20795
|
-
|
|
20805
|
+
// Default to the full recent-conversations set unless a caller
|
|
20806
|
+
// explicitly asks to hide triggered/background sessions.
|
|
20807
|
+
exclude_triggered: opts.exclude_triggered ?? false
|
|
20796
20808
|
})
|
|
20797
20809
|
});
|
|
20798
20810
|
if (!res.ok) {
|
|
@@ -24823,9 +24835,9 @@ function AthenaProvider({
|
|
|
24823
24835
|
const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
|
|
24824
24836
|
const bridge = useParentBridge();
|
|
24825
24837
|
const effectiveToken = configuredToken !== void 0 ? configuredToken : bridge.token;
|
|
24826
|
-
const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl
|
|
24827
|
-
const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl
|
|
24828
|
-
const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl
|
|
24838
|
+
const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl;
|
|
24839
|
+
const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl;
|
|
24840
|
+
const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl;
|
|
24829
24841
|
if (!bridge.ready) {
|
|
24830
24842
|
return null;
|
|
24831
24843
|
}
|
|
@@ -60786,7 +60798,7 @@ const TiptapComposer = ({ tools = [] }) => {
|
|
|
60786
60798
|
composerRuntime.send();
|
|
60787
60799
|
}
|
|
60788
60800
|
editor2.commands.clearContent();
|
|
60789
|
-
}, [aui, composerRuntime, clearAttachments, clearQuote]);
|
|
60801
|
+
}, [aui, composerRuntime, clearAttachments, clearQuote, appUrl]);
|
|
60790
60802
|
const handleSubmitRef = React.useRef(handleSubmit);
|
|
60791
60803
|
handleSubmitRef.current = handleSubmit;
|
|
60792
60804
|
const editor = useEditor({
|
|
@@ -63958,6 +63970,23 @@ const ComposerDropZone = ({
|
|
|
63958
63970
|
}
|
|
63959
63971
|
);
|
|
63960
63972
|
};
|
|
63973
|
+
function useSendMessage() {
|
|
63974
|
+
const aui = useAui();
|
|
63975
|
+
return React.useCallback(
|
|
63976
|
+
async (text2, options) => {
|
|
63977
|
+
if (!text2.trim()) return;
|
|
63978
|
+
const composer = aui.composer();
|
|
63979
|
+
const currentText = composer.getState().text;
|
|
63980
|
+
const shouldReplace = (options == null ? void 0 : options.replace) ?? true;
|
|
63981
|
+
composer.setText(
|
|
63982
|
+
shouldReplace || !currentText ? text2 : `${currentText}
|
|
63983
|
+
${text2}`
|
|
63984
|
+
);
|
|
63985
|
+
await composer.send();
|
|
63986
|
+
},
|
|
63987
|
+
[aui]
|
|
63988
|
+
);
|
|
63989
|
+
}
|
|
63961
63990
|
const EMPTY_MENTION_TOOLS = [];
|
|
63962
63991
|
function QuotePostMessageBridge() {
|
|
63963
63992
|
useQuoteFromPostMessage();
|
|
@@ -63989,14 +64018,11 @@ const SuggestionCard = ({
|
|
|
63989
64018
|
suggestion,
|
|
63990
64019
|
index: index2
|
|
63991
64020
|
}) => {
|
|
63992
|
-
const aui = useAui();
|
|
63993
64021
|
const Icon2 = suggestion.icon;
|
|
64022
|
+
const sendMessage = useSendMessage();
|
|
63994
64023
|
const handleClick2 = React.useCallback(() => {
|
|
63995
|
-
|
|
63996
|
-
|
|
63997
|
-
content: [{ type: "text", text: suggestion.prompt }]
|
|
63998
|
-
});
|
|
63999
|
-
}, [aui, suggestion.prompt]);
|
|
64024
|
+
void sendMessage(suggestion.prompt);
|
|
64025
|
+
}, [sendMessage, suggestion.prompt]);
|
|
64000
64026
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
64001
64027
|
"button",
|
|
64002
64028
|
{
|
|
@@ -64143,7 +64169,7 @@ const ComposerSendWithQuote = () => {
|
|
|
64143
64169
|
editor == null ? void 0 : editor.clear();
|
|
64144
64170
|
clearQuote();
|
|
64145
64171
|
clearAttachments();
|
|
64146
|
-
}, [aui, quote, attachments, isUploading, clearQuote, clearAttachments, editorRef]);
|
|
64172
|
+
}, [aui, quote, attachments, isUploading, clearQuote, clearAttachments, editorRef, appUrl]);
|
|
64147
64173
|
if (hasExtras) {
|
|
64148
64174
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
64149
64175
|
TooltipIconButton,
|
|
@@ -64785,4 +64811,5 @@ exports.useParentAuth = useParentAuth;
|
|
|
64785
64811
|
exports.useParentBridge = useParentBridge;
|
|
64786
64812
|
exports.useQuote = useQuote;
|
|
64787
64813
|
exports.useRefreshThreadList = useRefreshThreadList;
|
|
64814
|
+
exports.useSendMessage = useSendMessage;
|
|
64788
64815
|
//# sourceMappingURL=index.cjs.map
|