@mindstone/mcp-server-google-workspace 0.4.2 → 0.5.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 +43 -5
- package/dist/modules/docs/service.d.ts +76 -6
- package/dist/modules/docs/service.js +791 -103
- package/dist/modules/docs/tabCopy.d.ts +266 -0
- package/dist/modules/docs/tabCopy.js +794 -0
- package/dist/modules/docs/tabs.d.ts +161 -0
- package/dist/modules/docs/tabs.js +416 -0
- package/dist/modules/docs/types.d.ts +141 -1
- package/dist/modules/drive/service.d.ts +15 -0
- package/dist/modules/drive/service.js +77 -2
- package/dist/modules/drive/types.d.ts +1 -1
- package/dist/modules/sheets/a1Utils.d.ts +13 -0
- package/dist/modules/sheets/a1Utils.js +33 -7
- package/dist/modules/sheets/formatters.d.ts +33 -2
- package/dist/modules/sheets/formatters.js +84 -5
- package/dist/modules/sheets/service.d.ts +26 -1
- package/dist/modules/sheets/service.js +264 -8
- package/dist/modules/sheets/types.d.ts +71 -0
- package/dist/modules/sheets/types.js +12 -1
- package/dist/modules/sheets/writeGuards.js +2 -2
- package/dist/tools/definitions/destructive-overrides.json +8 -0
- package/dist/tools/definitions/docs.js +395 -9
- package/dist/tools/definitions/drive.js +9 -4
- package/dist/tools/definitions/open-world-overrides.json +8 -0
- package/dist/tools/definitions/sheets.js +177 -1
- package/dist/tools/docs-handlers.d.ts +125 -0
- package/dist/tools/docs-handlers.js +397 -15
- package/dist/tools/param-normalizer.js +16 -0
- package/dist/tools/server.js +35 -3
- package/dist/tools/sheets-handlers.d.ts +54 -1
- package/dist/tools/sheets-handlers.js +107 -13
- package/dist/tools/type-guards.d.ts +89 -0
- package/dist/tools/type-guards.js +190 -6
- package/dist/tools/types.d.ts +1 -1
- package/dist/utils/apiError.d.ts +6 -0
- package/dist/utils/apiError.js +12 -0
- package/dist/utils/tabPosition.d.ts +20 -0
- package/dist/utils/tabPosition.js +19 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnchorMode, ReadValueView, CellColor, BorderStyle } from '../modules/sheets/types.js';
|
|
1
|
+
import { AnchorMode, ReadValueView, CellColor, BorderStyle, SheetDimension } from '../modules/sheets/types.js';
|
|
2
2
|
import { McpToolResponse } from './types.js';
|
|
3
3
|
interface ReadSpreadsheetArgs {
|
|
4
4
|
email?: string;
|
|
@@ -90,6 +90,47 @@ interface DeleteSheetArgs {
|
|
|
90
90
|
sheet_id?: number;
|
|
91
91
|
sheetId?: number;
|
|
92
92
|
}
|
|
93
|
+
interface DuplicateSheetArgs {
|
|
94
|
+
email?: string;
|
|
95
|
+
spreadsheet_id?: string;
|
|
96
|
+
spreadsheetId?: string;
|
|
97
|
+
sheet_id?: number;
|
|
98
|
+
sheetId?: number;
|
|
99
|
+
sheet_title?: string;
|
|
100
|
+
sheetTitle?: string;
|
|
101
|
+
title?: string;
|
|
102
|
+
new_title?: string;
|
|
103
|
+
newTitle?: string;
|
|
104
|
+
position?: number;
|
|
105
|
+
}
|
|
106
|
+
interface UpdateSheetArgs {
|
|
107
|
+
email?: string;
|
|
108
|
+
spreadsheet_id?: string;
|
|
109
|
+
spreadsheetId?: string;
|
|
110
|
+
sheet_id?: number;
|
|
111
|
+
sheetId?: number;
|
|
112
|
+
sheet_title?: string;
|
|
113
|
+
sheetTitle?: string;
|
|
114
|
+
title?: string;
|
|
115
|
+
new_title?: string;
|
|
116
|
+
newTitle?: string;
|
|
117
|
+
position?: number;
|
|
118
|
+
}
|
|
119
|
+
interface InsertDimensionArgs {
|
|
120
|
+
email?: string;
|
|
121
|
+
spreadsheet_id?: string;
|
|
122
|
+
spreadsheetId?: string;
|
|
123
|
+
sheet_id?: number;
|
|
124
|
+
sheetId?: number;
|
|
125
|
+
sheet_title?: string;
|
|
126
|
+
sheetTitle?: string;
|
|
127
|
+
dimension: SheetDimension;
|
|
128
|
+
start_index?: number;
|
|
129
|
+
startIndex?: number;
|
|
130
|
+
count?: number;
|
|
131
|
+
inherit_from?: 'before' | 'after';
|
|
132
|
+
inheritFrom?: 'before' | 'after';
|
|
133
|
+
}
|
|
93
134
|
interface ExtractIdArgs {
|
|
94
135
|
input: string;
|
|
95
136
|
}
|
|
@@ -206,6 +247,18 @@ export declare function handleAddSheet(args: AddSheetArgs): Promise<McpToolRespo
|
|
|
206
247
|
* Delete a sheet from a spreadsheet
|
|
207
248
|
*/
|
|
208
249
|
export declare function handleDeleteSheet(args: DeleteSheetArgs): Promise<McpToolResponse | string | object>;
|
|
250
|
+
/**
|
|
251
|
+
* Duplicate a sheet (tab) within its spreadsheet
|
|
252
|
+
*/
|
|
253
|
+
export declare function handleDuplicateSheet(args: DuplicateSheetArgs): Promise<McpToolResponse | string | object>;
|
|
254
|
+
/**
|
|
255
|
+
* Rename and/or reorder a sheet (tab)
|
|
256
|
+
*/
|
|
257
|
+
export declare function handleUpdateSheet(args: UpdateSheetArgs): Promise<McpToolResponse | string | object>;
|
|
258
|
+
/**
|
|
259
|
+
* Insert empty rows or columns into a sheet
|
|
260
|
+
*/
|
|
261
|
+
export declare function handleInsertDimension(args: InsertDimensionArgs): Promise<McpToolResponse | string | object>;
|
|
209
262
|
/**
|
|
210
263
|
* Extract spreadsheet ID from URL or validate existing ID
|
|
211
264
|
*/
|
|
@@ -3,7 +3,7 @@ import { getAccountManager, resolveEmail } from '../modules/accounts/index.js';
|
|
|
3
3
|
import { getSheetsService } from '../modules/sheets/index.js';
|
|
4
4
|
import { ActionableA1Error, normaliseA1Range } from '../modules/sheets/a1Utils.js';
|
|
5
5
|
import { rewriteSheetsApiError } from '../modules/sheets/errorRewriter.js';
|
|
6
|
-
import { extractSpreadsheetIdFromUrl, formatAnchorReadResponse, formatSpreadsheetAsText, formatOperationResult, formatShapedReadResponse, formatValuesAsTable,
|
|
6
|
+
import { extractSpreadsheetIdFromUrl, firstSheetRowNumber, formatAnchorReadResponse, formatSpreadsheetAsText, formatOperationResult, formatShapedReadResponse, formatValuesAsTable, formatSheetListResultAsText, formatSheetAddedAsText, formatSheetDuplicatedAsText, formatSheetUpdatedAsText, formatDimensionInsertedAsText, } from '../modules/sheets/formatters.js';
|
|
7
7
|
import { readAliasedBoolean, readAliasedNumber, readAliasedString, readAliasedValue } from './arg-aliases.js';
|
|
8
8
|
import { wrapUntrustedJsonStrings } from '../utils/untrusted-content.js';
|
|
9
9
|
function normaliseRangeOrThrow(range) {
|
|
@@ -150,12 +150,14 @@ export async function handleReadSpreadsheetValues(args) {
|
|
|
150
150
|
return formatAnchorReadResponse(result.data);
|
|
151
151
|
}
|
|
152
152
|
if (valueView === 'shaped') {
|
|
153
|
-
return formatShapedReadResponse(result.data);
|
|
153
|
+
return formatShapedReadResponse(result.data, { majorDimension });
|
|
154
154
|
}
|
|
155
155
|
// Format as human-readable text
|
|
156
156
|
const response = result.data;
|
|
157
157
|
const header = `Range: ${args.range}\nSpreadsheet: ${response.spreadsheetUrl}\n---\n`;
|
|
158
|
-
const table = formatValuesAsTable(response.values
|
|
158
|
+
const table = formatValuesAsTable(response.values, {
|
|
159
|
+
firstRowNumber: firstSheetRowNumber(response.valuesRange, majorDimension),
|
|
160
|
+
});
|
|
159
161
|
return header + table;
|
|
160
162
|
});
|
|
161
163
|
}
|
|
@@ -304,10 +306,7 @@ export async function handleListSheets(args) {
|
|
|
304
306
|
if (!result.success || !result.data) {
|
|
305
307
|
throw new McpError(ErrorCode.InternalError, rewriteSheetsHandlerError(result.error, 'Failed to list sheets', 'list_workspace_spreadsheet_sheets', rawArgs));
|
|
306
308
|
}
|
|
307
|
-
|
|
308
|
-
const header = `Spreadsheet: ${response.title}\nURL: ${response.spreadsheetUrl}\n---\n`;
|
|
309
|
-
const sheetsList = formatSheetsListAsText(response.sheets || []);
|
|
310
|
-
return header + sheetsList;
|
|
309
|
+
return formatSheetListResultAsText(result.data);
|
|
311
310
|
});
|
|
312
311
|
}
|
|
313
312
|
/**
|
|
@@ -333,10 +332,7 @@ export async function handleAddSheet(args) {
|
|
|
333
332
|
if (!result.success || !result.data) {
|
|
334
333
|
throw new McpError(ErrorCode.InternalError, rewriteSheetsHandlerError(result.error, 'Failed to add sheet', 'add_workspace_spreadsheet_sheet', rawArgs));
|
|
335
334
|
}
|
|
336
|
-
|
|
337
|
-
return formatOperationResult('Add sheet', spreadsheetId, {
|
|
338
|
-
sheetTitle: sheetInfo.title,
|
|
339
|
-
}) + `\nSheet ID: ${sheetInfo.sheetId}`;
|
|
335
|
+
return formatSheetAddedAsText(spreadsheetId, result.data);
|
|
340
336
|
});
|
|
341
337
|
}
|
|
342
338
|
/**
|
|
@@ -362,6 +358,102 @@ export async function handleDeleteSheet(args) {
|
|
|
362
358
|
return `Sheet deleted successfully!\n\nSpreadsheet URL: https://docs.google.com/spreadsheets/d/${spreadsheetId}/edit\nDeleted sheet ID: ${sheetId}`;
|
|
363
359
|
});
|
|
364
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* The sheet a tab tool acts on: exactly one of sheet_id or sheet_title.
|
|
363
|
+
*/
|
|
364
|
+
function readSheetRef(rawArgs) {
|
|
365
|
+
const sheetId = readAliasedNumber(rawArgs, 'sheet_id', 'sheetId');
|
|
366
|
+
const sheetTitle = readAliasedString(rawArgs, 'sheet_title', 'sheetTitle');
|
|
367
|
+
if ((sheetId === undefined) === (sheetTitle === undefined)) {
|
|
368
|
+
throw new McpError(ErrorCode.InvalidParams, 'Pass exactly one of sheet_id or sheet_title.');
|
|
369
|
+
}
|
|
370
|
+
return sheetId !== undefined ? { sheetId } : { sheetTitle: sheetTitle };
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Duplicate a sheet (tab) within its spreadsheet
|
|
374
|
+
*/
|
|
375
|
+
export async function handleDuplicateSheet(args) {
|
|
376
|
+
const accountManager = getAccountManager();
|
|
377
|
+
const rawArgs = args;
|
|
378
|
+
const spreadsheetId = readAliasedString(rawArgs, 'spreadsheet_id', 'spreadsheetId');
|
|
379
|
+
const sheetRef = readSheetRef(rawArgs);
|
|
380
|
+
// `new_title` (and `newTitle`, rewritten to it by the normalizer) name the copy too,
|
|
381
|
+
// so a model using either key gets its title instead of a silent "Copy of …".
|
|
382
|
+
const title = readAliasedString(rawArgs, 'title', 'new_title');
|
|
383
|
+
const position = typeof rawArgs.position === 'number' ? rawArgs.position : undefined;
|
|
384
|
+
const email = await resolveEmail(args);
|
|
385
|
+
return await accountManager.withTokenRenewal(email, async () => {
|
|
386
|
+
const result = await getSheetsService().duplicateSheet(email, {
|
|
387
|
+
spreadsheetId: spreadsheetId,
|
|
388
|
+
...sheetRef,
|
|
389
|
+
...(title !== undefined ? { title } : {}),
|
|
390
|
+
...(position !== undefined ? { position } : {}),
|
|
391
|
+
});
|
|
392
|
+
if (!result.success || !result.data) {
|
|
393
|
+
throw new McpError(ErrorCode.InternalError,
|
|
394
|
+
// Already enveloped by the service; the range-error rewriter would unwrap it.
|
|
395
|
+
result.error || 'Failed to duplicate sheet');
|
|
396
|
+
}
|
|
397
|
+
return formatSheetDuplicatedAsText(result.data);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Rename and/or reorder a sheet (tab)
|
|
402
|
+
*/
|
|
403
|
+
export async function handleUpdateSheet(args) {
|
|
404
|
+
const accountManager = getAccountManager();
|
|
405
|
+
const rawArgs = args;
|
|
406
|
+
const spreadsheetId = readAliasedString(rawArgs, 'spreadsheet_id', 'spreadsheetId');
|
|
407
|
+
const sheetRef = readSheetRef(rawArgs);
|
|
408
|
+
// `new_title` (and `newTitle`, rewritten to it by the normalizer) rename the sheet too, as on
|
|
409
|
+
// duplicate, so a model carrying that key over gets the rename instead of only the move.
|
|
410
|
+
const title = readAliasedString(rawArgs, 'title', 'new_title');
|
|
411
|
+
const position = typeof rawArgs.position === 'number' ? rawArgs.position : undefined;
|
|
412
|
+
const email = await resolveEmail(args);
|
|
413
|
+
return await accountManager.withTokenRenewal(email, async () => {
|
|
414
|
+
const result = await getSheetsService().updateSheet(email, {
|
|
415
|
+
spreadsheetId: spreadsheetId,
|
|
416
|
+
...sheetRef,
|
|
417
|
+
...(title !== undefined ? { title } : {}),
|
|
418
|
+
...(position !== undefined ? { position } : {}),
|
|
419
|
+
});
|
|
420
|
+
if (!result.success || !result.data) {
|
|
421
|
+
throw new McpError(ErrorCode.InternalError,
|
|
422
|
+
// Already enveloped by the service; the range-error rewriter would unwrap it.
|
|
423
|
+
result.error || 'Failed to update sheet');
|
|
424
|
+
}
|
|
425
|
+
return formatSheetUpdatedAsText(result.data);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Insert empty rows or columns into a sheet
|
|
430
|
+
*/
|
|
431
|
+
export async function handleInsertDimension(args) {
|
|
432
|
+
const accountManager = getAccountManager();
|
|
433
|
+
const rawArgs = args;
|
|
434
|
+
const spreadsheetId = readAliasedString(rawArgs, 'spreadsheet_id', 'spreadsheetId');
|
|
435
|
+
const sheetRef = readSheetRef(rawArgs);
|
|
436
|
+
const startIndex = readAliasedNumber(rawArgs, 'start_index', 'startIndex');
|
|
437
|
+
const count = typeof rawArgs.count === 'number' ? rawArgs.count : undefined;
|
|
438
|
+
const inheritFrom = readAliasedValue(rawArgs, 'inherit_from', 'inheritFrom');
|
|
439
|
+
const email = await resolveEmail(args);
|
|
440
|
+
return await accountManager.withTokenRenewal(email, async () => {
|
|
441
|
+
const result = await getSheetsService().insertDimension(email, {
|
|
442
|
+
spreadsheetId: spreadsheetId,
|
|
443
|
+
...sheetRef,
|
|
444
|
+
dimension: args.dimension,
|
|
445
|
+
startIndex: startIndex,
|
|
446
|
+
...(count !== undefined ? { count } : {}),
|
|
447
|
+
...(inheritFrom !== undefined ? { inheritFrom } : {}),
|
|
448
|
+
});
|
|
449
|
+
if (!result.success || !result.data) {
|
|
450
|
+
throw new McpError(ErrorCode.InternalError,
|
|
451
|
+
// Already enveloped by the service; the range-error rewriter would unwrap it.
|
|
452
|
+
result.error || 'Failed to insert rows or columns');
|
|
453
|
+
}
|
|
454
|
+
return formatDimensionInsertedAsText(result.data);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
365
457
|
/**
|
|
366
458
|
* Extract spreadsheet ID from URL or validate existing ID
|
|
367
459
|
*/
|
|
@@ -418,7 +510,7 @@ export async function handleBatchGetValues(args) {
|
|
|
418
510
|
output += formatAnchorReadResponse(rangeData.anchor);
|
|
419
511
|
}
|
|
420
512
|
else {
|
|
421
|
-
output += formatShapedReadResponse(rangeData.shaped);
|
|
513
|
+
output += formatShapedReadResponse(rangeData.shaped, { majorDimension });
|
|
422
514
|
}
|
|
423
515
|
}
|
|
424
516
|
return output;
|
|
@@ -432,7 +524,9 @@ export async function handleBatchGetValues(args) {
|
|
|
432
524
|
output += formatAnchorReadResponse(rangeData.anchor);
|
|
433
525
|
}
|
|
434
526
|
else {
|
|
435
|
-
output += formatValuesAsTable(rangeData.values
|
|
527
|
+
output += formatValuesAsTable(rangeData.values, {
|
|
528
|
+
firstRowNumber: firstSheetRowNumber(rangeData.range, majorDimension),
|
|
529
|
+
});
|
|
436
530
|
}
|
|
437
531
|
}
|
|
438
532
|
return output;
|
|
@@ -85,6 +85,8 @@ interface ReadDocumentArgs {
|
|
|
85
85
|
documentId: string;
|
|
86
86
|
maxChars?: number;
|
|
87
87
|
returnJson?: boolean;
|
|
88
|
+
tabId?: string;
|
|
89
|
+
allTabs?: boolean;
|
|
88
90
|
}
|
|
89
91
|
interface CreateDocumentArgs {
|
|
90
92
|
email: string;
|
|
@@ -95,11 +97,13 @@ interface AppendDocumentArgs {
|
|
|
95
97
|
email: string;
|
|
96
98
|
documentId: string;
|
|
97
99
|
text: string;
|
|
100
|
+
tabId?: string;
|
|
98
101
|
}
|
|
99
102
|
interface ReplaceDocumentArgs {
|
|
100
103
|
email: string;
|
|
101
104
|
documentId: string;
|
|
102
105
|
content: string;
|
|
106
|
+
tabId?: string;
|
|
103
107
|
}
|
|
104
108
|
interface FindReplaceArgs {
|
|
105
109
|
email: string;
|
|
@@ -107,6 +111,7 @@ interface FindReplaceArgs {
|
|
|
107
111
|
findText: string;
|
|
108
112
|
replaceText: string;
|
|
109
113
|
matchCase?: boolean;
|
|
114
|
+
tabId?: string;
|
|
110
115
|
}
|
|
111
116
|
interface ExtractIdArgs {
|
|
112
117
|
input: string;
|
|
@@ -115,6 +120,7 @@ interface ListTabsArgs {
|
|
|
115
120
|
email: string;
|
|
116
121
|
documentId: string;
|
|
117
122
|
includeWordCount?: boolean;
|
|
123
|
+
returnJson?: boolean;
|
|
118
124
|
}
|
|
119
125
|
export declare function isReadDocumentArgs(args: unknown): args is ReadDocumentArgs;
|
|
120
126
|
export declare function assertReadDocumentArgs(args: unknown): asserts args is ReadDocumentArgs;
|
|
@@ -130,6 +136,57 @@ export declare function isExtractIdArgs(args: unknown): args is ExtractIdArgs;
|
|
|
130
136
|
export declare function assertExtractIdArgs(args: unknown): asserts args is ExtractIdArgs;
|
|
131
137
|
export declare function isListTabsArgs(args: unknown): args is ListTabsArgs;
|
|
132
138
|
export declare function assertListTabsArgs(args: unknown): asserts args is ListTabsArgs;
|
|
139
|
+
interface AddDocumentTabArgs {
|
|
140
|
+
email?: string;
|
|
141
|
+
documentId: string;
|
|
142
|
+
title: string;
|
|
143
|
+
parentTabId?: string;
|
|
144
|
+
position?: number;
|
|
145
|
+
}
|
|
146
|
+
interface UpdateDocumentTabArgs {
|
|
147
|
+
email?: string;
|
|
148
|
+
documentId: string;
|
|
149
|
+
tabId: string;
|
|
150
|
+
title?: string;
|
|
151
|
+
parentTabId?: string;
|
|
152
|
+
position?: number;
|
|
153
|
+
}
|
|
154
|
+
interface DeleteDocumentTabArgs {
|
|
155
|
+
email?: string;
|
|
156
|
+
documentId: string;
|
|
157
|
+
tabId: string;
|
|
158
|
+
deleteSubTabs?: boolean;
|
|
159
|
+
}
|
|
160
|
+
interface InsertDocumentTextArgs {
|
|
161
|
+
email?: string;
|
|
162
|
+
documentId: string;
|
|
163
|
+
tabId?: string;
|
|
164
|
+
anchorText: string;
|
|
165
|
+
position?: string;
|
|
166
|
+
text: string;
|
|
167
|
+
matchCase?: boolean;
|
|
168
|
+
expectEmptyParagraph?: boolean;
|
|
169
|
+
}
|
|
170
|
+
export declare function isAddDocumentTabArgs(args: unknown): args is AddDocumentTabArgs;
|
|
171
|
+
export declare function assertAddDocumentTabArgs(args: unknown): asserts args is AddDocumentTabArgs;
|
|
172
|
+
export declare function isUpdateDocumentTabArgs(args: unknown): args is UpdateDocumentTabArgs;
|
|
173
|
+
export declare function assertUpdateDocumentTabArgs(args: unknown): asserts args is UpdateDocumentTabArgs;
|
|
174
|
+
export declare function isDeleteDocumentTabArgs(args: unknown): args is DeleteDocumentTabArgs;
|
|
175
|
+
export declare function assertDeleteDocumentTabArgs(args: unknown): asserts args is DeleteDocumentTabArgs;
|
|
176
|
+
export declare function isInsertDocumentTextArgs(args: unknown): args is InsertDocumentTextArgs;
|
|
177
|
+
export declare function assertInsertDocumentTextArgs(args: unknown): asserts args is InsertDocumentTextArgs;
|
|
178
|
+
interface CopyDocumentTabArgs {
|
|
179
|
+
email?: string;
|
|
180
|
+
documentId: string;
|
|
181
|
+
sourceTabId: string;
|
|
182
|
+
targetTabId?: string;
|
|
183
|
+
overwriteExisting?: boolean;
|
|
184
|
+
newTabTitle?: string;
|
|
185
|
+
newTabParentId?: string;
|
|
186
|
+
newTabPosition?: number;
|
|
187
|
+
}
|
|
188
|
+
export declare function isCopyDocumentTabArgs(args: unknown): args is CopyDocumentTabArgs;
|
|
189
|
+
export declare function assertCopyDocumentTabArgs(args: unknown): asserts args is CopyDocumentTabArgs;
|
|
133
190
|
interface BatchUpdateDocumentArgs {
|
|
134
191
|
email: string;
|
|
135
192
|
documentId: string;
|
|
@@ -269,6 +326,38 @@ export declare function isAddSpreadsheetSheetArgs(args: unknown): args is AddSpr
|
|
|
269
326
|
export declare function assertAddSpreadsheetSheetArgs(args: unknown): asserts args is AddSpreadsheetSheetArgs;
|
|
270
327
|
export declare function isDeleteSpreadsheetSheetArgs(args: unknown): args is DeleteSpreadsheetSheetArgs;
|
|
271
328
|
export declare function assertDeleteSpreadsheetSheetArgs(args: unknown): asserts args is DeleteSpreadsheetSheetArgs;
|
|
329
|
+
interface DuplicateSpreadsheetSheetArgs {
|
|
330
|
+
email?: string;
|
|
331
|
+
spreadsheetId: string;
|
|
332
|
+
sheetId?: number;
|
|
333
|
+
sheetTitle?: string;
|
|
334
|
+
title?: string;
|
|
335
|
+
position?: number;
|
|
336
|
+
}
|
|
337
|
+
interface UpdateSpreadsheetSheetArgs {
|
|
338
|
+
email?: string;
|
|
339
|
+
spreadsheetId: string;
|
|
340
|
+
sheetId?: number;
|
|
341
|
+
sheetTitle?: string;
|
|
342
|
+
title?: string;
|
|
343
|
+
position?: number;
|
|
344
|
+
}
|
|
345
|
+
interface InsertSpreadsheetDimensionArgs {
|
|
346
|
+
email?: string;
|
|
347
|
+
spreadsheetId: string;
|
|
348
|
+
sheetId?: number;
|
|
349
|
+
sheetTitle?: string;
|
|
350
|
+
dimension: 'ROWS' | 'COLUMNS';
|
|
351
|
+
startIndex: number;
|
|
352
|
+
count?: number;
|
|
353
|
+
inheritFrom?: 'before' | 'after';
|
|
354
|
+
}
|
|
355
|
+
export declare function isDuplicateSpreadsheetSheetArgs(args: unknown): args is DuplicateSpreadsheetSheetArgs;
|
|
356
|
+
export declare function assertDuplicateSpreadsheetSheetArgs(args: unknown): asserts args is DuplicateSpreadsheetSheetArgs;
|
|
357
|
+
export declare function isUpdateSpreadsheetSheetArgs(args: unknown): args is UpdateSpreadsheetSheetArgs;
|
|
358
|
+
export declare function assertUpdateSpreadsheetSheetArgs(args: unknown): asserts args is UpdateSpreadsheetSheetArgs;
|
|
359
|
+
export declare function isInsertSpreadsheetDimensionArgs(args: unknown): args is InsertSpreadsheetDimensionArgs;
|
|
360
|
+
export declare function assertInsertSpreadsheetDimensionArgs(args: unknown): asserts args is InsertSpreadsheetDimensionArgs;
|
|
272
361
|
export declare function isExtractSpreadsheetIdArgs(args: unknown): args is ExtractSpreadsheetIdArgs;
|
|
273
362
|
export declare function assertExtractSpreadsheetIdArgs(args: unknown): asserts args is ExtractSpreadsheetIdArgs;
|
|
274
363
|
interface BatchGetSpreadsheetValuesArgs {
|
|
@@ -125,7 +125,7 @@ export function isDriveFileListArgs(args) {
|
|
|
125
125
|
return (opts.folderId === undefined || typeof opts.folderId === 'string') &&
|
|
126
126
|
(opts.query === undefined || typeof opts.query === 'string') &&
|
|
127
127
|
(opts.pageSize === undefined || typeof opts.pageSize === 'number') &&
|
|
128
|
-
(opts.orderBy === undefined || (Array.isArray(opts.orderBy) && opts.orderBy.every((o) => typeof o === 'string'))) &&
|
|
128
|
+
(opts.orderBy === undefined || typeof opts.orderBy === 'string' || (Array.isArray(opts.orderBy) && opts.orderBy.every((o) => typeof o === 'string'))) &&
|
|
129
129
|
(opts.fields === undefined || (Array.isArray(opts.fields) && opts.fields.every((f) => typeof f === 'string'))) &&
|
|
130
130
|
(opts.driveId === undefined || typeof opts.driveId === 'string') &&
|
|
131
131
|
isValidCorpora(opts.corpora);
|
|
@@ -479,10 +479,14 @@ export function isReadDocumentArgs(args) {
|
|
|
479
479
|
const documentId = readAliasedArg(rawParams, 'document_id', 'documentId');
|
|
480
480
|
const maxChars = readAliasedArg(rawParams, 'max_chars', 'maxChars');
|
|
481
481
|
const returnJson = readAliasedArg(rawParams, 'return_json', 'returnJson');
|
|
482
|
+
const tabId = readAliasedArg(rawParams, 'tab_id', 'tabId');
|
|
483
|
+
const allTabs = readAliasedArg(rawParams, 'all_tabs', 'allTabs');
|
|
482
484
|
return (params.email === undefined || typeof params.email === 'string') &&
|
|
483
485
|
typeof documentId === 'string' &&
|
|
484
486
|
(maxChars === undefined || typeof maxChars === 'number') &&
|
|
485
|
-
(returnJson === undefined || typeof returnJson === 'boolean')
|
|
487
|
+
(returnJson === undefined || typeof returnJson === 'boolean') &&
|
|
488
|
+
(tabId === undefined || typeof tabId === 'string') &&
|
|
489
|
+
(allTabs === undefined || typeof allTabs === 'boolean');
|
|
486
490
|
}
|
|
487
491
|
export function assertReadDocumentArgs(args) {
|
|
488
492
|
if (!isReadDocumentArgs(args)) {
|
|
@@ -507,9 +511,11 @@ export function isAppendDocumentArgs(args) {
|
|
|
507
511
|
return false;
|
|
508
512
|
const params = args;
|
|
509
513
|
const documentId = readAliasedArg(args, 'document_id', 'documentId');
|
|
514
|
+
const tabId = readAliasedArg(args, 'tab_id', 'tabId');
|
|
510
515
|
return (params.email === undefined || typeof params.email === 'string') &&
|
|
511
516
|
typeof documentId === 'string' &&
|
|
512
|
-
typeof params.text === 'string'
|
|
517
|
+
typeof params.text === 'string' &&
|
|
518
|
+
(tabId === undefined || typeof tabId === 'string');
|
|
513
519
|
}
|
|
514
520
|
export function assertAppendDocumentArgs(args) {
|
|
515
521
|
if (!isAppendDocumentArgs(args)) {
|
|
@@ -521,9 +527,11 @@ export function isReplaceDocumentArgs(args) {
|
|
|
521
527
|
return false;
|
|
522
528
|
const params = args;
|
|
523
529
|
const documentId = readAliasedArg(args, 'document_id', 'documentId');
|
|
530
|
+
const tabId = readAliasedArg(args, 'tab_id', 'tabId');
|
|
524
531
|
return (params.email === undefined || typeof params.email === 'string') &&
|
|
525
532
|
typeof documentId === 'string' &&
|
|
526
|
-
typeof params.content === 'string'
|
|
533
|
+
typeof params.content === 'string' &&
|
|
534
|
+
(tabId === undefined || typeof tabId === 'string');
|
|
527
535
|
}
|
|
528
536
|
export function assertReplaceDocumentArgs(args) {
|
|
529
537
|
if (!isReplaceDocumentArgs(args)) {
|
|
@@ -539,11 +547,13 @@ export function isFindReplaceArgs(args) {
|
|
|
539
547
|
const findText = readAliasedArg(rawParams, 'find_text', 'findText');
|
|
540
548
|
const replaceText = readAliasedArg(rawParams, 'replace_text', 'replaceText');
|
|
541
549
|
const matchCase = readAliasedArg(rawParams, 'match_case', 'matchCase');
|
|
550
|
+
const tabId = readAliasedArg(rawParams, 'tab_id', 'tabId');
|
|
542
551
|
return (params.email === undefined || typeof params.email === 'string') &&
|
|
543
552
|
typeof documentId === 'string' &&
|
|
544
553
|
typeof findText === 'string' &&
|
|
545
554
|
typeof replaceText === 'string' &&
|
|
546
|
-
(matchCase === undefined || typeof matchCase === 'boolean')
|
|
555
|
+
(matchCase === undefined || typeof matchCase === 'boolean') &&
|
|
556
|
+
(tabId === undefined || typeof tabId === 'string');
|
|
547
557
|
}
|
|
548
558
|
export function assertFindReplaceArgs(args) {
|
|
549
559
|
if (!isFindReplaceArgs(args)) {
|
|
@@ -568,15 +578,123 @@ export function isListTabsArgs(args) {
|
|
|
568
578
|
const rawParams = args;
|
|
569
579
|
const documentId = readAliasedArg(rawParams, 'document_id', 'documentId');
|
|
570
580
|
const includeWordCount = readAliasedArg(rawParams, 'include_word_count', 'includeWordCount');
|
|
581
|
+
const returnJson = readAliasedArg(rawParams, 'return_json', 'returnJson');
|
|
571
582
|
return (params.email === undefined || typeof params.email === 'string') &&
|
|
572
583
|
typeof documentId === 'string' &&
|
|
573
|
-
(includeWordCount === undefined || typeof includeWordCount === 'boolean')
|
|
584
|
+
(includeWordCount === undefined || typeof includeWordCount === 'boolean') &&
|
|
585
|
+
(returnJson === undefined || typeof returnJson === 'boolean');
|
|
574
586
|
}
|
|
575
587
|
export function assertListTabsArgs(args) {
|
|
576
588
|
if (!isListTabsArgs(args)) {
|
|
577
589
|
throw new Error('Invalid list tabs parameters. Required: email, document_id');
|
|
578
590
|
}
|
|
579
591
|
}
|
|
592
|
+
function isOptional(value, type) {
|
|
593
|
+
return value === undefined || typeof value === type;
|
|
594
|
+
}
|
|
595
|
+
export function isAddDocumentTabArgs(args) {
|
|
596
|
+
if (typeof args !== 'object' || args === null)
|
|
597
|
+
return false;
|
|
598
|
+
const rawParams = args;
|
|
599
|
+
const documentId = readAliasedArg(rawParams, 'document_id', 'documentId');
|
|
600
|
+
const parentTabId = readAliasedArg(rawParams, 'parent_tab_id', 'parentTabId');
|
|
601
|
+
return isOptional(rawParams.email, 'string') &&
|
|
602
|
+
typeof documentId === 'string' &&
|
|
603
|
+
typeof rawParams.title === 'string' &&
|
|
604
|
+
isOptional(parentTabId, 'string') &&
|
|
605
|
+
isOptional(rawParams.position, 'number');
|
|
606
|
+
}
|
|
607
|
+
export function assertAddDocumentTabArgs(args) {
|
|
608
|
+
if (!isAddDocumentTabArgs(args)) {
|
|
609
|
+
throw new Error('Invalid add document tab parameters. Required: document_id, title. Optional: parent_tab_id (string), position (number)');
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
export function isUpdateDocumentTabArgs(args) {
|
|
613
|
+
if (typeof args !== 'object' || args === null)
|
|
614
|
+
return false;
|
|
615
|
+
const rawParams = args;
|
|
616
|
+
const documentId = readAliasedArg(rawParams, 'document_id', 'documentId');
|
|
617
|
+
const tabId = readAliasedArg(rawParams, 'tab_id', 'tabId');
|
|
618
|
+
const parentTabId = readAliasedArg(rawParams, 'parent_tab_id', 'parentTabId');
|
|
619
|
+
return isOptional(rawParams.email, 'string') &&
|
|
620
|
+
typeof documentId === 'string' &&
|
|
621
|
+
typeof tabId === 'string' &&
|
|
622
|
+
isOptional(rawParams.title, 'string') &&
|
|
623
|
+
isOptional(parentTabId, 'string') &&
|
|
624
|
+
isOptional(rawParams.position, 'number');
|
|
625
|
+
}
|
|
626
|
+
export function assertUpdateDocumentTabArgs(args) {
|
|
627
|
+
if (!isUpdateDocumentTabArgs(args)) {
|
|
628
|
+
throw new Error('Invalid update document tab parameters. Required: document_id, tab_id. Optional: title (string), parent_tab_id (string), position (number)');
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
export function isDeleteDocumentTabArgs(args) {
|
|
632
|
+
if (typeof args !== 'object' || args === null)
|
|
633
|
+
return false;
|
|
634
|
+
const rawParams = args;
|
|
635
|
+
const documentId = readAliasedArg(rawParams, 'document_id', 'documentId');
|
|
636
|
+
const tabId = readAliasedArg(rawParams, 'tab_id', 'tabId');
|
|
637
|
+
const deleteSubTabs = readAliasedArg(rawParams, 'delete_sub_tabs', 'deleteSubTabs');
|
|
638
|
+
return isOptional(rawParams.email, 'string') &&
|
|
639
|
+
typeof documentId === 'string' &&
|
|
640
|
+
typeof tabId === 'string' &&
|
|
641
|
+
isOptional(deleteSubTabs, 'boolean');
|
|
642
|
+
}
|
|
643
|
+
export function assertDeleteDocumentTabArgs(args) {
|
|
644
|
+
if (!isDeleteDocumentTabArgs(args)) {
|
|
645
|
+
throw new Error('Invalid delete document tab parameters. Required: document_id, tab_id. Optional: delete_sub_tabs (boolean)');
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
export function isInsertDocumentTextArgs(args) {
|
|
649
|
+
if (typeof args !== 'object' || args === null)
|
|
650
|
+
return false;
|
|
651
|
+
const rawParams = args;
|
|
652
|
+
const documentId = readAliasedArg(rawParams, 'document_id', 'documentId');
|
|
653
|
+
const tabId = readAliasedArg(rawParams, 'tab_id', 'tabId');
|
|
654
|
+
const anchorText = readAliasedArg(rawParams, 'anchor_text', 'anchorText');
|
|
655
|
+
const matchCase = readAliasedArg(rawParams, 'match_case', 'matchCase');
|
|
656
|
+
const expectEmptyParagraph = readAliasedArg(rawParams, 'expect_empty_paragraph', 'expectEmptyParagraph');
|
|
657
|
+
return isOptional(rawParams.email, 'string') &&
|
|
658
|
+
typeof documentId === 'string' &&
|
|
659
|
+
isOptional(tabId, 'string') &&
|
|
660
|
+
typeof anchorText === 'string' &&
|
|
661
|
+
// Allowed values are checked by the service, which names them in its error.
|
|
662
|
+
isOptional(rawParams.position, 'string') &&
|
|
663
|
+
typeof rawParams.text === 'string' &&
|
|
664
|
+
isOptional(matchCase, 'boolean') &&
|
|
665
|
+
isOptional(expectEmptyParagraph, 'boolean');
|
|
666
|
+
}
|
|
667
|
+
export function assertInsertDocumentTextArgs(args) {
|
|
668
|
+
if (!isInsertDocumentTextArgs(args)) {
|
|
669
|
+
throw new Error('Invalid insert document text parameters. Required: document_id, anchor_text, text. Optional: tab_id (string), position ("after" | "before" | "next_paragraph_start"), match_case (boolean), expect_empty_paragraph (boolean)');
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
export function isCopyDocumentTabArgs(args) {
|
|
673
|
+
if (typeof args !== 'object' || args === null)
|
|
674
|
+
return false;
|
|
675
|
+
const rawParams = args;
|
|
676
|
+
const documentId = readAliasedArg(rawParams, 'document_id', 'documentId');
|
|
677
|
+
const sourceTabId = readAliasedArg(rawParams, 'source_tab_id', 'sourceTabId');
|
|
678
|
+
const targetTabId = readAliasedArg(rawParams, 'target_tab_id', 'targetTabId');
|
|
679
|
+
const overwriteExisting = readAliasedArg(rawParams, 'overwrite_existing', 'overwriteExisting');
|
|
680
|
+
const newTabTitle = readAliasedArg(rawParams, 'new_tab_title', 'newTabTitle');
|
|
681
|
+
const newTabParentId = readAliasedArg(rawParams, 'new_tab_parent_id', 'newTabParentId');
|
|
682
|
+
const newTabPosition = readAliasedArg(rawParams, 'new_tab_position', 'newTabPosition');
|
|
683
|
+
// Which target arguments may be combined is checked by the service, which explains it.
|
|
684
|
+
return isOptional(rawParams.email, 'string') &&
|
|
685
|
+
typeof documentId === 'string' &&
|
|
686
|
+
typeof sourceTabId === 'string' &&
|
|
687
|
+
isOptional(targetTabId, 'string') &&
|
|
688
|
+
isOptional(overwriteExisting, 'boolean') &&
|
|
689
|
+
isOptional(newTabTitle, 'string') &&
|
|
690
|
+
isOptional(newTabParentId, 'string') &&
|
|
691
|
+
isOptional(newTabPosition, 'number');
|
|
692
|
+
}
|
|
693
|
+
export function assertCopyDocumentTabArgs(args) {
|
|
694
|
+
if (!isCopyDocumentTabArgs(args)) {
|
|
695
|
+
throw new Error('Invalid copy document tab parameters. Required: document_id, source_tab_id, and either target_tab_id (with overwrite_existing: true) or new_tab_title. Optional with new_tab_title: new_tab_parent_id (string), new_tab_position (number)');
|
|
696
|
+
}
|
|
697
|
+
}
|
|
580
698
|
export function isBatchUpdateDocumentArgs(args) {
|
|
581
699
|
if (typeof args !== 'object' || args === null)
|
|
582
700
|
return false;
|
|
@@ -862,6 +980,72 @@ export function assertDeleteSpreadsheetSheetArgs(args) {
|
|
|
862
980
|
throw new Error('Invalid delete spreadsheet sheet parameters. Required: email, spreadsheet_id, sheet_id');
|
|
863
981
|
}
|
|
864
982
|
}
|
|
983
|
+
export function isDuplicateSpreadsheetSheetArgs(args) {
|
|
984
|
+
if (typeof args !== 'object' || args === null)
|
|
985
|
+
return false;
|
|
986
|
+
const rawParams = args;
|
|
987
|
+
const spreadsheetId = readAliasedArg(rawParams, 'spreadsheet_id', 'spreadsheetId');
|
|
988
|
+
const sheetId = readAliasedArg(rawParams, 'sheet_id', 'sheetId');
|
|
989
|
+
const sheetTitle = readAliasedArg(rawParams, 'sheet_title', 'sheetTitle');
|
|
990
|
+
return isOptional(rawParams.email, 'string') &&
|
|
991
|
+
typeof spreadsheetId === 'string' &&
|
|
992
|
+
isOptional(sheetId, 'number') &&
|
|
993
|
+
isOptional(sheetTitle, 'string') &&
|
|
994
|
+
(sheetId !== undefined || sheetTitle !== undefined) &&
|
|
995
|
+
isOptional(rawParams.title, 'string') &&
|
|
996
|
+
isOptional(rawParams.new_title, 'string') &&
|
|
997
|
+
isOptional(rawParams.position, 'number');
|
|
998
|
+
}
|
|
999
|
+
export function assertDuplicateSpreadsheetSheetArgs(args) {
|
|
1000
|
+
if (!isDuplicateSpreadsheetSheetArgs(args)) {
|
|
1001
|
+
throw new Error('Invalid duplicate spreadsheet sheet parameters. Required: spreadsheet_id, sheet_id (number) or sheet_title (string). Optional: title (string), position (number)');
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
export function isUpdateSpreadsheetSheetArgs(args) {
|
|
1005
|
+
if (typeof args !== 'object' || args === null)
|
|
1006
|
+
return false;
|
|
1007
|
+
const rawParams = args;
|
|
1008
|
+
const spreadsheetId = readAliasedArg(rawParams, 'spreadsheet_id', 'spreadsheetId');
|
|
1009
|
+
const sheetId = readAliasedArg(rawParams, 'sheet_id', 'sheetId');
|
|
1010
|
+
const sheetTitle = readAliasedArg(rawParams, 'sheet_title', 'sheetTitle');
|
|
1011
|
+
return isOptional(rawParams.email, 'string') &&
|
|
1012
|
+
typeof spreadsheetId === 'string' &&
|
|
1013
|
+
isOptional(sheetId, 'number') &&
|
|
1014
|
+
isOptional(sheetTitle, 'string') &&
|
|
1015
|
+
(sheetId !== undefined || sheetTitle !== undefined) &&
|
|
1016
|
+
isOptional(rawParams.title, 'string') &&
|
|
1017
|
+
isOptional(rawParams.new_title, 'string') &&
|
|
1018
|
+
isOptional(rawParams.position, 'number');
|
|
1019
|
+
}
|
|
1020
|
+
export function assertUpdateSpreadsheetSheetArgs(args) {
|
|
1021
|
+
if (!isUpdateSpreadsheetSheetArgs(args)) {
|
|
1022
|
+
throw new Error('Invalid update spreadsheet sheet parameters. Required: spreadsheet_id, sheet_id (number) or sheet_title (string). Optional: title (string), position (number)');
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
export function isInsertSpreadsheetDimensionArgs(args) {
|
|
1026
|
+
if (typeof args !== 'object' || args === null)
|
|
1027
|
+
return false;
|
|
1028
|
+
const rawParams = args;
|
|
1029
|
+
const spreadsheetId = readAliasedArg(rawParams, 'spreadsheet_id', 'spreadsheetId');
|
|
1030
|
+
const sheetId = readAliasedArg(rawParams, 'sheet_id', 'sheetId');
|
|
1031
|
+
const sheetTitle = readAliasedArg(rawParams, 'sheet_title', 'sheetTitle');
|
|
1032
|
+
const startIndex = readAliasedArg(rawParams, 'start_index', 'startIndex');
|
|
1033
|
+
const inheritFrom = readAliasedArg(rawParams, 'inherit_from', 'inheritFrom');
|
|
1034
|
+
return isOptional(rawParams.email, 'string') &&
|
|
1035
|
+
typeof spreadsheetId === 'string' &&
|
|
1036
|
+
isOptional(sheetId, 'number') &&
|
|
1037
|
+
isOptional(sheetTitle, 'string') &&
|
|
1038
|
+
(sheetId !== undefined || sheetTitle !== undefined) &&
|
|
1039
|
+
(rawParams.dimension === 'ROWS' || rawParams.dimension === 'COLUMNS') &&
|
|
1040
|
+
typeof startIndex === 'number' &&
|
|
1041
|
+
isOptional(rawParams.count, 'number') &&
|
|
1042
|
+
(inheritFrom === undefined || inheritFrom === 'before' || inheritFrom === 'after');
|
|
1043
|
+
}
|
|
1044
|
+
export function assertInsertSpreadsheetDimensionArgs(args) {
|
|
1045
|
+
if (!isInsertSpreadsheetDimensionArgs(args)) {
|
|
1046
|
+
throw new Error('Invalid insert dimension parameters. Required: spreadsheet_id, sheet_id (number) or sheet_title (string), dimension ("ROWS" or "COLUMNS"), start_index (number). Optional: count (number), inherit_from ("before" or "after")');
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
865
1049
|
export function isExtractSpreadsheetIdArgs(args) {
|
|
866
1050
|
if (typeof args !== 'object' || args === null)
|
|
867
1051
|
return false;
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export interface DriveFileListArgs extends BaseToolArguments {
|
|
|
134
134
|
folderId?: string;
|
|
135
135
|
query?: string;
|
|
136
136
|
pageSize?: number;
|
|
137
|
-
orderBy?: string[];
|
|
137
|
+
orderBy?: string | string[];
|
|
138
138
|
fields?: string[];
|
|
139
139
|
driveId?: string;
|
|
140
140
|
corpora?: 'user' | 'drive' | 'allDrives';
|
package/dist/utils/apiError.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export declare function extractHttpStatus(error: unknown): number | undefined;
|
|
|
12
12
|
* to the user instead of collapsing to "Unknown error".
|
|
13
13
|
*/
|
|
14
14
|
export declare function describeApiError(error: unknown): string;
|
|
15
|
+
/**
|
|
16
|
+
* describeApiError with the error message wrapped as untrusted content (the
|
|
17
|
+
* HTTP status stays outside). Google's error text can quote request or
|
|
18
|
+
* document content, so results that reach the model carry it enveloped.
|
|
19
|
+
*/
|
|
20
|
+
export declare function describeApiErrorUntrusted(error: unknown, source: string): string;
|
|
15
21
|
/**
|
|
16
22
|
* Structural check for this connector's domain error classes (GmailError,
|
|
17
23
|
* CalendarError, ContactsError, GoogleServiceError). They all share a
|