notebooklm-sdk 0.3.0 → 0.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/dist/index.cjs +105 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +106 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,10 @@ __export(enums_exports, {
|
|
|
21
21
|
ArtifactTypeCode: () => exports.ArtifactTypeCode,
|
|
22
22
|
AudioFormat: () => exports.AudioFormat,
|
|
23
23
|
AudioLength: () => exports.AudioLength,
|
|
24
|
+
ChatGoal: () => exports.ChatGoal,
|
|
24
25
|
ChatMode: () => exports.ChatMode,
|
|
26
|
+
ChatResponseLength: () => exports.ChatResponseLength,
|
|
27
|
+
DriveMimeType: () => exports.DriveMimeType,
|
|
25
28
|
ExportType: () => exports.ExportType,
|
|
26
29
|
InfographicDetail: () => exports.InfographicDetail,
|
|
27
30
|
InfographicOrientation: () => exports.InfographicOrientation,
|
|
@@ -64,7 +67,7 @@ function sourceStatusFromCode(code) {
|
|
|
64
67
|
function chatModeToParams(mode) {
|
|
65
68
|
return CHAT_MODE_PARAMS[mode];
|
|
66
69
|
}
|
|
67
|
-
exports.RPCMethod = void 0; exports.ArtifactTypeCode = void 0; var ArtifactStatusCode, SourceStatusCode; exports.AudioFormat = void 0; exports.AudioLength = void 0; exports.VideoFormat = void 0; exports.VideoStyle = void 0; exports.QuizQuantity = void 0; exports.QuizDifficulty = void 0; exports.InfographicOrientation = void 0; exports.InfographicDetail = void 0; exports.InfographicStyle = void 0; exports.SlideDeckFormat = void 0; exports.SlideDeckLength = void 0; exports.ExportType = void 0; var SOURCE_TYPE_MAP, ARTIFACT_TYPE_MAP, ARTIFACT_STATUS_MAP, SOURCE_STATUS_MAP; exports.ChatMode = void 0; var CHAT_MODE_PARAMS; exports.ShareAccess = void 0; exports.ShareViewLevel = void 0; exports.SharePermission = void 0;
|
|
70
|
+
exports.RPCMethod = void 0; exports.ArtifactTypeCode = void 0; var ArtifactStatusCode, SourceStatusCode; exports.AudioFormat = void 0; exports.AudioLength = void 0; exports.VideoFormat = void 0; exports.VideoStyle = void 0; exports.QuizQuantity = void 0; exports.QuizDifficulty = void 0; exports.InfographicOrientation = void 0; exports.InfographicDetail = void 0; exports.InfographicStyle = void 0; exports.SlideDeckFormat = void 0; exports.SlideDeckLength = void 0; exports.ExportType = void 0; exports.DriveMimeType = void 0; var SOURCE_TYPE_MAP, ARTIFACT_TYPE_MAP, ARTIFACT_STATUS_MAP, SOURCE_STATUS_MAP; exports.ChatMode = void 0; var CHAT_MODE_PARAMS; exports.ChatGoal = void 0; exports.ChatResponseLength = void 0; exports.ShareAccess = void 0; exports.ShareViewLevel = void 0; exports.SharePermission = void 0;
|
|
68
71
|
var init_enums = __esm({
|
|
69
72
|
"src/types/enums.ts"() {
|
|
70
73
|
exports.RPCMethod = {
|
|
@@ -213,6 +216,12 @@ var init_enums = __esm({
|
|
|
213
216
|
DOCS: 1,
|
|
214
217
|
SHEETS: 2
|
|
215
218
|
};
|
|
219
|
+
exports.DriveMimeType = {
|
|
220
|
+
GOOGLE_DOC: "application/vnd.google-apps.document",
|
|
221
|
+
GOOGLE_SLIDES: "application/vnd.google-apps.presentation",
|
|
222
|
+
GOOGLE_SHEETS: "application/vnd.google-apps.spreadsheet",
|
|
223
|
+
PDF: "application/pdf"
|
|
224
|
+
};
|
|
216
225
|
SOURCE_TYPE_MAP = {
|
|
217
226
|
1: "google_docs",
|
|
218
227
|
2: "google_slides",
|
|
@@ -264,6 +273,22 @@ var init_enums = __esm({
|
|
|
264
273
|
concise: [1, 5],
|
|
265
274
|
detailed: [1, 4]
|
|
266
275
|
};
|
|
276
|
+
exports.ChatGoal = {
|
|
277
|
+
/** General purpose research and brainstorming. */
|
|
278
|
+
DEFAULT: 1,
|
|
279
|
+
/** Custom instructions (up to 10,000 characters). */
|
|
280
|
+
CUSTOM: 2,
|
|
281
|
+
/** Educational focus with learning-oriented responses. */
|
|
282
|
+
LEARNING_GUIDE: 3
|
|
283
|
+
};
|
|
284
|
+
exports.ChatResponseLength = {
|
|
285
|
+
/** Standard response length. */
|
|
286
|
+
DEFAULT: 1,
|
|
287
|
+
/** Verbose, detailed responses. */
|
|
288
|
+
LONGER: 4,
|
|
289
|
+
/** Concise, brief responses. */
|
|
290
|
+
SHORTER: 5
|
|
291
|
+
};
|
|
267
292
|
exports.ShareAccess = {
|
|
268
293
|
/** Only explicitly shared users can access */
|
|
269
294
|
RESTRICTED: 0,
|
|
@@ -786,6 +811,30 @@ var ArtifactsAPI = class {
|
|
|
786
811
|
const artifacts = await this.list(notebookId);
|
|
787
812
|
return artifacts.find((a) => a.id === artifactId) ?? null;
|
|
788
813
|
}
|
|
814
|
+
async listAudio(notebookId) {
|
|
815
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "audio");
|
|
816
|
+
}
|
|
817
|
+
async listVideo(notebookId) {
|
|
818
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "video");
|
|
819
|
+
}
|
|
820
|
+
async listReports(notebookId) {
|
|
821
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "report");
|
|
822
|
+
}
|
|
823
|
+
async listQuizzes(notebookId) {
|
|
824
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "quiz");
|
|
825
|
+
}
|
|
826
|
+
async listFlashcards(notebookId) {
|
|
827
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "flashcards");
|
|
828
|
+
}
|
|
829
|
+
async listInfographics(notebookId) {
|
|
830
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "infographic");
|
|
831
|
+
}
|
|
832
|
+
async listSlideDecks(notebookId) {
|
|
833
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "slide_deck");
|
|
834
|
+
}
|
|
835
|
+
async listDataTables(notebookId) {
|
|
836
|
+
return (await this.list(notebookId)).filter((a) => a.kind === "data_table");
|
|
837
|
+
}
|
|
789
838
|
async delete(notebookId, artifactId) {
|
|
790
839
|
const params = [[2], notebookId, artifactId];
|
|
791
840
|
await this.rpc.call(exports.RPCMethod.DELETE_ARTIFACT, params, {
|
|
@@ -1410,6 +1459,23 @@ var ChatAPI = class {
|
|
|
1410
1459
|
}
|
|
1411
1460
|
return null;
|
|
1412
1461
|
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Low-level chat configuration. Set goal, response length, and optional
|
|
1464
|
+
* custom instructions directly. Persists on the server per notebook.
|
|
1465
|
+
* Use `setMode()` for preset combinations instead.
|
|
1466
|
+
*/
|
|
1467
|
+
async configure(notebookId, goal, length, customPrompt) {
|
|
1468
|
+
if (goal === exports.ChatGoal.CUSTOM && !customPrompt) {
|
|
1469
|
+
throw new Error("customPrompt is required when goal is ChatGoal.CUSTOM");
|
|
1470
|
+
}
|
|
1471
|
+
const goalArray = goal === exports.ChatGoal.CUSTOM ? [goal, customPrompt] : [goal];
|
|
1472
|
+
const chatSettings = [goalArray, [length]];
|
|
1473
|
+
const params = [notebookId, [[null, null, null, null, null, null, null, chatSettings]]];
|
|
1474
|
+
await this.rpc.call(exports.RPCMethod.RENAME_NOTEBOOK, params, {
|
|
1475
|
+
sourcePath: `/notebook/${notebookId}`,
|
|
1476
|
+
allowNull: true
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1413
1479
|
/**
|
|
1414
1480
|
* Set the chat mode for a notebook. Persists on the server — affects all
|
|
1415
1481
|
* subsequent `ask()` calls until changed.
|
|
@@ -2121,6 +2187,44 @@ var SourcesAPI = class {
|
|
|
2121
2187
|
_typeCode: null
|
|
2122
2188
|
};
|
|
2123
2189
|
}
|
|
2190
|
+
async addDrive(notebookId, fileId, title, mimeType = exports.DriveMimeType.GOOGLE_DOC, opts = {}) {
|
|
2191
|
+
const sourceData = [
|
|
2192
|
+
[fileId, mimeType, 1, title],
|
|
2193
|
+
null,
|
|
2194
|
+
null,
|
|
2195
|
+
null,
|
|
2196
|
+
null,
|
|
2197
|
+
null,
|
|
2198
|
+
null,
|
|
2199
|
+
null,
|
|
2200
|
+
null,
|
|
2201
|
+
null,
|
|
2202
|
+
1
|
|
2203
|
+
];
|
|
2204
|
+
const params = [
|
|
2205
|
+
[sourceData],
|
|
2206
|
+
notebookId,
|
|
2207
|
+
[2],
|
|
2208
|
+
[1, null, null, null, null, null, null, null, null, null, [1]]
|
|
2209
|
+
];
|
|
2210
|
+
const result = await this.rpc.call(exports.RPCMethod.ADD_SOURCE, params, {
|
|
2211
|
+
sourcePath: `/notebook/${notebookId}`,
|
|
2212
|
+
allowNull: true
|
|
2213
|
+
});
|
|
2214
|
+
const sourceId = extractSourceId(result);
|
|
2215
|
+
if (opts.waitUntilReady) {
|
|
2216
|
+
return this.waitUntilReady(notebookId, sourceId, opts.waitTimeout);
|
|
2217
|
+
}
|
|
2218
|
+
return {
|
|
2219
|
+
id: sourceId,
|
|
2220
|
+
title,
|
|
2221
|
+
url: null,
|
|
2222
|
+
kind: "unknown",
|
|
2223
|
+
createdAt: null,
|
|
2224
|
+
status: "processing",
|
|
2225
|
+
_typeCode: null
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2124
2228
|
async addFile(notebookId, filePath, mimeType, opts = {}) {
|
|
2125
2229
|
const fileData = fs.readFileSync(filePath);
|
|
2126
2230
|
const fileName = filePath.split("/").pop() ?? "file";
|