open-research 1.0.0 → 1.0.1
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/chunk-3GZIDCV2.js +185 -0
- package/dist/{chunk-TQSQRNX6.js → chunk-3KZN54JZ.js} +23 -34
- package/dist/{chunk-I5NVYKG7.js → chunk-4HCPHCC2.js} +4 -0
- package/dist/chunk-77Q5B5H7.js +27 -0
- package/dist/chunk-GVEVKDGV.js +68 -0
- package/dist/{chunk-ZUSIRA5S.js → chunk-HRVDYJEC.js} +1 -1
- package/dist/cli.js +656 -204
- package/dist/gemini-login-EYY3EFH4.js +94 -0
- package/dist/{manager-queue-F4VVZMTE.js → manager-queue-FBAUCAGI.js} +4 -1
- package/dist/{query-agent-LRUUJR4F.js → query-agent-WM6UNZ37.js} +5 -2
- package/dist/{relevance-agent-CCN7JGTM.js → relevance-agent-H3U6TROD.js} +4 -1
- package/dist/{sessions-GRES2MUV.js → sessions-KL4LUGD7.js} +2 -2
- package/dist/{web-search-B7D5WMHU.js → web-search-TKBFSU3M.js} +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildGeminiAuthorizationUrl,
|
|
3
|
+
exchangeGeminiCodeForTokens,
|
|
4
|
+
getGeminiRedirectUri,
|
|
5
|
+
getGeminiUserEmail,
|
|
6
|
+
loadCodeAssistProject,
|
|
7
|
+
saveGeminiAuth
|
|
8
|
+
} from "./chunk-3GZIDCV2.js";
|
|
9
|
+
import "./chunk-77Q5B5H7.js";
|
|
10
|
+
import "./chunk-4HCPHCC2.js";
|
|
11
|
+
import "./chunk-3RG5ZIWI.js";
|
|
12
|
+
|
|
13
|
+
// src/lib/auth/gemini-login.ts
|
|
14
|
+
import http from "http";
|
|
15
|
+
import crypto from "crypto";
|
|
16
|
+
async function loginWithGemini(options) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const state = crypto.randomBytes(16).toString("hex");
|
|
19
|
+
const server = http.createServer(async (req, res) => {
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(req.url ?? "/", `http://127.0.0.1`);
|
|
22
|
+
if (url.pathname !== "/oauth2callback") {
|
|
23
|
+
res.writeHead(404);
|
|
24
|
+
res.end("Not found");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const code = url.searchParams.get("code");
|
|
28
|
+
const returnedState = url.searchParams.get("state");
|
|
29
|
+
const error = url.searchParams.get("error");
|
|
30
|
+
if (error) {
|
|
31
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
32
|
+
res.end(`<html><body><h2>Authentication failed</h2><p>${error}</p><p>You can close this tab.</p></body></html>`);
|
|
33
|
+
server.close();
|
|
34
|
+
reject(new Error(`Google OAuth error: ${error}`));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!code || returnedState !== state) {
|
|
38
|
+
res.writeHead(400, { "Content-Type": "text/html" });
|
|
39
|
+
res.end("<html><body><h2>Invalid callback</h2><p>Missing code or state mismatch.</p></body></html>");
|
|
40
|
+
server.close();
|
|
41
|
+
reject(new Error("Invalid OAuth callback"));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const port = server.address().port;
|
|
45
|
+
const redirectUri = getGeminiRedirectUri(port);
|
|
46
|
+
const tokenResponse = await exchangeGeminiCodeForTokens(code, redirectUri);
|
|
47
|
+
const email = await getGeminiUserEmail(tokenResponse.access_token);
|
|
48
|
+
const projectId = await loadCodeAssistProject(tokenResponse.access_token);
|
|
49
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
50
|
+
const stored = {
|
|
51
|
+
provider: "gemini_auth",
|
|
52
|
+
tokens: {
|
|
53
|
+
access: tokenResponse.access_token,
|
|
54
|
+
refresh: tokenResponse.refresh_token ?? "",
|
|
55
|
+
expires: Date.now() + tokenResponse.expires_in * 1e3,
|
|
56
|
+
email,
|
|
57
|
+
projectId
|
|
58
|
+
},
|
|
59
|
+
createdAt: now,
|
|
60
|
+
updatedAt: now
|
|
61
|
+
};
|
|
62
|
+
await saveGeminiAuth(stored, { homeDir: options?.homeDir });
|
|
63
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
64
|
+
res.end(`<html><body><h2>Connected to Google</h2><p>${email}</p><p>You can close this tab and return to Open Research.</p></body></html>`);
|
|
65
|
+
server.close();
|
|
66
|
+
resolve(stored);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
res.writeHead(500, { "Content-Type": "text/html" });
|
|
69
|
+
res.end("<html><body><h2>Error</h2><p>Authentication failed. Check the CLI for details.</p></body></html>");
|
|
70
|
+
server.close();
|
|
71
|
+
reject(err);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
server.listen(0, "127.0.0.1", async () => {
|
|
75
|
+
const port = server.address().port;
|
|
76
|
+
const authUrl = buildGeminiAuthorizationUrl({ port, state });
|
|
77
|
+
try {
|
|
78
|
+
const openModule = await import("open");
|
|
79
|
+
await openModule.default(authUrl);
|
|
80
|
+
} catch {
|
|
81
|
+
console.log(`Open this URL in your browser:
|
|
82
|
+
${authUrl}`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
server.on("error", reject);
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
server.close();
|
|
88
|
+
reject(new Error("Gemini login timed out (5 min). Try again."));
|
|
89
|
+
}, 3e5);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
loginWithGemini
|
|
94
|
+
};
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_CONFIDENCE
|
|
7
7
|
} from "./chunk-KJHM7ZW2.js";
|
|
8
|
+
import {
|
|
9
|
+
getProviderCatalog
|
|
10
|
+
} from "./chunk-GVEVKDGV.js";
|
|
8
11
|
import {
|
|
9
12
|
getConnections,
|
|
10
13
|
getNote,
|
|
@@ -548,7 +551,7 @@ async function runOntologyManager(input) {
|
|
|
548
551
|
for await (const chunk of input.provider.callLLMStreaming({
|
|
549
552
|
messages,
|
|
550
553
|
tools: MANAGER_TOOLS,
|
|
551
|
-
model:
|
|
554
|
+
model: getProviderCatalog(input.provider.kind).defaultModel
|
|
552
555
|
})) {
|
|
553
556
|
if (chunk.type === "text_delta") {
|
|
554
557
|
fullText += chunk.content;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadOntology
|
|
3
3
|
} from "./chunk-3WM33M3O.js";
|
|
4
|
+
import {
|
|
5
|
+
getProviderCatalog
|
|
6
|
+
} from "./chunk-GVEVKDGV.js";
|
|
4
7
|
import {
|
|
5
8
|
getConnections,
|
|
6
9
|
getNote,
|
|
@@ -145,7 +148,7 @@ async function runQueryAgent(input) {
|
|
|
145
148
|
for await (const chunk of input.provider.callLLMStreaming({
|
|
146
149
|
messages,
|
|
147
150
|
tools: QUERY_TOOLS,
|
|
148
|
-
model:
|
|
151
|
+
model: getProviderCatalog(input.provider.kind).backgroundModel
|
|
149
152
|
})) {
|
|
150
153
|
if (chunk.type === "text_delta") {
|
|
151
154
|
fullText += chunk.content;
|
|
@@ -182,7 +185,7 @@ async function runQueryAgent(input) {
|
|
|
182
185
|
let finalText = "";
|
|
183
186
|
for await (const chunk of input.provider.callLLMStreaming({
|
|
184
187
|
messages,
|
|
185
|
-
model:
|
|
188
|
+
model: getProviderCatalog(input.provider.kind).backgroundModel
|
|
186
189
|
})) {
|
|
187
190
|
if (chunk.type === "text_delta") finalText += chunk.content;
|
|
188
191
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getProviderCatalog
|
|
3
|
+
} from "./chunk-GVEVKDGV.js";
|
|
1
4
|
import "./chunk-3RG5ZIWI.js";
|
|
2
5
|
|
|
3
6
|
// src/lib/ontology/relevance-agent.ts
|
|
@@ -53,7 +56,7 @@ ${userMessage}
|
|
|
53
56
|
${noteList}`
|
|
54
57
|
}
|
|
55
58
|
],
|
|
56
|
-
model:
|
|
59
|
+
model: getProviderCatalog(input.provider.kind).backgroundModel,
|
|
57
60
|
maxTokens: 500,
|
|
58
61
|
temperature: 0
|
|
59
62
|
});
|
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
fetchAndParseContent,
|
|
5
5
|
formatExtractionResults,
|
|
6
6
|
loadOpenResearchConfig
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-3KZN54JZ.js";
|
|
8
|
+
import "./chunk-77Q5B5H7.js";
|
|
9
|
+
import "./chunk-4HCPHCC2.js";
|
|
10
|
+
import "./chunk-GVEVKDGV.js";
|
|
9
11
|
import "./chunk-3RG5ZIWI.js";
|
|
10
12
|
|
|
11
13
|
// src/lib/search/duckduckgo.ts
|
package/package.json
CHANGED