research-agent-ui 0.1.293 → 0.1.294
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 +42 -1
- package/dist/ArticleExtractPanel-25tRTnpl.cjs +2 -0
- package/dist/ArticleExtractPanel-D_y16YHG.js +389 -0
- package/dist/ChatConversationThread-BIJ8aNug.js +1428 -0
- package/dist/ChatConversationThread-BoNH0wvs.cjs +17 -0
- package/dist/DownloadsDialog-CCPj0hA8.cjs +1 -0
- package/dist/{DownloadsDialog-bTEDe2DI.js → DownloadsDialog-DvS23Dh-.js} +8 -9
- package/dist/api/handlers/autocomplete.d.ts +6 -9
- package/dist/api/handlers/openai-transcription.d.ts +53 -0
- package/dist/api/handlers/transcript.d.ts +33 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api.cjs +10 -10
- package/dist/api.mjs +161 -208
- package/dist/app/index.d.ts +1 -1
- package/dist/app/useChunkErrorReload.d.ts +13 -2
- package/dist/components/ArticleReader/ArticleReaderMount.d.ts +5 -0
- package/dist/components/ArticleReader/ExtractPanelContext.d.ts +17 -1
- package/dist/components/ChatConversation/MessageBubble/AssistantMessageActions.d.ts +2 -1
- package/dist/components/ChatConversation/background-art.d.ts +3 -1
- package/dist/components/ChatConversation/background-cache.d.ts +41 -0
- package/dist/components/Footer.d.ts +5 -4
- package/dist/components/Footer.stories.d.ts +3 -3
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.mjs +4 -3
- package/dist/dialog-7GDz0sWx.cjs +1 -0
- package/dist/dialog-Cufn2u50.js +80 -0
- package/dist/hooks/voice/useKokoroTTS.d.ts +2 -0
- package/dist/hooks/voice/useTextToVoice.d.ts +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +4 -2
- package/dist/lib/file-sources.d.ts +8 -0
- package/dist/lib/google-drive-source.d.ts +100 -0
- package/dist/lib/kokoro.d.ts +14 -2
- package/dist/lib/qwksearch-connect.d.ts +79 -0
- package/dist/settings/index.d.ts +15 -0
- package/dist/src-GPr1ceY8.js +6165 -0
- package/dist/src-ebmQu_if.cjs +34 -0
- package/dist/tooltip-Bl3IdX-I.js +179 -0
- package/dist/tooltip-DmUO6ZUz.cjs +1 -0
- package/dist/types/fileSource.d.ts +9 -0
- package/dist/workspace/QwkSearchWorkspaceApp.d.ts +9 -2
- package/dist/workspace/ResearchWorkspaceView.d.ts +18 -4
- package/dist/workspace.cjs +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.mjs +234 -91
- package/package.json +54 -51
- package/src/app/useChunkErrorReload.ts +92 -0
- package/src/settings/index.ts +23 -0
- package/src/settings/search.json +19 -1
- package/dist/DownloadsDialog-Ca6aRRcP.cjs +0 -1
- package/dist/src-HL9JjPc-.js +0 -8218
- package/dist/src-r4BsCIB4.cjs +0 -51
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { o as e } from "./dialog-Cufn2u50.js";
|
|
2
|
+
import { createContext as t, useContext as n, useEffect as r, useState as i } from "react";
|
|
3
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
4
|
+
import * as s from "@radix-ui/react-tooltip";
|
|
5
|
+
// src/hooks/useChat/ChatContext.tsx
|
|
6
|
+
var c = t({
|
|
7
|
+
chatHistory: [],
|
|
8
|
+
chatId: "",
|
|
9
|
+
fileIds: [],
|
|
10
|
+
files: [],
|
|
11
|
+
focusMode: "",
|
|
12
|
+
category: "",
|
|
13
|
+
hasError: !1,
|
|
14
|
+
isMessagesLoaded: !1,
|
|
15
|
+
isReady: !1,
|
|
16
|
+
loading: !1,
|
|
17
|
+
messageAppeared: !1,
|
|
18
|
+
messages: [],
|
|
19
|
+
chatTurns: [],
|
|
20
|
+
sections: [],
|
|
21
|
+
notFound: !1,
|
|
22
|
+
optimizationMode: "",
|
|
23
|
+
chatModelProvider: {
|
|
24
|
+
key: "",
|
|
25
|
+
providerId: ""
|
|
26
|
+
},
|
|
27
|
+
rewrite: () => {},
|
|
28
|
+
sendMessage: async () => {},
|
|
29
|
+
setFileIds: () => {},
|
|
30
|
+
setFiles: () => {},
|
|
31
|
+
deleteAttachedFile: async () => {},
|
|
32
|
+
setFocusMode: () => {},
|
|
33
|
+
setCategory: () => {},
|
|
34
|
+
setOptimizationMode: () => {},
|
|
35
|
+
setChatModelProvider: () => {},
|
|
36
|
+
stopStreaming: () => {},
|
|
37
|
+
newChat: () => {},
|
|
38
|
+
startNewChat: () => {},
|
|
39
|
+
switchToChat: () => {},
|
|
40
|
+
incognito: !1,
|
|
41
|
+
setIncognito: () => {}
|
|
42
|
+
});
|
|
43
|
+
function l() {
|
|
44
|
+
return n(c);
|
|
45
|
+
}
|
|
46
|
+
// src/hooks/useSession.tsx
|
|
47
|
+
var u = t({
|
|
48
|
+
user: null,
|
|
49
|
+
isLoading: !0,
|
|
50
|
+
isAuthenticated: !1,
|
|
51
|
+
signIn: () => {},
|
|
52
|
+
signOut: async () => {}
|
|
53
|
+
});
|
|
54
|
+
function d({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
|
|
55
|
+
let [o, s] = i(null), [c, l] = i(!0);
|
|
56
|
+
return r(() => {
|
|
57
|
+
(async () => {
|
|
58
|
+
try {
|
|
59
|
+
let { data: e } = await t.getSession();
|
|
60
|
+
s(e?.user ?? null);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error("Failed to fetch session:", e), s(null);
|
|
63
|
+
} finally {
|
|
64
|
+
l(!1);
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
}, []), r(() => {
|
|
68
|
+
c || o || !n || t.oneTap({ fetchOptions: { onSuccess: async () => {
|
|
69
|
+
let { data: e } = await t.getSession();
|
|
70
|
+
s(e?.user ?? null);
|
|
71
|
+
} } });
|
|
72
|
+
}, [
|
|
73
|
+
c,
|
|
74
|
+
o,
|
|
75
|
+
n
|
|
76
|
+
]), /* @__PURE__ */ a(u.Provider, {
|
|
77
|
+
value: {
|
|
78
|
+
user: o,
|
|
79
|
+
isLoading: c,
|
|
80
|
+
isAuthenticated: !!o,
|
|
81
|
+
signIn: () => {
|
|
82
|
+
t.signIn.social({
|
|
83
|
+
provider: "google",
|
|
84
|
+
callbackURL: "/"
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
signOut: async () => {
|
|
88
|
+
try {
|
|
89
|
+
await t.signOut({ fetchOptions: { onSuccess: () => {
|
|
90
|
+
s(null), window.location.href = "/";
|
|
91
|
+
} } });
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.error("Sign out failed:", e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
children: e
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function f() {
|
|
101
|
+
let e = n(u);
|
|
102
|
+
if (!e) throw Error("useSession must be used within SessionProvider");
|
|
103
|
+
return e;
|
|
104
|
+
}
|
|
105
|
+
// src/components/ArticleReader/ExtractPanelContext.tsx
|
|
106
|
+
var p = t(void 0), m = () => {
|
|
107
|
+
let e = n(p);
|
|
108
|
+
if (!e) throw Error("useExtractPanel must be used within an ExtractPanelProvider");
|
|
109
|
+
return e;
|
|
110
|
+
}, h = () => n(p), g = ({ children: e }) => {
|
|
111
|
+
let [t, n] = i(!1), [r, o] = i(""), [s, c] = i(""), [l, u] = i(!1), [d, f] = i(600);
|
|
112
|
+
return /* @__PURE__ */ a(p.Provider, {
|
|
113
|
+
value: {
|
|
114
|
+
isOpen: t,
|
|
115
|
+
url: r,
|
|
116
|
+
searchText: s,
|
|
117
|
+
suggestQuestions: l,
|
|
118
|
+
panelWidth: d,
|
|
119
|
+
setIsOpen: n,
|
|
120
|
+
setUrl: o,
|
|
121
|
+
setSearchText: c,
|
|
122
|
+
setPanelWidth: f,
|
|
123
|
+
openPanel: (e, t = "", r = {}) => {
|
|
124
|
+
console.log("[ExtractPanelContext] openPanel called with URL:", e);
|
|
125
|
+
try {
|
|
126
|
+
let t = new URL(e);
|
|
127
|
+
(t.pathname === "/" || t.pathname === "") && console.error("[ExtractPanelContext] URL is domain-only, missing article path:", e);
|
|
128
|
+
} catch (t) {
|
|
129
|
+
console.error("[ExtractPanelContext] Invalid URL format:", e, t);
|
|
130
|
+
}
|
|
131
|
+
if (o(e), c(t), u(!!r.suggestQuestions), n(!0), typeof window < "u") {
|
|
132
|
+
let t = new URLSearchParams(window.location.search);
|
|
133
|
+
t.set("extract", encodeURIComponent(e));
|
|
134
|
+
let n = `${window.location.pathname}?${t.toString()}`;
|
|
135
|
+
window.history.pushState({}, "", n);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
closePanel: () => {
|
|
139
|
+
if (n(!1), typeof window < "u") {
|
|
140
|
+
let e = new URLSearchParams(window.location.search);
|
|
141
|
+
e.delete("extract");
|
|
142
|
+
let t = e.toString() ? `${window.location.pathname}?${e.toString()}` : window.location.pathname;
|
|
143
|
+
window.history.pushState({}, "", t);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
children: e
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
// src/ui/tooltip.tsx
|
|
151
|
+
function _({ delayDuration: e = 0, ...t }) {
|
|
152
|
+
return /* @__PURE__ */ a(s.Provider, {
|
|
153
|
+
"data-slot": "tooltip-provider",
|
|
154
|
+
delayDuration: e,
|
|
155
|
+
...t
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function v({ ...e }) {
|
|
159
|
+
return /* @__PURE__ */ a(_, { children: /* @__PURE__ */ a(s.Root, {
|
|
160
|
+
"data-slot": "tooltip",
|
|
161
|
+
...e
|
|
162
|
+
}) });
|
|
163
|
+
}
|
|
164
|
+
function y({ ...e }) {
|
|
165
|
+
return /* @__PURE__ */ a(s.Trigger, {
|
|
166
|
+
"data-slot": "tooltip-trigger",
|
|
167
|
+
...e
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function b({ className: t, sideOffset: n = 0, children: r, ...i }) {
|
|
171
|
+
return /* @__PURE__ */ a(s.Portal, { children: /* @__PURE__ */ o(s.Content, {
|
|
172
|
+
"data-slot": "tooltip-content",
|
|
173
|
+
sideOffset: n,
|
|
174
|
+
className: e("bg-popover text-popover-foreground border border-border shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-2xl px-3 py-1.5 text-xs text-balance", t),
|
|
175
|
+
...i,
|
|
176
|
+
children: [r, /* @__PURE__ */ a(s.Arrow, { className: "bg-popover fill-popover z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]" })]
|
|
177
|
+
}) });
|
|
178
|
+
}
|
|
179
|
+
export { m as a, f as c, g as i, c as l, b as n, h as o, y as r, d as s, v as t, l as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./dialog-7GDz0sWx.cjs");let n=require("react");n=e.t(n,1);let r=require("react/jsx-runtime"),i=require("@radix-ui/react-tooltip");i=e.t(i,1);var a=(0,n.createContext)({chatHistory:[],chatId:``,fileIds:[],files:[],focusMode:``,category:``,hasError:!1,isMessagesLoaded:!1,isReady:!1,loading:!1,messageAppeared:!1,messages:[],chatTurns:[],sections:[],notFound:!1,optimizationMode:``,chatModelProvider:{key:``,providerId:``},rewrite:()=>{},sendMessage:async()=>{},setFileIds:()=>{},setFiles:()=>{},deleteAttachedFile:async()=>{},setFocusMode:()=>{},setCategory:()=>{},setOptimizationMode:()=>{},setChatModelProvider:()=>{},stopStreaming:()=>{},newChat:()=>{},startNewChat:()=>{},switchToChat:()=>{},incognito:!1,setIncognito:()=>{}});function o(){return(0,n.useContext)(a)}var s=(0,n.createContext)({user:null,isLoading:!0,isAuthenticated:!1,signIn:()=>{},signOut:async()=>{}});function c({children:e,authClient:t,enableGoogleOneTap:i=!0}){let[a,o]=(0,n.useState)(null),[c,l]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{(async()=>{try{let{data:e}=await t.getSession();o(e?.user??null)}catch(e){console.error(`Failed to fetch session:`,e),o(null)}finally{l(!1)}})()},[]),(0,n.useEffect)(()=>{c||a||!i||t.oneTap({fetchOptions:{onSuccess:async()=>{let{data:e}=await t.getSession();o(e?.user??null)}}})},[c,a,i]),(0,r.jsx)(s.Provider,{value:{user:a,isLoading:c,isAuthenticated:!!a,signIn:()=>{t.signIn.social({provider:`google`,callbackURL:`/`})},signOut:async()=>{try{await t.signOut({fetchOptions:{onSuccess:()=>{o(null),window.location.href=`/`}}})}catch(e){console.error(`Sign out failed:`,e)}}},children:e})}function l(){let e=(0,n.useContext)(s);if(!e)throw Error(`useSession must be used within SessionProvider`);return e}var u=(0,n.createContext)(void 0),d=()=>{let e=(0,n.useContext)(u);if(!e)throw Error(`useExtractPanel must be used within an ExtractPanelProvider`);return e},f=()=>(0,n.useContext)(u),p=({children:e})=>{let[t,i]=(0,n.useState)(!1),[a,o]=(0,n.useState)(``),[s,c]=(0,n.useState)(``),[l,d]=(0,n.useState)(!1),[f,p]=(0,n.useState)(600);return(0,r.jsx)(u.Provider,{value:{isOpen:t,url:a,searchText:s,suggestQuestions:l,panelWidth:f,setIsOpen:i,setUrl:o,setSearchText:c,setPanelWidth:p,openPanel:(e,t=``,n={})=>{console.log(`[ExtractPanelContext] openPanel called with URL:`,e);try{let t=new URL(e);(t.pathname===`/`||t.pathname===``)&&console.error(`[ExtractPanelContext] URL is domain-only, missing article path:`,e)}catch(t){console.error(`[ExtractPanelContext] Invalid URL format:`,e,t)}if(o(e),c(t),d(!!n.suggestQuestions),i(!0),typeof window<`u`){let t=new URLSearchParams(window.location.search);t.set(`extract`,encodeURIComponent(e));let n=`${window.location.pathname}?${t.toString()}`;window.history.pushState({},``,n)}},closePanel:()=>{if(i(!1),typeof window<`u`){let e=new URLSearchParams(window.location.search);e.delete(`extract`);let t=e.toString()?`${window.location.pathname}?${e.toString()}`:window.location.pathname;window.history.pushState({},``,t)}}},children:e})};function m({delayDuration:e=0,...t}){return(0,r.jsx)(i.Provider,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function h({...e}){return(0,r.jsx)(m,{children:(0,r.jsx)(i.Root,{"data-slot":`tooltip`,...e})})}function g({...e}){return(0,r.jsx)(i.Trigger,{"data-slot":`tooltip-trigger`,...e})}function _({className:e,sideOffset:n=0,children:a,...o}){return(0,r.jsx)(i.Portal,{children:(0,r.jsxs)(i.Content,{"data-slot":`tooltip-content`,sideOffset:n,className:t.o(`bg-popover text-popover-foreground border border-border shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-2xl px-3 py-1.5 text-xs text-balance`,e),...o,children:[a,(0,r.jsx)(i.Arrow,{className:`bg-popover fill-popover z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]`})]})})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return o}});
|
|
@@ -63,6 +63,15 @@ export interface GoogleDocsCredentials {
|
|
|
63
63
|
/** Connected Google account email. */
|
|
64
64
|
email?: string;
|
|
65
65
|
folderIds?: string[];
|
|
66
|
+
/**
|
|
67
|
+
* The synced folders with their display names, in the order they were
|
|
68
|
+
* added. `id` is a Drive folder ID, or `root` for all of My Drive.
|
|
69
|
+
* `folderIds` mirrors the IDs for older readers.
|
|
70
|
+
*/
|
|
71
|
+
folders?: Array<{
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
}>;
|
|
66
75
|
/** Indicates whether the Google connection is active. */
|
|
67
76
|
isAuthenticated: boolean;
|
|
68
77
|
}
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* editor, and file sidebar alongside the conversation.
|
|
5
5
|
*/
|
|
6
6
|
import { type QwkSearchProvidersProps } from '../app/QwkSearchProviders';
|
|
7
|
-
|
|
8
|
-
export
|
|
7
|
+
import { type ResearchWorkspaceViewProps } from './ResearchWorkspaceView';
|
|
8
|
+
export type QwkSearchWorkspaceAppProps = Omit<QwkSearchProvidersProps, 'children' | 'docsEnabled'> & ResearchWorkspaceViewProps;
|
|
9
|
+
/**
|
|
10
|
+
* Pass `showDock={false}` when the host draws its own app dock (this app's
|
|
11
|
+
* dock — Research, Docs, Settings — is then not rendered at all), and
|
|
12
|
+
* `SidebarComponent` / `openSidebarEvent` to host chrome in, and drive, the
|
|
13
|
+
* workspace's own sidebar.
|
|
14
|
+
*/
|
|
15
|
+
export declare function QwkSearchWorkspaceApp({ SidebarComponent, SidebarContentComponent, openSidebarEvent, ...providerProps }: QwkSearchWorkspaceAppProps): import("react").JSX.Element;
|
|
9
16
|
export default QwkSearchWorkspaceApp;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
export interface ResearchWorkspaceViewProps {
|
|
3
|
+
/**
|
|
4
|
+
* Replaces the REASON files/outline sidebar. A host embedding the workspace
|
|
5
|
+
* uses it to wrap `Sidebar` with its own chrome (e.g. its app dock) while the
|
|
6
|
+
* column stays the research agent's own sidebar.
|
|
7
|
+
*/
|
|
8
|
+
SidebarComponent?: ComponentType<any>;
|
|
9
|
+
/** Replaces the sidebar's right-panel body. Defaults to the REASON pair's. */
|
|
10
|
+
SidebarContentComponent?: ComponentType<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Name of a `window` event that opens the files sidebar when dispatched. The
|
|
13
|
+
* host's toolbar button is outside this tree, so this is how it reaches the
|
|
14
|
+
* sidebar the workspace owns (below `md` that sidebar is a slide-over sheet).
|
|
15
|
+
*/
|
|
16
|
+
openSidebarEvent?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function ResearchWorkspaceView({ SidebarComponent, SidebarContentComponent, openSidebarEvent, }?: ResearchWorkspaceViewProps): import("react").JSX.Element;
|
package/dist/workspace.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./
|
|
1
|
+
"use client";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./src-ebmQu_if.cjs"),n=require("./config.cjs"),r=require("./tooltip-DmUO6ZUz.cjs"),i=require("./dialog-7GDz0sWx.cjs");let a=require("react"),o=require("next/navigation"),s=require("react/jsx-runtime"),c=require("grab-url");c=e.t(c,1);let l=require("react-reason-editor/reason-docs"),u=require("react-reason-editor/theme"),d=require("react-reason-editor/locale-bundle"),f=require("react-reason-editor-sidebar");function p(e){return e.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,` `).replace(/<[^>]+>/g,` `).replace(/ /g,` `).replace(/\s+/g,` `).trim()}var m=async(e,t)=>{try{let n=await(0,c.default)(`agent/page-tips`,{method:`POST`,body:JSON.stringify({title:e,content:t})});return Array.isArray(n.tips)?n.tips:[]}catch{return[]}},h=async(e,t)=>{try{let n=await(0,c.default)(`agent/topic-searches`,{method:`POST`,body:JSON.stringify({title:e,content:t})});return Array.isArray(n.topics)?n.topics:[]}catch{return[]}},g=`/api/doc/google-docs`,_=`application/vnd.google-apps.document`,v=`application/vnd.google-apps.spreadsheet`,y=`application/vnd.google-apps.presentation`,b=`application/vnd.google-apps.drawing`,x=`application/vnd.google-apps.folder`,S=class extends Error{needsReauth;needsFolderAccess;status;constructor(e,t,n={}){super(e),this.name=`GoogleDriveError`,this.status=t,this.needsReauth=!!n.needsReauth,this.needsFolderAccess=!!n.needsFolderAccess}};async function C(e){let t=await fetch(`${g}${e}`,{credentials:`same-origin`}),n={};try{n=await t.json()}catch{}if(!t.ok||n?.success===!1)throw new S(n?.error||`Google Drive request failed (${t.status})`,t.status,n);return n}function w(e){return e===_||e===`text/plain`||e===`text/markdown`?`editor`:e===`application/pdf`||e===v||e===y?`pdf`:e===b||e.startsWith(`image/`)?`image`:`unsupported`}function T(e){if(e.mimeType===_)return`docx`;if(e.mimeType===v)return`xlsx`;if(e.mimeType===y)return`pptx`;if(e.mimeType===b)return`png`;let t=e.name.lastIndexOf(`.`);if(t>0&&t<e.name.length-1)return e.name.slice(t+1).toLowerCase();if(e.mimeType===`application/pdf`)return`pdf`;let n=e.mimeType.split(`/`)[1];return n&&/^[a-z0-9]{2,5}$/.test(n)?n:void 0}var E=(e,t)=>`${e}:${t}`,D=e=>`${g}/content?fileId=${encodeURIComponent(e)}`;function O(e,t){let n=[],r=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,{numeric:!0,sensitivity:`base`});for(let{root:a,items:o}of t){let s=E(e,a.id);if(r.has(s))continue;r.add(s),n.push({id:s,title:a.name,content:``,parentId:null,isFolder:!0,isExpanded:t.length===1,external:{sourceId:e,fileId:a.id,mimeType:x,view:`unsupported`,webViewLink:a.webViewLink}});let c=new Set([a.id,...o.filter(e=>e.mimeType===x).map(e=>e.id)]);for(let t of[...o].sort(i)){let i=E(e,t.id);if(r.has(i))continue;r.add(i);let o=t.parents?.find(e=>c.has(e))??a.id,s=t.mimeType===x,l=s?`unsupported`:w(t.mimeType);n.push({id:i,title:t.name,content:``,parentId:E(e,o),isFolder:s,isExpanded:!1,external:{sourceId:e,fileId:t.id,mimeType:t.mimeType,view:l,extension:s?void 0:T(t),contentUrl:s||l===`unsupported`?void 0:D(t.id),webViewLink:t.webViewLink}})}}return n}function k(e){return e?.folders?.length?e.folders:(e?.folderIds??[]).map(e=>({id:e,name:e===`root`?`My Drive`:e}))}async function A(e){let t=k(e.credentials);if(t.length===0)return[];let n=await Promise.allSettled(t.map(e=>C(`/folder-tree?folderId=${encodeURIComponent(e.id)}`))),r=n.flatMap(e=>e.status===`fulfilled`?[e.value]:[]);if(r.length===0)throw n[0].reason;return O(e.id,r)}function j(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function M(e){return e.split(/\r?\n\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${j(e).replace(/\r?\n/g,`<br>`)}</p>`).join(``)}function N(e){if(typeof DOMParser>`u`){let t=e.match(/<body[^>]*>([\s\S]*)<\/body>/i);return(t?t[1]:e).replace(/<(script|style)[\s\S]*?<\/\1>/gi,``)}let t=new DOMParser().parseFromString(e,`text/html`),n=new Map;for(let e of Array.from(t.querySelectorAll(`style`)))for(let t of(e.textContent??``).matchAll(/\.([A-Za-z0-9_-]+)\s*\{([^}]*)\}/g))n.set(t[1],`${n.get(t[1])??``};${t[2]}`);t.querySelectorAll(`script, style, meta, link, title`).forEach(e=>e.remove());for(let e of Array.from(t.body.querySelectorAll(`span`))){let r=[...Array.from(e.classList).map(e=>n.get(e)??``),e.getAttribute(`style`)??``].join(`;`),i=Array.from(e.childNodes),a=e=>{let n=t.createElement(e);i.forEach(e=>n.appendChild(e)),i=[n]};/font-weight:\s*(700|800|900|bold)/i.test(r)&&a(`strong`),/font-style:\s*italic/i.test(r)&&a(`em`),/text-decoration[^;]*underline/i.test(r)&&a(`u`),/text-decoration[^;]*line-through/i.test(r)&&a(`s`),e.replaceWith(...i)}for(let e of Array.from(t.body.querySelectorAll(`a[href]`)))try{let t=new URL(e.getAttribute(`href`));t.hostname===`www.google.com`&&t.pathname===`/url`&&t.searchParams.get(`q`)&&e.setAttribute(`href`,t.searchParams.get(`q`))}catch{}for(let e of Array.from(t.body.querySelectorAll(`[class], [style], [id]`)))e.removeAttribute(`class`),e.removeAttribute(`style`),e.removeAttribute(`id`);return t.body.innerHTML.trim()}async function P(e){let t=e.external;if(!t?.contentUrl)return``;let n=await fetch(t.contentUrl,{credentials:`same-origin`});if(!n.ok){let e={};try{e=await n.json()}catch{}throw new S(e?.error||`Couldn't load the file (${n.status})`,n.status,e)}let r=await n.text();return t.mimeType===_?N(r):M(r)}var F={canList:e=>e.type===`gdocs`,listDocuments:e=>A(e),loadDocumentContent:P};function I({SidebarComponent:e=f.Sidebar,SidebarContentComponent:i=f.SidebarContent,openSidebarEvent:c}={}){let{activeView:g,toggleToDocs:_,toggleToResearch:v,filesSidebarRequestId:y,requestFilesSidebar:b}=t.b(),{chatTabs:x,activeChatId:S,openChat:C,newChat:w,closeChat:T,closeChats:E}=t.t(),{sendMessage:D}=r.u(),{signIn:O}=r.c(),k=(0,o.useSearchParams)(),[A,j]=(0,a.useState)(null),[M,N]=(0,a.useState)(null),[P,I]=(0,a.useState)(!1),[L,R]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(c)return window.addEventListener(c,b),()=>window.removeEventListener(c,b)},[c,b]),(0,a.useEffect)(()=>{d.localeActions.setLang(`en`),u.themeActions.setColor(`default`)},[]);let z=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(z.current)return;z.current=!0;let e=k.get(`docs`),t=k.get(`chat`);e?(N(e),_()):t&&(C(t),v()),I(!0)},[]),(0,a.useEffect)(()=>{if(typeof window>`u`||!P)return;let e=new URL(window.location.href);e.searchParams.set(`chat`,g===`research`?S??``:``),e.searchParams.set(`docs`,g===`docs`?A??``:``);let t=`${e.pathname}?${e.searchParams.toString()}${e.hash}`;t!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(null,``,t)},[g,S,A,P]);let B=x.map(e=>({id:e.id,title:e.title,kind:`chat`})),V=e=>{C(e),v()},H=e=>{let{closedWasActive:t,nextActiveId:n}=T(e);t&&!n&&_()},U=e=>{let{closedWasActive:t,nextActiveId:n}=E(e);t&&!n&&_()},W=()=>{w(),v()},G=(0,a.useCallback)(e=>(C(e),v(),!0),[C,v]);(0,a.useEffect)(()=>(n.configureResearchAgentUI({onOpenChat:G}),()=>n.configureResearchAgentUI({onOpenChat:void 0})),[G]);let K=async(e,t)=>m(e,p(t)),q=async(e,t)=>h(e,p(t)),J=(0,a.useCallback)(e=>{w(),v(),R(e)},[w,v]);(0,a.useEffect)(()=>{L&&S&&(D(L),R(null))},[L,S,D]);let Y={extraTabs:B,activeExtraTabId:g===`research`?S??void 0:void 0,onExtraTabSelect:V,onExtraTabClose:H,onExtraTabsClose:U,onExtraTabAdd:W,onFileTabSelect:_,initialDocId:M,onActiveDocumentChange:j,onGenerateTips:K,onGenerateTopics:q,onSearchTopic:J,onSignIn:O,fileSourceProvider:F};return g===`docs`?(0,s.jsx)(l.ReasonDocs,{SidebarComponent:e,SidebarContentComponent:i,belowMainContent:(0,s.jsx)(t.U,{}),openFilesSidebarSignal:y,...Y}):(0,s.jsx)(l.ReasonDocs,{SidebarComponent:e,SidebarContentComponent:i,mainContent:(0,s.jsx)(t.L,{}),openFilesSidebarSignal:y,...Y})}function L({SidebarComponent:e,SidebarContentComponent:n,openSidebarEvent:r,...i}){return(0,s.jsx)(t.r,{...i,docsEnabled:!0,children:(0,s.jsx)(I,{SidebarComponent:e,SidebarContentComponent:n,openSidebarEvent:r})})}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=r.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.QwkSearchWorkspaceApp=L,exports.ResearchWorkspaceView=I,exports.SPOTLIGHT_LINKS=t.v,exports.SPOTLIGHT_PREFIXES=t.h,exports.SessionProvider=r.s,exports.SpotlightPalette=t.p,exports.UnifiedMarkdown=t.x,exports.VoiceSettingsPanel=t.l,exports.buildConnectStartUrl=t.M,exports.cn=i.o,exports.configureResearchAgentUI=n.configureResearchAgentUI,exports.createQwkSearchConnectAuthClient=t.N,exports.formatMessageTime=i.s,exports.formatTimeDifference=i.c,exports.formatToolbarShortcut=t.k,exports.getPageTips=m,exports.getQwkSearchApiKey=t.P,exports.getTopicSearches=h,exports.htmlToPlainText=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=n.researchAgentUIConfig,exports.setQwkSearchApiKey=t.I,exports.useChat=r.u,exports.useChatState=t.et,exports.useChatTabs=t.t,exports.useChunkErrorReload=t.o,exports.useExtractPanel=r.a,exports.useHistoryState=t.H,exports.useKokoroTTS=t.f,exports.useMainView=t.b,exports.useOptionalExtractPanel=r.o,exports.useSession=r.c,exports.useTextToSpeech=t.d;
|
package/dist/workspace.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { QwkSearchWorkspaceApp, type QwkSearchWorkspaceAppProps, } from './workspace/QwkSearchWorkspaceApp';
|
|
2
|
-
export { ResearchWorkspaceView } from './workspace/ResearchWorkspaceView';
|
|
2
|
+
export { ResearchWorkspaceView, type ResearchWorkspaceViewProps, } from './workspace/ResearchWorkspaceView';
|
|
3
3
|
export { getPageTips, htmlToPlainText } from './workspace/page-tips';
|
|
4
4
|
export { getTopicSearches } from './workspace/topic-searches';
|
|
5
5
|
export * from './index';
|