notebooklm-sdk 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 agmmnn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,249 @@
1
+ # notebooklm-sdk
2
+
3
+ A lightweight, zero-dependency TypeScript SDK for the NotebookLM API. Works with Node.js, Bun, and Deno.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install notebooklm-sdk
9
+ # or
10
+ bun add notebooklm-sdk
11
+ ```
12
+
13
+ ## Authentication
14
+
15
+ This SDK uses **manual cookie auth only** — no Playwright, no headless browser. You extract your cookies once and pass them in.
16
+
17
+ **Option 1 — Raw cookie string** (from browser DevTools → Network tab → copy `Cookie` request header):
18
+ ```bash
19
+ NOTEBOOKLM_COOKIE="SID=...; HSID=...; ..."
20
+ ```
21
+
22
+ **Option 2 — Playwright `storage_state.json`** (JSON array of cookie objects):
23
+ ```bash
24
+ NOTEBOOKLM_COOKIE='[{"name":"SID","value":"...","domain":".google.com",...}]'
25
+ ```
26
+
27
+ Then connect:
28
+ ```typescript
29
+ import { NotebookLMClient } from "notebooklm-sdk";
30
+
31
+ const client = await NotebookLMClient.connect({
32
+ cookies: process.env.NOTEBOOKLM_COOKIE,
33
+ });
34
+ ```
35
+
36
+ ## API Reference
37
+
38
+ ### Notebooks
39
+
40
+ ```typescript
41
+ const notebooks = await client.notebooks.list();
42
+ const nb = await client.notebooks.get(notebookId);
43
+ const { notebookId } = await client.notebooks.create("My Notebook");
44
+ await client.notebooks.rename(notebookId, "New Title");
45
+ await client.notebooks.delete(notebookId);
46
+
47
+ const summary = await client.notebooks.getSummary(notebookId);
48
+ const description = await client.notebooks.getDescription(notebookId);
49
+ // description.summary, description.suggestedTopics
50
+ ```
51
+
52
+ ### Sources
53
+
54
+ ```typescript
55
+ const sources = await client.sources.list(notebookId);
56
+ const source = await client.sources.get(notebookId, sourceId);
57
+
58
+ // Add sources
59
+ const { sourceId } = await client.sources.addUrl(notebookId, "https://example.com");
60
+ const { sourceId } = await client.sources.addText(notebookId, "My text", "My Title");
61
+ const { sourceId } = await client.sources.addFile(notebookId, buffer, "file.pdf");
62
+
63
+ // Poll until ready (status: "ready")
64
+ const source = await client.sources.waitUntilReady(notebookId, sourceId);
65
+
66
+ await client.sources.delete(notebookId, sourceId);
67
+ ```
68
+
69
+ ### Artifacts
70
+
71
+ Generate AI artifacts from notebook sources:
72
+
73
+ ```typescript
74
+ // Audio podcast
75
+ const { artifactId } = await client.artifacts.createAudio(notebookId, {
76
+ format: AudioFormat.DEEP_DIVE, // DEEP_DIVE | BRIEF | CRITIQUE | DEBATE
77
+ length: AudioLength.DEFAULT, // SHORT | DEFAULT | LONG
78
+ language: "en",
79
+ });
80
+
81
+ // Video
82
+ const { artifactId } = await client.artifacts.createVideo(notebookId, {
83
+ format: VideoFormat.EXPLAINER, // EXPLAINER | BRIEF | CINEMATIC
84
+ });
85
+
86
+ // Quiz / Flashcards
87
+ const { artifactId } = await client.artifacts.createQuiz(notebookId, {
88
+ difficulty: QuizDifficulty.MEDIUM,
89
+ quantity: QuizQuantity.STANDARD,
90
+ });
91
+ const { artifactId } = await client.artifacts.createFlashcards(notebookId);
92
+
93
+ // Report (markdown)
94
+ const { artifactId } = await client.artifacts.createReport(notebookId, {
95
+ format: "briefing_doc", // "briefing_doc" | "study_guide" | "blog_post" | "custom"
96
+ language: "en",
97
+ });
98
+
99
+ // Other artifact types
100
+ await client.artifacts.createInfographic(notebookId);
101
+ await client.artifacts.createSlideDeck(notebookId);
102
+ await client.artifacts.createMindMap(notebookId);
103
+ ```
104
+
105
+ Poll and download:
106
+
107
+ ```typescript
108
+ // Wait until ready
109
+ const artifact = await client.artifacts.waitUntilReady(notebookId, artifactId);
110
+
111
+ // Download
112
+ const audioBuffer = await client.artifacts.downloadAudio(notebookId, artifactId);
113
+ const videoBuffer = await client.artifacts.downloadVideo(notebookId, artifactId);
114
+ const markdown = await client.artifacts.getReportMarkdown(notebookId, artifactId);
115
+ const html = await client.artifacts.getInteractiveHtml(notebookId, artifactId); // quiz/flashcards
116
+ ```
117
+
118
+ ### Chat
119
+
120
+ ```typescript
121
+ // Ask a question
122
+ const result = await client.chat.ask(notebookId, "What is this about?");
123
+ console.log(result.answer);
124
+ console.log(result.references); // [{ sourceId, title, url }]
125
+
126
+ // Follow-up (pass conversationId to continue the thread)
127
+ const result2 = await client.chat.ask(notebookId, "Tell me more.", {
128
+ conversationId: result.conversationId,
129
+ });
130
+
131
+ // Fetch conversation history
132
+ const lastConvId = await client.chat.getLastConversationId(notebookId);
133
+ const turns = await client.chat.getConversationTurns(notebookId, lastConvId);
134
+ ```
135
+
136
+ ### Notes
137
+
138
+ ```typescript
139
+ const { notes, mindMaps } = await client.notes.list(notebookId);
140
+
141
+ const { noteId } = await client.notes.create(notebookId, "# My Note\n\nContent here.");
142
+ await client.notes.update(notebookId, noteId, "Updated content.");
143
+ await client.notes.delete(notebookId, noteId);
144
+ ```
145
+
146
+ ### Research
147
+
148
+ ```typescript
149
+ // Start a fast web search or deep research
150
+ const task = await client.research.start(notebookId, "Latest advances in quantum computing", "web", "deep");
151
+
152
+ // Poll for results
153
+ const result = await client.research.poll(notebookId);
154
+
155
+ if (result.status === "completed") {
156
+ console.log(result.summary);
157
+ console.log(`Found ${result.sources.length} sources.`);
158
+
159
+ // Import desired sources into the notebook
160
+ await client.research.importSources(notebookId, result.taskId, result.sources.slice(0, 2));
161
+ }
162
+ ```
163
+
164
+ ### Sharing
165
+
166
+ ```typescript
167
+ const status = await client.sharing.getStatus(notebookId);
168
+ // status.isPublic, status.sharedUsers, status.shareUrl
169
+
170
+ // Enable/disable public link sharing
171
+ await client.sharing.setPublic(notebookId, true);
172
+
173
+ // Share with a specific user
174
+ await client.sharing.addUser(notebookId, "user@example.com", SharePermission.VIEWER);
175
+ await client.sharing.updateUser(notebookId, "user@example.com", SharePermission.EDITOR);
176
+ await client.sharing.removeUser(notebookId, "user@example.com");
177
+ ```
178
+
179
+ ### Settings
180
+
181
+ ```typescript
182
+ const lang = await client.settings.getOutputLanguage(); // "en"
183
+ await client.settings.setOutputLanguage("ja");
184
+ ```
185
+
186
+ ## Examples
187
+
188
+ Runnable scripts in [`examples/`](./examples). Requires `.env` with `NOTEBOOKLM_COOKIE`.
189
+
190
+ | Script | What it does |
191
+ |--------|-------------|
192
+ | `basic.ts` | List notebooks and sources |
193
+ | `report.ts` | Generate and download a report |
194
+ | `audio.ts` | Generate a podcast (long wait) |
195
+ | `download.ts` | Download all completed artifacts (audio, video, reports, quiz, flashcards) |
196
+ | `chat.ts` | Ask questions and follow up |
197
+ | `research.ts` | Start a web research session and import sources |
198
+ | `settings.ts` | Check output language and sharing status |
199
+
200
+ ```bash
201
+ bunx dotenv -e .env -- bunx tsx examples/basic.ts
202
+ ```
203
+
204
+ ## Error Handling
205
+
206
+ All errors extend `NotebookLMError`:
207
+
208
+ ```typescript
209
+ import { ArtifactNotReadyError, AuthError, RateLimitError } from "notebooklm-sdk";
210
+
211
+ try {
212
+ await client.artifacts.downloadAudio(notebookId, artifactId);
213
+ } catch (err) {
214
+ if (err instanceof ArtifactNotReadyError) { /* artifact still processing */ }
215
+ if (err instanceof AuthError) { /* cookies expired */ }
216
+ if (err instanceof RateLimitError) { /* back off */ }
217
+ }
218
+ ```
219
+
220
+ Error classes: `AuthError`, `RateLimitError`, `NetworkError`, `ServerError`, `RPCError`, `RPCTimeoutError`, `ArtifactNotReadyError`, `ArtifactNotFoundError`, `SourceAddError`, `SourceProcessingError`, `SourceTimeoutError`, and more.
221
+
222
+ ## Project Structure
223
+
224
+ ```
225
+ src/
226
+ ├── client.ts — NotebookLMClient
227
+ ├── auth.ts — Cookie auth, token fetching
228
+ ├── index.ts — Public exports
229
+ ├── api/
230
+ │ ├── artifacts.ts — Audio, video, quiz, report, slide deck, infographic, mind map
231
+ │ ├── chat.ts — Chat / Q&A
232
+ │ ├── notebooks.ts — CRUD + summary
233
+ │ ├── notes.ts — Notes + mind maps
234
+ │ ├── settings.ts — User settings
235
+ │ ├── sharing.ts — Notebook sharing
236
+ │ └── sources.ts — URL, text, file sources
237
+ ├── rpc/
238
+ │ ├── core.ts — HTTP + decode pipeline
239
+ │ ├── encoder.ts — Request encoding
240
+ │ └── decoder.ts — Response decoding
241
+ └── types/
242
+ ├── enums.ts — RPC method IDs, format options, status codes
243
+ ├── errors.ts — Error hierarchy
244
+ └── models.ts — Interfaces + response parsers
245
+ ```
246
+
247
+ ## License
248
+
249
+ MIT
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+
3
+ // src/types/errors.ts
4
+ var NotebookLMError = class extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = this.constructor.name;
8
+ }
9
+ };
10
+ var NetworkError = class extends NotebookLMError {
11
+ methodId;
12
+ originalError;
13
+ constructor(message, opts = {}) {
14
+ super(message);
15
+ this.methodId = opts.methodId;
16
+ this.originalError = opts.originalError;
17
+ }
18
+ };
19
+ var RPCTimeoutError = class extends NetworkError {
20
+ };
21
+ var RPCError = class extends NotebookLMError {
22
+ methodId;
23
+ rawResponse;
24
+ rpcCode;
25
+ foundIds;
26
+ constructor(message, opts = {}) {
27
+ super(message);
28
+ this.methodId = opts.methodId;
29
+ this.rawResponse = opts.rawResponse ? opts.rawResponse.slice(0, 500) : void 0;
30
+ this.rpcCode = opts.rpcCode;
31
+ this.foundIds = opts.foundIds ?? [];
32
+ }
33
+ };
34
+ var AuthError = class extends RPCError {
35
+ };
36
+ var RateLimitError = class extends RPCError {
37
+ retryAfter;
38
+ constructor(message, opts = {}) {
39
+ super(message, opts);
40
+ this.retryAfter = opts.retryAfter;
41
+ }
42
+ };
43
+ var ServerError = class extends RPCError {
44
+ statusCode;
45
+ constructor(message, opts = {}) {
46
+ super(message, opts);
47
+ this.statusCode = opts.statusCode;
48
+ }
49
+ };
50
+ var ClientError = class extends RPCError {
51
+ statusCode;
52
+ constructor(message, opts = {}) {
53
+ super(message, opts);
54
+ this.statusCode = opts.statusCode;
55
+ }
56
+ };
57
+ var NotebookError = class extends NotebookLMError {
58
+ };
59
+ var NotebookNotFoundError = class extends NotebookError {
60
+ notebookId;
61
+ constructor(notebookId) {
62
+ super(`Notebook not found: ${notebookId}`);
63
+ this.notebookId = notebookId;
64
+ }
65
+ };
66
+ var SourceError = class extends NotebookLMError {
67
+ };
68
+ var SourceNotFoundError = class extends SourceError {
69
+ sourceId;
70
+ constructor(sourceId) {
71
+ super(`Source not found: ${sourceId}`);
72
+ this.sourceId = sourceId;
73
+ }
74
+ };
75
+ var SourceAddError = class extends SourceError {
76
+ url;
77
+ cause;
78
+ constructor(url, opts = {}) {
79
+ super(
80
+ opts.message ?? `Failed to add source: ${url}
81
+ Possible causes:
82
+ - URL is invalid or inaccessible
83
+ - Content is behind a paywall or requires authentication
84
+ - Rate limiting or quota exceeded`
85
+ );
86
+ this.url = url;
87
+ this.cause = opts.cause;
88
+ }
89
+ };
90
+ var SourceProcessingError = class extends SourceError {
91
+ sourceId;
92
+ status;
93
+ constructor(sourceId, status = 3, message) {
94
+ super(message ?? `Source ${sourceId} failed to process`);
95
+ this.sourceId = sourceId;
96
+ this.status = status;
97
+ }
98
+ };
99
+ var SourceTimeoutError = class extends SourceError {
100
+ sourceId;
101
+ timeout;
102
+ lastStatus;
103
+ constructor(sourceId, timeout, lastStatus) {
104
+ const statusInfo = lastStatus != null ? ` (last status: ${lastStatus})` : "";
105
+ super(`Source ${sourceId} not ready after ${timeout.toFixed(1)}s${statusInfo}`);
106
+ this.sourceId = sourceId;
107
+ this.timeout = timeout;
108
+ this.lastStatus = lastStatus;
109
+ }
110
+ };
111
+ var ArtifactError = class extends NotebookLMError {
112
+ };
113
+ var ArtifactNotFoundError = class extends ArtifactError {
114
+ artifactId;
115
+ artifactType;
116
+ constructor(artifactId, artifactType) {
117
+ const typeInfo = artifactType ? ` ${artifactType}` : "";
118
+ super(`${typeInfo.trim() || "Artifact"} ${artifactId} not found`);
119
+ this.artifactId = artifactId;
120
+ this.artifactType = artifactType;
121
+ }
122
+ };
123
+ var ArtifactNotReadyError = class extends ArtifactError {
124
+ artifactType;
125
+ artifactId;
126
+ status;
127
+ constructor(artifactType, opts = {}) {
128
+ const base = opts.artifactId ? `${artifactType} artifact ${opts.artifactId} is not ready` : `No completed ${artifactType} found`;
129
+ const statusInfo = opts.status ? ` (status: ${opts.status})` : "";
130
+ super(`${base}${statusInfo}`);
131
+ this.artifactType = artifactType;
132
+ this.artifactId = opts.artifactId;
133
+ this.status = opts.status;
134
+ }
135
+ };
136
+ var ArtifactParseError = class extends ArtifactError {
137
+ artifactType;
138
+ artifactId;
139
+ details;
140
+ cause;
141
+ constructor(artifactType, opts = {}) {
142
+ let msg = `Failed to parse ${artifactType} artifact`;
143
+ if (opts.artifactId) msg += ` ${opts.artifactId}`;
144
+ if (opts.details) msg += `: ${opts.details}`;
145
+ super(msg);
146
+ this.artifactType = artifactType;
147
+ this.artifactId = opts.artifactId;
148
+ this.details = opts.details;
149
+ this.cause = opts.cause;
150
+ }
151
+ };
152
+ var ArtifactDownloadError = class extends ArtifactError {
153
+ artifactType;
154
+ artifactId;
155
+ details;
156
+ cause;
157
+ constructor(artifactType, opts = {}) {
158
+ let msg = `Failed to download ${artifactType} artifact`;
159
+ if (opts.artifactId) msg += ` ${opts.artifactId}`;
160
+ if (opts.details) msg += `: ${opts.details}`;
161
+ super(msg);
162
+ this.artifactType = artifactType;
163
+ this.artifactId = opts.artifactId;
164
+ this.details = opts.details;
165
+ this.cause = opts.cause;
166
+ }
167
+ };
168
+ var ChatError = class extends NotebookLMError {
169
+ };
170
+
171
+ exports.ArtifactDownloadError = ArtifactDownloadError;
172
+ exports.ArtifactError = ArtifactError;
173
+ exports.ArtifactNotFoundError = ArtifactNotFoundError;
174
+ exports.ArtifactNotReadyError = ArtifactNotReadyError;
175
+ exports.ArtifactParseError = ArtifactParseError;
176
+ exports.AuthError = AuthError;
177
+ exports.ChatError = ChatError;
178
+ exports.ClientError = ClientError;
179
+ exports.NetworkError = NetworkError;
180
+ exports.NotebookError = NotebookError;
181
+ exports.NotebookLMError = NotebookLMError;
182
+ exports.NotebookNotFoundError = NotebookNotFoundError;
183
+ exports.RPCError = RPCError;
184
+ exports.RPCTimeoutError = RPCTimeoutError;
185
+ exports.RateLimitError = RateLimitError;
186
+ exports.ServerError = ServerError;
187
+ exports.SourceAddError = SourceAddError;
188
+ exports.SourceError = SourceError;
189
+ exports.SourceNotFoundError = SourceNotFoundError;
190
+ exports.SourceProcessingError = SourceProcessingError;
191
+ exports.SourceTimeoutError = SourceTimeoutError;
192
+ //# sourceMappingURL=errors.cjs.map
193
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/errors.ts"],"names":[],"mappings":";;;AAOO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EACz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,UAAA,EAAY,GAAA,IAAO,CAAA,CAAA,EAAI,KAAK,UAAU,CAAA,CAAA;AAC/C,IAAA,IAAI,IAAA,CAAK,OAAA,EAAS,GAAA,IAAO,CAAA,EAAA,EAAK,KAAK,OAAO,CAAA,CAAA;AAC1C,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AACpB,IAAA,IAAA,CAAK,aAAa,IAAA,CAAK,UAAA;AACvB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,KAAA;AAAA,EACpB;AACF;AAEO,IAAM,qBAAA,GAAN,cAAoC,aAAA,CAAc;AAAA,EAC9C,YAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EAET,WAAA,CACE,YAAA,EACA,IAAA,GAAiE,EAAC,EAClE;AACA,IAAA,IAAI,GAAA,GAAM,sBAAsB,YAAY,CAAA,SAAA,CAAA;AAC5C,IAAA,IAAI,IAAA,CAAK,UAAA,EAAY,GAAA,IAAO,CAAA,CAAA,EAAI,KAAK,UAAU,CAAA,CAAA;AAC/C,IAAA,IAAI,IAAA,CAAK,OAAA,EAAS,GAAA,IAAO,CAAA,EAAA,EAAK,KAAK,OAAO,CAAA,CAAA;AAC1C,IAAA,KAAA,CAAM,GAAG,CAAA;AACT,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AACpB,IAAA,IAAA,CAAK,aAAa,IAAA,CAAK,UAAA;AACvB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AACpB,IAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,KAAA;AAAA,EACpB;AACF;AAMO,IAAM,SAAA,GAAN,cAAwB,eAAA,CAAgB;AAAC","file":"errors.cjs","sourcesContent":["/**\n * All exceptions for notebooklm-sdk.\n *\n * All errors extend NotebookLMError so you can catch everything with:\n * try { ... } catch (e) { if (e instanceof NotebookLMError) ... }\n */\n\nexport class NotebookLMError extends Error {\n constructor(message: string) {\n super(message);\n this.name = this.constructor.name;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Network (transport-level, before RPC processing)\n// ---------------------------------------------------------------------------\n\nexport class NetworkError extends NotebookLMError {\n readonly methodId?: string;\n readonly originalError?: Error;\n\n constructor(message: string, opts: { methodId?: string; originalError?: Error } = {}) {\n super(message);\n this.methodId = opts.methodId;\n this.originalError = opts.originalError;\n }\n}\n\nexport class RPCTimeoutError extends NetworkError {}\n\n// ---------------------------------------------------------------------------\n// RPC Protocol (after connection established)\n// ---------------------------------------------------------------------------\n\nexport class RPCError extends NotebookLMError {\n readonly methodId?: string;\n readonly rawResponse?: string;\n readonly rpcCode?: string | number;\n readonly foundIds: string[];\n\n constructor(\n message: string,\n opts: {\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n foundIds?: string[];\n } = {},\n ) {\n super(message);\n this.methodId = opts.methodId;\n this.rawResponse = opts.rawResponse ? opts.rawResponse.slice(0, 500) : undefined;\n this.rpcCode = opts.rpcCode;\n this.foundIds = opts.foundIds ?? [];\n }\n}\n\nexport class AuthError extends RPCError {}\n\nexport class RateLimitError extends RPCError {\n readonly retryAfter?: number;\n\n constructor(\n message: string,\n opts: {\n retryAfter?: number;\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n foundIds?: string[];\n } = {},\n ) {\n super(message, opts);\n this.retryAfter = opts.retryAfter;\n }\n}\n\nexport class ServerError extends RPCError {\n readonly statusCode?: number;\n\n constructor(\n message: string,\n opts: {\n statusCode?: number;\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n } = {},\n ) {\n super(message, opts);\n this.statusCode = opts.statusCode;\n }\n}\n\nexport class ClientError extends RPCError {\n readonly statusCode?: number;\n\n constructor(\n message: string,\n opts: {\n statusCode?: number;\n methodId?: string;\n rawResponse?: string;\n rpcCode?: string | number;\n } = {},\n ) {\n super(message, opts);\n this.statusCode = opts.statusCode;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Notebooks\n// ---------------------------------------------------------------------------\n\nexport class NotebookError extends NotebookLMError {}\n\nexport class NotebookNotFoundError extends NotebookError {\n readonly notebookId: string;\n\n constructor(notebookId: string) {\n super(`Notebook not found: ${notebookId}`);\n this.notebookId = notebookId;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Sources\n// ---------------------------------------------------------------------------\n\nexport class SourceError extends NotebookLMError {}\n\nexport class SourceNotFoundError extends SourceError {\n readonly sourceId: string;\n\n constructor(sourceId: string) {\n super(`Source not found: ${sourceId}`);\n this.sourceId = sourceId;\n }\n}\n\nexport class SourceAddError extends SourceError {\n readonly url: string;\n readonly cause?: Error;\n\n constructor(url: string, opts: { cause?: Error; message?: string } = {}) {\n super(\n opts.message ??\n `Failed to add source: ${url}\\n` +\n \"Possible causes:\\n\" +\n \" - URL is invalid or inaccessible\\n\" +\n \" - Content is behind a paywall or requires authentication\\n\" +\n \" - Rate limiting or quota exceeded\",\n );\n this.url = url;\n this.cause = opts.cause;\n }\n}\n\nexport class SourceProcessingError extends SourceError {\n readonly sourceId: string;\n readonly status: number;\n\n constructor(sourceId: string, status = 3, message?: string) {\n super(message ?? `Source ${sourceId} failed to process`);\n this.sourceId = sourceId;\n this.status = status;\n }\n}\n\nexport class SourceTimeoutError extends SourceError {\n readonly sourceId: string;\n readonly timeout: number;\n readonly lastStatus?: number;\n\n constructor(sourceId: string, timeout: number, lastStatus?: number) {\n const statusInfo = lastStatus != null ? ` (last status: ${lastStatus})` : \"\";\n super(`Source ${sourceId} not ready after ${timeout.toFixed(1)}s${statusInfo}`);\n this.sourceId = sourceId;\n this.timeout = timeout;\n this.lastStatus = lastStatus;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Artifacts\n// ---------------------------------------------------------------------------\n\nexport class ArtifactError extends NotebookLMError {}\n\nexport class ArtifactNotFoundError extends ArtifactError {\n readonly artifactId: string;\n readonly artifactType?: string;\n\n constructor(artifactId: string, artifactType?: string) {\n const typeInfo = artifactType ? ` ${artifactType}` : \"\";\n super(`${typeInfo.trim() || \"Artifact\"} ${artifactId} not found`);\n this.artifactId = artifactId;\n this.artifactType = artifactType;\n }\n}\n\nexport class ArtifactNotReadyError extends ArtifactError {\n readonly artifactType: string;\n readonly artifactId?: string;\n readonly status?: string;\n\n constructor(artifactType: string, opts: { artifactId?: string; status?: string } = {}) {\n const base = opts.artifactId\n ? `${artifactType} artifact ${opts.artifactId} is not ready`\n : `No completed ${artifactType} found`;\n const statusInfo = opts.status ? ` (status: ${opts.status})` : \"\";\n super(`${base}${statusInfo}`);\n this.artifactType = artifactType;\n this.artifactId = opts.artifactId;\n this.status = opts.status;\n }\n}\n\nexport class ArtifactParseError extends ArtifactError {\n readonly artifactType: string;\n readonly artifactId?: string;\n readonly details?: string;\n readonly cause?: Error;\n\n constructor(\n artifactType: string,\n opts: { details?: string; artifactId?: string; cause?: Error } = {},\n ) {\n let msg = `Failed to parse ${artifactType} artifact`;\n if (opts.artifactId) msg += ` ${opts.artifactId}`;\n if (opts.details) msg += `: ${opts.details}`;\n super(msg);\n this.artifactType = artifactType;\n this.artifactId = opts.artifactId;\n this.details = opts.details;\n this.cause = opts.cause;\n }\n}\n\nexport class ArtifactDownloadError extends ArtifactError {\n readonly artifactType: string;\n readonly artifactId?: string;\n readonly details?: string;\n readonly cause?: Error;\n\n constructor(\n artifactType: string,\n opts: { details?: string; artifactId?: string; cause?: Error } = {},\n ) {\n let msg = `Failed to download ${artifactType} artifact`;\n if (opts.artifactId) msg += ` ${opts.artifactId}`;\n if (opts.details) msg += `: ${opts.details}`;\n super(msg);\n this.artifactType = artifactType;\n this.artifactId = opts.artifactId;\n this.details = opts.details;\n this.cause = opts.cause;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Domain: Chat\n// ---------------------------------------------------------------------------\n\nexport class ChatError extends NotebookLMError {}\n"]}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * All exceptions for notebooklm-sdk.
3
+ *
4
+ * All errors extend NotebookLMError so you can catch everything with:
5
+ * try { ... } catch (e) { if (e instanceof NotebookLMError) ... }
6
+ */
7
+ declare class NotebookLMError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ declare class NetworkError extends NotebookLMError {
11
+ readonly methodId?: string;
12
+ readonly originalError?: Error;
13
+ constructor(message: string, opts?: {
14
+ methodId?: string;
15
+ originalError?: Error;
16
+ });
17
+ }
18
+ declare class RPCTimeoutError extends NetworkError {
19
+ }
20
+ declare class RPCError extends NotebookLMError {
21
+ readonly methodId?: string;
22
+ readonly rawResponse?: string;
23
+ readonly rpcCode?: string | number;
24
+ readonly foundIds: string[];
25
+ constructor(message: string, opts?: {
26
+ methodId?: string;
27
+ rawResponse?: string;
28
+ rpcCode?: string | number;
29
+ foundIds?: string[];
30
+ });
31
+ }
32
+ declare class AuthError extends RPCError {
33
+ }
34
+ declare class RateLimitError extends RPCError {
35
+ readonly retryAfter?: number;
36
+ constructor(message: string, opts?: {
37
+ retryAfter?: number;
38
+ methodId?: string;
39
+ rawResponse?: string;
40
+ rpcCode?: string | number;
41
+ foundIds?: string[];
42
+ });
43
+ }
44
+ declare class ServerError extends RPCError {
45
+ readonly statusCode?: number;
46
+ constructor(message: string, opts?: {
47
+ statusCode?: number;
48
+ methodId?: string;
49
+ rawResponse?: string;
50
+ rpcCode?: string | number;
51
+ });
52
+ }
53
+ declare class ClientError extends RPCError {
54
+ readonly statusCode?: number;
55
+ constructor(message: string, opts?: {
56
+ statusCode?: number;
57
+ methodId?: string;
58
+ rawResponse?: string;
59
+ rpcCode?: string | number;
60
+ });
61
+ }
62
+ declare class NotebookError extends NotebookLMError {
63
+ }
64
+ declare class NotebookNotFoundError extends NotebookError {
65
+ readonly notebookId: string;
66
+ constructor(notebookId: string);
67
+ }
68
+ declare class SourceError extends NotebookLMError {
69
+ }
70
+ declare class SourceNotFoundError extends SourceError {
71
+ readonly sourceId: string;
72
+ constructor(sourceId: string);
73
+ }
74
+ declare class SourceAddError extends SourceError {
75
+ readonly url: string;
76
+ readonly cause?: Error;
77
+ constructor(url: string, opts?: {
78
+ cause?: Error;
79
+ message?: string;
80
+ });
81
+ }
82
+ declare class SourceProcessingError extends SourceError {
83
+ readonly sourceId: string;
84
+ readonly status: number;
85
+ constructor(sourceId: string, status?: number, message?: string);
86
+ }
87
+ declare class SourceTimeoutError extends SourceError {
88
+ readonly sourceId: string;
89
+ readonly timeout: number;
90
+ readonly lastStatus?: number;
91
+ constructor(sourceId: string, timeout: number, lastStatus?: number);
92
+ }
93
+ declare class ArtifactError extends NotebookLMError {
94
+ }
95
+ declare class ArtifactNotFoundError extends ArtifactError {
96
+ readonly artifactId: string;
97
+ readonly artifactType?: string;
98
+ constructor(artifactId: string, artifactType?: string);
99
+ }
100
+ declare class ArtifactNotReadyError extends ArtifactError {
101
+ readonly artifactType: string;
102
+ readonly artifactId?: string;
103
+ readonly status?: string;
104
+ constructor(artifactType: string, opts?: {
105
+ artifactId?: string;
106
+ status?: string;
107
+ });
108
+ }
109
+ declare class ArtifactParseError extends ArtifactError {
110
+ readonly artifactType: string;
111
+ readonly artifactId?: string;
112
+ readonly details?: string;
113
+ readonly cause?: Error;
114
+ constructor(artifactType: string, opts?: {
115
+ details?: string;
116
+ artifactId?: string;
117
+ cause?: Error;
118
+ });
119
+ }
120
+ declare class ArtifactDownloadError extends ArtifactError {
121
+ readonly artifactType: string;
122
+ readonly artifactId?: string;
123
+ readonly details?: string;
124
+ readonly cause?: Error;
125
+ constructor(artifactType: string, opts?: {
126
+ details?: string;
127
+ artifactId?: string;
128
+ cause?: Error;
129
+ });
130
+ }
131
+ declare class ChatError extends NotebookLMError {
132
+ }
133
+
134
+ export { ArtifactDownloadError, ArtifactError, ArtifactNotFoundError, ArtifactNotReadyError, ArtifactParseError, AuthError, ChatError, ClientError, NetworkError, NotebookError, NotebookLMError, NotebookNotFoundError, RPCError, RPCTimeoutError, RateLimitError, ServerError, SourceAddError, SourceError, SourceNotFoundError, SourceProcessingError, SourceTimeoutError };