research-agent-ui 0.1.294 → 0.1.296
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-D_y16YHG.js → ArticleExtractPanel-BPNXuezE.js} +1 -1
- package/dist/{ArticleExtractPanel-25tRTnpl.cjs → ArticleExtractPanel-DAPLUpyx.cjs} +1 -1
- package/dist/{ChatConversationThread-BoNH0wvs.cjs → ChatConversationThread-D1RR0Bcx.cjs} +2 -2
- package/dist/{ChatConversationThread-BIJ8aNug.js → ChatConversationThread-DMPdu2sr.js} +2 -2
- package/dist/api.cjs +6 -6
- package/dist/api.mjs +304 -66
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-GPr1ceY8.js → src-BqV2Vwpv.js} +912 -702
- package/dist/src-Ckb1ciEL.cjs +34 -0
- package/dist/workspace.cjs +1 -1
- package/dist/workspace.mjs +1 -1
- package/package.json +14 -14
- package/dist/src-ebmQu_if.cjs +0 -34
package/dist/api.mjs
CHANGED
|
@@ -3,12 +3,14 @@ import t from "chat-agent-toolkit/models/registry";
|
|
|
3
3
|
import { and as n, count as r, eq as i, inArray as a, like as o, max as s, or as c, sql as l } from "drizzle-orm";
|
|
4
4
|
import u from "chat-agent-toolkit/tools/search/titleGeneratorAgent";
|
|
5
5
|
import { searchSearxng as d, searchWeb as f } from "search-web-api/search/public-searxng";
|
|
6
|
-
import
|
|
7
|
-
import m from "
|
|
8
|
-
import
|
|
9
|
-
import
|
|
6
|
+
import p from "fuse.js";
|
|
7
|
+
import { parse as m } from "tldts";
|
|
8
|
+
import h from "domain-rank/data/domain-rank-merged.json";
|
|
9
|
+
import g from "chat-agent-toolkit/tools/search/suggestionGeneratorAgent";
|
|
10
|
+
import { testProviderModels as _ } from "chat-agent-toolkit/config/model-tester";
|
|
11
|
+
import { LANGUAGE_MODELS as v } from "chat-agent-toolkit/config/language-models-database";
|
|
10
12
|
// src/api/handlers/article-followups.ts
|
|
11
|
-
function
|
|
13
|
+
function y(n) {
|
|
12
14
|
return async (n) => {
|
|
13
15
|
try {
|
|
14
16
|
let { article: r, chatHistory: i = [], maxQuestions: a = 5, chatModel: o } = await n.json();
|
|
@@ -44,7 +46,7 @@ Generate ${a} follow-up questions that would help readers dive deeper into this
|
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
// src/api/handlers/page-tips.ts
|
|
47
|
-
function
|
|
49
|
+
function b(n) {
|
|
48
50
|
return async (n) => {
|
|
49
51
|
try {
|
|
50
52
|
let { title: r = "", content: i, maxTips: a = 4, chatModel: o } = await n.json();
|
|
@@ -80,7 +82,7 @@ Generate ${a} short tips about this page.`, { text: d } = await e({
|
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
// src/api/handlers/topic-searches.ts
|
|
83
|
-
function
|
|
85
|
+
function x(n) {
|
|
84
86
|
return async (n) => {
|
|
85
87
|
try {
|
|
86
88
|
let { title: r = "", content: i, maxTopics: a = 4, chatModel: o } = await n.json();
|
|
@@ -116,7 +118,7 @@ Generate ${a} short related search queries for this page.`, { text: d } = await
|
|
|
116
118
|
};
|
|
117
119
|
}
|
|
118
120
|
// src/api/handlers/article-qa.ts
|
|
119
|
-
function
|
|
121
|
+
function ee(n) {
|
|
120
122
|
return async (n) => {
|
|
121
123
|
try {
|
|
122
124
|
let { article: r, question: i, chatHistory: a = [], chatModel: o } = await n.json();
|
|
@@ -152,7 +154,7 @@ Please provide a helpful answer based on the article content above.`, { text: d
|
|
|
152
154
|
};
|
|
153
155
|
}
|
|
154
156
|
// src/api/handlers/chats.ts
|
|
155
|
-
function
|
|
157
|
+
function te(e) {
|
|
156
158
|
let { chats: t, messages: o } = e.schema;
|
|
157
159
|
return {
|
|
158
160
|
GET: async (a) => {
|
|
@@ -189,7 +191,7 @@ function x(e) {
|
|
|
189
191
|
}
|
|
190
192
|
};
|
|
191
193
|
}
|
|
192
|
-
function
|
|
194
|
+
function ne(e) {
|
|
193
195
|
let { chats: t, messages: r } = e.schema;
|
|
194
196
|
return {
|
|
195
197
|
GET: async (n, { params: a }) => {
|
|
@@ -222,7 +224,7 @@ function ee(e) {
|
|
|
222
224
|
}
|
|
223
225
|
};
|
|
224
226
|
}
|
|
225
|
-
function
|
|
227
|
+
function re(e) {
|
|
226
228
|
let { chats: t, messages: r } = e.schema;
|
|
227
229
|
return { GET: async (a) => {
|
|
228
230
|
try {
|
|
@@ -255,7 +257,7 @@ function S(e) {
|
|
|
255
257
|
}
|
|
256
258
|
} };
|
|
257
259
|
}
|
|
258
|
-
function
|
|
260
|
+
function ie(e) {
|
|
259
261
|
let { chats: t } = e.schema;
|
|
260
262
|
return { POST: async (n) => {
|
|
261
263
|
try {
|
|
@@ -294,7 +296,7 @@ function C(e) {
|
|
|
294
296
|
} };
|
|
295
297
|
}
|
|
296
298
|
// src/api/handlers/chat-title.ts
|
|
297
|
-
function
|
|
299
|
+
function ae(e) {
|
|
298
300
|
let { chats: n } = e.schema;
|
|
299
301
|
return { POST: async (r) => {
|
|
300
302
|
try {
|
|
@@ -319,22 +321,22 @@ function w(e) {
|
|
|
319
321
|
} };
|
|
320
322
|
}
|
|
321
323
|
// src/api/handlers/messages.ts
|
|
322
|
-
var
|
|
324
|
+
var oe = [
|
|
323
325
|
"assistant",
|
|
324
326
|
"user",
|
|
325
327
|
"source",
|
|
326
328
|
"suggestion"
|
|
327
329
|
];
|
|
328
|
-
function
|
|
330
|
+
function S(e) {
|
|
329
331
|
let t = [], n = e;
|
|
330
332
|
for (let e = 0; n != null && e < 5; e++) t.push(n instanceof Error ? n.message : String(n)), n = n instanceof Error ? n.cause : void 0;
|
|
331
333
|
return t.join(" <- caused by: ");
|
|
332
334
|
}
|
|
333
|
-
function
|
|
335
|
+
function se(e) {
|
|
334
336
|
return { POST: async (t) => {
|
|
335
337
|
try {
|
|
336
338
|
let n = e.getDB(), r = await e.requireUserId(), { chatId: i, messageId: a, role: o, suggestions: s, content: c, sources: l } = await t.json();
|
|
337
|
-
return !i || !a || !o ? Response.json({ message: "Missing required fields" }, { status: 400 }) :
|
|
339
|
+
return !i || !a || !o ? Response.json({ message: "Missing required fields" }, { status: 400 }) : oe.includes(o) ? (await n.insert(e.messagesSchema).values({
|
|
338
340
|
chatId: i,
|
|
339
341
|
userId: r,
|
|
340
342
|
messageId: a,
|
|
@@ -345,12 +347,12 @@ function D(e) {
|
|
|
345
347
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
346
348
|
}), Response.json({ message: "Message saved successfully" }, { status: 200 })) : Response.json({ message: `Invalid role: ${o}` }, { status: 400 });
|
|
347
349
|
} catch (e) {
|
|
348
|
-
return console.error("Error saving message:",
|
|
350
|
+
return console.error("Error saving message:", S(e)), Response.json({ message: "Failed to save message" }, { status: 500 });
|
|
349
351
|
}
|
|
350
352
|
} };
|
|
351
353
|
}
|
|
352
354
|
// src/api/handlers/providers.ts
|
|
353
|
-
function
|
|
355
|
+
function ce(e) {
|
|
354
356
|
return {
|
|
355
357
|
GET: async (n) => {
|
|
356
358
|
try {
|
|
@@ -380,7 +382,7 @@ function O(e) {
|
|
|
380
382
|
}
|
|
381
383
|
};
|
|
382
384
|
}
|
|
383
|
-
function
|
|
385
|
+
function C() {
|
|
384
386
|
return {
|
|
385
387
|
DELETE: async (e, { params: n }) => {
|
|
386
388
|
try {
|
|
@@ -402,7 +404,7 @@ function k() {
|
|
|
402
404
|
}
|
|
403
405
|
};
|
|
404
406
|
}
|
|
405
|
-
function
|
|
407
|
+
function le() {
|
|
406
408
|
return {
|
|
407
409
|
POST: async (e, { params: n }) => {
|
|
408
410
|
try {
|
|
@@ -423,7 +425,7 @@ function A() {
|
|
|
423
425
|
};
|
|
424
426
|
}
|
|
425
427
|
// src/api/handlers/mcpservers.ts
|
|
426
|
-
function
|
|
428
|
+
function ue(e) {
|
|
427
429
|
return {
|
|
428
430
|
GET: async (t) => {
|
|
429
431
|
try {
|
|
@@ -445,7 +447,7 @@ function j(e) {
|
|
|
445
447
|
}
|
|
446
448
|
};
|
|
447
449
|
}
|
|
448
|
-
function
|
|
450
|
+
function de(e) {
|
|
449
451
|
return {
|
|
450
452
|
DELETE: async (t, { params: n }) => {
|
|
451
453
|
try {
|
|
@@ -467,7 +469,7 @@ function M(e) {
|
|
|
467
469
|
}
|
|
468
470
|
};
|
|
469
471
|
}
|
|
470
|
-
function
|
|
472
|
+
function fe(e) {
|
|
471
473
|
return { POST: async (t, { params: n }) => {
|
|
472
474
|
try {
|
|
473
475
|
let { enabled: r } = await t.json(), { id: i } = await n;
|
|
@@ -480,7 +482,7 @@ function N(e) {
|
|
|
480
482
|
} };
|
|
481
483
|
}
|
|
482
484
|
// src/api/handlers/search.ts
|
|
483
|
-
var
|
|
485
|
+
var pe = {
|
|
484
486
|
tech: {
|
|
485
487
|
query: [
|
|
486
488
|
"technology news",
|
|
@@ -546,7 +548,7 @@ var te = {
|
|
|
546
548
|
]
|
|
547
549
|
}
|
|
548
550
|
};
|
|
549
|
-
function
|
|
551
|
+
function me(e = {}) {
|
|
550
552
|
let t = e.searxngDomain ?? "https://search.qwksearch.com";
|
|
551
553
|
return { GET: async (e) => {
|
|
552
554
|
let n = new URL(e.url).searchParams, r = n.get("q"), i = n.get("cat") || "general", a = parseInt(n.get("page") || "1", 10), o = Number.isFinite(a) && a > 0 ? a : 1, s = n.get("lang") || "en-US", c = n.get("safesearch") === "true", l = n.get("recency") || void 0, u = n.get("publicInstances") === "true";
|
|
@@ -594,10 +596,10 @@ function P(e = {}) {
|
|
|
594
596
|
}
|
|
595
597
|
} };
|
|
596
598
|
}
|
|
597
|
-
function
|
|
599
|
+
function he() {
|
|
598
600
|
return { GET: async (e) => {
|
|
599
601
|
try {
|
|
600
|
-
let t = new URL(e.url).searchParams, n = t.get("mode") || "normal", r =
|
|
602
|
+
let t = new URL(e.url).searchParams, n = t.get("mode") || "normal", r = pe[t.get("topic") || "tech"], i = [];
|
|
601
603
|
if (n === "normal") {
|
|
602
604
|
let e = /* @__PURE__ */ new Set();
|
|
603
605
|
i = (await Promise.all(r.links.flatMap((e) => r.query.map(async (t) => (await d(`site:${e} ${t}`, {
|
|
@@ -619,13 +621,249 @@ function F() {
|
|
|
619
621
|
}
|
|
620
622
|
} };
|
|
621
623
|
}
|
|
624
|
+
// ../search-autocomplete/dist/index.mjs
|
|
625
|
+
async function w(e, t, n = {}) {
|
|
626
|
+
let r = t.fetch ?? fetch, i = new AbortController(), a = setTimeout(() => i.abort(/* @__PURE__ */ Error(`Timed out after ${t.timeoutMs ?? 3e3}ms`)), t.timeoutMs ?? 3e3), o = () => i.abort(t.signal?.reason);
|
|
627
|
+
t.signal?.aborted && o(), t.signal?.addEventListener("abort", o, { once: !0 });
|
|
628
|
+
try {
|
|
629
|
+
let t = await r(e, {
|
|
630
|
+
headers: {
|
|
631
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
|
632
|
+
...n
|
|
633
|
+
},
|
|
634
|
+
signal: i.signal
|
|
635
|
+
});
|
|
636
|
+
if (!t.ok) throw Error(`HTTP ${t.status} from ${new URL(e).hostname}`);
|
|
637
|
+
return await t.text();
|
|
638
|
+
} finally {
|
|
639
|
+
clearTimeout(a), t.signal?.removeEventListener("abort", o);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function T(e) {
|
|
643
|
+
let t = JSON.parse(e);
|
|
644
|
+
return Array.isArray(t) && Array.isArray(t[1]) ? t[1].filter((e) => typeof e == "string") : [];
|
|
645
|
+
}
|
|
646
|
+
var ge = {
|
|
647
|
+
amp: "&",
|
|
648
|
+
lt: "<",
|
|
649
|
+
gt: ">",
|
|
650
|
+
quot: "\"",
|
|
651
|
+
apos: "'",
|
|
652
|
+
nbsp: " "
|
|
653
|
+
};
|
|
654
|
+
function _e(e) {
|
|
655
|
+
return e.replace(/<[^>]*>/g, "").replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (e, t) => {
|
|
656
|
+
if (t[0] === "#") {
|
|
657
|
+
let n = t[1] === "x" || t[1] === "X" ? parseInt(t.slice(2), 16) : parseInt(t.slice(1), 10);
|
|
658
|
+
return Number.isFinite(n) ? String.fromCodePoint(n) : e;
|
|
659
|
+
}
|
|
660
|
+
return ge[t.toLowerCase()] ?? e;
|
|
661
|
+
}).trim();
|
|
662
|
+
}
|
|
663
|
+
function E(e = "en-US") {
|
|
664
|
+
return e.split(/[-_]/)[0].toLowerCase();
|
|
665
|
+
}
|
|
666
|
+
var D = async (e, t = {}) => {
|
|
667
|
+
let n = new URLSearchParams({
|
|
668
|
+
ie: "utf-8",
|
|
669
|
+
json: "1",
|
|
670
|
+
prod: "pc",
|
|
671
|
+
wd: e
|
|
672
|
+
}), r = JSON.parse(await w(`https://www.baidu.com/sugrec?${n}`, t));
|
|
673
|
+
return Array.isArray(r?.g) ? r.g.map((e) => e.q) : [];
|
|
674
|
+
}, O = async (e, t = {}) => T(await w(`https://api.bing.com/osjson.aspx?${new URLSearchParams({
|
|
675
|
+
query: e,
|
|
676
|
+
mkt: t.locale ?? "en-US"
|
|
677
|
+
})}`, t)), k = async (e, t = {}) => T(await w(`https://search.brave.com/api/suggest?${new URLSearchParams({ q: e })}`, t, { Cookie: "country=all" })), A = async (e, t = {}) => {
|
|
678
|
+
let n = (t.locale ?? "en-US").toLowerCase().split(/[-_]/).reverse().join("-");
|
|
679
|
+
return T(await w(`https://duckduckgo.com/ac/?type=list&${new URLSearchParams({
|
|
680
|
+
q: e,
|
|
681
|
+
kl: n
|
|
682
|
+
})}`, t));
|
|
683
|
+
}, j = {
|
|
684
|
+
de: "google.de",
|
|
685
|
+
fr: "google.fr",
|
|
686
|
+
es: "google.es",
|
|
687
|
+
it: "google.it",
|
|
688
|
+
nl: "google.nl",
|
|
689
|
+
pt: "google.pt",
|
|
690
|
+
ru: "google.ru",
|
|
691
|
+
ja: "google.co.jp",
|
|
692
|
+
zh: "google.com.hk",
|
|
693
|
+
ko: "google.co.kr"
|
|
694
|
+
}, M = async (e, t = {}) => {
|
|
695
|
+
let n = E(t.locale), r = new URLSearchParams({
|
|
696
|
+
q: e,
|
|
697
|
+
client: "gws-wiz",
|
|
698
|
+
hl: n
|
|
699
|
+
}), i = await w(`https://${j[n] ?? "google.com"}/complete/search?${r}`, t), a = i.indexOf("["), o = i.lastIndexOf("]") + 1;
|
|
700
|
+
if (a < 0 || o <= a) return [];
|
|
701
|
+
let s = JSON.parse(i.slice(a, o));
|
|
702
|
+
return Array.isArray(s?.[0]) ? s[0].map((e) => typeof e?.[0] == "string" ? _e(e[0]) : "").filter(Boolean) : [];
|
|
703
|
+
}, N = async (e, t = {}) => {
|
|
704
|
+
let n = new URLSearchParams({
|
|
705
|
+
q: e,
|
|
706
|
+
locale: (t.locale ?? "en-US").replace("-", "_"),
|
|
707
|
+
version: "2"
|
|
708
|
+
}), r = JSON.parse(await w(`https://api.qwant.com/v3/suggest?${n}`, t));
|
|
709
|
+
return r?.status === "success" && Array.isArray(r?.data?.items) ? r.data.items.map((e) => e.value) : [];
|
|
710
|
+
}, P = {
|
|
711
|
+
da: "dansk",
|
|
712
|
+
de: "deutsch",
|
|
713
|
+
en: "english",
|
|
714
|
+
es: "espanol",
|
|
715
|
+
fr: "francais",
|
|
716
|
+
nb: "norsk",
|
|
717
|
+
nl: "nederlands",
|
|
718
|
+
pl: "polski",
|
|
719
|
+
pt: "portugues",
|
|
720
|
+
sv: "svenska"
|
|
721
|
+
}, F = async (e, t = {}) => T(await w(`https://www.startpage.com/suggestions?${new URLSearchParams({
|
|
722
|
+
q: e,
|
|
723
|
+
format: "opensearch",
|
|
724
|
+
segment: "startpage.defaultffx",
|
|
725
|
+
lui: P[E(t.locale)] ?? "english"
|
|
726
|
+
})}`, t)), I = /* @__PURE__ */ new Set([
|
|
727
|
+
"en",
|
|
728
|
+
"de",
|
|
729
|
+
"fr",
|
|
730
|
+
"es",
|
|
731
|
+
"it",
|
|
732
|
+
"nl",
|
|
733
|
+
"pt",
|
|
734
|
+
"ru",
|
|
735
|
+
"ja",
|
|
736
|
+
"zh",
|
|
737
|
+
"ar",
|
|
738
|
+
"ko"
|
|
739
|
+
]), L = {
|
|
740
|
+
baidu: D,
|
|
741
|
+
bing: O,
|
|
742
|
+
brave: k,
|
|
743
|
+
duckduckgo: A,
|
|
744
|
+
google: M,
|
|
745
|
+
qwant: N,
|
|
746
|
+
startpage: F,
|
|
747
|
+
wikipedia: async (e, t = {}) => {
|
|
748
|
+
let n = E(t.locale), r = new URLSearchParams({
|
|
749
|
+
action: "opensearch",
|
|
750
|
+
format: "json",
|
|
751
|
+
formatversion: "2",
|
|
752
|
+
search: e,
|
|
753
|
+
namespace: "0",
|
|
754
|
+
limit: "10"
|
|
755
|
+
});
|
|
756
|
+
return T(await w(`https://${`${I.has(n) ? n : "en"}.wikipedia.org`}/w/api.php?${r}`, t));
|
|
757
|
+
},
|
|
758
|
+
yandex: async (e, t = {}) => T(await w(`https://suggest.yandex.com/suggest-ff.cgi?${new URLSearchParams({ part: e })}`, t))
|
|
759
|
+
};
|
|
760
|
+
Object.keys(L);
|
|
761
|
+
function ve(e) {
|
|
762
|
+
return Object.prototype.hasOwnProperty.call(L, e);
|
|
763
|
+
}
|
|
764
|
+
var ye = "google", be = 3;
|
|
765
|
+
function R(e) {
|
|
766
|
+
let t = e?.trim().toLowerCase();
|
|
767
|
+
return t === "ddg" ? "duckduckgo" : t && ve(t) ? t : ye;
|
|
768
|
+
}
|
|
769
|
+
async function z(e, t = {}) {
|
|
770
|
+
let n = R(t.engine);
|
|
771
|
+
try {
|
|
772
|
+
return await L[n](e, t);
|
|
773
|
+
} catch (e) {
|
|
774
|
+
return t.signal?.aborted || console.error(`Autocomplete engine '${n}' failed:`, e), [];
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
async function xe(e, t = {}) {
|
|
778
|
+
let n = (e) => Array.from(new Set(e)), r = await z(e, t);
|
|
779
|
+
if (r.length > 0) return n(r);
|
|
780
|
+
let i = e.split(/\s+/).filter(Boolean), a = Math.min(be, i.length - 1);
|
|
781
|
+
for (let n = a; n >= 1; n--) {
|
|
782
|
+
if (t.signal?.aborted) return [];
|
|
783
|
+
let r = i.slice(-n).join(" "), a = i.slice(0, -n).join(" "), o = await z(r, t), s = /* @__PURE__ */ new Set();
|
|
784
|
+
for (let t of o) {
|
|
785
|
+
let n = a ? `${a} ${t}` : t;
|
|
786
|
+
n.toLowerCase() !== e.toLowerCase() && s.add(n);
|
|
787
|
+
}
|
|
788
|
+
if (s.size > 0) return Array.from(s);
|
|
789
|
+
}
|
|
790
|
+
return [];
|
|
791
|
+
}
|
|
792
|
+
// ../search-autocomplete/dist/server.mjs
|
|
793
|
+
var Se = 3, B = null;
|
|
794
|
+
function Ce() {
|
|
795
|
+
if (!B) {
|
|
796
|
+
let e = Object.entries(h).map(([e, t]) => ({
|
|
797
|
+
domain: e,
|
|
798
|
+
name: typeof t?.[0] == "string" ? t[0] : "",
|
|
799
|
+
rank: typeof t?.[1] == "number" ? t[1] : 2 ** 53 - 1
|
|
800
|
+
}));
|
|
801
|
+
B = new p(e, {
|
|
802
|
+
keys: [{
|
|
803
|
+
name: "name",
|
|
804
|
+
weight: .6
|
|
805
|
+
}, {
|
|
806
|
+
name: "domain",
|
|
807
|
+
weight: .4
|
|
808
|
+
}],
|
|
809
|
+
threshold: .1,
|
|
810
|
+
ignoreLocation: !0,
|
|
811
|
+
includeScore: !0,
|
|
812
|
+
minMatchCharLength: 3
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
return B;
|
|
816
|
+
}
|
|
817
|
+
function V(e, t, n) {
|
|
818
|
+
return {
|
|
819
|
+
domain: e,
|
|
820
|
+
name: t,
|
|
821
|
+
favicon: `https://www.google.com/s2/favicons?domain=${encodeURIComponent(e)}&sz=64`,
|
|
822
|
+
rank: n
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
function we(e) {
|
|
826
|
+
let t = m(e);
|
|
827
|
+
return t.domain && t.isIcann ? t.hostname : null;
|
|
828
|
+
}
|
|
829
|
+
function Te(e) {
|
|
830
|
+
let t = e.split(/\s+/).filter(Boolean), n = t[t.length - 1] || "";
|
|
831
|
+
if (n.length < 3) return [];
|
|
832
|
+
let r = Ce().search(n, { limit: 12 }).sort((e, t) => Math.round((e.score ?? 1) * 10) - Math.round((t.score ?? 1) * 10) || e.item.rank - t.item.rank).map(({ item: e }) => V(e.domain, e.name, e.rank)), i = we(n);
|
|
833
|
+
return i && !r.some((e) => e.domain === i) && r.unshift(V(i, "", 2 ** 53 - 1)), r.slice(0, Se);
|
|
834
|
+
}
|
|
835
|
+
function Ee(e = {}) {
|
|
836
|
+
return { GET: async (t) => {
|
|
837
|
+
let { searchParams: n } = new URL(t.url), r = n.get("q")?.trim(), i = n.get("locale") || "en-US", a = parseInt(n.get("limit") || String(e.defaultLimit ?? 8), 10), o = n.get("engine") || n.get("backends")?.split(",")[0] || e.engine;
|
|
838
|
+
if (!r) return Response.json({
|
|
839
|
+
suggestions: [],
|
|
840
|
+
domains: []
|
|
841
|
+
});
|
|
842
|
+
try {
|
|
843
|
+
let e = await xe(r, {
|
|
844
|
+
engine: R(o),
|
|
845
|
+
locale: i,
|
|
846
|
+
signal: t.signal
|
|
847
|
+
}), n = Te(r);
|
|
848
|
+
return Response.json({
|
|
849
|
+
suggestions: e.slice(0, a),
|
|
850
|
+
domains: n
|
|
851
|
+
});
|
|
852
|
+
} catch (e) {
|
|
853
|
+
return console.error("Autocomplete error:", e), Response.json({
|
|
854
|
+
suggestions: [],
|
|
855
|
+
domains: []
|
|
856
|
+
}, { status: 500 });
|
|
857
|
+
}
|
|
858
|
+
} };
|
|
859
|
+
}
|
|
622
860
|
// src/api/handlers/suggestions.ts
|
|
623
|
-
function
|
|
861
|
+
function De() {
|
|
624
862
|
return { POST: async (e) => {
|
|
625
863
|
let n = await e.json(), r = n.chatHistory.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
626
864
|
role: e.role,
|
|
627
865
|
content: String(e.content ?? "")
|
|
628
|
-
})), i = await new t().loadChatModel(n.chatModel.providerId, n.chatModel.key), a = (await
|
|
866
|
+
})), i = await new t().loadChatModel(n.chatModel.providerId, n.chatModel.key), a = (await g({
|
|
629
867
|
chat_history: r,
|
|
630
868
|
maxQuestions: n.maxQuestions,
|
|
631
869
|
promptTemplate: n.promptTemplate
|
|
@@ -634,7 +872,7 @@ function I() {
|
|
|
634
872
|
} };
|
|
635
873
|
}
|
|
636
874
|
// src/api/handlers/agents.ts
|
|
637
|
-
function
|
|
875
|
+
function Oe(e) {
|
|
638
876
|
return { POST: async (t) => {
|
|
639
877
|
let n;
|
|
640
878
|
try {
|
|
@@ -648,36 +886,36 @@ function L(e) {
|
|
|
648
886
|
} };
|
|
649
887
|
}
|
|
650
888
|
// src/api/handlers/rewrite.ts
|
|
651
|
-
var
|
|
652
|
-
function
|
|
889
|
+
var ke = "llama-3.3-70b-versatile";
|
|
890
|
+
function H(e) {
|
|
653
891
|
return e instanceof Error ? e.message : typeof e == "string" ? e : String(e);
|
|
654
892
|
}
|
|
655
|
-
async function
|
|
893
|
+
async function Ae(e, t) {
|
|
656
894
|
let n = [];
|
|
657
895
|
if (t && e.loadChatModel) try {
|
|
658
896
|
return await e.loadChatModel(t);
|
|
659
897
|
} catch (e) {
|
|
660
|
-
n.push(
|
|
898
|
+
n.push(H(e));
|
|
661
899
|
}
|
|
662
900
|
let r = e.getEnv("GROQ_API_KEY");
|
|
663
|
-
if (r) return e.createGroq({ apiKey: r })(
|
|
901
|
+
if (r) return e.createGroq({ apiKey: r })(ke);
|
|
664
902
|
if (e.loadChatModel) try {
|
|
665
903
|
return await e.loadChatModel();
|
|
666
904
|
} catch (e) {
|
|
667
|
-
n.push(
|
|
905
|
+
n.push(H(e));
|
|
668
906
|
}
|
|
669
907
|
throw Error(n.length ? `AI service is not configured: ${n.join("; ")}` : "AI service is not configured. Please contact the administrator.");
|
|
670
908
|
}
|
|
671
|
-
function
|
|
909
|
+
function je(e) {
|
|
672
910
|
return { POST: async (t) => {
|
|
673
911
|
try {
|
|
674
912
|
let { text: n, prompt: r, stream: i, chatModel: a } = await t.json();
|
|
675
913
|
if (!n || typeof n != "string") return Response.json({ error: "Text is required and must be a string" }, { status: 400 });
|
|
676
914
|
let o;
|
|
677
915
|
try {
|
|
678
|
-
o = await
|
|
916
|
+
o = await Ae(e, a);
|
|
679
917
|
} catch (e) {
|
|
680
|
-
let t =
|
|
918
|
+
let t = H(e);
|
|
681
919
|
return console.error("AI rewrite has no usable model:", t), Response.json({ error: t }, { status: 500 });
|
|
682
920
|
}
|
|
683
921
|
let s = r || `Rewrite the following text to improve clarity, grammar, and style while maintaining the original meaning and tone. Only return the rewritten text without any explanation or additional commentary:
|
|
@@ -714,7 +952,7 @@ ${n}`;
|
|
|
714
952
|
})).text.trim();
|
|
715
953
|
return Response.json({ rewrittenText: c });
|
|
716
954
|
} catch (e) {
|
|
717
|
-
let t =
|
|
955
|
+
let t = H(e);
|
|
718
956
|
return console.error("AI rewrite error:", e), Response.json({
|
|
719
957
|
error: `Failed to process AI request: ${t}`,
|
|
720
958
|
details: t
|
|
@@ -723,7 +961,7 @@ ${n}`;
|
|
|
723
961
|
} };
|
|
724
962
|
}
|
|
725
963
|
// src/api/handlers/voice.ts
|
|
726
|
-
function
|
|
964
|
+
function Me(e) {
|
|
727
965
|
return { POST: async (t) => {
|
|
728
966
|
let n, r, i;
|
|
729
967
|
try {
|
|
@@ -786,7 +1024,7 @@ async function q(e, t, n) {
|
|
|
786
1024
|
model: r
|
|
787
1025
|
};
|
|
788
1026
|
}
|
|
789
|
-
function
|
|
1027
|
+
function Ne(e) {
|
|
790
1028
|
return { POST: async (t) => {
|
|
791
1029
|
try {
|
|
792
1030
|
let n = await t.formData(), r = n.get("file");
|
|
@@ -802,8 +1040,8 @@ function J(e) {
|
|
|
802
1040
|
} };
|
|
803
1041
|
}
|
|
804
1042
|
// src/api/handlers/openai-transcription.ts
|
|
805
|
-
var
|
|
806
|
-
function
|
|
1043
|
+
var J = ["json"];
|
|
1044
|
+
function Y(e, t, n, r = null, i = null) {
|
|
807
1045
|
return Response.json({ error: {
|
|
808
1046
|
message: t,
|
|
809
1047
|
type: n,
|
|
@@ -811,13 +1049,13 @@ function X(e, t, n, r = null, i = null) {
|
|
|
811
1049
|
code: i
|
|
812
1050
|
} }, { status: e });
|
|
813
1051
|
}
|
|
814
|
-
async function
|
|
1052
|
+
async function X(e, t) {
|
|
815
1053
|
let n = await e.authorize(t);
|
|
816
1054
|
if (n.authorized) return null;
|
|
817
1055
|
let { status: r, message: i } = n;
|
|
818
|
-
return
|
|
1056
|
+
return Y(r ?? 401, i, "authentication_error", null, "invalid_api_key");
|
|
819
1057
|
}
|
|
820
|
-
function
|
|
1058
|
+
function Z() {
|
|
821
1059
|
return {
|
|
822
1060
|
object: "list",
|
|
823
1061
|
data: U.map((e) => ({
|
|
@@ -828,44 +1066,44 @@ function Q() {
|
|
|
828
1066
|
}))
|
|
829
1067
|
};
|
|
830
1068
|
}
|
|
831
|
-
function
|
|
832
|
-
return { GET: async (t) => await
|
|
1069
|
+
function Pe(e) {
|
|
1070
|
+
return { GET: async (t) => await X(e, t) || Response.json(Z()) };
|
|
833
1071
|
}
|
|
834
|
-
function
|
|
1072
|
+
function Q(e) {
|
|
835
1073
|
return { POST: async (t) => {
|
|
836
|
-
let n = await
|
|
1074
|
+
let n = await X(e, t);
|
|
837
1075
|
if (n) return n;
|
|
838
1076
|
let r;
|
|
839
1077
|
try {
|
|
840
1078
|
r = await t.formData();
|
|
841
1079
|
} catch {
|
|
842
|
-
return
|
|
1080
|
+
return Y(400, "Request body must be multipart/form-data with a `file` field.", "invalid_request_error", null, "invalid_body");
|
|
843
1081
|
}
|
|
844
1082
|
let i = r.get("file");
|
|
845
|
-
if (!i || !(i instanceof File)) return
|
|
846
|
-
if (i.size === 0) return
|
|
1083
|
+
if (!i || !(i instanceof File)) return Y(400, "`file` is required.", "invalid_request_error", "file", "missing_file");
|
|
1084
|
+
if (i.size === 0) return Y(400, "`file` is empty.", "invalid_request_error", "file", "empty_file");
|
|
847
1085
|
let a = r.get("model"), o = a === null || a === "" ? W : a;
|
|
848
|
-
if (!G(o)) return
|
|
1086
|
+
if (!G(o)) return Y(400, `Unsupported model. Use one of: ${U.join(", ")}.`, "invalid_request_error", "model", "model_not_found");
|
|
849
1087
|
let s = r.get("response_format");
|
|
850
|
-
if (s !== null && s !== "" && s !== "json") return
|
|
1088
|
+
if (s !== null && s !== "" && s !== "json") return Y(400, `Unsupported response_format. Only ${J.join(", ")} is supported.`, "invalid_request_error", "response_format", "unsupported_response_format");
|
|
851
1089
|
try {
|
|
852
1090
|
let t = await q(e, i, o);
|
|
853
|
-
return t.ok ? Response.json({ text: t.text }) :
|
|
1091
|
+
return t.ok ? Response.json({ text: t.text }) : Y(503, "Transcription is not available right now.", "server_error", null, "ai_unavailable");
|
|
854
1092
|
} catch (e) {
|
|
855
|
-
return console.error("[v1/audio/transcriptions] Workers AI failed:", e instanceof Error ? e.name : typeof e),
|
|
1093
|
+
return console.error("[v1/audio/transcriptions] Workers AI failed:", e instanceof Error ? e.name : typeof e), Y(500, "Failed to transcribe audio.", "server_error", null, "transcription_failed");
|
|
856
1094
|
}
|
|
857
1095
|
} };
|
|
858
1096
|
}
|
|
859
1097
|
// src/api/handlers/test-models.ts
|
|
860
|
-
function
|
|
1098
|
+
function Fe() {
|
|
861
1099
|
return { POST: async (e) => {
|
|
862
1100
|
try {
|
|
863
1101
|
let { providerType: t, apiKey: n, onlyFree: r = !0 } = await e.json();
|
|
864
1102
|
if (!t) return Response.json({ error: "Provider type is required" }, { status: 400 });
|
|
865
1103
|
if (!n) return Response.json({ error: "API key is required" }, { status: 400 });
|
|
866
|
-
let i =
|
|
1104
|
+
let i = v.find((e) => e.provider.toLowerCase() === t.toLowerCase());
|
|
867
1105
|
if (!i) return Response.json({ error: `Provider ${t} not found` }, { status: 404 });
|
|
868
|
-
let a = await
|
|
1106
|
+
let a = await _(t, n, i.models, {
|
|
869
1107
|
onlyFree: r,
|
|
870
1108
|
concurrency: 3,
|
|
871
1109
|
timeout: 15e3
|
|
@@ -877,13 +1115,13 @@ function ie() {
|
|
|
877
1115
|
} };
|
|
878
1116
|
}
|
|
879
1117
|
// src/api/handlers/validate-openrouter.ts
|
|
880
|
-
var
|
|
881
|
-
function
|
|
1118
|
+
var Ie = 864e5, $ = null;
|
|
1119
|
+
function Le(e) {
|
|
882
1120
|
return {
|
|
883
1121
|
GET: async (t) => {
|
|
884
1122
|
try {
|
|
885
1123
|
let t = Date.now();
|
|
886
|
-
if ($ && t - $.timestamp <
|
|
1124
|
+
if ($ && t - $.timestamp < Ie) return Response.json({
|
|
887
1125
|
...$.result,
|
|
888
1126
|
cached: !0,
|
|
889
1127
|
cacheAge: t - $.timestamp
|
|
@@ -916,4 +1154,4 @@ function oe(e) {
|
|
|
916
1154
|
}
|
|
917
1155
|
};
|
|
918
1156
|
}
|
|
919
|
-
export { W as DEFAULT_TRANSCRIPTION_MODEL,
|
|
1157
|
+
export { W as DEFAULT_TRANSCRIPTION_MODEL, J as SUPPORTED_RESPONSE_FORMATS, U as TRANSCRIPTION_MODELS, Oe as createAgentsHandler, y as createArticleFollowupsHandler, ee as createArticleQAHandler, Ee as createAutocompleteHandler, ne as createChatByIdHandler, ae as createChatTitleHandler, te as createChatsHandler, re as createChatsSearchHandler, ie as createChatsShareHandler, he as createDiscoverHandler, de as createMCPServerByIdHandler, fe as createMCPServerToggleHandler, ue as createMCPServersHandler, se as createMessagesHandler, Pe as createOpenAIModelsHandler, Q as createOpenAITranscriptionHandler, b as createPageTipsHandler, C as createProviderByIdHandler, le as createProviderModelsHandler, ce as createProvidersHandler, je as createRewriteHandler, me as createSearchHandler, De as createSuggestionsHandler, Fe as createTestModelsHandler, x as createTopicSearchesHandler, Ne as createTranscriptHandler, Le as createValidateOpenRouterHandler, Me as createVoiceHandler, S as describeError, K as getWhisperModel, G as isTranscriptionModel, Z as listTranscriptionModels, Y as openAIError, q as transcribeAudio };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config.cjs"),t=require("./src-
|
|
1
|
+
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./config.cjs"),t=require("./src-Ckb1ciEL.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./dialog-7GDz0sWx.cjs");exports.ARTICLE_TOOLBAR_SHORTCUTS=t.D,exports.ArticleAIResponse=t.w,exports.ArticleActionButtons=t.O,exports.ArticleContent=t.S,exports.ArticleFollowupQuestions=t.T,exports.ArticlePanelHeader=t.A,exports.ArticlePromptInput=t.E,exports.ArticleReaderMount=t.R,exports.CategoryDock=t.c,exports.ChatInputBox=t.U,exports.ChatProvider=t.$,exports.ChatWindow=t.L,exports.CookieConsent=t.s,exports.ExtractPanelProvider=n.i,exports.HistoryDialogs=t.B,exports.HistoryDropdown=t.z,exports.KokoroVoiceSelector=t.u,exports.LexicalArticleViewer=t.C,exports.MainViewProvider=t.y,exports.QWKSEARCH_DEFAULT_ORIGIN=t.j,exports.QwkSearchApp=t.n,exports.QwkSearchProviders=t.r,exports.SPOTLIGHT_LINKS=t.v,exports.SPOTLIGHT_PREFIXES=t.h,exports.SessionProvider=n.s,exports.SpotlightPalette=t.p,exports.UnifiedMarkdown=t.x,exports.VoiceSettingsPanel=t.l,exports.buildConnectStartUrl=t.M,exports.cn=r.o,exports.configureResearchAgentUI=e.configureResearchAgentUI,exports.createQwkSearchConnectAuthClient=t.N,exports.formatMessageTime=r.s,exports.formatTimeDifference=r.c,exports.formatToolbarShortcut=t.k,exports.getQwkSearchApiKey=t.P,exports.isChunkLoadError=t.i,exports.isQwkSearchApiRequest=t.F,exports.matchSpotlight=t.g,exports.openSpotlight=t.m,exports.parsePrefix=t._,exports.reloadForChunkError=t.a,exports.researchAgentUIConfig=e.researchAgentUIConfig,exports.setQwkSearchApiKey=t.I,exports.useChat=n.u,exports.useChatState=t.et,exports.useChatTabs=t.t,exports.useChunkErrorReload=t.o,exports.useExtractPanel=n.a,exports.useHistoryState=t.H,exports.useKokoroTTS=t.f,exports.useMainView=t.b,exports.useOptionalExtractPanel=n.o,exports.useSession=n.c,exports.useTextToSpeech=t.d;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
import { configureResearchAgentUI as e, researchAgentUIConfig as t } from "./config.mjs";
|
|
4
|
-
import { $ as n, A as r, B as i, C as a, D as o, E as s, F as c, H as l, I as u, L as d, M as f, N as p, O as m, P as h, R as g, S as _, T as v, U as y, _ as b, a as x, b as S, c as C, d as w, et as T, f as E, g as D, h as O, i as k, j as A, k as j, l as M, m as N, n as P, o as F, p as I, r as L, s as R, t as z, u as B, v as V, w as H, x as U, y as W, z as G } from "./src-
|
|
4
|
+
import { $ as n, A as r, B as i, C as a, D as o, E as s, F as c, H as l, I as u, L as d, M as f, N as p, O as m, P as h, R as g, S as _, T as v, U as y, _ as b, a as x, b as S, c as C, d as w, et as T, f as E, g as D, h as O, i as k, j as A, k as j, l as M, m as N, n as P, o as F, p as I, r as L, s as R, t as z, u as B, v as V, w as H, x as U, y as W, z as G } from "./src-BqV2Vwpv.js";
|
|
5
5
|
import { a as K, c as q, i as J, o as Y, s as X, u as Z } from "./tooltip-Bl3IdX-I.js";
|
|
6
6
|
import { c as Q, o as $, s as ee } from "./dialog-Cufn2u50.js";
|
|
7
7
|
export { o as ARTICLE_TOOLBAR_SHORTCUTS, H as ArticleAIResponse, m as ArticleActionButtons, _ as ArticleContent, v as ArticleFollowupQuestions, r as ArticlePanelHeader, s as ArticlePromptInput, g as ArticleReaderMount, C as CategoryDock, y as ChatInputBox, n as ChatProvider, d as ChatWindow, R as CookieConsent, J as ExtractPanelProvider, i as HistoryDialogs, G as HistoryDropdown, B as KokoroVoiceSelector, a as LexicalArticleViewer, W as MainViewProvider, A as QWKSEARCH_DEFAULT_ORIGIN, P as QwkSearchApp, L as QwkSearchProviders, V as SPOTLIGHT_LINKS, O as SPOTLIGHT_PREFIXES, X as SessionProvider, I as SpotlightPalette, U as UnifiedMarkdown, M as VoiceSettingsPanel, f as buildConnectStartUrl, $ as cn, e as configureResearchAgentUI, p as createQwkSearchConnectAuthClient, ee as formatMessageTime, Q as formatTimeDifference, j as formatToolbarShortcut, h as getQwkSearchApiKey, k as isChunkLoadError, c as isQwkSearchApiRequest, D as matchSpotlight, N as openSpotlight, b as parsePrefix, x as reloadForChunkError, t as researchAgentUIConfig, u as setQwkSearchApiKey, Z as useChat, T as useChatState, z as useChatTabs, F as useChunkErrorReload, K as useExtractPanel, l as useHistoryState, E as useKokoroTTS, S as useMainView, Y as useOptionalExtractPanel, q as useSession, w as useTextToSpeech };
|