@athenaintel/react 0.9.16 → 0.9.17
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 +64 -193
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.js +64 -193
- package/dist/index.js.map +1 -1
- package/package.json +9 -10
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,6 @@ export declare interface AssetPanelState {
|
|
|
51
51
|
openAsset: (assetId: string, meta?: {
|
|
52
52
|
name?: string;
|
|
53
53
|
type?: AssetType;
|
|
54
|
-
embedSearchParams?: Record<string, string> | null;
|
|
55
54
|
}) => void;
|
|
56
55
|
closeTab: (assetId: string) => void;
|
|
57
56
|
setActiveTab: (assetId: string) => void;
|
|
@@ -68,7 +67,6 @@ export declare interface AssetTab {
|
|
|
68
67
|
id: string;
|
|
69
68
|
name: string | null;
|
|
70
69
|
type: AssetType;
|
|
71
|
-
embedSearchParams: Record<string, string> | null;
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
export declare type AssetType = 'presentation' | 'spreadsheet' | 'document' | 'notebook' | 'unknown';
|
|
@@ -148,8 +146,6 @@ export declare interface AthenaCitationLinkMetadata {
|
|
|
148
146
|
assetId: string;
|
|
149
147
|
assetIds: string[];
|
|
150
148
|
assetType: AssetType | null;
|
|
151
|
-
assetName: string | null;
|
|
152
|
-
embedSearchParams: Record<string, string>;
|
|
153
149
|
}
|
|
154
150
|
|
|
155
151
|
/**
|
|
@@ -590,8 +586,6 @@ export declare interface ParsedAthenaCitationLink {
|
|
|
590
586
|
assetId: string;
|
|
591
587
|
assetIds: string[];
|
|
592
588
|
assetType: AssetType | null;
|
|
593
|
-
assetName: string | null;
|
|
594
|
-
embedSearchParams: Record<string, string>;
|
|
595
589
|
}
|
|
596
590
|
|
|
597
591
|
declare interface QuoteContextValue {
|
|
@@ -1024,15 +1018,12 @@ export declare function useAssetEmbed(assetId: string | null, options?: UseAsset
|
|
|
1024
1018
|
export declare interface UseAssetEmbedOptions {
|
|
1025
1019
|
readOnly?: boolean;
|
|
1026
1020
|
expiresInSeconds?: number;
|
|
1027
|
-
embedSearchParams?: Record<string, string> | null;
|
|
1028
1021
|
}
|
|
1029
1022
|
|
|
1030
1023
|
export declare interface UseAssetEmbedResult {
|
|
1031
1024
|
embedUrl: string | null;
|
|
1032
1025
|
isLoading: boolean;
|
|
1033
1026
|
error: string | null;
|
|
1034
|
-
assetTitle: string | null;
|
|
1035
|
-
assetType: AssetType | null;
|
|
1036
1027
|
}
|
|
1037
1028
|
|
|
1038
1029
|
export declare const useAssetPanelStore: UseBoundStore<Omit<StoreApi<AssetPanelState>, "setState" | "persist"> & {
|
package/dist/index.js
CHANGED
|
@@ -19849,14 +19849,20 @@ const joinExternalMessages = (messages) => {
|
|
|
19849
19849
|
)
|
|
19850
19850
|
);
|
|
19851
19851
|
}
|
|
19852
|
+
const { messages: existingMessages, ...toolCallRest } = toolCall;
|
|
19852
19853
|
const updatedToolCall = {
|
|
19853
|
-
...
|
|
19854
|
+
...toolCallRest,
|
|
19854
19855
|
result: output.result,
|
|
19855
19856
|
artifact: output.artifact,
|
|
19856
19857
|
isError: output.isError,
|
|
19857
|
-
|
|
19858
|
+
...(output.messages ?? existingMessages) !== void 0 && {
|
|
19859
|
+
messages: output.messages ?? existingMessages
|
|
19860
|
+
}
|
|
19858
19861
|
};
|
|
19859
|
-
bindExternalStoreMessage(updatedToolCall, [
|
|
19862
|
+
bindExternalStoreMessage(updatedToolCall, [
|
|
19863
|
+
...getExternalStoreMessages(toolCallRest),
|
|
19864
|
+
output
|
|
19865
|
+
]);
|
|
19860
19866
|
assistantMessage.content[toolCallIdx] = updatedToolCall;
|
|
19861
19867
|
} else {
|
|
19862
19868
|
console.warn(
|
|
@@ -19865,10 +19871,14 @@ const joinExternalMessages = (messages) => {
|
|
|
19865
19871
|
}
|
|
19866
19872
|
} else {
|
|
19867
19873
|
const role = output.role;
|
|
19868
|
-
const
|
|
19874
|
+
const rawContent = typeof output.content === "string" ? [{ type: "text", text: output.content }] : Array.isArray(output.content) ? output.content : [];
|
|
19875
|
+
const content = rawContent.flatMap((c) => {
|
|
19876
|
+
if (!c || typeof c !== "object") {
|
|
19877
|
+
return [];
|
|
19878
|
+
}
|
|
19869
19879
|
const mapped = { ...c };
|
|
19870
19880
|
bindExternalStoreMessage(mapped, output);
|
|
19871
|
-
return mapped;
|
|
19881
|
+
return [mapped];
|
|
19872
19882
|
});
|
|
19873
19883
|
switch (role) {
|
|
19874
19884
|
case "system":
|
|
@@ -19999,7 +20009,13 @@ const convertExternalMessages = (messages, callback, isRunning, metadata) => {
|
|
|
19999
20009
|
const callbackResults = [];
|
|
20000
20010
|
for (const message of messages) {
|
|
20001
20011
|
const output = callback(message, metadata);
|
|
20002
|
-
const
|
|
20012
|
+
const rawOutputs = Array.isArray(output) ? output : [output];
|
|
20013
|
+
const outputs = rawOutputs.filter(
|
|
20014
|
+
(candidate) => candidate != null
|
|
20015
|
+
);
|
|
20016
|
+
if (outputs.length === 0) {
|
|
20017
|
+
continue;
|
|
20018
|
+
}
|
|
20003
20019
|
const result = { input: message, outputs };
|
|
20004
20020
|
callbackResults.push(result);
|
|
20005
20021
|
}
|
|
@@ -20022,37 +20038,40 @@ const warnForUnknownMessagePartType = (type) => {
|
|
|
20022
20038
|
};
|
|
20023
20039
|
const contentToParts = (content) => {
|
|
20024
20040
|
if (typeof content === "string") return [{ type: "text", text: content }];
|
|
20025
|
-
return content.
|
|
20041
|
+
return content.flatMap((part) => {
|
|
20042
|
+
if (!part || typeof part !== "object" || !("type" in part)) {
|
|
20043
|
+
return [];
|
|
20044
|
+
}
|
|
20026
20045
|
const type = part.type;
|
|
20027
20046
|
switch (type) {
|
|
20028
20047
|
case "text":
|
|
20029
|
-
return { type: "text", text: part.text };
|
|
20048
|
+
return [{ type: "text", text: part.text }];
|
|
20030
20049
|
case "text_delta":
|
|
20031
|
-
return { type: "text", text: part.text };
|
|
20050
|
+
return [{ type: "text", text: part.text }];
|
|
20032
20051
|
case "image_url":
|
|
20033
20052
|
if (typeof part.image_url === "string") {
|
|
20034
|
-
return { type: "image", image: part.image_url };
|
|
20053
|
+
return [{ type: "image", image: part.image_url }];
|
|
20035
20054
|
}
|
|
20036
|
-
return {
|
|
20055
|
+
return [{
|
|
20037
20056
|
type: "image",
|
|
20038
20057
|
image: part.image_url.url
|
|
20039
|
-
};
|
|
20058
|
+
}];
|
|
20040
20059
|
case "thinking":
|
|
20041
|
-
return { type: "reasoning", text: part.thinking };
|
|
20060
|
+
return [{ type: "reasoning", text: part.thinking }];
|
|
20042
20061
|
case "reasoning":
|
|
20043
|
-
return {
|
|
20062
|
+
return [{
|
|
20044
20063
|
type: "reasoning",
|
|
20045
20064
|
text: part.summary.map((s) => s.text).join("\n\n\n")
|
|
20046
|
-
};
|
|
20065
|
+
}];
|
|
20047
20066
|
case "tool_use":
|
|
20048
|
-
return
|
|
20067
|
+
return [];
|
|
20049
20068
|
case "input_json_delta":
|
|
20050
|
-
return
|
|
20069
|
+
return [];
|
|
20051
20070
|
default:
|
|
20052
20071
|
warnForUnknownMessagePartType(type);
|
|
20053
|
-
return
|
|
20072
|
+
return [];
|
|
20054
20073
|
}
|
|
20055
|
-
})
|
|
20074
|
+
});
|
|
20056
20075
|
};
|
|
20057
20076
|
const getNumberAtPath = (value, path) => {
|
|
20058
20077
|
let current = value;
|
|
@@ -20157,7 +20176,7 @@ const convertLangChainMessage = (message) => {
|
|
|
20157
20176
|
(_b = message.additional_kwargs) == null ? void 0 : _b.reasoning,
|
|
20158
20177
|
...normalizedContent,
|
|
20159
20178
|
...((_c = message.additional_kwargs) == null ? void 0 : _c.tool_outputs) ?? []
|
|
20160
|
-
].filter((c) => c
|
|
20179
|
+
].filter((c) => c != null);
|
|
20161
20180
|
return {
|
|
20162
20181
|
role: "assistant",
|
|
20163
20182
|
id: message.id,
|
|
@@ -20180,6 +20199,8 @@ const convertLangChainMessage = (message) => {
|
|
|
20180
20199
|
isError: message.status === "error"
|
|
20181
20200
|
};
|
|
20182
20201
|
}
|
|
20202
|
+
default:
|
|
20203
|
+
return null;
|
|
20183
20204
|
}
|
|
20184
20205
|
};
|
|
20185
20206
|
const convertLangChainToThreadMessages = (messages, isRunning = false, metadata = {}) => {
|
|
@@ -58857,20 +58878,14 @@ const useAssetPanelStore = create()(
|
|
|
58857
58878
|
const existing = s.tabs.find((t) => t.id === assetId);
|
|
58858
58879
|
if (existing) {
|
|
58859
58880
|
const tabs = meta ? s.tabs.map(
|
|
58860
|
-
(t) => t.id === assetId ? {
|
|
58861
|
-
...t,
|
|
58862
|
-
name: meta.name ?? t.name,
|
|
58863
|
-
type: meta.type ?? t.type,
|
|
58864
|
-
embedSearchParams: meta.embedSearchParams ?? t.embedSearchParams
|
|
58865
|
-
} : t
|
|
58881
|
+
(t) => t.id === assetId ? { ...t, name: meta.name ?? t.name, type: meta.type ?? t.type } : t
|
|
58866
58882
|
) : s.tabs;
|
|
58867
58883
|
return { isOpen: true, tabs, activeTabId: assetId };
|
|
58868
58884
|
}
|
|
58869
58885
|
const newTab = {
|
|
58870
58886
|
id: assetId,
|
|
58871
58887
|
name: (meta == null ? void 0 : meta.name) ?? null,
|
|
58872
|
-
type: (meta == null ? void 0 : meta.type) ?? "unknown"
|
|
58873
|
-
embedSearchParams: (meta == null ? void 0 : meta.embedSearchParams) ?? null
|
|
58888
|
+
type: (meta == null ? void 0 : meta.type) ?? "unknown"
|
|
58874
58889
|
};
|
|
58875
58890
|
return { isOpen: true, tabs: [...s.tabs, newTab], activeTabId: assetId };
|
|
58876
58891
|
}),
|
|
@@ -58931,43 +58946,13 @@ const ASSET_TYPE_ALIASES = {
|
|
|
58931
58946
|
super_document: "document"
|
|
58932
58947
|
};
|
|
58933
58948
|
const isAthenaSpacesPath = (url) => url.pathname.replace(/\/+$/, "") === "/dashboard/spaces";
|
|
58934
|
-
const normalizeAssetType
|
|
58949
|
+
const normalizeAssetType = (value) => {
|
|
58935
58950
|
if (!value) {
|
|
58936
58951
|
return null;
|
|
58937
58952
|
}
|
|
58938
58953
|
const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
|
|
58939
58954
|
return ASSET_TYPE_ALIASES[normalizedValue] ?? null;
|
|
58940
58955
|
};
|
|
58941
|
-
const isLikelyAssetId = (value) => !!value && /^(asset|thread|project|collection)_[a-z0-9-]+$/i.test(value.trim());
|
|
58942
|
-
const sanitizeDisplayName = (value) => {
|
|
58943
|
-
if (!value) {
|
|
58944
|
-
return null;
|
|
58945
|
-
}
|
|
58946
|
-
const trimmedValue = value.trim();
|
|
58947
|
-
if (!trimmedValue) {
|
|
58948
|
-
return null;
|
|
58949
|
-
}
|
|
58950
|
-
if (trimmedValue.startsWith('"') && trimmedValue.endsWith('"') || trimmedValue.startsWith("'") && trimmedValue.endsWith("'")) {
|
|
58951
|
-
return trimmedValue.slice(1, -1).trim() || null;
|
|
58952
|
-
}
|
|
58953
|
-
return trimmedValue;
|
|
58954
|
-
};
|
|
58955
|
-
const getCitationDisplayName = ({
|
|
58956
|
-
assetName,
|
|
58957
|
-
linkText
|
|
58958
|
-
}) => {
|
|
58959
|
-
const sanitizedAssetName = sanitizeDisplayName(assetName);
|
|
58960
|
-
const sanitizedLinkText = sanitizeDisplayName(linkText);
|
|
58961
|
-
const genericLinkTextPattern = /^(this|that|the)\s+asset$/i;
|
|
58962
|
-
if (sanitizedAssetName && !isLikelyAssetId(sanitizedAssetName)) {
|
|
58963
|
-
return sanitizedAssetName;
|
|
58964
|
-
}
|
|
58965
|
-
if (sanitizedLinkText && !genericLinkTextPattern.test(sanitizedLinkText)) {
|
|
58966
|
-
return sanitizedLinkText;
|
|
58967
|
-
}
|
|
58968
|
-
return sanitizedAssetName ?? sanitizedLinkText;
|
|
58969
|
-
};
|
|
58970
|
-
const getEmbedSearchParams = (url) => Object.fromEntries(url.searchParams.entries());
|
|
58971
58956
|
const getOrigin = (value) => {
|
|
58972
58957
|
if (!value) {
|
|
58973
58958
|
return null;
|
|
@@ -59049,11 +59034,7 @@ const parseAthenaCitationLink = ({
|
|
|
59049
59034
|
url,
|
|
59050
59035
|
assetId,
|
|
59051
59036
|
assetIds,
|
|
59052
|
-
assetType: normalizeAssetType
|
|
59053
|
-
url.searchParams.get("asset_type") ?? url.searchParams.get("assetType") ?? url.searchParams.get("type")
|
|
59054
|
-
),
|
|
59055
|
-
assetName: sanitizeDisplayName(url.searchParams.get("name")),
|
|
59056
|
-
embedSearchParams: getEmbedSearchParams(url)
|
|
59037
|
+
assetType: normalizeAssetType(url.searchParams.get("asset_type") ?? url.searchParams.get("type"))
|
|
59057
59038
|
};
|
|
59058
59039
|
};
|
|
59059
59040
|
const isAthenaCitationUrl = ({
|
|
@@ -59101,19 +59082,12 @@ const useAthenaLinkClickHandler = () => {
|
|
|
59101
59082
|
const citationMetadata = citationLink ? {
|
|
59102
59083
|
assetId: citationLink.assetId,
|
|
59103
59084
|
assetIds: citationLink.assetIds,
|
|
59104
|
-
assetType: citationLink.assetType
|
|
59105
|
-
assetName: citationLink.assetName,
|
|
59106
|
-
embedSearchParams: citationLink.embedSearchParams
|
|
59085
|
+
assetType: citationLink.assetType
|
|
59107
59086
|
} : null;
|
|
59108
59087
|
const openInAssetPanel = citationLink ? () => {
|
|
59109
|
-
const displayName = getCitationDisplayName({
|
|
59110
|
-
assetName: citationLink.assetName,
|
|
59111
|
-
linkText: trimmedLinkText
|
|
59112
|
-
});
|
|
59113
59088
|
openAsset(citationLink.assetId, {
|
|
59114
|
-
name:
|
|
59115
|
-
type: citationLink.assetType ?? void 0
|
|
59116
|
-
embedSearchParams: citationLink.embedSearchParams
|
|
59089
|
+
name: trimmedLinkText ?? void 0,
|
|
59090
|
+
type: citationLink.assetType ?? void 0
|
|
59117
59091
|
});
|
|
59118
59092
|
} : void 0;
|
|
59119
59093
|
const context2 = {
|
|
@@ -63553,12 +63527,6 @@ function extractAssetId(result) {
|
|
|
63553
63527
|
if (typeof id === "string" && id.startsWith("asset_")) return id;
|
|
63554
63528
|
return null;
|
|
63555
63529
|
}
|
|
63556
|
-
function extractAssetTitle(result) {
|
|
63557
|
-
const data = normalizeResult(result);
|
|
63558
|
-
if (!data) return null;
|
|
63559
|
-
const title = data.assetTitle ?? data.asset_title ?? data.title ?? data.name;
|
|
63560
|
-
return typeof title === "string" && title.trim().length > 0 ? title.trim() : null;
|
|
63561
|
-
}
|
|
63562
63530
|
function resetAssetAutoOpen() {
|
|
63563
63531
|
useAssetPanelStore.getState().resetAutoOpen();
|
|
63564
63532
|
}
|
|
@@ -64278,7 +64246,6 @@ const OpenAssetToolUIImpl = ({
|
|
|
64278
64246
|
const typedArgs = args;
|
|
64279
64247
|
const argsAssetId = (typedArgs == null ? void 0 : typedArgs.asset_id) ?? (typedArgs == null ? void 0 : typedArgs.assetId) ?? "";
|
|
64280
64248
|
const resultAssetId = extractAssetId(result);
|
|
64281
|
-
const resultAssetTitle = extractAssetTitle(result);
|
|
64282
64249
|
const assetId = resultAssetId ?? (argsAssetId.startsWith("asset_") ? argsAssetId : null);
|
|
64283
64250
|
const isRunning = (status == null ? void 0 : status.type) === "running";
|
|
64284
64251
|
const isComplete = (status == null ? void 0 : status.type) === "complete" || !status;
|
|
@@ -64290,10 +64257,10 @@ const OpenAssetToolUIImpl = ({
|
|
|
64290
64257
|
if (isComplete && !isCancelled && assetId && !wasCompleteAtMount.current) {
|
|
64291
64258
|
const store = useAssetPanelStore.getState();
|
|
64292
64259
|
if (store.markAutoOpened(assetId)) {
|
|
64293
|
-
store.openAsset(assetId
|
|
64260
|
+
store.openAsset(assetId);
|
|
64294
64261
|
}
|
|
64295
64262
|
}
|
|
64296
|
-
}, [isComplete, isCancelled, assetId
|
|
64263
|
+
}, [isComplete, isCancelled, assetId]);
|
|
64297
64264
|
return /* @__PURE__ */ jsx(
|
|
64298
64265
|
ToolCard,
|
|
64299
64266
|
{
|
|
@@ -64309,7 +64276,7 @@ const OpenAssetToolUIImpl = ({
|
|
|
64309
64276
|
"button",
|
|
64310
64277
|
{
|
|
64311
64278
|
type: "button",
|
|
64312
|
-
onClick: () => openAsset(assetId
|
|
64279
|
+
onClick: () => openAsset(assetId),
|
|
64313
64280
|
className: "flex items-center gap-1.5 rounded-md border border-border/60 px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",
|
|
64314
64281
|
children: [
|
|
64315
64282
|
/* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
|
|
@@ -65234,58 +65201,14 @@ const AthenaUserMessage = ({
|
|
|
65234
65201
|
children: /* @__PURE__ */ jsx("div", { className: "aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground", children: /* @__PURE__ */ jsx(MessagePrimitiveParts, { components: { Text: TextComponent } }) })
|
|
65235
65202
|
}
|
|
65236
65203
|
);
|
|
65237
|
-
const EMBED_ASSET_TYPE_ALIASES = {
|
|
65238
|
-
document: "document",
|
|
65239
|
-
image: "document",
|
|
65240
|
-
notebook: "notebook",
|
|
65241
|
-
pdf: "document",
|
|
65242
|
-
powerpoint_deck: "presentation",
|
|
65243
|
-
presentation: "presentation",
|
|
65244
|
-
puck_presentation: "presentation",
|
|
65245
|
-
sheet: "spreadsheet",
|
|
65246
|
-
spreadsheet: "spreadsheet",
|
|
65247
|
-
super_document: "document"
|
|
65248
|
-
};
|
|
65249
65204
|
const embedCache = /* @__PURE__ */ new Map();
|
|
65250
|
-
const normalizeAssetType = (value) => {
|
|
65251
|
-
if (!value) {
|
|
65252
|
-
return null;
|
|
65253
|
-
}
|
|
65254
|
-
const normalizedValue = value.trim().replace(/^athena\//, "").toLowerCase().replace(/-/g, "_");
|
|
65255
|
-
return EMBED_ASSET_TYPE_ALIASES[normalizedValue] ?? null;
|
|
65256
|
-
};
|
|
65257
|
-
const appendEmbedSearchParams = ({
|
|
65258
|
-
embedUrl,
|
|
65259
|
-
embedSearchParams
|
|
65260
|
-
}) => {
|
|
65261
|
-
if (!embedSearchParams || Object.keys(embedSearchParams).length === 0) {
|
|
65262
|
-
return embedUrl;
|
|
65263
|
-
}
|
|
65264
|
-
const url = new URL(embedUrl);
|
|
65265
|
-
for (const [key, value] of Object.entries(embedSearchParams)) {
|
|
65266
|
-
if (!value) {
|
|
65267
|
-
continue;
|
|
65268
|
-
}
|
|
65269
|
-
url.searchParams.set(key, value);
|
|
65270
|
-
}
|
|
65271
|
-
return url.toString();
|
|
65272
|
-
};
|
|
65273
65205
|
function useAssetEmbed(assetId, options = {
|
|
65274
65206
|
backendUrl: ""
|
|
65275
65207
|
}) {
|
|
65276
|
-
const {
|
|
65277
|
-
readOnly = false,
|
|
65278
|
-
expiresInSeconds = 60 * 60 * 24 * 30,
|
|
65279
|
-
backendUrl,
|
|
65280
|
-
apiKey,
|
|
65281
|
-
token,
|
|
65282
|
-
embedSearchParams
|
|
65283
|
-
} = options;
|
|
65208
|
+
const { readOnly = false, expiresInSeconds = 60 * 60 * 24 * 30, backendUrl, apiKey, token } = options;
|
|
65284
65209
|
const [embedUrl, setEmbedUrl] = useState(null);
|
|
65285
65210
|
const [isLoading, setIsLoading] = useState(false);
|
|
65286
65211
|
const [error2, setError] = useState(null);
|
|
65287
|
-
const [assetTitle, setAssetTitle] = useState(null);
|
|
65288
|
-
const [assetType, setAssetType] = useState(null);
|
|
65289
65212
|
const abortRef = useRef(null);
|
|
65290
65213
|
useEffect(() => {
|
|
65291
65214
|
var _a2;
|
|
@@ -65293,18 +65216,14 @@ function useAssetEmbed(assetId, options = {
|
|
|
65293
65216
|
setEmbedUrl(null);
|
|
65294
65217
|
setIsLoading(false);
|
|
65295
65218
|
setError(null);
|
|
65296
|
-
setAssetTitle(null);
|
|
65297
|
-
setAssetType(null);
|
|
65298
65219
|
return;
|
|
65299
65220
|
}
|
|
65300
|
-
const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}
|
|
65221
|
+
const cacheKey = `${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}`;
|
|
65301
65222
|
const cached = embedCache.get(cacheKey);
|
|
65302
65223
|
if (cached && cached.expiresAt > Date.now() / 1e3) {
|
|
65303
65224
|
setEmbedUrl(cached.url);
|
|
65304
65225
|
setIsLoading(false);
|
|
65305
65226
|
setError(null);
|
|
65306
|
-
setAssetTitle(cached.assetTitle);
|
|
65307
|
-
setAssetType(cached.assetType);
|
|
65308
65227
|
return;
|
|
65309
65228
|
}
|
|
65310
65229
|
const apiBaseUrl = backendUrl.replace(/\/api\/assistant-ui\/?$/, "");
|
|
@@ -65312,14 +65231,11 @@ function useAssetEmbed(assetId, options = {
|
|
|
65312
65231
|
(_a2 = abortRef.current) == null ? void 0 : _a2.abort();
|
|
65313
65232
|
const controller = new AbortController();
|
|
65314
65233
|
abortRef.current = controller;
|
|
65315
|
-
setEmbedUrl(null);
|
|
65316
65234
|
setIsLoading(true);
|
|
65317
65235
|
setError(null);
|
|
65318
|
-
setAssetTitle(null);
|
|
65319
|
-
setAssetType(null);
|
|
65320
65236
|
const headers = { "Content-Type": "application/json" };
|
|
65321
65237
|
if (token) {
|
|
65322
|
-
headers
|
|
65238
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
65323
65239
|
} else if (apiKey) {
|
|
65324
65240
|
headers["X-API-KEY"] = apiKey;
|
|
65325
65241
|
}
|
|
@@ -65339,31 +65255,17 @@ function useAssetEmbed(assetId, options = {
|
|
|
65339
65255
|
}
|
|
65340
65256
|
return res.json();
|
|
65341
65257
|
}).then((data) => {
|
|
65342
|
-
|
|
65343
|
-
|
|
65344
|
-
embedUrl: data.embed_url,
|
|
65345
|
-
embedSearchParams
|
|
65346
|
-
});
|
|
65347
|
-
embedCache.set(cacheKey, {
|
|
65348
|
-
url: resolvedEmbedUrl,
|
|
65349
|
-
expiresAt: data.expires_at,
|
|
65350
|
-
assetTitle: data.title ?? null,
|
|
65351
|
-
assetType: resolvedAssetType
|
|
65352
|
-
});
|
|
65353
|
-
setEmbedUrl(resolvedEmbedUrl);
|
|
65354
|
-
setAssetTitle(data.title ?? null);
|
|
65355
|
-
setAssetType(resolvedAssetType);
|
|
65258
|
+
embedCache.set(`${assetId}:${readOnly}:${token ?? apiKey ?? "anon"}`, { url: data.embed_url, expiresAt: data.expires_at });
|
|
65259
|
+
setEmbedUrl(data.embed_url);
|
|
65356
65260
|
setIsLoading(false);
|
|
65357
65261
|
}).catch((err) => {
|
|
65358
|
-
if (err.name === "AbortError")
|
|
65359
|
-
return;
|
|
65360
|
-
}
|
|
65262
|
+
if (err.name === "AbortError") return;
|
|
65361
65263
|
setError(err.message);
|
|
65362
65264
|
setIsLoading(false);
|
|
65363
65265
|
});
|
|
65364
65266
|
return () => controller.abort();
|
|
65365
|
-
}, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, token
|
|
65366
|
-
return { embedUrl, isLoading, error: error2
|
|
65267
|
+
}, [assetId, readOnly, expiresInSeconds, backendUrl, apiKey, token]);
|
|
65268
|
+
return { embedUrl, isLoading, error: error2 };
|
|
65367
65269
|
}
|
|
65368
65270
|
const ASSET_TYPE_CONFIG = {
|
|
65369
65271
|
presentation: { icon: Presentation, label: "Presentation" },
|
|
@@ -65373,28 +65275,13 @@ const ASSET_TYPE_CONFIG = {
|
|
|
65373
65275
|
unknown: { icon: File$1, label: "Asset" }
|
|
65374
65276
|
};
|
|
65375
65277
|
const AssetIframe = memo(
|
|
65376
|
-
({ tabId, tabName
|
|
65278
|
+
({ tabId, tabName }) => {
|
|
65377
65279
|
const { backendUrl, apiKey, token } = useAthenaConfig();
|
|
65378
|
-
const { embedUrl, isLoading, error: error2
|
|
65280
|
+
const { embedUrl, isLoading, error: error2 } = useAssetEmbed(tabId, {
|
|
65379
65281
|
backendUrl,
|
|
65380
65282
|
apiKey,
|
|
65381
|
-
token
|
|
65382
|
-
embedSearchParams
|
|
65283
|
+
token
|
|
65383
65284
|
});
|
|
65384
|
-
useEffect(() => {
|
|
65385
|
-
if (!assetTitle && !assetType) {
|
|
65386
|
-
return;
|
|
65387
|
-
}
|
|
65388
|
-
const nextName = assetTitle ?? tabName;
|
|
65389
|
-
const nextType = assetType ?? tabType;
|
|
65390
|
-
if (nextName === tabName && nextType === tabType) {
|
|
65391
|
-
return;
|
|
65392
|
-
}
|
|
65393
|
-
useAssetPanelStore.getState().openAsset(tabId, {
|
|
65394
|
-
name: nextName ?? void 0,
|
|
65395
|
-
type: nextType
|
|
65396
|
-
});
|
|
65397
|
-
}, [assetTitle, assetType, tabId, tabName, tabType]);
|
|
65398
65285
|
if (isLoading) {
|
|
65399
65286
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
65400
65287
|
/* @__PURE__ */ jsx(LoaderCircle, { className: "mx-auto size-6 animate-spin text-muted-foreground" }),
|
|
@@ -65479,15 +65366,7 @@ const PanelContent = ({
|
|
|
65479
65366
|
}
|
|
65480
65367
|
)
|
|
65481
65368
|
] }),
|
|
65482
|
-
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
65483
|
-
AssetIframe,
|
|
65484
|
-
{
|
|
65485
|
-
tabId: tab.id,
|
|
65486
|
-
tabName: tab.name,
|
|
65487
|
-
tabType: tab.type,
|
|
65488
|
-
embedSearchParams: tab.embedSearchParams
|
|
65489
|
-
}
|
|
65490
|
-
) })
|
|
65369
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(AssetIframe, { tabId: tab.id, tabName: tab.name }) })
|
|
65491
65370
|
]
|
|
65492
65371
|
},
|
|
65493
65372
|
tab.id
|
|
@@ -65497,15 +65376,7 @@ const PanelContent = ({
|
|
|
65497
65376
|
"div",
|
|
65498
65377
|
{
|
|
65499
65378
|
className: isActive2 ? "h-full w-full" : "hidden",
|
|
65500
|
-
children: /* @__PURE__ */ jsx(
|
|
65501
|
-
AssetIframe,
|
|
65502
|
-
{
|
|
65503
|
-
tabId: tab.id,
|
|
65504
|
-
tabName: tab.name,
|
|
65505
|
-
tabType: tab.type,
|
|
65506
|
-
embedSearchParams: tab.embedSearchParams
|
|
65507
|
-
}
|
|
65508
|
-
)
|
|
65379
|
+
children: /* @__PURE__ */ jsx(AssetIframe, { tabId: tab.id, tabName: tab.name })
|
|
65509
65380
|
},
|
|
65510
65381
|
tab.id
|
|
65511
65382
|
);
|