research-agent-ui 0.1.354 → 0.1.355
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/ArticleExtractPanel-B6tyR_bs.js +389 -0
- package/dist/ArticleExtractPanel-YlXZ8P18.cjs +2 -0
- package/dist/{ChatConversationThread-CEsCKbEo.js → ChatConversationThread-B70yZMw_.js} +38 -38
- package/dist/{ChatConversationThread-CPqjlfWV.cjs → ChatConversationThread-BDzlHmvK.cjs} +3 -3
- package/dist/components/ArticleReader/ArticleContent.d.ts +0 -2
- package/dist/components/ArticleReader/LexicalArticleViewer.d.ts +0 -3
- package/dist/components/ArticleReader/index.d.ts +0 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +4 -4
- package/dist/{src-Czo4Yrd2.js → src-Cgy6IAES.js} +790 -895
- package/dist/src-D7eu9lB9.cjs +34 -0
- package/dist/workspace.cjs +1 -1
- package/dist/workspace.mjs +87 -87
- package/package.json +12 -14
- package/dist/ArticleExtractPanel-BnRqqEL_.cjs +0 -2
- package/dist/ArticleExtractPanel-Dce2hQz6.js +0 -418
- package/dist/components/ArticleReader/ArticleOutline.d.ts +0 -7
- package/dist/components/ArticleReader/ArticleSidebarTabs.d.ts +0 -15
- package/dist/components/ArticleReader/articleOutline.d.ts +0 -29
- package/dist/src-DgR_99cQ.cjs +0 -34
package/dist/workspace.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import {
|
|
4
|
-
import { configureResearchAgentUI as L, researchAgentUIConfig as
|
|
5
|
-
import { a as
|
|
6
|
-
import { c as
|
|
7
|
-
import { useCallback as B, useEffect as V, useRef as
|
|
8
|
-
import { useSearchParams as
|
|
3
|
+
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, U as _, _ as v, a as y, b, c as x, d as S, et as C, f as w, g as T, h as E, i as D, j as O, k, l as ee, m as te, n as ne, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as re, x as ie, y as ae, z as oe } from "./src-Cgy6IAES.js";
|
|
4
|
+
import { configureResearchAgentUI as L, researchAgentUIConfig as se } from "./config.mjs";
|
|
5
|
+
import { a as ce, c as R, i as le, o as ue, s as de, u as z } from "./tooltip-Bl3IdX-I.js";
|
|
6
|
+
import { c as fe, o as pe, s as me } from "./dialog-Cufn2u50.js";
|
|
7
|
+
import { useCallback as B, useEffect as V, useRef as he, useState as H } from "react";
|
|
8
|
+
import { useSearchParams as ge } from "next/navigation";
|
|
9
9
|
import { jsx as U } from "react/jsx-runtime";
|
|
10
10
|
import W from "grab-url";
|
|
11
11
|
import { ReasonDocs as G } from "react-reason-editor/reason-docs";
|
|
12
|
-
import { themeActions as
|
|
13
|
-
import { localeActions as
|
|
14
|
-
import { Sidebar as
|
|
12
|
+
import { themeActions as _e } from "react-reason-editor/theme";
|
|
13
|
+
import { localeActions as ve } from "react-reason-editor/locale-bundle";
|
|
14
|
+
import { Sidebar as ye, SidebarContent as be } from "react-reason-editor-sidebar";
|
|
15
15
|
// src/workspace/page-tips.ts
|
|
16
16
|
function K(e) {
|
|
17
17
|
return e.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi, " ").replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -42,7 +42,7 @@ var q = async (e, t) => {
|
|
|
42
42
|
} catch {
|
|
43
43
|
return [];
|
|
44
44
|
}
|
|
45
|
-
}, Y = "/api/doc/google-docs", X = "application/vnd.google-apps.document", Z = "application/vnd.google-apps.spreadsheet",
|
|
45
|
+
}, Y = "/api/doc/google-docs", X = "application/vnd.google-apps.document", Z = "application/vnd.google-apps.spreadsheet", xe = "application/vnd.google-apps.presentation", Se = "application/vnd.google-apps.drawing", Q = "application/vnd.google-apps.folder", Ce = class extends Error {
|
|
46
46
|
needsReauth;
|
|
47
47
|
needsFolderAccess;
|
|
48
48
|
status;
|
|
@@ -50,30 +50,30 @@ var q = async (e, t) => {
|
|
|
50
50
|
super(e), this.name = "GoogleDriveError", this.status = t, this.needsReauth = !!n.needsReauth, this.needsFolderAccess = !!n.needsFolderAccess;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
async function
|
|
53
|
+
async function we(e) {
|
|
54
54
|
let t = await fetch(`${Y}${e}`, { credentials: "same-origin" }), n = {};
|
|
55
55
|
try {
|
|
56
56
|
n = await t.json();
|
|
57
57
|
} catch {}
|
|
58
|
-
if (!t.ok || n?.success === !1) throw new
|
|
58
|
+
if (!t.ok || n?.success === !1) throw new Ce(n?.error || `Google Drive request failed (${t.status})`, t.status, n);
|
|
59
59
|
return n;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
return e === X || e === "text/plain" || e === "text/markdown" ? "editor" : e === "application/pdf" || e === Z || e ===
|
|
61
|
+
function Te(e) {
|
|
62
|
+
return e === X || e === "text/plain" || e === "text/markdown" ? "editor" : e === "application/pdf" || e === Z || e === xe ? "pdf" : e === Se || e.startsWith("image/") ? "image" : "unsupported";
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Ee(e) {
|
|
65
65
|
if (e.mimeType === X) return "docx";
|
|
66
66
|
if (e.mimeType === Z) return "xlsx";
|
|
67
|
-
if (e.mimeType ===
|
|
68
|
-
if (e.mimeType ===
|
|
67
|
+
if (e.mimeType === xe) return "pptx";
|
|
68
|
+
if (e.mimeType === Se) return "png";
|
|
69
69
|
let t = e.name.lastIndexOf(".");
|
|
70
70
|
if (t > 0 && t < e.name.length - 1) return e.name.slice(t + 1).toLowerCase();
|
|
71
71
|
if (e.mimeType === "application/pdf") return "pdf";
|
|
72
72
|
let n = e.mimeType.split("/")[1];
|
|
73
73
|
return n && /^[a-z0-9]{2,5}$/.test(n) ? n : void 0;
|
|
74
74
|
}
|
|
75
|
-
var $ = (e, t) => `${e}:${t}`,
|
|
76
|
-
function
|
|
75
|
+
var $ = (e, t) => `${e}:${t}`, De = (e) => `${Y}/content?fileId=${encodeURIComponent(e)}`;
|
|
76
|
+
function Oe(e, t) {
|
|
77
77
|
let n = [], r = /* @__PURE__ */ new Set(), i = (e, t) => Number(t.mimeType === "application/vnd.google-apps.folder") - Number(e.mimeType === "application/vnd.google-apps.folder") || e.name.localeCompare(t.name, void 0, {
|
|
78
78
|
numeric: !0,
|
|
79
79
|
sensitivity: "base"
|
|
@@ -101,7 +101,7 @@ function Me(e, t) {
|
|
|
101
101
|
let i = $(e, t.id);
|
|
102
102
|
if (r.has(i)) continue;
|
|
103
103
|
r.add(i);
|
|
104
|
-
let o = t.parents?.find((e) => c.has(e)) ?? a.id, s = t.mimeType === Q, l = s ? "unsupported" :
|
|
104
|
+
let o = t.parents?.find((e) => c.has(e)) ?? a.id, s = t.mimeType === Q, l = s ? "unsupported" : Te(t.mimeType);
|
|
105
105
|
n.push({
|
|
106
106
|
id: i,
|
|
107
107
|
title: t.name,
|
|
@@ -114,8 +114,8 @@ function Me(e, t) {
|
|
|
114
114
|
fileId: t.id,
|
|
115
115
|
mimeType: t.mimeType,
|
|
116
116
|
view: l,
|
|
117
|
-
extension: s ? void 0 :
|
|
118
|
-
contentUrl: s || l === "unsupported" ? void 0 :
|
|
117
|
+
extension: s ? void 0 : Ee(t),
|
|
118
|
+
contentUrl: s || l === "unsupported" ? void 0 : De(t.id),
|
|
119
119
|
webViewLink: t.webViewLink
|
|
120
120
|
}
|
|
121
121
|
});
|
|
@@ -123,26 +123,26 @@ function Me(e, t) {
|
|
|
123
123
|
}
|
|
124
124
|
return n;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function ke(e) {
|
|
127
127
|
return e?.folders?.length ? e.folders : (e?.folderIds ?? []).map((e) => ({
|
|
128
128
|
id: e,
|
|
129
129
|
name: e === "root" ? "My Drive" : e
|
|
130
130
|
}));
|
|
131
131
|
}
|
|
132
|
-
async function
|
|
133
|
-
let t =
|
|
132
|
+
async function Ae(e) {
|
|
133
|
+
let t = ke(e.credentials);
|
|
134
134
|
if (t.length === 0) return [];
|
|
135
|
-
let n = await Promise.allSettled(t.map((e) =>
|
|
135
|
+
let n = await Promise.allSettled(t.map((e) => we(`/folder-tree?folderId=${encodeURIComponent(e.id)}`))), r = n.flatMap((e) => e.status === "fulfilled" ? [e.value] : []);
|
|
136
136
|
if (r.length === 0) throw n[0].reason;
|
|
137
|
-
return
|
|
137
|
+
return Oe(e.id, r);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function je(e) {
|
|
140
140
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
return e.split(/\r?\n\r?\n/).map((e) => e.trim()).filter(Boolean).map((e) => `<p>${
|
|
142
|
+
function Me(e) {
|
|
143
|
+
return e.split(/\r?\n\r?\n/).map((e) => e.trim()).filter(Boolean).map((e) => `<p>${je(e).replace(/\r?\n/g, "<br>")}</p>`).join("");
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function Ne(e) {
|
|
146
146
|
if (typeof DOMParser > "u") {
|
|
147
147
|
let t = e.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
|
148
148
|
return (t ? t[1] : e).replace(/<(script|style)[\s\S]*?<\/\1>/gi, "");
|
|
@@ -164,7 +164,7 @@ function Le(e) {
|
|
|
164
164
|
for (let e of Array.from(t.body.querySelectorAll("[class], [style], [id]"))) e.removeAttribute("class"), e.removeAttribute("style"), e.removeAttribute("id");
|
|
165
165
|
return t.body.innerHTML.trim();
|
|
166
166
|
}
|
|
167
|
-
async function
|
|
167
|
+
async function Pe(e) {
|
|
168
168
|
let t = e.external;
|
|
169
169
|
if (!t?.contentUrl) return "";
|
|
170
170
|
let n = await fetch(t.contentUrl, { credentials: "same-origin" });
|
|
@@ -173,108 +173,108 @@ async function Re(e) {
|
|
|
173
173
|
try {
|
|
174
174
|
e = await n.json();
|
|
175
175
|
} catch {}
|
|
176
|
-
throw new
|
|
176
|
+
throw new Ce(e?.error || `Couldn't load the file (${n.status})`, n.status, e);
|
|
177
177
|
}
|
|
178
178
|
let r = await n.text();
|
|
179
|
-
return t.mimeType === X ?
|
|
179
|
+
return t.mimeType === X ? Ne(r) : Me(r);
|
|
180
180
|
}
|
|
181
|
-
var
|
|
181
|
+
var Fe = {
|
|
182
182
|
canList: (e) => e.type === "gdocs",
|
|
183
|
-
listDocuments: (e) =>
|
|
184
|
-
loadDocumentContent:
|
|
183
|
+
listDocuments: (e) => Ae(e),
|
|
184
|
+
loadDocumentContent: Pe
|
|
185
185
|
};
|
|
186
186
|
// src/workspace/ResearchWorkspaceView.tsx
|
|
187
|
-
function
|
|
188
|
-
let { activeView: r, toggleToDocs: i, toggleToResearch: a, filesSidebarRequestId: o, requestFilesSidebar: s } =
|
|
187
|
+
function Ie({ SidebarComponent: e = ye, SidebarContentComponent: t = be, openSidebarEvent: n } = {}) {
|
|
188
|
+
let { activeView: r, toggleToDocs: i, toggleToResearch: a, filesSidebarRequestId: o, requestFilesSidebar: s } = b(), { chatTabs: c, activeChatId: u, openChat: d, newChat: f, closeChat: p, closeChats: m } = P(), { sendMessage: h } = z(), { signIn: g } = R(), v = ge(), [y, x] = H(null), [S, C] = H(null), [w, T] = H(!1), [E, D] = H(null);
|
|
189
189
|
V(() => {
|
|
190
190
|
if (n) return window.addEventListener(n, s), () => window.removeEventListener(n, s);
|
|
191
191
|
}, [n, s]), V(() => {
|
|
192
|
-
|
|
192
|
+
ve.setLang("en"), _e.setColor("default");
|
|
193
193
|
}, []);
|
|
194
|
-
let
|
|
194
|
+
let O = he(!1);
|
|
195
195
|
V(() => {
|
|
196
|
-
if (
|
|
197
|
-
|
|
198
|
-
let e =
|
|
199
|
-
e ? (
|
|
196
|
+
if (O.current) return;
|
|
197
|
+
O.current = !0;
|
|
198
|
+
let e = v.get("docs"), t = v.get("chat");
|
|
199
|
+
e ? (C(e), i()) : t && (d(t), a()), T(!0);
|
|
200
200
|
}, []), V(() => {
|
|
201
|
-
if (typeof window > "u" || !
|
|
201
|
+
if (typeof window > "u" || !w) return;
|
|
202
202
|
let e = new URL(window.location.href);
|
|
203
|
-
e.searchParams.set("chat", r === "research" ?
|
|
203
|
+
e.searchParams.set("chat", r === "research" ? u ?? "" : ""), e.searchParams.set("docs", r === "docs" ? y ?? "" : "");
|
|
204
204
|
let t = `${e.pathname}?${e.searchParams.toString()}${e.hash}`;
|
|
205
205
|
t !== `${window.location.pathname}${window.location.search}${window.location.hash}` && window.history.replaceState(null, "", t);
|
|
206
206
|
}, [
|
|
207
207
|
r,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
u,
|
|
209
|
+
y,
|
|
210
|
+
w
|
|
211
211
|
]);
|
|
212
|
-
let
|
|
212
|
+
let k = c.map((e) => ({
|
|
213
213
|
id: e.id,
|
|
214
214
|
title: e.title,
|
|
215
215
|
kind: "chat"
|
|
216
|
-
})),
|
|
217
|
-
|
|
218
|
-
},
|
|
219
|
-
let { closedWasActive: t, nextActiveId: n } = f(e);
|
|
220
|
-
t && !n && i();
|
|
221
|
-
}, k = (e) => {
|
|
216
|
+
})), ee = (e) => {
|
|
217
|
+
d(e), a();
|
|
218
|
+
}, te = (e) => {
|
|
222
219
|
let { closedWasActive: t, nextActiveId: n } = p(e);
|
|
223
220
|
t && !n && i();
|
|
221
|
+
}, ne = (e) => {
|
|
222
|
+
let { closedWasActive: t, nextActiveId: n } = m(e);
|
|
223
|
+
t && !n && i();
|
|
224
224
|
}, A = () => {
|
|
225
|
-
|
|
226
|
-
}, j = B((e) => (
|
|
225
|
+
f(), a();
|
|
226
|
+
}, j = B((e) => (d(e), a(), !0), [d, a]);
|
|
227
227
|
V(() => (L({ onOpenChat: j }), () => L({ onOpenChat: void 0 })), [j]);
|
|
228
|
-
let
|
|
229
|
-
|
|
230
|
-
}, [
|
|
228
|
+
let M = async (e, t) => q(e, K(t)), N = async (e, t) => J(e, K(t)), F = B((e) => {
|
|
229
|
+
f(), a(), D(e);
|
|
230
|
+
}, [f, a]);
|
|
231
231
|
V(() => {
|
|
232
|
-
|
|
232
|
+
E && u && (h(E), D(null));
|
|
233
233
|
}, [
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
E,
|
|
235
|
+
u,
|
|
236
|
+
h
|
|
237
237
|
]);
|
|
238
|
-
let
|
|
239
|
-
extraTabs:
|
|
240
|
-
activeExtraTabId: r === "research" ?
|
|
241
|
-
onExtraTabSelect:
|
|
242
|
-
onExtraTabClose:
|
|
243
|
-
onExtraTabsClose:
|
|
238
|
+
let I = {
|
|
239
|
+
extraTabs: k,
|
|
240
|
+
activeExtraTabId: r === "research" ? u ?? void 0 : void 0,
|
|
241
|
+
onExtraTabSelect: ee,
|
|
242
|
+
onExtraTabClose: te,
|
|
243
|
+
onExtraTabsClose: ne,
|
|
244
244
|
onExtraTabAdd: A,
|
|
245
245
|
onFileTabSelect: i,
|
|
246
|
-
initialDocId:
|
|
247
|
-
onActiveDocumentChange:
|
|
248
|
-
onGenerateTips:
|
|
249
|
-
onGenerateTopics:
|
|
250
|
-
onSearchTopic:
|
|
251
|
-
onSignIn:
|
|
252
|
-
fileSourceProvider:
|
|
246
|
+
initialDocId: S,
|
|
247
|
+
onActiveDocumentChange: x,
|
|
248
|
+
onGenerateTips: M,
|
|
249
|
+
onGenerateTopics: N,
|
|
250
|
+
onSearchTopic: F,
|
|
251
|
+
onSignIn: g,
|
|
252
|
+
fileSourceProvider: Fe
|
|
253
253
|
};
|
|
254
254
|
return r === "docs" ? /* @__PURE__ */ U(G, {
|
|
255
255
|
SidebarComponent: e,
|
|
256
256
|
SidebarContentComponent: t,
|
|
257
|
-
belowMainContent: /* @__PURE__ */ U(
|
|
257
|
+
belowMainContent: /* @__PURE__ */ U(_, {}),
|
|
258
258
|
openFilesSidebarSignal: o,
|
|
259
|
-
...
|
|
259
|
+
...I
|
|
260
260
|
}) : /* @__PURE__ */ U(G, {
|
|
261
261
|
SidebarComponent: e,
|
|
262
262
|
SidebarContentComponent: t,
|
|
263
|
-
mainContent: /* @__PURE__ */ U(
|
|
263
|
+
mainContent: /* @__PURE__ */ U(l, {}),
|
|
264
264
|
openFilesSidebarSignal: o,
|
|
265
|
-
...
|
|
265
|
+
...I
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
// src/workspace/QwkSearchWorkspaceApp.tsx
|
|
269
|
-
function
|
|
270
|
-
return /* @__PURE__ */ U(
|
|
269
|
+
function Le({ SidebarComponent: e, SidebarContentComponent: t, openSidebarEvent: n, ...r }) {
|
|
270
|
+
return /* @__PURE__ */ U(M, {
|
|
271
271
|
...r,
|
|
272
272
|
docsEnabled: !0,
|
|
273
|
-
children: /* @__PURE__ */ U(
|
|
273
|
+
children: /* @__PURE__ */ U(Ie, {
|
|
274
274
|
SidebarComponent: e,
|
|
275
275
|
SidebarContentComponent: t,
|
|
276
276
|
openSidebarEvent: n
|
|
277
277
|
})
|
|
278
278
|
});
|
|
279
279
|
}
|
|
280
|
-
export {
|
|
280
|
+
export { i as ARTICLE_TOOLBAR_SHORTCUTS, re as ArticleAIResponse, f as ArticleActionButtons, h as ArticleContent, g as ArticleFollowupQuestions, t as ArticlePanelHeader, a as ArticlePromptInput, m as ArticleReaderMount, x as CategoryDock, _ as ChatInputBox, e as ChatProvider, l as ChatWindow, N as CookieConsent, le as ExtractPanelProvider, n as HistoryDialogs, oe as HistoryDropdown, F as KokoroVoiceSelector, r as LexicalArticleViewer, ae as MainViewProvider, O as QWKSEARCH_DEFAULT_ORIGIN, ne as QwkSearchApp, M as QwkSearchProviders, Le as QwkSearchWorkspaceApp, Ie as ResearchWorkspaceView, I as SPOTLIGHT_LINKS, E as SPOTLIGHT_PREFIXES, de as SessionProvider, j as SpotlightPalette, ie as UnifiedMarkdown, ee as VoiceSettingsPanel, u as buildConnectStartUrl, pe as cn, L as configureResearchAgentUI, d as createQwkSearchConnectAuthClient, me as formatMessageTime, fe as formatTimeDifference, k as formatToolbarShortcut, q as getPageTips, p as getQwkSearchApiKey, J as getTopicSearches, K as htmlToPlainText, D as isChunkLoadError, o as isQwkSearchApiRequest, T as matchSpotlight, te as openSpotlight, v as parsePrefix, y as reloadForChunkError, se as researchAgentUIConfig, c as setQwkSearchApiKey, z as useChat, C as useChatState, P as useChatTabs, A as useChunkErrorReload, ce as useExtractPanel, s as useHistoryState, w as useKokoroTTS, b as useMainView, ue as useOptionalExtractPanel, R as useSession, S as useTextToSpeech };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "research-agent-ui",
|
|
3
3
|
"description": "The QwkSearch app UI: conversation window, article reader, search config, file uploads, chat history, and the app shell — exported both with and without the REASON editor and its sidebar",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.355",
|
|
5
5
|
"author": "vtempest",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -97,37 +97,35 @@
|
|
|
97
97
|
"@radix-ui/react-slot": "^1.5.0",
|
|
98
98
|
"@radix-ui/react-tooltip": "^1.4.1",
|
|
99
99
|
"ai": "^7.0.159",
|
|
100
|
-
"chat-agent-toolkit": "^1.2.
|
|
100
|
+
"chat-agent-toolkit": "^1.2.489",
|
|
101
101
|
"class-variance-authority": "^0.7.1",
|
|
102
102
|
"clsx": "^2.1.1",
|
|
103
103
|
"dompurify": "^3.4.17",
|
|
104
104
|
"drizzle-orm": "^0.45.4",
|
|
105
|
-
"extract-webpage": "^1.2.
|
|
106
|
-
"fumadocs-core": "^16.15.17",
|
|
107
|
-
"fumadocs-ui": "^16.15.17",
|
|
105
|
+
"extract-webpage": "^1.2.482",
|
|
108
106
|
"grab-url": "^3.0.9",
|
|
109
107
|
"html2canvas": "^1.4.1",
|
|
110
108
|
"kokoro-js": "^1.2.1",
|
|
111
|
-
"legal-terms-privacy-policy": "^0.1.
|
|
109
|
+
"legal-terms-privacy-policy": "^0.1.304",
|
|
112
110
|
"lucide-react": "^1.66.0",
|
|
113
111
|
"markdown-to-jsx": "^9.10.4",
|
|
114
112
|
"motion": "^14.9.0",
|
|
115
113
|
"quantum-sphere-loading-icon": "^1.0.6",
|
|
116
|
-
"qwksearch-api-client": "^1.0.
|
|
114
|
+
"qwksearch-api-client": "^1.0.299",
|
|
117
115
|
"react-icons": "^5.7.0",
|
|
118
116
|
"react-app-store-buttons": "^0.1.176",
|
|
119
117
|
"react-textarea-autosize": "^8.5.9",
|
|
120
|
-
"search-web-api": "^1.0.
|
|
121
|
-
"shadcn-app-dock": "^0.1.
|
|
118
|
+
"search-web-api": "^1.0.341",
|
|
119
|
+
"shadcn-app-dock": "^0.1.339",
|
|
122
120
|
"shadcn-theme-menu": "^1.1.74",
|
|
123
121
|
"sonner": "^2.0.8",
|
|
124
122
|
"streamdown": "^2.7.1",
|
|
125
123
|
"tailwind-merge": "^3.7.0",
|
|
126
|
-
"trending-news-api": "^0.1.
|
|
127
|
-
"education-playlists": "^0.1.
|
|
124
|
+
"trending-news-api": "^0.1.217",
|
|
125
|
+
"education-playlists": "^0.1.163",
|
|
128
126
|
"turndown": "^7.2.4",
|
|
129
127
|
"use-voice-control": "^0.1.235",
|
|
130
|
-
"use-weather-forecast": "^0.1.
|
|
128
|
+
"use-weather-forecast": "^0.1.441"
|
|
131
129
|
},
|
|
132
130
|
"devDependencies": {
|
|
133
131
|
"@cloudflare/workers-types": "^5.20261101.1",
|
|
@@ -144,8 +142,8 @@
|
|
|
144
142
|
"next": "^16.4.3",
|
|
145
143
|
"react": "^19.3.1",
|
|
146
144
|
"react-dom": "^19.3.1",
|
|
147
|
-
"react-reason-editor": "^1.0.
|
|
148
|
-
"react-reason-editor-sidebar": "^0.1.
|
|
145
|
+
"react-reason-editor": "^1.0.291",
|
|
146
|
+
"react-reason-editor-sidebar": "^0.1.346",
|
|
149
147
|
"search-autocomplete": "^0.1.0",
|
|
150
148
|
"storybook": "^10.6.5",
|
|
151
149
|
"tailwindcss": "^4.3.3",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./src-DgR_99cQ.cjs"),i=require("./config.cjs");let a=require("react");a=e.t(a,1);let o=require("react/jsx-runtime"),s=require("sonner"),c=require("qwksearch-api-client");var l=a.forwardRef(({className:e,...n},r)=>(0,o.jsx)(`span`,{ref:r,className:t.o(`absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap border-0`,e),style:{clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`},...n}));l.displayName=`VisuallyHidden`;function u(e){return e instanceof Error&&e.name===`AbortError`}async function ee(e,t){if(t.share)try{return await t.share(e),`shared`}catch(e){if(u(e))return`cancelled`}return await t.writeText(e.url),`copied`}var d=e=>{let{isOpen:u,url:d,searchText:te,suggestQuestions:f,panelWidth:ne,setPanelWidth:p,closePanel:re}=n.a(),{isAuthenticated:ie}=n.c(),{chatModelProvider:m}=n.u(),h=e.isOpen===void 0?u:e.isOpen,g=e.onClose||re,_=e.url||d,ae=e.searchText===void 0?te:e.searchText,[v,y]=(0,a.useState)(null),[b,oe]=(0,a.useState)([]),[se,x]=(0,a.useState)(!1),[ce,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(i.researchAgentUIConfig.defaultSummarizePrompt),[le,T]=(0,a.useState)(!1),[E,ue]=(0,a.useState)(!1),[D,de]=(0,a.useState)(!1),[O,fe]=(0,a.useState)(``),[k,pe]=(0,a.useState)(``),[me,A]=(0,a.useState)([]),[he,ge]=(0,a.useState)(``),[j,M]=(0,a.useState)(!1),[_e,N]=(0,a.useState)(!1),[P,F]=(0,a.useState)(!1),[ve,ye]=(0,a.useState)(!1),[be,xe]=(0,a.useState)(ne),[I,L]=(0,a.useState)(!1),[Se,R]=(0,a.useState)(!1),[z,B]=(0,a.useState)(1),[V,Ce]=(0,a.useState)(`questions`),[we,Te]=(0,a.useState)([]),H=(0,a.useId)(),U=(0,a.useRef)(null),Ee=(0,a.useRef)(null),W=(0,a.useRef)({}),G=.5,K=1.8,q=.1;(0,a.useEffect)(()=>{let e=parseFloat(localStorage.getItem(`articleFontScale`)||``);Number.isNaN(e)||B(Math.min(K,Math.max(G,e)))},[]);let J=e=>{let t=Math.min(K,Math.max(G,Math.round(e*100)/100));B(t);try{localStorage.setItem(`articleFontScale`,String(t))}catch(e){console.error(`Error storing article font scale:`,e)}},De=e=>{Ce(e),e===`questions`&&U.current?.scrollTo?.({top:0})},Y=()=>J(z+q),X=()=>J(z-q),Z=()=>J(1);(0,a.useEffect)(()=>{let e=()=>{ye(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{let e=e=>{if(!I)return;let t=window.innerWidth-e.clientX,n=Math.max(400,Math.min(t,window.innerWidth-100));xe(n),p(n)},t=()=>{L(!1)};return I&&(document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.cursor=`ew-resize`,document.body.style.userSelect=`none`),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[I,p]),(0,a.useEffect)(()=>{h&&_?(R(!1),Oe()):h||R(!1)},[h,_]);let Oe=async()=>{console.log(`[ArticleExtractPanel] Extracting URL:`,_);try{let e=new URL(_);if([/^https?:\/\/(www\.)?google\.[^/]+\/search/i,/^https?:\/\/(www\.)?bing\.com\/search/i,/^https?:\/\/(www\.)?duckduckgo\.com\/\?/i].some(e=>e.test(_))){s.toast.error(`Cannot extract articles from search result pages`),T(!1),R(!0);return}(e.pathname===`/`||e.pathname===``)&&(console.error(`[ArticleExtractPanel] URL is domain-only, missing article path:`,_),s.toast.error(`Invalid article URL - only domain provided`))}catch(e){console.error(`[ArticleExtractPanel] Invalid URL format:`,_,e)}T(!0);try{let{data:e}=await(0,c.getArticle)({query:{url:_}}),t=e?.article,n=t?.html?.replace(/<[^>]*>/g,``).trim()||``;t?.error||n.length<20?(document.dispatchEvent(new CustomEvent(`onInvokeChromeAPI`,{detail:{type:`extractURL`,url:_}})),await Promise.race([new Promise(e=>{let t=async n=>{window.removeEventListener(`onExtractionResult`,t);let{data:r}=await(0,c.getArticle)({query:{url:_}}),i=r?.article;i&&(y(i),i.followUpQuestions?.length>0?A(i.followUpQuestions):f&&(A([]),$(`suggest-followups`,{source:i}))),e()};window.addEventListener(`onExtractionResult`,t)}),new Promise(e=>setTimeout(e,1e4))])):(y(t),t?.followUpQuestions&&t.followUpQuestions.length>0?A(t.followUpQuestions):f&&t&&(A([]),$(`suggest-followups`,{source:t}))),ie&&ke()}catch(e){console.error(`[ArticleExtractPanel] Error extracting URL:`,e),s.toast.error(`Failed to load article`)}finally{T(!1),R(!0)}},ke=async()=>{try{let{data:e}=await(0,c.listFavorites)(),t=e?.favorites?.some(e=>e.url===_);M(!!t)}catch(e){console.error(`Error checking favorite status:`,e)}},Q=async()=>{if(v){N(!0);try{j?(await(0,c.removeFavorite)({query:{url:_}}),M(!1),s.toast.info(`Removed from favorites`)):(await(0,c.addFavorite)({body:{url:v.url||_,title:v.title,cite:v.cite,author:v.author,author_cite:v.author_cite,date:v.date,source:v.source,word_count:v.word_count,html:v.html}}),M(!0),s.toast.success(`Added to favorites`))}catch(e){console.error(`Error toggling favorite:`,e),s.toast.error(`Failed to toggle favorite`)}finally{N(!1)}}},Ae=()=>{if(m?.key&&m?.providerId)return m;try{let e=localStorage.getItem(`chatModelKey`)||``,t=localStorage.getItem(`chatModelProviderId`)||``;if(e&&t)return{key:e,providerId:t}}catch(e){console.error(`Error reading persisted chat model:`,e)}return m},$=async(e,{source:t=v,question:n=C}={})=>{if(!t)return;let r=Ae(),a=t.html?.replace(/<[^>]*>?/g,``).slice(0,i.researchAgentUIConfig.maxArticleLength),o=e===`question`,s=o?ue:de,l=o?pe:ge;s(!0),l(``);try{if(o){let e=[ae,n].filter(Boolean).join(`
|
|
2
|
-
`);if(!a||a.length===0)throw Error(`Article content is empty`);let{data:t,error:i}=await(0,c.articleQa)({body:{article:a,question:e,chatHistory:b.slice(-5),chatModel:r}});if(i){let e=i.details||i.error||i.message||`Article QA failed`;throw Error(e)}let o=t?.content||``;fe(o),oe(e=>[...e,{role:`user`,content:n,time:new Date().toISOString()},{role:`assistant`,content:o,time:new Date().toISOString()}]);try{await(0,c.updateArticle)({body:{url:_,question:n,answer:o}})}catch(e){console.error(`Error storing Q&A in cache:`,e)}}else{let e=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`);if(!a||a.length===0)throw Error(`Article content is empty`);let{data:t,error:n}=await(0,c.articleFollowups)({body:{article:a,chatHistory:b.slice(-5),maxQuestions:e,chatModel:r}});if(n){let e=n.details||n.error||n.message||`Article followups failed`;throw Error(e)}let i=t?.extract||[];A(i);try{await(0,c.updateArticle)({body:{url:_,followUpQuestions:i}})}catch(e){console.error(`Error storing follow-up questions in cache:`,e)}}}catch(e){console.error(`Error calling language API:`,e),l(e instanceof Error||typeof e==`object`&&e&&`message`in e?e.message:`Failed to get AI response`)}finally{s(!1)}},je=e=>{w(e),$(`question`,{question:e})},Me=async()=>{if(!v)return;let e=`${O}\n\n\n${v.cite||``}\n\n\n${v.html}`;try{await navigator.clipboard.writeText(e),x(!0),setTimeout(()=>x(!1),2e3)}catch(e){console.error(`Failed to copy to clipboard:`,e)}},Ne=async()=>{let e=v?.url||_;if(e)try{await ee({title:v?.title,text:v?.cite,url:e},{share:typeof navigator<`u`&&navigator.share?e=>navigator.share(e):void 0,writeText:e=>navigator.clipboard.writeText(e)})===`copied`&&(S(!0),setTimeout(()=>S(!1),2e3))}catch(e){console.error(`Failed to share article:`,e)}};W.current={ask:()=>$(`question`),suggest:()=>$(`suggest-followups`),copy:Me,highlight:()=>F(e=>!e),favorite:Q,open:()=>{let e=v?.url||_;e&&window.open(e,`_blank`,`noopener,noreferrer`)},zoomIn:Y,zoomOut:X,zoomReset:Z,close:g},(0,a.useEffect)(()=>{if(!h)return;let e=e=>/^[a-z]$/.test(e)?`Key${e.toUpperCase()}`:/^[0-9]$/.test(e)?`Digit${e}`:e===`-`?`Minus`:e===`=`?`Equal`:e,t={};Object.keys(r.j).forEach(n=>{let{alt:i,key:a}=r.j[n];i&&(t[e(a.toLowerCase())]=n)});let n=e=>{if(e.key===`Escape`){W.current.close?.();return}if(!e.altKey||e.ctrlKey||e.metaKey)return;let n=e.target;if(n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable))return;let r=t[e.code];if(!r)return;let i=W.current[r];i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[h]);let Pe=()=>(0,o.jsxs)(`div`,{className:`flex h-full flex-col bg-background shadow-xl`,children:[(0,o.jsx)(`div`,{className:`shrink-0 border-b border-border bg-background/95 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/80`,children:(0,o.jsx)(r.M,{isLoadingAI:E,isLoadingFollowups:D,isLoadingFavorite:_e,isFavorited:j,isHighlightMode:P,articleUrl:v?.url||_,fontScale:z,onAskClick:()=>$(`question`),onSuggestClick:()=>$(`suggest-followups`),onCopyClick:Me,onShareClick:Ne,onFavoriteClick:Q,onHighlightToggle:()=>F(!P),onZoomIn:Y,onZoomOut:X,onZoomReset:Z,onClose:g})}),(0,o.jsx)(`div`,{className:`shrink-0 px-4 pt-2`,children:(0,o.jsx)(r.S,{value:V,onValueChange:De,idBase:H})}),(0,o.jsx)(`div`,{role:`tabpanel`,id:r.C(H,`outline`).panel,"aria-labelledby":r.C(H,`outline`).tab,hidden:V!==`outline`,className:`flex max-h-[40%] min-h-0 shrink-0 flex-col border-b border-border px-4`,children:V===`outline`&&(0,o.jsx)(r.w,{items:we})}),(0,o.jsx)(`div`,{ref:U,className:`flex-1 overflow-y-auto`,children:(0,o.jsxs)(`div`,{className:`p-4 space-y-6`,children:[(0,o.jsxs)(`div`,{className:`space-y-4`,children:[se&&(0,o.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Copied!`}),ce&&(0,o.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Link copied!`}),(0,o.jsxs)(`div`,{role:`tabpanel`,id:r.C(H,`questions`).panel,"aria-labelledby":r.C(H,`questions`).tab,hidden:V!==`questions`,className:`space-y-4`,children:[(0,o.jsx)(r.A,{value:C,onChange:w,onSubmit:()=>$(`question`)}),(0,o.jsx)(r.k,{questions:me,isLoading:D,error:he,onQuestionClick:je})]}),b.length>0&&(0,o.jsx)(`div`,{className:`space-y-4`,children:b.map((e,t)=>(0,o.jsx)(`div`,{className:`space-y-2`,children:e.role===`user`?(0,o.jsxs)(`div`,{className:`bg-primary/10 border border-primary/20 rounded-lg p-3`,children:[(0,o.jsx)(`div`,{className:`text-xs font-semibold text-primary mb-1`,children:`Your Question`}),(0,o.jsx)(`div`,{className:`text-sm text-foreground`,children:e.content})]}):(0,o.jsxs)(`div`,{className:`bg-muted rounded-lg shadow-md p-4`,children:[(0,o.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-2`,children:`AI Response`}),(0,o.jsx)(`div`,{className:`text-sm`,dangerouslySetInnerHTML:{__html:e.content}})]})},t))}),(E||O&&b.length===0)&&(0,o.jsx)(r.O,{response:O,isLoading:E,error:k}),k&&!E&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:k})]}),v&&(0,o.jsx)(r.T,{article:v,isHighlightMode:P,fontScale:z,onOutlineChange:Te})]})})]});return!h||!Se?null:ve?(0,o.jsxs)(`div`,{className:`fixed top-0 right-0 h-screen z-40 transition-all duration-300`,style:{width:`${be}px`},children:[(0,o.jsx)(`div`,{ref:Ee,onMouseDown:()=>L(!0),className:`absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-primary bg-transparent transition-colors z-50`,style:{touchAction:`none`},children:(0,o.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-12 rounded-full bg-muted-foreground opacity-50 hover:opacity-100 transition-opacity`})}),Pe()]}):(0,o.jsx)(t.t,{open:h,onOpenChange:e=>!e&&g(),children:(0,o.jsxs)(t.n,{className:`pointer-events-auto fixed inset-0 !top-0 !left-0 !translate-x-0 !translate-y-0 h-full w-full max-w-none p-0 m-0 rounded-none border-0 overflow-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right`,hideCloseButton:!0,children:[(0,o.jsx)(l,{children:(0,o.jsx)(t.i,{children:`Article Details`})}),(0,o.jsx)(`div`,{className:`h-full overflow-y-auto`,children:Pe()})]})})};exports.default=d;
|