@pan-sec/notebooklm-mcp 2026.2.11 → 2026.3.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/README.md +62 -19
- package/SECURITY.md +31 -61
- package/dist/auth/auth-manager.d.ts +2 -1
- package/dist/auth/auth-manager.d.ts.map +1 -1
- package/dist/auth/auth-manager.js +117 -44
- package/dist/auth/auth-manager.js.map +1 -1
- package/dist/auth/mcp-auth.d.ts +24 -4
- package/dist/auth/mcp-auth.d.ts.map +1 -1
- package/dist/auth/mcp-auth.js +149 -19
- package/dist/auth/mcp-auth.js.map +1 -1
- package/dist/compliance/alert-manager.d.ts.map +1 -1
- package/dist/compliance/alert-manager.js +7 -4
- package/dist/compliance/alert-manager.js.map +1 -1
- package/dist/compliance/breach-detection.d.ts.map +1 -1
- package/dist/compliance/breach-detection.js +14 -7
- package/dist/compliance/breach-detection.js.map +1 -1
- package/dist/compliance/change-log.d.ts.map +1 -1
- package/dist/compliance/change-log.js +7 -4
- package/dist/compliance/change-log.js.map +1 -1
- package/dist/compliance/compliance-logger.d.ts.map +1 -1
- package/dist/compliance/compliance-logger.js +11 -6
- package/dist/compliance/compliance-logger.js.map +1 -1
- package/dist/compliance/consent-manager.d.ts.map +1 -1
- package/dist/compliance/consent-manager.js +5 -3
- package/dist/compliance/consent-manager.js.map +1 -1
- package/dist/compliance/data-erasure.d.ts +1 -1
- package/dist/compliance/data-erasure.d.ts.map +1 -1
- package/dist/compliance/data-erasure.js +142 -83
- package/dist/compliance/data-erasure.js.map +1 -1
- package/dist/compliance/data-export.d.ts.map +1 -1
- package/dist/compliance/data-export.js +23 -12
- package/dist/compliance/data-export.js.map +1 -1
- package/dist/compliance/data-inventory.d.ts.map +1 -1
- package/dist/compliance/data-inventory.js +7 -6
- package/dist/compliance/data-inventory.js.map +1 -1
- package/dist/compliance/dsar-handler.d.ts +7 -1
- package/dist/compliance/dsar-handler.d.ts.map +1 -1
- package/dist/compliance/dsar-handler.js +74 -61
- package/dist/compliance/dsar-handler.js.map +1 -1
- package/dist/compliance/evidence-collector.d.ts.map +1 -1
- package/dist/compliance/evidence-collector.js +10 -6
- package/dist/compliance/evidence-collector.js.map +1 -1
- package/dist/compliance/health-monitor.d.ts.map +1 -1
- package/dist/compliance/health-monitor.js +15 -9
- package/dist/compliance/health-monitor.js.map +1 -1
- package/dist/compliance/incident-manager.d.ts.map +1 -1
- package/dist/compliance/incident-manager.js +5 -3
- package/dist/compliance/incident-manager.js.map +1 -1
- package/dist/compliance/policy-docs.d.ts.map +1 -1
- package/dist/compliance/policy-docs.js +14 -11
- package/dist/compliance/policy-docs.js.map +1 -1
- package/dist/compliance/privacy-notice-text.d.ts.map +1 -1
- package/dist/compliance/privacy-notice-text.js +3 -4
- package/dist/compliance/privacy-notice-text.js.map +1 -1
- package/dist/compliance/privacy-notice.d.ts.map +1 -1
- package/dist/compliance/privacy-notice.js +5 -3
- package/dist/compliance/privacy-notice.js.map +1 -1
- package/dist/compliance/report-generator.d.ts.map +1 -1
- package/dist/compliance/report-generator.js +5 -3
- package/dist/compliance/report-generator.js.map +1 -1
- package/dist/compliance/retention-engine.d.ts.map +1 -1
- package/dist/compliance/retention-engine.js +24 -10
- package/dist/compliance/retention-engine.js.map +1 -1
- package/dist/compliance/siem-exporter.d.ts.map +1 -1
- package/dist/compliance/siem-exporter.js +40 -16
- package/dist/compliance/siem-exporter.js.map +1 -1
- package/dist/config.d.ts +8 -31
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -64
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +22 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +55 -4
- package/dist/errors.js.map +1 -1
- package/dist/gemini/gemini-client.d.ts +1 -0
- package/dist/gemini/gemini-client.d.ts.map +1 -1
- package/dist/gemini/gemini-client.js +50 -49
- package/dist/gemini/gemini-client.js.map +1 -1
- package/dist/gemini/types.d.ts +3 -1
- package/dist/gemini/types.d.ts.map +1 -1
- package/dist/gemini/types.js.map +1 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +412 -89
- package/dist/index.js.map +1 -1
- package/dist/library/notebook-library.d.ts.map +1 -1
- package/dist/library/notebook-library.js +2 -1
- package/dist/library/notebook-library.js.map +1 -1
- package/dist/logging/query-logger.d.ts +13 -1
- package/dist/logging/query-logger.d.ts.map +1 -1
- package/dist/logging/query-logger.js +62 -10
- package/dist/logging/query-logger.js.map +1 -1
- package/dist/notebook-creation/audio-manager.d.ts.map +1 -1
- package/dist/notebook-creation/audio-manager.js +19 -24
- package/dist/notebook-creation/audio-manager.js.map +1 -1
- package/dist/notebook-creation/browser-options.d.ts +28 -0
- package/dist/notebook-creation/browser-options.d.ts.map +1 -0
- package/dist/notebook-creation/browser-options.js +75 -0
- package/dist/notebook-creation/browser-options.js.map +1 -0
- package/dist/notebook-creation/data-table-manager.d.ts.map +1 -1
- package/dist/notebook-creation/data-table-manager.js +20 -21
- package/dist/notebook-creation/data-table-manager.js.map +1 -1
- package/dist/notebook-creation/discover-creation-flow.d.ts +0 -6
- package/dist/notebook-creation/discover-creation-flow.d.ts.map +1 -1
- package/dist/notebook-creation/discover-creation-flow.js +10 -10
- package/dist/notebook-creation/discover-creation-flow.js.map +1 -1
- package/dist/notebook-creation/discover-quota.d.ts +0 -6
- package/dist/notebook-creation/discover-quota.d.ts.map +1 -1
- package/dist/notebook-creation/discover-quota.js +12 -13
- package/dist/notebook-creation/discover-quota.js.map +1 -1
- package/dist/notebook-creation/discover-sources.js +15 -16
- package/dist/notebook-creation/discover-sources.js.map +1 -1
- package/dist/notebook-creation/dom-scripts.d.ts +10 -0
- package/dist/notebook-creation/dom-scripts.d.ts.map +1 -0
- package/dist/notebook-creation/dom-scripts.js +58 -0
- package/dist/notebook-creation/dom-scripts.js.map +1 -0
- package/dist/notebook-creation/errors.d.ts +18 -0
- package/dist/notebook-creation/errors.d.ts.map +1 -0
- package/dist/notebook-creation/errors.js +20 -0
- package/dist/notebook-creation/errors.js.map +1 -0
- package/dist/notebook-creation/index.d.ts +2 -1
- package/dist/notebook-creation/index.d.ts.map +1 -1
- package/dist/notebook-creation/index.js +2 -1
- package/dist/notebook-creation/index.js.map +1 -1
- package/dist/notebook-creation/notebook-creator.d.ts +6 -82
- package/dist/notebook-creation/notebook-creator.d.ts.map +1 -1
- package/dist/notebook-creation/notebook-creator.js +49 -835
- package/dist/notebook-creation/notebook-creator.js.map +1 -1
- package/dist/notebook-creation/notebook-nav.d.ts +19 -0
- package/dist/notebook-creation/notebook-nav.d.ts.map +1 -0
- package/dist/notebook-creation/notebook-nav.js +240 -0
- package/dist/notebook-creation/notebook-nav.js.map +1 -0
- package/dist/notebook-creation/notebook-sync.d.ts.map +1 -1
- package/dist/notebook-creation/notebook-sync.js +36 -38
- package/dist/notebook-creation/notebook-sync.js.map +1 -1
- package/dist/notebook-creation/selector-discovery.d.ts.map +1 -1
- package/dist/notebook-creation/selector-discovery.js +17 -24
- package/dist/notebook-creation/selector-discovery.js.map +1 -1
- package/dist/notebook-creation/selectors.d.ts +23 -37
- package/dist/notebook-creation/selectors.d.ts.map +1 -1
- package/dist/notebook-creation/selectors.js +56 -60
- package/dist/notebook-creation/selectors.js.map +1 -1
- package/dist/notebook-creation/source-manager.d.ts +25 -0
- package/dist/notebook-creation/source-manager.d.ts.map +1 -1
- package/dist/notebook-creation/source-manager.js +689 -50
- package/dist/notebook-creation/source-manager.js.map +1 -1
- package/dist/notebook-creation/types.d.ts +4 -0
- package/dist/notebook-creation/types.d.ts.map +1 -1
- package/dist/notebook-creation/video-manager.d.ts.map +1 -1
- package/dist/notebook-creation/video-manager.js +33 -35
- package/dist/notebook-creation/video-manager.js.map +1 -1
- package/dist/observability/metrics.d.ts +19 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/metrics.js +35 -0
- package/dist/observability/metrics.js.map +1 -0
- package/dist/quota/quota-manager.d.ts +11 -3
- package/dist/quota/quota-manager.d.ts.map +1 -1
- package/dist/quota/quota-manager.js +139 -47
- package/dist/quota/quota-manager.js.map +1 -1
- package/dist/resources/resource-handlers.d.ts.map +1 -1
- package/dist/resources/resource-handlers.js +39 -17
- package/dist/resources/resource-handlers.js.map +1 -1
- package/dist/session/browser-session.d.ts.map +1 -1
- package/dist/session/browser-session.js +22 -22
- package/dist/session/browser-session.js.map +1 -1
- package/dist/session/session-timeout.d.ts.map +1 -1
- package/dist/session/session-timeout.js +4 -2
- package/dist/session/session-timeout.js.map +1 -1
- package/dist/session/shared-context-manager.d.ts.map +1 -1
- package/dist/session/shared-context-manager.js +31 -30
- package/dist/session/shared-context-manager.js.map +1 -1
- package/dist/tools/annotations.d.ts.map +1 -1
- package/dist/tools/annotations.js +9 -56
- package/dist/tools/annotations.js.map +1 -1
- package/dist/tools/definitions/ask-question.d.ts.map +1 -1
- package/dist/tools/definitions/ask-question.js +35 -100
- package/dist/tools/definitions/ask-question.js.map +1 -1
- package/dist/tools/definitions/chat-history.d.ts +47 -1
- package/dist/tools/definitions/chat-history.d.ts.map +1 -1
- package/dist/tools/definitions/chat-history.js +10 -1
- package/dist/tools/definitions/chat-history.js.map +1 -1
- package/dist/tools/definitions/data-tables.d.ts.map +1 -1
- package/dist/tools/definitions/data-tables.js +2 -0
- package/dist/tools/definitions/data-tables.js.map +1 -1
- package/dist/tools/definitions/gemini.d.ts.map +1 -1
- package/dist/tools/definitions/gemini.js +54 -11
- package/dist/tools/definitions/gemini.js.map +1 -1
- package/dist/tools/definitions/notebook-management.d.ts.map +1 -1
- package/dist/tools/definitions/notebook-management.js +100 -70
- package/dist/tools/definitions/notebook-management.js.map +1 -1
- package/dist/tools/definitions/query-history.d.ts +47 -1
- package/dist/tools/definitions/query-history.d.ts.map +1 -1
- package/dist/tools/definitions/query-history.js +7 -0
- package/dist/tools/definitions/query-history.js.map +1 -1
- package/dist/tools/definitions/session-management.d.ts.map +1 -1
- package/dist/tools/definitions/session-management.js +5 -0
- package/dist/tools/definitions/session-management.js.map +1 -1
- package/dist/tools/definitions/system.d.ts.map +1 -1
- package/dist/tools/definitions/system.js +71 -100
- package/dist/tools/definitions/system.js.map +1 -1
- package/dist/tools/definitions/video.d.ts.map +1 -1
- package/dist/tools/definitions/video.js +4 -1
- package/dist/tools/definitions/video.js.map +1 -1
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/definitions.js +4 -0
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/handlers/ask-question.d.ts +1 -1
- package/dist/tools/handlers/ask-question.d.ts.map +1 -1
- package/dist/tools/handlers/ask-question.js +57 -13
- package/dist/tools/handlers/ask-question.js.map +1 -1
- package/dist/tools/handlers/audio-video.d.ts.map +1 -1
- package/dist/tools/handlers/audio-video.js +22 -161
- package/dist/tools/handlers/audio-video.js.map +1 -1
- package/dist/tools/handlers/auth.d.ts +14 -19
- package/dist/tools/handlers/auth.d.ts.map +1 -1
- package/dist/tools/handlers/auth.js +77 -121
- package/dist/tools/handlers/auth.js.map +1 -1
- package/dist/tools/handlers/error-utils.d.ts +16 -0
- package/dist/tools/handlers/error-utils.d.ts.map +1 -0
- package/dist/tools/handlers/error-utils.js +39 -0
- package/dist/tools/handlers/error-utils.js.map +1 -0
- package/dist/tools/handlers/gemini.d.ts +2 -0
- package/dist/tools/handlers/gemini.d.ts.map +1 -1
- package/dist/tools/handlers/gemini.js +88 -51
- package/dist/tools/handlers/gemini.js.map +1 -1
- package/dist/tools/handlers/index.d.ts +39 -47
- package/dist/tools/handlers/index.d.ts.map +1 -1
- package/dist/tools/handlers/index.js +15 -4
- package/dist/tools/handlers/index.js.map +1 -1
- package/dist/tools/handlers/notebook-creation.d.ts.map +1 -1
- package/dist/tools/handlers/notebook-creation.js +102 -86
- package/dist/tools/handlers/notebook-creation.js.map +1 -1
- package/dist/tools/handlers/notebook-management.d.ts +8 -8
- package/dist/tools/handlers/notebook-management.d.ts.map +1 -1
- package/dist/tools/handlers/notebook-management.js +34 -80
- package/dist/tools/handlers/notebook-management.js.map +1 -1
- package/dist/tools/handlers/session-management.d.ts +8 -10
- package/dist/tools/handlers/session-management.d.ts.map +1 -1
- package/dist/tools/handlers/session-management.js +34 -63
- package/dist/tools/handlers/session-management.js.map +1 -1
- package/dist/tools/handlers/system.d.ts.map +1 -1
- package/dist/tools/handlers/system.js +45 -10
- package/dist/tools/handlers/system.js.map +1 -1
- package/dist/tools/handlers/types.d.ts +1 -1
- package/dist/tools/handlers/types.d.ts.map +1 -1
- package/dist/tools/handlers/webhooks.d.ts.map +1 -1
- package/dist/tools/handlers/webhooks.js +15 -13
- package/dist/tools/handlers/webhooks.js.map +1 -1
- package/dist/types.d.ts +7 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/audit-logger.d.ts +19 -1
- package/dist/utils/audit-logger.d.ts.map +1 -1
- package/dist/utils/audit-logger.js +198 -30
- package/dist/utils/audit-logger.js.map +1 -1
- package/dist/utils/cleanup-manager.d.ts.map +1 -1
- package/dist/utils/cleanup-manager.js +6 -3
- package/dist/utils/cleanup-manager.js.map +1 -1
- package/dist/utils/crypto.d.ts +4 -1
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +32 -21
- package/dist/utils/crypto.js.map +1 -1
- package/dist/utils/file-lock.d.ts.map +1 -1
- package/dist/utils/file-lock.js +87 -16
- package/dist/utils/file-lock.js.map +1 -1
- package/dist/utils/file-permissions.d.ts +2 -0
- package/dist/utils/file-permissions.d.ts.map +1 -1
- package/dist/utils/file-permissions.js +2 -1
- package/dist/utils/file-permissions.js.map +1 -1
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +16 -0
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/page-utils.d.ts +13 -0
- package/dist/utils/page-utils.d.ts.map +1 -1
- package/dist/utils/page-utils.js +61 -39
- package/dist/utils/page-utils.js.map +1 -1
- package/dist/utils/response-validator.d.ts.map +1 -1
- package/dist/utils/response-validator.js +27 -22
- package/dist/utils/response-validator.js.map +1 -1
- package/dist/utils/secrets-scanner.d.ts +11 -0
- package/dist/utils/secrets-scanner.d.ts.map +1 -1
- package/dist/utils/secrets-scanner.js +65 -17
- package/dist/utils/secrets-scanner.js.map +1 -1
- package/dist/utils/secure-memory.d.ts +9 -31
- package/dist/utils/secure-memory.d.ts.map +1 -1
- package/dist/utils/secure-memory.js +17 -102
- package/dist/utils/secure-memory.js.map +1 -1
- package/dist/utils/security.d.ts +4 -3
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js +43 -13
- package/dist/utils/security.js.map +1 -1
- package/dist/utils/stealth-utils.d.ts.map +1 -1
- package/dist/utils/stealth-utils.js +4 -4
- package/dist/utils/stealth-utils.js.map +1 -1
- package/dist/webhooks/types.d.ts +4 -0
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/webhooks/webhook-dispatcher.d.ts +80 -12
- package/dist/webhooks/webhook-dispatcher.d.ts.map +1 -1
- package/dist/webhooks/webhook-dispatcher.js +497 -74
- package/dist/webhooks/webhook-dispatcher.js.map +1 -1
- package/docs/archive/ISSUES-legacy-2026-04-24.md +644 -0
- package/docs/dependency-risk.md +25 -0
- package/docs/testing-runbook.md +166 -0
- package/docs/usage-guide.md +2 -1
- package/package.json +34 -16
package/dist/config.js
CHANGED
|
@@ -16,11 +16,12 @@ import { SecureCredential } from "./utils/secure-memory.js";
|
|
|
16
16
|
/**
|
|
17
17
|
* Clamp an integer to a [min, max] range
|
|
18
18
|
*/
|
|
19
|
-
function clampInteger(value, min, max) {
|
|
19
|
+
export function clampInteger(value, min, max) {
|
|
20
20
|
return Math.max(min, Math.min(max, value));
|
|
21
21
|
}
|
|
22
22
|
/** Credential TTL: 30 minutes */
|
|
23
23
|
const CREDENTIAL_TTL_MS = 30 * 60 * 1000;
|
|
24
|
+
const DEFAULT_FOLLOW_UP_REMINDER = "\n\nEXTREMELY IMPORTANT: Is that ALL you need to know? You can always ask another question using the same session ID! Think about it carefully: before you reply to the user, review their original request and this answer. If anything is still unclear or missing, ask me another question first.";
|
|
24
25
|
/** Secure credential holders (module-level so they persist) */
|
|
25
26
|
let secureLoginPassword = null;
|
|
26
27
|
let secureGeminiApiKey = null;
|
|
@@ -34,6 +35,7 @@ const paths = envPaths("notebooklm-mcp", { suffix: "" });
|
|
|
34
35
|
* Google NotebookLM Auth URL (used by setup_auth)
|
|
35
36
|
* This is the base Google login URL that redirects to NotebookLM
|
|
36
37
|
*/
|
|
38
|
+
export const NOTEBOOKLM_URL = "https://notebooklm.google.com/";
|
|
37
39
|
export const NOTEBOOKLM_AUTH_URL = "https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fnotebooklm.google.com%2F&flowName=GlifWebSignIn&flowEntry=ServiceLogin";
|
|
38
40
|
/**
|
|
39
41
|
* Default Configuration (works out of the box!)
|
|
@@ -90,7 +92,7 @@ const DEFAULTS = {
|
|
|
90
92
|
// NotebookLM response timeout
|
|
91
93
|
responseTimeout: 120000, // 2 minutes
|
|
92
94
|
// Follow-up reminder
|
|
93
|
-
followUpReminder:
|
|
95
|
+
followUpReminder: DEFAULT_FOLLOW_UP_REMINDER,
|
|
94
96
|
followUpEnabled: true,
|
|
95
97
|
};
|
|
96
98
|
/**
|
|
@@ -112,16 +114,22 @@ export function parseBoolean(value, defaultValue) {
|
|
|
112
114
|
export function parseInteger(value, defaultValue) {
|
|
113
115
|
if (value === undefined)
|
|
114
116
|
return defaultValue;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
if (value.trim() === "")
|
|
118
|
+
return defaultValue;
|
|
119
|
+
const parsed = Number(value);
|
|
120
|
+
const result = Math.trunc(parsed);
|
|
121
|
+
if (!Number.isFinite(result) || !Number.isInteger(result)) {
|
|
122
|
+
return defaultValue;
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
117
125
|
}
|
|
118
126
|
/**
|
|
119
|
-
* Parse comma-separated array (for env vars)
|
|
127
|
+
* Parse comma/semicolon-separated array (for env vars)
|
|
120
128
|
*/
|
|
121
129
|
export function parseArray(value, defaultValue) {
|
|
122
130
|
if (!value)
|
|
123
131
|
return defaultValue;
|
|
124
|
-
return value.split(
|
|
132
|
+
return value.split(/[,;]/).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
125
133
|
}
|
|
126
134
|
/**
|
|
127
135
|
* Apply environment variable overrides (legacy support)
|
|
@@ -182,8 +190,14 @@ function applyEnvOverrides(config) {
|
|
|
182
190
|
noGemini: parseBoolean(process.env.NOTEBOOKLM_NO_GEMINI, config.noGemini),
|
|
183
191
|
// NotebookLM response timeout
|
|
184
192
|
responseTimeout: parseInteger(process.env.NLMCP_RESPONSE_TIMEOUT_MS, config.responseTimeout),
|
|
185
|
-
// Follow-up reminder
|
|
186
|
-
followUpReminder:
|
|
193
|
+
// Follow-up reminder — validate to prevent env-based prompt injection (I318)
|
|
194
|
+
followUpReminder: (() => {
|
|
195
|
+
const raw = process.env.NLMCP_FOLLOW_UP_REMINDER;
|
|
196
|
+
if (!raw)
|
|
197
|
+
return config.followUpReminder;
|
|
198
|
+
// Strip any embedded null bytes or control chars (except newline/tab)
|
|
199
|
+
return raw.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, "").slice(0, 2000);
|
|
200
|
+
})(),
|
|
187
201
|
followUpEnabled: parseBoolean(process.env.NLMCP_FOLLOW_UP_ENABLED, config.followUpEnabled),
|
|
188
202
|
};
|
|
189
203
|
}
|
|
@@ -211,17 +225,14 @@ function buildConfig() {
|
|
|
211
225
|
* Global configuration instance
|
|
212
226
|
*/
|
|
213
227
|
export const CONFIG = buildConfig();
|
|
214
|
-
/**
|
|
215
|
-
* Get configuration (alias for CONFIG, used by compliance modules)
|
|
216
|
-
*/
|
|
217
|
-
export function getConfig() {
|
|
218
|
-
return CONFIG;
|
|
219
|
-
}
|
|
220
228
|
/**
|
|
221
229
|
* Ensure all required directories exist
|
|
222
230
|
* NOTE: We do NOT create configDir - it's not needed!
|
|
223
231
|
*/
|
|
224
232
|
export function ensureDirectories() {
|
|
233
|
+
if (process.env.NODE_ENV === "test") {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
225
236
|
const dirs = [
|
|
226
237
|
CONFIG.dataDir,
|
|
227
238
|
CONFIG.browserStateDir,
|
|
@@ -234,54 +245,5 @@ export function ensureDirectories() {
|
|
|
234
245
|
}
|
|
235
246
|
}
|
|
236
247
|
}
|
|
237
|
-
|
|
238
|
-
* Apply browser options to CONFIG (returns modified copy, doesn't mutate global CONFIG)
|
|
239
|
-
*/
|
|
240
|
-
export function applyBrowserOptions(options, legacyShowBrowser) {
|
|
241
|
-
const config = { ...CONFIG };
|
|
242
|
-
// Handle legacy show_browser parameter
|
|
243
|
-
if (legacyShowBrowser !== undefined) {
|
|
244
|
-
config.headless = !legacyShowBrowser;
|
|
245
|
-
}
|
|
246
|
-
// Apply browser_options (takes precedence over legacy parameter)
|
|
247
|
-
if (options) {
|
|
248
|
-
if (options.show !== undefined) {
|
|
249
|
-
config.headless = !options.show;
|
|
250
|
-
}
|
|
251
|
-
if (options.headless !== undefined) {
|
|
252
|
-
config.headless = options.headless;
|
|
253
|
-
}
|
|
254
|
-
if (options.timeout_ms !== undefined) {
|
|
255
|
-
config.browserTimeout = options.timeout_ms;
|
|
256
|
-
}
|
|
257
|
-
if (options.stealth) {
|
|
258
|
-
const s = options.stealth;
|
|
259
|
-
if (s.enabled !== undefined)
|
|
260
|
-
config.stealthEnabled = s.enabled;
|
|
261
|
-
if (s.random_delays !== undefined)
|
|
262
|
-
config.stealthRandomDelays = s.random_delays;
|
|
263
|
-
if (s.human_typing !== undefined)
|
|
264
|
-
config.stealthHumanTyping = s.human_typing;
|
|
265
|
-
if (s.mouse_movements !== undefined)
|
|
266
|
-
config.stealthMouseMovements = s.mouse_movements;
|
|
267
|
-
if (s.typing_wpm_min !== undefined)
|
|
268
|
-
config.typingWpmMin = s.typing_wpm_min;
|
|
269
|
-
if (s.typing_wpm_max !== undefined)
|
|
270
|
-
config.typingWpmMax = s.typing_wpm_max;
|
|
271
|
-
if (s.delay_min_ms !== undefined)
|
|
272
|
-
config.minDelayMs = s.delay_min_ms;
|
|
273
|
-
if (s.delay_max_ms !== undefined)
|
|
274
|
-
config.maxDelayMs = s.delay_max_ms;
|
|
275
|
-
}
|
|
276
|
-
if (options.viewport) {
|
|
277
|
-
config.viewport = {
|
|
278
|
-
width: options.viewport.width ?? config.viewport.width,
|
|
279
|
-
height: options.viewport.height ?? config.viewport.height,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return config;
|
|
284
|
-
}
|
|
285
|
-
// Create directories on import
|
|
286
|
-
ensureDirectories();
|
|
248
|
+
export { applyBrowserOptions } from "./notebook-creation/browser-options.js";
|
|
287
249
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,GA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AAmB,EAAE,MAAM,wCAAwC,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -20,7 +20,27 @@ export declare class RateLimitError extends Error {
|
|
|
20
20
|
* Especially useful when upgrading from old installation (notebooklm-mcp-nodejs).
|
|
21
21
|
*/
|
|
22
22
|
export declare class AuthenticationError extends Error {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class ValidationError extends Error {
|
|
26
|
+
field?: string;
|
|
27
|
+
constructor(message: string, field?: string);
|
|
28
|
+
}
|
|
29
|
+
export declare class QuotaError extends Error {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
export declare class NotFoundError extends Error {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
export declare class UpstreamError extends Error {
|
|
36
|
+
statusCode?: number;
|
|
37
|
+
constructor(message: string, statusCode?: number);
|
|
38
|
+
}
|
|
39
|
+
export declare class BrowserError extends Error {
|
|
40
|
+
constructor(message: string);
|
|
41
|
+
}
|
|
42
|
+
export declare class SessionExpiredError extends Error {
|
|
43
|
+
sessionId?: string;
|
|
44
|
+
constructor(message: string, sessionId?: string);
|
|
25
45
|
}
|
|
26
46
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,GAAE,MAA2E;CASjG;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,GAAE,MAA2E;CASjG;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAQ5B;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAM5C;AAED,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;gBACR,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAMjD;AAED,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;gBACP,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAMhD"}
|
package/dist/errors.js
CHANGED
|
@@ -27,15 +27,66 @@ export class RateLimitError extends Error {
|
|
|
27
27
|
* Especially useful when upgrading from old installation (notebooklm-mcp-nodejs).
|
|
28
28
|
*/
|
|
29
29
|
export class AuthenticationError extends Error {
|
|
30
|
-
|
|
31
|
-
constructor(message, suggestCleanup = false) {
|
|
30
|
+
constructor(message) {
|
|
32
31
|
super(message);
|
|
33
32
|
this.name = "AuthenticationError";
|
|
34
|
-
this.suggestCleanup = suggestCleanup;
|
|
35
|
-
// Maintain proper stack trace for where error was thrown (V8 only)
|
|
36
33
|
if (Error.captureStackTrace) {
|
|
37
34
|
Error.captureStackTrace(this, AuthenticationError);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
}
|
|
38
|
+
export class ValidationError extends Error {
|
|
39
|
+
field;
|
|
40
|
+
constructor(message, field) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = "ValidationError";
|
|
43
|
+
this.field = field;
|
|
44
|
+
if (Error.captureStackTrace)
|
|
45
|
+
Error.captureStackTrace(this, ValidationError);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class QuotaError extends Error {
|
|
49
|
+
constructor(message) {
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = "QuotaError";
|
|
52
|
+
if (Error.captureStackTrace)
|
|
53
|
+
Error.captureStackTrace(this, QuotaError);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class NotFoundError extends Error {
|
|
57
|
+
constructor(message) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.name = "NotFoundError";
|
|
60
|
+
if (Error.captureStackTrace)
|
|
61
|
+
Error.captureStackTrace(this, NotFoundError);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class UpstreamError extends Error {
|
|
65
|
+
statusCode;
|
|
66
|
+
constructor(message, statusCode) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = "UpstreamError";
|
|
69
|
+
this.statusCode = statusCode;
|
|
70
|
+
if (Error.captureStackTrace)
|
|
71
|
+
Error.captureStackTrace(this, UpstreamError);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export class BrowserError extends Error {
|
|
75
|
+
constructor(message) {
|
|
76
|
+
super(message);
|
|
77
|
+
this.name = "BrowserError";
|
|
78
|
+
if (Error.captureStackTrace)
|
|
79
|
+
Error.captureStackTrace(this, BrowserError);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export class SessionExpiredError extends Error {
|
|
83
|
+
sessionId;
|
|
84
|
+
constructor(message, sessionId) {
|
|
85
|
+
super(message);
|
|
86
|
+
this.name = "SessionExpiredError";
|
|
87
|
+
this.sessionId = sessionId;
|
|
88
|
+
if (Error.captureStackTrace)
|
|
89
|
+
Error.captureStackTrace(this, SessionExpiredError);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
41
92
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,UAAkB,kEAAkE;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAE7B,mEAAmE;QACnE,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,UAAkB,kEAAkE;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAE7B,mEAAmE;QACnE,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAElC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,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C3B,IAAI,KAAK,CAAC,iBAAiB;YAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,SAAS,CAAU;IACnB,YAAY,OAAe,EAAE,SAAkB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,KAAK,CAAC,iBAAiB;YAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAClF,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini-client.d.ts","sourceRoot":"","sources":["../../src/gemini/gemini-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EAGnB,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,EAEV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"gemini-client.d.ts","sourceRoot":"","sources":["../../src/gemini/gemini-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EAGnB,qBAAqB,EACrB,oBAAoB,EACpB,UAAU,EAEV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EAGpB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAuJjD;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA4B;gBAE9B,MAA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AAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,GACA,OAAO,CAAC,mBAAmB,CAAC;IA2E/B;;OAEG;IACH,OAAO,CAAC,OAAO;IA0Bf;;OAEG;IACH,OAAO,CAAC,cAAc;IAyBtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAK5B"}
|
|
@@ -46,6 +46,11 @@ async function retryWithBackoff(fn, options = {}) {
|
|
|
46
46
|
}
|
|
47
47
|
throw lastError;
|
|
48
48
|
}
|
|
49
|
+
function normalizeGeminiModel(model) {
|
|
50
|
+
return model === "gemini-3-pro-preview"
|
|
51
|
+
? "gemini-3-pro-preview"
|
|
52
|
+
: "gemini-3-flash-preview";
|
|
53
|
+
}
|
|
49
54
|
/**
|
|
50
55
|
* Client for Gemini Interactions API
|
|
51
56
|
*/
|
|
@@ -68,14 +73,18 @@ export class GeminiClient {
|
|
|
68
73
|
isAvailable() {
|
|
69
74
|
return this.client !== null;
|
|
70
75
|
}
|
|
76
|
+
requireClient() {
|
|
77
|
+
if (!this.client) {
|
|
78
|
+
throw new Error("Gemini API key not configured. Set GEMINI_API_KEY environment variable.");
|
|
79
|
+
}
|
|
80
|
+
return this.client;
|
|
81
|
+
}
|
|
71
82
|
/**
|
|
72
83
|
* Perform a quick query to Gemini
|
|
73
84
|
*/
|
|
74
85
|
async query(options) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
const model = options.model || CONFIG.geminiDefaultModel || "gemini-3-flash-preview";
|
|
86
|
+
const client = this.requireClient();
|
|
87
|
+
const model = normalizeGeminiModel(options.model || CONFIG.geminiDefaultModel);
|
|
79
88
|
log.info(`Gemini query to ${model}: ${options.query.substring(0, 50)}...`);
|
|
80
89
|
// Check for deprecated model
|
|
81
90
|
const deprecationWarning = this.getDeprecationWarning(model);
|
|
@@ -83,7 +92,6 @@ export class GeminiClient {
|
|
|
83
92
|
log.warning(`[DEPRECATION] ${deprecationWarning}`);
|
|
84
93
|
}
|
|
85
94
|
try {
|
|
86
|
-
// Build tools array - use 'as any' to bypass strict SDK typing
|
|
87
95
|
const tools = [];
|
|
88
96
|
if (options.tools) {
|
|
89
97
|
for (const tool of options.tools) {
|
|
@@ -98,8 +106,7 @@ export class GeminiClient {
|
|
|
98
106
|
}
|
|
99
107
|
// Retry with exponential backoff on transient errors
|
|
100
108
|
const response = await retryWithBackoff(async () => {
|
|
101
|
-
|
|
102
|
-
return this.client.interactions.create({
|
|
109
|
+
return client.interactions.create({
|
|
103
110
|
model,
|
|
104
111
|
input,
|
|
105
112
|
tools: tools.length > 0 ? tools : undefined,
|
|
@@ -135,8 +142,8 @@ export class GeminiClient {
|
|
|
135
142
|
*/
|
|
136
143
|
getDeprecationWarning(model) {
|
|
137
144
|
const DEPRECATED_MODELS = {
|
|
138
|
-
"gemini-2.5-flash": "gemini-2.5-flash
|
|
139
|
-
"gemini-2.5-pro": "gemini-2.5-pro
|
|
145
|
+
"gemini-2.5-flash": "gemini-2.5-flash was retired March 31, 2026. Use gemini-3-flash-preview instead.",
|
|
146
|
+
"gemini-2.5-pro": "gemini-2.5-pro was retired March 31, 2026. Use gemini-3-pro-preview instead.",
|
|
140
147
|
};
|
|
141
148
|
return DEPRECATED_MODELS[model] || null;
|
|
142
149
|
}
|
|
@@ -144,18 +151,18 @@ export class GeminiClient {
|
|
|
144
151
|
* Start deep research using the Deep Research agent
|
|
145
152
|
*/
|
|
146
153
|
async deepResearch(options) {
|
|
147
|
-
|
|
148
|
-
throw new Error("Gemini API key not configured. Set GEMINI_API_KEY environment variable.");
|
|
149
|
-
}
|
|
154
|
+
const client = this.requireClient();
|
|
150
155
|
if (!CONFIG.geminiDeepResearchEnabled) {
|
|
151
156
|
throw new Error("Deep Research is disabled. Set GEMINI_DEEP_RESEARCH_ENABLED=true to enable.");
|
|
152
157
|
}
|
|
153
158
|
log.info(`Starting deep research: ${options.query.substring(0, 50)}...`);
|
|
154
159
|
try {
|
|
155
|
-
|
|
156
|
-
const response = await this.client.interactions.create({
|
|
160
|
+
const response = await client.interactions.create({
|
|
157
161
|
input: options.query,
|
|
158
162
|
agent: "deep-research-pro-preview-12-2025",
|
|
163
|
+
...(options.thinkingLevel && {
|
|
164
|
+
generationConfig: { thinkingLevel: options.thinkingLevel },
|
|
165
|
+
}),
|
|
159
166
|
background: options.background !== false,
|
|
160
167
|
store: true,
|
|
161
168
|
});
|
|
@@ -178,11 +185,9 @@ export class GeminiClient {
|
|
|
178
185
|
* Get an existing interaction by ID
|
|
179
186
|
*/
|
|
180
187
|
async getInteraction(interactionId) {
|
|
181
|
-
|
|
182
|
-
throw new Error("Gemini API key not configured.");
|
|
183
|
-
}
|
|
188
|
+
const client = this.requireClient();
|
|
184
189
|
try {
|
|
185
|
-
const response = await
|
|
190
|
+
const response = await client.interactions.get(interactionId);
|
|
186
191
|
return this.mapInteraction(response);
|
|
187
192
|
}
|
|
188
193
|
catch (error) {
|
|
@@ -241,11 +246,9 @@ export class GeminiClient {
|
|
|
241
246
|
* Delete a stored interaction
|
|
242
247
|
*/
|
|
243
248
|
async deleteInteraction(interactionId) {
|
|
244
|
-
|
|
245
|
-
throw new Error("Gemini API key not configured.");
|
|
246
|
-
}
|
|
249
|
+
const client = this.requireClient();
|
|
247
250
|
try {
|
|
248
|
-
await
|
|
251
|
+
await client.interactions.delete(interactionId);
|
|
249
252
|
log.info(`Deleted interaction: ${interactionId}`);
|
|
250
253
|
}
|
|
251
254
|
catch (error) {
|
|
@@ -289,9 +292,7 @@ export class GeminiClient {
|
|
|
289
292
|
* Large PDFs (>50MB or >1000 pages) are automatically chunked
|
|
290
293
|
*/
|
|
291
294
|
async uploadDocument(options) {
|
|
292
|
-
|
|
293
|
-
throw new Error("Gemini API key not configured. Set GEMINI_API_KEY environment variable.");
|
|
294
|
-
}
|
|
295
|
+
const client = this.requireClient();
|
|
295
296
|
const { filePath, displayName, mimeType } = options;
|
|
296
297
|
// Verify file exists
|
|
297
298
|
if (!fs.existsSync(filePath)) {
|
|
@@ -317,7 +318,7 @@ export class GeminiClient {
|
|
|
317
318
|
log.info(`Uploading document: ${fileName} (${this.formatBytes(stats.size)})`);
|
|
318
319
|
try {
|
|
319
320
|
// Upload file using SDK
|
|
320
|
-
const uploadResult = await
|
|
321
|
+
const uploadResult = await client.files.upload({
|
|
321
322
|
file: filePath,
|
|
322
323
|
config: {
|
|
323
324
|
displayName: fileName,
|
|
@@ -325,7 +326,11 @@ export class GeminiClient {
|
|
|
325
326
|
},
|
|
326
327
|
});
|
|
327
328
|
// Poll for processing completion
|
|
328
|
-
|
|
329
|
+
const uploadedFileName = uploadResult.name;
|
|
330
|
+
if (!uploadedFileName) {
|
|
331
|
+
throw new Error("Files API upload response did not include a file name");
|
|
332
|
+
}
|
|
333
|
+
let file = await this.waitForFileProcessing(uploadedFileName);
|
|
329
334
|
log.success(`Document uploaded: ${file.name}`);
|
|
330
335
|
return {
|
|
331
336
|
fileName: file.name,
|
|
@@ -360,7 +365,7 @@ export class GeminiClient {
|
|
|
360
365
|
// Upload each chunk
|
|
361
366
|
for (const chunk of chunkResult.chunks) {
|
|
362
367
|
log.info(` Uploading chunk ${chunk.chunkIndex + 1}/${chunk.totalChunks} (pages ${chunk.pageStart}-${chunk.pageEnd})...`);
|
|
363
|
-
const uploadResult = await this.
|
|
368
|
+
const uploadResult = await this.requireClient().files.upload({
|
|
364
369
|
file: chunk.filePath,
|
|
365
370
|
config: {
|
|
366
371
|
displayName: `${displayName} (Part ${chunk.chunkIndex + 1}/${chunk.totalChunks})`,
|
|
@@ -368,7 +373,11 @@ export class GeminiClient {
|
|
|
368
373
|
},
|
|
369
374
|
});
|
|
370
375
|
// Wait for processing
|
|
371
|
-
const
|
|
376
|
+
const uploadedFileName = uploadResult.name;
|
|
377
|
+
if (!uploadedFileName) {
|
|
378
|
+
throw new Error("Files API upload response did not include a file name");
|
|
379
|
+
}
|
|
380
|
+
const file = await this.waitForFileProcessing(uploadedFileName);
|
|
372
381
|
uploadedChunks.push({
|
|
373
382
|
fileName: file.name,
|
|
374
383
|
chunkIndex: chunk.chunkIndex,
|
|
@@ -428,11 +437,9 @@ export class GeminiClient {
|
|
|
428
437
|
* Get file metadata
|
|
429
438
|
*/
|
|
430
439
|
async getFile(fileName) {
|
|
431
|
-
|
|
432
|
-
throw new Error("Gemini API key not configured.");
|
|
433
|
-
}
|
|
440
|
+
const client = this.requireClient();
|
|
434
441
|
try {
|
|
435
|
-
const response = await
|
|
442
|
+
const response = await client.files.get({ name: fileName });
|
|
436
443
|
return this.mapFile(response);
|
|
437
444
|
}
|
|
438
445
|
catch (error) {
|
|
@@ -445,11 +452,9 @@ export class GeminiClient {
|
|
|
445
452
|
* List all uploaded files
|
|
446
453
|
*/
|
|
447
454
|
async listFiles(pageSize = 100, pageToken) {
|
|
448
|
-
|
|
449
|
-
throw new Error("Gemini API key not configured.");
|
|
450
|
-
}
|
|
455
|
+
const client = this.requireClient();
|
|
451
456
|
try {
|
|
452
|
-
const response = await
|
|
457
|
+
const response = await client.files.list({
|
|
453
458
|
pageSize,
|
|
454
459
|
pageToken,
|
|
455
460
|
});
|
|
@@ -470,11 +475,9 @@ export class GeminiClient {
|
|
|
470
475
|
* Delete an uploaded file
|
|
471
476
|
*/
|
|
472
477
|
async deleteFile(fileName) {
|
|
473
|
-
|
|
474
|
-
throw new Error("Gemini API key not configured.");
|
|
475
|
-
}
|
|
478
|
+
const client = this.requireClient();
|
|
476
479
|
try {
|
|
477
|
-
await
|
|
480
|
+
await client.files.delete({ name: fileName });
|
|
478
481
|
log.info(`Deleted file: ${fileName}`);
|
|
479
482
|
}
|
|
480
483
|
catch (error) {
|
|
@@ -487,11 +490,9 @@ export class GeminiClient {
|
|
|
487
490
|
* Query an uploaded document
|
|
488
491
|
*/
|
|
489
492
|
async queryDocument(options) {
|
|
490
|
-
|
|
491
|
-
throw new Error("Gemini API key not configured. Set GEMINI_API_KEY environment variable.");
|
|
492
|
-
}
|
|
493
|
+
const client = this.requireClient();
|
|
493
494
|
const { fileName, query, model, additionalFiles, generationConfig } = options;
|
|
494
|
-
const modelId = model || CONFIG.geminiDefaultModel
|
|
495
|
+
const modelId = normalizeGeminiModel(model || CONFIG.geminiDefaultModel);
|
|
495
496
|
log.info(`Querying document ${fileName}: ${query.substring(0, 50)}...`);
|
|
496
497
|
try {
|
|
497
498
|
// Get file metadata for URI
|
|
@@ -517,7 +518,7 @@ export class GeminiClient {
|
|
|
517
518
|
}
|
|
518
519
|
}
|
|
519
520
|
// Generate content with the document
|
|
520
|
-
const response = await
|
|
521
|
+
const response = await client.models.generateContent({
|
|
521
522
|
model: modelId,
|
|
522
523
|
contents: [
|
|
523
524
|
{
|
|
@@ -569,10 +570,10 @@ export class GeminiClient {
|
|
|
569
570
|
return this.queryDocument({
|
|
570
571
|
fileName: fileNames[0],
|
|
571
572
|
query,
|
|
572
|
-
model: options?.model,
|
|
573
|
+
model: normalizeGeminiModel(options?.model || CONFIG.geminiDefaultModel),
|
|
573
574
|
});
|
|
574
575
|
}
|
|
575
|
-
const modelId = options?.model || CONFIG.geminiDefaultModel
|
|
576
|
+
const modelId = normalizeGeminiModel(options?.model || CONFIG.geminiDefaultModel);
|
|
576
577
|
log.info(`Querying ${fileNames.length} document chunks...`);
|
|
577
578
|
// Query each chunk
|
|
578
579
|
const chunkResults = [];
|
|
@@ -582,7 +583,7 @@ export class GeminiClient {
|
|
|
582
583
|
const result = await this.queryDocument({
|
|
583
584
|
fileName: fileNames[i],
|
|
584
585
|
query,
|
|
585
|
-
model:
|
|
586
|
+
model: modelId,
|
|
586
587
|
});
|
|
587
588
|
chunkResults.push({
|
|
588
589
|
chunkIndex: i,
|