notebooklm-kit 2.1.1 → 2.2.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/README.md +147 -44
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/services/notebooks.d.ts +12 -2
- package/dist/src/services/notebooks.d.ts.map +1 -1
- package/dist/src/services/notebooks.js +84 -15
- package/dist/src/services/notebooks.js.map +1 -1
- package/dist/src/services/sources.d.ts +63 -14
- package/dist/src/services/sources.d.ts.map +1 -1
- package/dist/src/services/sources.js +349 -111
- package/dist/src/services/sources.js.map +1 -1
- package/dist/src/types/notebook.d.ts +10 -4
- package/dist/src/types/notebook.d.ts.map +1 -1
- package/dist/src/types/source.d.ts +23 -0
- package/dist/src/types/source.d.ts.map +1 -1
- package/package.json +20 -3
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
+
|
|
3
|
+

|
|
2
4
|
|
|
3
|
-
#
|
|
5
|
+
# notebooklm-kit
|
|
4
6
|
|
|
5
7
|
> A TypeScript SDK for programmatic access to Google NotebookLM.
|
|
6
8
|
|
|
@@ -15,9 +17,6 @@
|
|
|
15
17
|
|
|
16
18
|
The NotebookLM Kit provides a clean, service-based interface to all NotebookLM features. Perfect for building AI research assistants, study tools, content generators, and automated knowledge management systems.
|
|
17
19
|
|
|
18
|
-
> [!NOTE]
|
|
19
|
-
> **✨ Looking for advanced features, custom integrations, or enterprise support? Contact us at [vandit@photon.codes](mailto:vandit@photon.codes).**
|
|
20
|
-
|
|
21
20
|
## Features
|
|
22
21
|
|
|
23
22
|
<table>
|
|
@@ -60,7 +59,7 @@ The NotebookLM Kit provides a clean, service-based interface to all NotebookLM f
|
|
|
60
59
|
<td><a href="examples/notebook-delete.ts">notebook-delete.ts</a></td>
|
|
61
60
|
</tr>
|
|
62
61
|
<tr>
|
|
63
|
-
<td>Share Notebook</td>
|
|
62
|
+
<td>Share Notebook <small>⚠️ Experimental</small></td>
|
|
64
63
|
<td><code>sdk.notebooks.share()</code></td>
|
|
65
64
|
<td><a href="examples/notebook-share.ts">notebook-share.ts</a></td>
|
|
66
65
|
</tr>
|
|
@@ -95,7 +94,7 @@ The NotebookLM Kit provides a clean, service-based interface to all NotebookLM f
|
|
|
95
94
|
<td><a href="examples/source-add-file.ts">source-add-file.ts</a></td>
|
|
96
95
|
</tr>
|
|
97
96
|
<tr>
|
|
98
|
-
<td>Add Drive Source</td>
|
|
97
|
+
<td>Add Drive Source <small>⚠️ Experimental</small></td>
|
|
99
98
|
<td><code>sdk.sources.add.drive()</code></td>
|
|
100
99
|
<td><a href="examples/source-add-drive.ts">source-add-drive.ts</a></td>
|
|
101
100
|
</tr>
|
|
@@ -252,7 +251,7 @@ git clone https://github.com/photon-hq/notebooklm-kit.git && cd notebooklm-kit &
|
|
|
252
251
|
|
|
253
252
|
## Version
|
|
254
253
|
|
|
255
|
-
Current version: **2.
|
|
254
|
+
Current version: **2.2.0**
|
|
256
255
|
|
|
257
256
|
## Available Scripts
|
|
258
257
|
|
|
@@ -383,7 +382,7 @@ npx tsx examples/chat-basic.ts <notebook-id> "What are the key findings?" --no-s
|
|
|
383
382
|
| Create Notebook | Create a new notebook (auto-generates title if empty) | [`sdk.notebooks.create(options)`](#create-notebook) | [notebook-create.ts](examples/notebook-create.ts) |
|
|
384
383
|
| Update Notebook | Update notebook title or emoji | [`sdk.notebooks.update(notebookId, options)`](#update-notebook) | [notebook-update.ts](examples/notebook-update.ts) |
|
|
385
384
|
| Delete Notebook | Delete one or more notebooks | [`sdk.notebooks.delete(notebookIds)`](#delete-notebook) | [notebook-delete.ts](examples/notebook-delete.ts) |
|
|
386
|
-
| Share Notebook | Share notebook with users or enable link sharing | [`sdk.notebooks.share(notebookId, options)`](#share-notebook) | [notebook-share.ts](examples/notebook-share.ts) |
|
|
385
|
+
| Share Notebook <small>⚠️ Experimental</small> | Share notebook with users or enable link sharing | [`sdk.notebooks.share(notebookId, options)`](#share-notebook) | [notebook-share.ts](examples/notebook-share.ts) |
|
|
387
386
|
|
|
388
387
|
### `sdk.sources` - Source Management
|
|
389
388
|
|
|
@@ -395,7 +394,7 @@ npx tsx examples/chat-basic.ts <notebook-id> "What are the key findings?" --no-s
|
|
|
395
394
|
| Add Text | Add a source from text content | [`sdk.sources.add.text(notebookId, options)`](#add-text-source) | [source-add-text.ts](examples/source-add-text.ts) |
|
|
396
395
|
| Add File | Add a source from a file (PDF, image, etc.) | [`sdk.sources.add.file(notebookId, options)`](#add-file-source) | [source-add-file.ts](examples/source-add-file.ts) |
|
|
397
396
|
| Add YouTube | Add a YouTube video as a source | [`sdk.sources.add.youtube(notebookId, options)`](#add-youtube-source) | [source-add-youtube.ts](examples/source-add-youtube.ts) |
|
|
398
|
-
| Add Google Drive | Add a Google Drive file as a source | [`sdk.sources.add.drive(notebookId, options)`](#add-google-drive-source) | [source-add-drive.ts](examples/source-add-drive.ts) |
|
|
397
|
+
| Add Google Drive <small>⚠️ Experimental</small> | Add a Google Drive file as a source | [`sdk.sources.add.drive(notebookId, options)`](#add-google-drive-source) | [source-add-drive.ts](examples/source-add-drive.ts) |
|
|
399
398
|
| Batch Add | Add multiple sources at once | [`sdk.sources.add.batch(notebookId, options)`](#batch-add-sources) | [source-add-batch.ts](examples/source-add-batch.ts) |
|
|
400
399
|
| Web Search (Simple) | Search web and wait for results | [`sdk.sources.add.web.searchAndWait(notebookId, options)`](#web-search-simple) | [source-web-search.ts](examples/source-web-search.ts) |
|
|
401
400
|
| Web Search (Advanced) | Multi-step web search workflow | [`sdk.sources.add.web.search()`](#web-search-advanced) → `getResults()` → `addDiscovered()` | [source-web-search-advanced.ts](examples/source-web-search-advanced.ts) |
|
|
@@ -883,7 +882,6 @@ if (notebook.sharing?.isShared) {
|
|
|
883
882
|
**Parameters:**
|
|
884
883
|
- `options: CreateNotebookOptions`
|
|
885
884
|
- `title: string` - Notebook title (optional, auto-generated if empty)
|
|
886
|
-
- `description?: string` - Initial description (optional)
|
|
887
885
|
- `emoji?: string` - Notebook emoji (optional)
|
|
888
886
|
|
|
889
887
|
**Returns:** `Promise<Notebook>`
|
|
@@ -934,13 +932,6 @@ const notebook = await sdk.notebooks.create({
|
|
|
934
932
|
|
|
935
933
|
// Auto-generated title
|
|
936
934
|
const untitled = await sdk.notebooks.create({})
|
|
937
|
-
|
|
938
|
-
// With description and emoji
|
|
939
|
-
const notebook = await sdk.notebooks.create({
|
|
940
|
-
title: 'Project Notes',
|
|
941
|
-
description: 'Initial project description',
|
|
942
|
-
emoji: '🔬',
|
|
943
|
-
})
|
|
944
935
|
```
|
|
945
936
|
|
|
946
937
|
---
|
|
@@ -961,12 +952,12 @@ const notebook = await sdk.notebooks.create({
|
|
|
961
952
|
**Returns:** `Promise<Notebook>` (same as `get()` - full notebook details)
|
|
962
953
|
|
|
963
954
|
**Description:**
|
|
964
|
-
Updates notebook title
|
|
955
|
+
Updates notebook title or emoji. Returns full notebook details after update (same structure as `get()`). Supports updating emoji only, title only, or both together.
|
|
965
956
|
|
|
966
957
|
<details>
|
|
967
958
|
<summary><strong>Validation</strong></summary>
|
|
968
959
|
|
|
969
|
-
- At least one field (`title
|
|
960
|
+
- At least one field (`title` or `emoji`) must be provided
|
|
970
961
|
- Title maximum length: 100 characters
|
|
971
962
|
- Notebook ID is automatically trimmed (removes trailing spaces)
|
|
972
963
|
- Returns error if notebook doesn't exist
|
|
@@ -1015,21 +1006,25 @@ const updated = await sdk.notebooks.update('notebook-id', {
|
|
|
1015
1006
|
|
|
1016
1007
|
### Delete Notebook
|
|
1017
1008
|
|
|
1018
|
-
**Method:** `sdk.notebooks.delete(notebookIds)`
|
|
1009
|
+
**Method:** `sdk.notebooks.delete(notebookIds, options?)`
|
|
1019
1010
|
|
|
1020
1011
|
**Example:** [notebook-delete.ts](examples/notebook-delete.ts)
|
|
1021
1012
|
|
|
1022
1013
|
**Parameters:**
|
|
1023
1014
|
- `notebookIds: string | string[]` - Single notebook ID or array of IDs (required)
|
|
1015
|
+
- `options?: DeleteNotebookOptions` - Optional deletion options:
|
|
1016
|
+
- `mode?: 'parallel' | 'sequential'` - Execution mode (default: 'parallel')
|
|
1024
1017
|
|
|
1025
1018
|
**Returns:** `Promise<DeleteNotebookResult>`
|
|
1026
1019
|
|
|
1027
1020
|
**Description:**
|
|
1028
|
-
Deletes one or more notebooks. Returns confirmation with deleted IDs and count.
|
|
1021
|
+
Deletes one or more notebooks. For multiple notebooks, deletions are performed individually (either in parallel or sequentially) since Google's API does not support true batch deletion. Returns confirmation with deleted IDs and count.
|
|
1029
1022
|
|
|
1030
1023
|
**Return Fields:**
|
|
1031
|
-
- `deleted: string[]` - Array of deleted notebook IDs
|
|
1032
|
-
- `count: number` - Number of notebooks deleted
|
|
1024
|
+
- `deleted: string[]` - Array of successfully deleted notebook IDs
|
|
1025
|
+
- `count: number` - Number of notebooks successfully deleted
|
|
1026
|
+
- `failed?: string[]` - Array of notebook IDs that failed to delete (only present if some failed)
|
|
1027
|
+
- `failedCount?: number` - Number of notebooks that failed to delete
|
|
1033
1028
|
|
|
1034
1029
|
<details>
|
|
1035
1030
|
<summary><strong>Validation</strong></summary>
|
|
@@ -1040,13 +1035,23 @@ Deletes one or more notebooks. Returns confirmation with deleted IDs and count.
|
|
|
1040
1035
|
|
|
1041
1036
|
</details>
|
|
1042
1037
|
|
|
1038
|
+
<details>
|
|
1039
|
+
<summary><strong>Deletion Modes</strong></summary>
|
|
1040
|
+
|
|
1041
|
+
- **Parallel (default):** All notebooks are deleted simultaneously using `Promise.all()`. Faster but may hit rate limits.
|
|
1042
|
+
- **Sequential:** Notebooks are deleted one at a time. Slower but more reliable and avoids rate limit issues.
|
|
1043
|
+
|
|
1044
|
+
</details>
|
|
1045
|
+
|
|
1043
1046
|
<details>
|
|
1044
1047
|
<summary><strong>Notes</strong></summary>
|
|
1045
1048
|
|
|
1046
1049
|
- No confirmation required - deletion is immediate
|
|
1047
|
-
-
|
|
1048
|
-
-
|
|
1049
|
-
-
|
|
1050
|
+
- Google's API does not support batch deletion in a single call
|
|
1051
|
+
- Multiple notebooks are deleted individually, one per API call
|
|
1052
|
+
- Parallel mode is default but sequential mode is recommended for large batches to avoid rate limits
|
|
1053
|
+
- Failed deletions are tracked separately - if some succeed and some fail, you'll get both `deleted` and `failed` arrays
|
|
1054
|
+
- Throws error only if ALL deletions fail (partial failures return result with `failed` array)
|
|
1050
1055
|
|
|
1051
1056
|
</details>
|
|
1052
1057
|
|
|
@@ -1056,15 +1061,24 @@ Deletes one or more notebooks. Returns confirmation with deleted IDs and count.
|
|
|
1056
1061
|
const result = await sdk.notebooks.delete('notebook-id')
|
|
1057
1062
|
console.log(`Deleted ${result.count} notebook: ${result.deleted[0]}`)
|
|
1058
1063
|
|
|
1059
|
-
// Delete multiple notebooks
|
|
1064
|
+
// Delete multiple notebooks (parallel - default)
|
|
1060
1065
|
const result = await sdk.notebooks.delete(['id-1', 'id-2', 'id-3'])
|
|
1061
1066
|
console.log(`Deleted ${result.count} notebooks: ${result.deleted.join(', ')}`)
|
|
1067
|
+
|
|
1068
|
+
// Delete multiple notebooks (sequential - recommended for large batches)
|
|
1069
|
+
const result = await sdk.notebooks.delete(['id-1', 'id-2', 'id-3'], { mode: 'sequential' })
|
|
1070
|
+
console.log(`Deleted ${result.count} notebooks: ${result.deleted.join(', ')}`)
|
|
1071
|
+
if (result.failed && result.failed.length > 0) {
|
|
1072
|
+
console.log(`Failed to delete: ${result.failed.join(', ')}`)
|
|
1073
|
+
}
|
|
1062
1074
|
```
|
|
1063
1075
|
|
|
1064
1076
|
---
|
|
1065
1077
|
|
|
1066
1078
|
### Share Notebook
|
|
1067
1079
|
|
|
1080
|
+
> **⚠️ Experimental:** This feature is experimental and may have limitations or breaking changes in future versions.
|
|
1081
|
+
|
|
1068
1082
|
**Method:** `sdk.notebooks.share(notebookId, options)`
|
|
1069
1083
|
|
|
1070
1084
|
**Example:** [notebook-share.ts](examples/notebook-share.ts)
|
|
@@ -1189,49 +1203,80 @@ const sourceId = await sdk.sources.addFromURL('notebook-id', {
|
|
|
1189
1203
|
|
|
1190
1204
|
---
|
|
1191
1205
|
|
|
1192
|
-
#### `addFromText(notebookId: string, options: AddTextSourceOptions)` → `Promise<string>`
|
|
1206
|
+
#### `addFromText(notebookId: string, options: AddTextSourceOptions)` → `Promise<string | AddSourceResult>`
|
|
1193
1207
|
Add a source from text content.
|
|
1194
1208
|
|
|
1209
|
+
**Auto-Chunking:** Large texts (>500k words) are automatically split into chunks and uploaded in parallel.
|
|
1210
|
+
|
|
1195
1211
|
**Parameters:**
|
|
1196
1212
|
- `notebookId: string` - The notebook ID
|
|
1197
1213
|
- `options.title: string` - Source title
|
|
1198
1214
|
- `options.content: string` - Text content
|
|
1199
1215
|
|
|
1200
1216
|
**Returns:**
|
|
1201
|
-
- `string` - Source ID
|
|
1217
|
+
- `string` - Source ID (if not chunked)
|
|
1218
|
+
- `AddSourceResult` - Chunk metadata (if auto-chunked)
|
|
1202
1219
|
|
|
1203
1220
|
**Example:**
|
|
1204
1221
|
```typescript
|
|
1222
|
+
// Small text (returns string)
|
|
1205
1223
|
const sourceId = await sdk.sources.addFromText('notebook-id', {
|
|
1206
1224
|
title: 'Research Notes',
|
|
1207
1225
|
content: 'Your text content here...',
|
|
1208
1226
|
})
|
|
1227
|
+
|
|
1228
|
+
// Large text (auto-chunked)
|
|
1229
|
+
const result = await sdk.sources.addFromText('notebook-id', {
|
|
1230
|
+
title: 'Large Document',
|
|
1231
|
+
content: veryLongText, // > 500k words
|
|
1232
|
+
})
|
|
1233
|
+
if (typeof result === 'string') {
|
|
1234
|
+
console.log(`Source ID: ${result}`)
|
|
1235
|
+
} else {
|
|
1236
|
+
console.log(`Uploaded ${result.chunks?.length || 0} chunks`)
|
|
1237
|
+
}
|
|
1209
1238
|
```
|
|
1210
1239
|
|
|
1211
1240
|
---
|
|
1212
1241
|
|
|
1213
|
-
#### `addFromFile(notebookId: string, options: AddFileSourceOptions)` → `Promise<string>`
|
|
1242
|
+
#### `addFromFile(notebookId: string, options: AddFileSourceOptions)` → `Promise<string | AddSourceResult>`
|
|
1214
1243
|
Add a source from a file (PDF, image, etc.).
|
|
1215
1244
|
|
|
1245
|
+
**Auto-Chunking:** Large files (>200MB or >500k words) are automatically split into chunks and uploaded in parallel.
|
|
1246
|
+
|
|
1216
1247
|
**Parameters:**
|
|
1217
1248
|
- `notebookId: string` - The notebook ID
|
|
1218
|
-
- `options.content: Buffer` - File content as Buffer
|
|
1249
|
+
- `options.content: Buffer | string` - File content as Buffer or base64 string
|
|
1219
1250
|
- `options.fileName: string` - File name
|
|
1220
|
-
- `options.mimeType
|
|
1251
|
+
- `options.mimeType?: string` - MIME type (e.g., 'application/pdf')
|
|
1221
1252
|
|
|
1222
1253
|
**Returns:**
|
|
1223
|
-
- `string` - Source ID
|
|
1254
|
+
- `string` - Source ID (if not chunked)
|
|
1255
|
+
- `AddSourceResult` - Chunk metadata (if auto-chunked)
|
|
1224
1256
|
|
|
1225
1257
|
**Example:**
|
|
1226
1258
|
```typescript
|
|
1227
1259
|
import { readFile } from 'fs/promises'
|
|
1228
1260
|
|
|
1261
|
+
// Small file (returns string)
|
|
1229
1262
|
const buffer = await readFile('./document.pdf')
|
|
1230
1263
|
const sourceId = await sdk.sources.addFromFile('notebook-id', {
|
|
1231
1264
|
content: buffer,
|
|
1232
1265
|
fileName: 'document.pdf',
|
|
1233
1266
|
mimeType: 'application/pdf',
|
|
1234
1267
|
})
|
|
1268
|
+
|
|
1269
|
+
// Large file (auto-chunked)
|
|
1270
|
+
const largeBuffer = await readFile('./large-document.pdf')
|
|
1271
|
+
const result = await sdk.sources.addFromFile('notebook-id', {
|
|
1272
|
+
content: largeBuffer, // > 200MB or > 500k words
|
|
1273
|
+
fileName: 'large-document.pdf',
|
|
1274
|
+
})
|
|
1275
|
+
if (typeof result === 'string') {
|
|
1276
|
+
console.log(`Source ID: ${result}`)
|
|
1277
|
+
} else {
|
|
1278
|
+
console.log(`Uploaded ${result.chunks?.length || 0} chunks`)
|
|
1279
|
+
}
|
|
1235
1280
|
```
|
|
1236
1281
|
|
|
1237
1282
|
---
|
|
@@ -1472,17 +1517,46 @@ if (!status.processing.includes(sourceId)) {
|
|
|
1472
1517
|
- `content: string` - Text content (required)
|
|
1473
1518
|
- `title: string` - Source title (required)
|
|
1474
1519
|
|
|
1475
|
-
**Returns:** `Promise<string>` - Source ID
|
|
1520
|
+
**Returns:** `Promise<string | AddSourceResult>` - Source ID (string) if not chunked, or `AddSourceResult` if auto-chunked
|
|
1476
1521
|
|
|
1477
1522
|
**Description:**
|
|
1478
1523
|
Adds text content as a source. Useful for adding notes, research summaries, or any text-based content.
|
|
1479
1524
|
|
|
1525
|
+
**Auto-Chunking:**
|
|
1526
|
+
- If text exceeds 500,000 words, it's automatically split into chunks and uploaded in parallel
|
|
1527
|
+
- Each chunk is uploaded as a separate source (counts toward your source limit)
|
|
1528
|
+
- Returns `AddSourceResult` with chunk count and source IDs when chunked
|
|
1529
|
+
- Small texts (≤500k words) return a simple string (backward compatible)
|
|
1530
|
+
|
|
1531
|
+
<details>
|
|
1532
|
+
<summary><strong>Auto-Chunking Details</strong></summary>
|
|
1533
|
+
|
|
1534
|
+
- **Limit:** 500,000 words per source
|
|
1535
|
+
- **Behavior:** Large texts are automatically split into optimal chunks
|
|
1536
|
+
- **Upload:** All chunks are uploaded in parallel for faster processing
|
|
1537
|
+
- **Result:** Returns chunk metadata including number of chunks and all source IDs
|
|
1538
|
+
|
|
1539
|
+
</details>
|
|
1540
|
+
|
|
1480
1541
|
**Usage:**
|
|
1481
1542
|
```typescript
|
|
1543
|
+
// Small text (returns string - backward compatible)
|
|
1482
1544
|
const sourceId = await sdk.sources.add.text('notebook-id', {
|
|
1483
1545
|
title: 'Research Notes',
|
|
1484
1546
|
content: 'Key findings from research...',
|
|
1485
1547
|
})
|
|
1548
|
+
|
|
1549
|
+
// Large text (auto-chunked - returns AddSourceResult)
|
|
1550
|
+
const result = await sdk.sources.add.text('notebook-id', {
|
|
1551
|
+
title: 'Large Document',
|
|
1552
|
+
content: veryLongText, // > 500k words
|
|
1553
|
+
})
|
|
1554
|
+
if (typeof result === 'string') {
|
|
1555
|
+
console.log(`Source ID: ${result}`)
|
|
1556
|
+
} else {
|
|
1557
|
+
console.log(`Uploaded ${result.chunks?.length || 0} chunks`)
|
|
1558
|
+
console.log(`Source IDs: ${result.allSourceIds?.join(', ')}`)
|
|
1559
|
+
}
|
|
1486
1560
|
```
|
|
1487
1561
|
|
|
1488
1562
|
---
|
|
@@ -1498,22 +1572,43 @@ const sourceId = await sdk.sources.add.text('notebook-id', {
|
|
|
1498
1572
|
- `fileName: string` - File name (required)
|
|
1499
1573
|
- `mimeType?: string` - MIME type (optional, auto-detected if not provided)
|
|
1500
1574
|
|
|
1501
|
-
**Returns:** `Promise<string>` - Source ID
|
|
1575
|
+
**Returns:** `Promise<string | AddSourceResult>` - Source ID (string) if not chunked, or `AddSourceResult` if auto-chunked
|
|
1502
1576
|
|
|
1503
1577
|
**Description:**
|
|
1504
1578
|
Adds a file (PDF, image, video, etc.) as a source. Supports files as Buffer or base64 string.
|
|
1505
1579
|
|
|
1580
|
+
**Auto-Chunking:**
|
|
1581
|
+
- Files exceeding 200MB or containing more than 500,000 words are automatically split into chunks
|
|
1582
|
+
- Text-based files (txt, md, csv, json, etc.): Chunked by word count (500k words per chunk)
|
|
1583
|
+
- Binary files: Chunked by size (200MB per chunk)
|
|
1584
|
+
- All chunks are uploaded in parallel for faster processing
|
|
1585
|
+
- Each chunk counts as a separate source toward your source limit
|
|
1586
|
+
- Small files return a simple string (backward compatible)
|
|
1587
|
+
|
|
1588
|
+
<details>
|
|
1589
|
+
<summary><strong>Auto-Chunking Details</strong></summary>
|
|
1590
|
+
|
|
1591
|
+
- **Size Limit:** 200MB per source
|
|
1592
|
+
- **Word Limit:** 500,000 words per source
|
|
1593
|
+
- **Text Files:** Automatically extracted and chunked by word count
|
|
1594
|
+
- **Binary Files:** Chunked by file size
|
|
1595
|
+
- **PDFs:** Chunked by size (text extraction requires a PDF library)
|
|
1596
|
+
- **Result:** Returns chunk metadata including number of chunks and all source IDs
|
|
1597
|
+
|
|
1598
|
+
</details>
|
|
1599
|
+
|
|
1506
1600
|
**Supported File Types:**
|
|
1507
1601
|
- PDF files
|
|
1508
1602
|
- Image files (PNG, JPG, etc.)
|
|
1509
1603
|
- Video files
|
|
1604
|
+
- Text files (txt, md, csv, json, etc.)
|
|
1510
1605
|
- Other document types
|
|
1511
1606
|
|
|
1512
1607
|
**Usage:**
|
|
1513
1608
|
```typescript
|
|
1514
1609
|
import fs from 'fs'
|
|
1515
1610
|
|
|
1516
|
-
//
|
|
1611
|
+
// Small file (returns string - backward compatible)
|
|
1517
1612
|
const fileBuffer = fs.readFileSync('document.pdf')
|
|
1518
1613
|
const sourceId = await sdk.sources.add.file('notebook-id', {
|
|
1519
1614
|
content: fileBuffer,
|
|
@@ -1521,12 +1616,18 @@ const sourceId = await sdk.sources.add.file('notebook-id', {
|
|
|
1521
1616
|
mimeType: 'application/pdf',
|
|
1522
1617
|
})
|
|
1523
1618
|
|
|
1524
|
-
//
|
|
1525
|
-
const
|
|
1526
|
-
const
|
|
1527
|
-
content:
|
|
1528
|
-
fileName: 'document.pdf',
|
|
1619
|
+
// Large file (auto-chunked - returns AddSourceResult)
|
|
1620
|
+
const largeFileBuffer = fs.readFileSync('large-document.pdf')
|
|
1621
|
+
const result = await sdk.sources.add.file('notebook-id', {
|
|
1622
|
+
content: largeFileBuffer, // > 200MB or > 500k words
|
|
1623
|
+
fileName: 'large-document.pdf',
|
|
1529
1624
|
})
|
|
1625
|
+
if (typeof result === 'string') {
|
|
1626
|
+
console.log(`Source ID: ${result}`)
|
|
1627
|
+
} else {
|
|
1628
|
+
console.log(`Uploaded ${result.chunks?.length || 0} chunks`)
|
|
1629
|
+
console.log(`Source IDs: ${result.allSourceIds?.join(', ')}`)
|
|
1630
|
+
}
|
|
1530
1631
|
```
|
|
1531
1632
|
|
|
1532
1633
|
---
|
|
@@ -1565,6 +1666,8 @@ const sourceId = await sdk.sources.add.youtube('notebook-id', {
|
|
|
1565
1666
|
|
|
1566
1667
|
### Add Google Drive Source
|
|
1567
1668
|
|
|
1669
|
+
> **⚠️ Experimental:** This feature is experimental and may have limitations or breaking changes in future versions.
|
|
1670
|
+
|
|
1568
1671
|
**Method:** `sdk.sources.add.drive(notebookId, options)`
|
|
1569
1672
|
|
|
1570
1673
|
**Parameters:**
|
|
@@ -1622,7 +1725,7 @@ Adds multiple sources at once. Supports mixed source types (URLs, text, files, Y
|
|
|
1622
1725
|
- `{ type: 'text', title: string, content: string }` - Text source
|
|
1623
1726
|
- `{ type: 'file', content: Buffer | string, fileName: string, mimeType?: string }` - File source
|
|
1624
1727
|
- `{ type: 'youtube', urlOrId: string, title?: string }` - YouTube source
|
|
1625
|
-
- `{ type: 'gdrive', fileId: string, title?: string, mimeType?: string }` - Google Drive source
|
|
1728
|
+
- `{ type: 'gdrive', fileId: string, title?: string, mimeType?: string }` - Google Drive source <small>⚠️ Experimental</small>
|
|
1626
1729
|
|
|
1627
1730
|
**Usage:**
|
|
1628
1731
|
```typescript
|
|
@@ -1669,12 +1772,12 @@ const sourceIds = await sdk.sources.add.batch('notebook-id', {
|
|
|
1669
1772
|
|
|
1670
1773
|
**Source Types:**
|
|
1671
1774
|
- `SearchSourceType.WEB` - Search web (default)
|
|
1672
|
-
- `SearchSourceType.GOOGLE_DRIVE` - Search Google Drive (FAST mode only)
|
|
1775
|
+
- `SearchSourceType.GOOGLE_DRIVE` - Search Google Drive (FAST mode only) <small>⚠️ Experimental</small>
|
|
1673
1776
|
|
|
1674
1777
|
**Return Fields:**
|
|
1675
1778
|
- `sessionId: string` - Required for adding sources (use with `addDiscovered()`)
|
|
1676
1779
|
- `web: DiscoveredWebSource[]` - Discovered web sources
|
|
1677
|
-
- `drive: DiscoveredDriveSource[]` - Discovered Google Drive sources
|
|
1780
|
+
- `drive: DiscoveredDriveSource[]` - Discovered Google Drive sources <small>⚠️ Experimental</small>
|
|
1678
1781
|
|
|
1679
1782
|
<details>
|
|
1680
1783
|
<summary><strong>Notes</strong></summary>
|
package/dist/src/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type { InfographicImageData, FetchInfographicOptions } from './services/a
|
|
|
23
23
|
export type { NotebookLMConfig, RPCCall, RPCResponse, BatchExecuteConfig, } from './types/common.js';
|
|
24
24
|
export { NotebookLMError, NotebookLMAuthError, NotebookLMNetworkError, NotebookLMParseError, } from './types/common.js';
|
|
25
25
|
export type { Notebook, CreateNotebookOptions, UpdateNotebookOptions, SharingSettings, ShareNotebookOptions, ShareNotebookResult, DeleteNotebookResult, } from './types/notebook.js';
|
|
26
|
-
export type { Source, SourceInput, AddSourceFromURLOptions, AddSourceFromTextOptions, AddSourceFromFileOptions, SourceProcessingStatus, SourceContent, SourceFreshness, DiscoveredSource, DiscoveredWebSource, DiscoveredDriveSource, SearchWebSourcesOptions, AddDiscoveredSourcesOptions, AddGoogleDriveSourceOptions, AddYouTubeSourceOptions, BatchAddSourcesOptions, SearchWebAndWaitOptions, WebSearchResult, } from './types/source.js';
|
|
26
|
+
export type { Source, SourceInput, AddSourceFromURLOptions, AddSourceFromTextOptions, AddSourceFromFileOptions, SourceProcessingStatus, SourceContent, SourceFreshness, DiscoveredSource, DiscoveredWebSource, DiscoveredDriveSource, SearchWebSourcesOptions, AddDiscoveredSourcesOptions, AddGoogleDriveSourceOptions, AddYouTubeSourceOptions, BatchAddSourcesOptions, SearchWebAndWaitOptions, WebSearchResult, AddSourceResult, SourceChunk, } from './types/source.js';
|
|
27
27
|
export { ResearchMode, SearchSourceType } from './types/source.js';
|
|
28
28
|
export { SourceType, SourceStatus, } from './types/source.js';
|
|
29
29
|
export type { Note, CreateNoteOptions, UpdateNoteOptions, } from './types/note.js';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src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AAgB,EAChB,iBAAiB,EACjB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc;AACd,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEzF,WAAW;AACX,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,uGAAuG;AACvG,+EAA+E;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAW3D,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file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AC;AAEjC,gHAAgH;AAEhH,mBAAmB;AACnB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AA0B9B,OAAO,EACL,YAAY,EACZ,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,iCAAiC;AACjC,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AAEnD,gCAAgC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,0CAA0C;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,qCAAqC;AACrC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,cAAc,GACf,MAAM,mBAAmB,CAAC;AAG3B,qDAAqD;AACrD,OAAO,EACL,cAAc,EACd,SAAS,EACT,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAG3B,mBAAmB;AACnB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,GACZ,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RPCClient } from '../rpc/rpc-client.js';
|
|
2
|
-
import type { Notebook, CreateNotebookOptions, UpdateNotebookOptions, ShareNotebookOptions, ShareNotebookResult, DeleteNotebookResult } from '../types/notebook.js';
|
|
2
|
+
import type { Notebook, CreateNotebookOptions, UpdateNotebookOptions, ShareNotebookOptions, ShareNotebookResult, DeleteNotebookResult, DeleteNotebookOptions } from '../types/notebook.js';
|
|
3
3
|
export declare class NotebooksService {
|
|
4
4
|
private rpc;
|
|
5
5
|
private quota?;
|
|
@@ -8,7 +8,17 @@ export declare class NotebooksService {
|
|
|
8
8
|
get(notebookId: string): Promise<Notebook>;
|
|
9
9
|
create(options: CreateNotebookOptions): Promise<Notebook>;
|
|
10
10
|
update(notebookId: string, options: UpdateNotebookOptions): Promise<Notebook>;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Delete one or more notebooks
|
|
13
|
+
*
|
|
14
|
+
* Note: Google's API does not support batch deletion in a single call.
|
|
15
|
+
* Multiple notebooks are deleted individually, either in parallel (default) or sequentially.
|
|
16
|
+
*
|
|
17
|
+
* @param notebookIds - Single notebook ID or array of IDs
|
|
18
|
+
* @param options - Optional deletion options
|
|
19
|
+
* @returns Result with deleted IDs and count
|
|
20
|
+
*/
|
|
21
|
+
delete(notebookIds: string | string[], options?: DeleteNotebookOptions): Promise<DeleteNotebookResult>;
|
|
12
22
|
share(notebookId: string, options: ShareNotebookOptions): Promise<ShareNotebookResult>;
|
|
13
23
|
/**
|
|
14
24
|
* Parse sharing details response from JFMDGd RPC
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notebooks.d.ts","sourceRoot":"","sources":["../../../src/services/notebooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAmB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"notebooks.d.ts","sourceRoot":"","sources":["../../../src/services/notebooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAmB,MAAM,sBAAsB,CAAC;AAK5M,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,KAAK,CAAC;gBADN,GAAG,EAAE,SAAS,EACd,KAAK,CAAC,EAAE,OAAO,mBAAmB,EAAE,YAAY,YAAA;IAGpD,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAU3B,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAsB1C,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IA8BzD,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAqDnF;;;;;;;;;OASG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgFtG,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA2J5F;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAoG5B,OAAO,CAAC,iBAAiB;IA+BzB,OAAO,CAAC,gBAAgB;IA6GxB;;;OAGG;YACW,QAAQ;IAuBtB,OAAO,CAAC,mBAAmB;CAqD5B"}
|
|
@@ -54,23 +54,21 @@ export class NotebooksService {
|
|
|
54
54
|
if (!notebookId || typeof notebookId !== 'string') {
|
|
55
55
|
throw new APIError('Invalid notebook ID format', undefined, 400);
|
|
56
56
|
}
|
|
57
|
-
// Validate: at least one field must be provided (title
|
|
58
|
-
if (!options.title && !options.
|
|
59
|
-
throw new APIError('At least one field (title
|
|
57
|
+
// Validate: at least one field must be provided (title or emoji)
|
|
58
|
+
if (!options.title && !options.emoji) {
|
|
59
|
+
throw new APIError('At least one field (title or emoji) must be provided', undefined, 400);
|
|
60
60
|
}
|
|
61
61
|
if (options.title && options.title.length > 100) {
|
|
62
62
|
throw new APIError('Notebook title exceeds maximum length (100 characters)', undefined, 400);
|
|
63
63
|
}
|
|
64
|
-
// Set emoji if provided (supports: emoji only, title + emoji
|
|
64
|
+
// Set emoji if provided (supports: emoji only, title + emoji)
|
|
65
65
|
if (options.emoji !== undefined) {
|
|
66
66
|
await this.setEmoji(notebookId, options.emoji);
|
|
67
67
|
}
|
|
68
|
-
// Update title
|
|
69
|
-
if (options.title !== undefined
|
|
68
|
+
// Update title if provided (supports: title only, or title + emoji)
|
|
69
|
+
if (options.title !== undefined) {
|
|
70
70
|
const updateArray = [null, null, null, null];
|
|
71
|
-
|
|
72
|
-
updateArray[3] = [null, options.title];
|
|
73
|
-
}
|
|
71
|
+
updateArray[3] = [null, options.title];
|
|
74
72
|
const updates = [updateArray];
|
|
75
73
|
const response = await this.rpc.call(RPC.RPC_UPDATE_PROJECT, [notebookId, updates], notebookId);
|
|
76
74
|
const notebook = this.parseGetResponse(response, notebookId, null);
|
|
@@ -80,25 +78,96 @@ export class NotebooksService {
|
|
|
80
78
|
}
|
|
81
79
|
return notebook;
|
|
82
80
|
}
|
|
83
|
-
// If only emoji was updated (no title
|
|
81
|
+
// If only emoji was updated (no title), fetch the notebook and update emoji in response
|
|
84
82
|
const notebook = await this.get(notebookId);
|
|
85
83
|
if (options.emoji !== undefined) {
|
|
86
84
|
notebook.emoji = options.emoji;
|
|
87
85
|
}
|
|
88
86
|
return notebook;
|
|
89
87
|
}
|
|
90
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Delete one or more notebooks
|
|
90
|
+
*
|
|
91
|
+
* Note: Google's API does not support batch deletion in a single call.
|
|
92
|
+
* Multiple notebooks are deleted individually, either in parallel (default) or sequentially.
|
|
93
|
+
*
|
|
94
|
+
* @param notebookIds - Single notebook ID or array of IDs
|
|
95
|
+
* @param options - Optional deletion options
|
|
96
|
+
* @returns Result with deleted IDs and count
|
|
97
|
+
*/
|
|
98
|
+
async delete(notebookIds, options) {
|
|
91
99
|
const ids = Array.isArray(notebookIds) ? notebookIds : [notebookIds];
|
|
100
|
+
const mode = options?.mode || 'parallel';
|
|
101
|
+
// Validate all IDs first
|
|
92
102
|
for (const id of ids) {
|
|
93
103
|
if (!id || typeof id !== 'string') {
|
|
94
104
|
throw new APIError('Invalid notebook ID format', undefined, 400);
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
// Single notebook deletion - use batch API with single ID
|
|
108
|
+
if (ids.length === 1) {
|
|
109
|
+
try {
|
|
110
|
+
await this.rpc.call(RPC.RPC_DELETE_PROJECTS, [[ids[0]], [2]]);
|
|
111
|
+
return {
|
|
112
|
+
deleted: ids,
|
|
113
|
+
count: 1,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
throw new APIError(`Failed to delete notebook: ${error.message}`, undefined, 500);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Multiple notebook deletion - delete individually
|
|
121
|
+
const deleted = [];
|
|
122
|
+
const failed = [];
|
|
123
|
+
if (mode === 'parallel') {
|
|
124
|
+
// Delete all notebooks in parallel
|
|
125
|
+
const deletePromises = ids.map(async (id) => {
|
|
126
|
+
try {
|
|
127
|
+
// Each deletion uses a single-item array [id] to avoid batch API issues
|
|
128
|
+
await this.rpc.call(RPC.RPC_DELETE_PROJECTS, [[id], [2]]);
|
|
129
|
+
return { success: true, id };
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
return { success: false, id, error: error.message };
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const results = await Promise.all(deletePromises);
|
|
136
|
+
for (const result of results) {
|
|
137
|
+
if (result.success) {
|
|
138
|
+
deleted.push(result.id);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
failed.push(result.id);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// Sequential deletion - delete one at a time
|
|
147
|
+
for (const id of ids) {
|
|
148
|
+
try {
|
|
149
|
+
await this.rpc.call(RPC.RPC_DELETE_PROJECTS, [[id], [2]]);
|
|
150
|
+
deleted.push(id);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
failed.push(id);
|
|
154
|
+
// Continue with remaining deletions even if one fails
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const result = {
|
|
159
|
+
deleted,
|
|
160
|
+
count: deleted.length,
|
|
101
161
|
};
|
|
162
|
+
if (failed.length > 0) {
|
|
163
|
+
result.failed = failed;
|
|
164
|
+
result.failedCount = failed.length;
|
|
165
|
+
}
|
|
166
|
+
// Throw error if all deletions failed
|
|
167
|
+
if (deleted.length === 0 && failed.length > 0) {
|
|
168
|
+
throw new APIError(`Failed to delete all notebooks: ${failed.join(', ')}`, undefined, 500);
|
|
169
|
+
}
|
|
170
|
+
return result;
|
|
102
171
|
}
|
|
103
172
|
async share(notebookId, options) {
|
|
104
173
|
if (!notebookId || typeof notebookId !== 'string') {
|