@rnsk/toolkits 0.0.4 → 0.0.5
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.d.ts +3 -1
- package/dist/index.js +5 -1
- package/dist/toolkits/gmail/manifest.js +1 -1
- package/dist/toolkits/google-calendar/manifest.js +1 -6
- package/dist/toolkits/google-docs/icon.d.ts +5 -0
- package/dist/toolkits/google-docs/icon.js +6 -0
- package/dist/toolkits/google-docs/manifest.d.ts +3 -0
- package/dist/toolkits/google-docs/manifest.js +40 -0
- package/dist/toolkits/google-docs/tools/append-text.d.ts +30 -0
- package/dist/toolkits/google-docs/tools/append-text.js +48 -0
- package/dist/toolkits/google-docs/tools/copy-document.d.ts +27 -0
- package/dist/toolkits/google-docs/tools/copy-document.js +43 -0
- package/dist/toolkits/google-docs/tools/create-document.d.ts +26 -0
- package/dist/toolkits/google-docs/tools/create-document.js +39 -0
- package/dist/toolkits/google-docs/tools/delete-content.d.ts +28 -0
- package/dist/toolkits/google-docs/tools/delete-content.js +45 -0
- package/dist/toolkits/google-docs/tools/delete-document.d.ts +23 -0
- package/dist/toolkits/google-docs/tools/delete-document.js +30 -0
- package/dist/toolkits/google-docs/tools/get-document-text.d.ts +26 -0
- package/dist/toolkits/google-docs/tools/get-document-text.js +35 -0
- package/dist/toolkits/google-docs/tools/get-document.d.ts +5 -0
- package/dist/toolkits/google-docs/tools/get-document.js +29 -0
- package/dist/toolkits/google-docs/tools/index.d.ts +299 -0
- package/dist/toolkits/google-docs/tools/index.js +85 -0
- package/dist/toolkits/google-docs/tools/insert-text.d.ts +28 -0
- package/dist/toolkits/google-docs/tools/insert-text.js +39 -0
- package/dist/toolkits/google-docs/tools/list-documents.d.ts +21 -0
- package/dist/toolkits/google-docs/tools/list-documents.js +39 -0
- package/dist/toolkits/google-docs/tools/replace-text.d.ts +32 -0
- package/dist/toolkits/google-docs/tools/replace-text.js +48 -0
- package/dist/toolkits/google-docs/tools/utils.d.ts +12 -0
- package/dist/toolkits/google-docs/tools/utils.js +48 -0
- package/dist/toolkits/google-drive/icon.d.ts +5 -0
- package/dist/toolkits/google-drive/icon.js +6 -0
- package/dist/toolkits/google-drive/manifest.d.ts +3 -0
- package/dist/toolkits/google-drive/manifest.js +37 -0
- package/dist/toolkits/google-drive/tools/copy-file.d.ts +7 -0
- package/dist/toolkits/google-drive/tools/copy-file.js +41 -0
- package/dist/toolkits/google-drive/tools/create-folder.d.ts +6 -0
- package/dist/toolkits/google-drive/tools/create-folder.js +42 -0
- package/dist/toolkits/google-drive/tools/delete-file.d.ts +23 -0
- package/dist/toolkits/google-drive/tools/delete-file.js +30 -0
- package/dist/toolkits/google-drive/tools/download-file.d.ts +30 -0
- package/dist/toolkits/google-drive/tools/download-file.js +61 -0
- package/dist/toolkits/google-drive/tools/get-file.d.ts +5 -0
- package/dist/toolkits/google-drive/tools/get-file.js +31 -0
- package/dist/toolkits/google-drive/tools/index.d.ts +188 -0
- package/dist/toolkits/google-drive/tools/index.js +85 -0
- package/dist/toolkits/google-drive/tools/list-files.d.ts +21 -0
- package/dist/toolkits/google-drive/tools/list-files.js +42 -0
- package/dist/toolkits/google-drive/tools/move-file.d.ts +7 -0
- package/dist/toolkits/google-drive/tools/move-file.js +51 -0
- package/dist/toolkits/google-drive/tools/search-files.d.ts +21 -0
- package/dist/toolkits/google-drive/tools/search-files.js +36 -0
- package/dist/toolkits/google-drive/tools/update-file.d.ts +7 -0
- package/dist/toolkits/google-drive/tools/update-file.js +44 -0
- package/dist/toolkits/google-drive/tools/upload-file.d.ts +8 -0
- package/dist/toolkits/google-drive/tools/upload-file.js +58 -0
- package/dist/toolkits/google-sheets/manifest.js +1 -6
- package/package.json +17 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineToolkit, defineTool } from '../../core/define.js';
|
|
2
|
+
import { inferToolScope } from '../../core/scope.js';
|
|
3
|
+
import { GDRIVE_ICON } from './icon.js';
|
|
4
|
+
import { googleDriveTools } from './tools/index.js';
|
|
5
|
+
export default defineToolkit({
|
|
6
|
+
id: 'google-drive',
|
|
7
|
+
displayName: 'Google Drive',
|
|
8
|
+
shortDescription: 'List, search, upload, and manage files and folders in Google Drive.',
|
|
9
|
+
category: 'Document & File Management',
|
|
10
|
+
icon: GDRIVE_ICON,
|
|
11
|
+
auth: {
|
|
12
|
+
type: 'oauth2',
|
|
13
|
+
tokenField: 'googleDriveToken',
|
|
14
|
+
provider: {
|
|
15
|
+
slug: 'google-drive',
|
|
16
|
+
env: { clientId: 'GOOGLE_DRIVE_CLIENT_ID', clientSecret: 'GOOGLE_DRIVE_CLIENT_SECRET' },
|
|
17
|
+
authorizeUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
18
|
+
tokenUrl: 'https://oauth2.googleapis.com/token',
|
|
19
|
+
scopes: ['https://www.googleapis.com/auth/drive'],
|
|
20
|
+
exchangeStyle: 'form',
|
|
21
|
+
extraAuthParams: { access_type: 'offline', prompt: 'consent' },
|
|
22
|
+
connectDescription: 'Connect Google Drive to browse, upload, and manage files and folders.',
|
|
23
|
+
callbackPath: '/api/auth/google-drive/callback',
|
|
24
|
+
stateCookie: 'google_drive_oauth_state',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
allowedHosts: ['www.googleapis.com'],
|
|
28
|
+
tools: googleDriveTools.map((entry) => defineTool({
|
|
29
|
+
name: entry.name,
|
|
30
|
+
description: entry.description,
|
|
31
|
+
tool: entry.tool,
|
|
32
|
+
requiredAuth: entry.requiredAuth,
|
|
33
|
+
scope: entry.scope ?? inferToolScope(entry.name),
|
|
34
|
+
})),
|
|
35
|
+
meta: { since: '0.0.5' },
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const copyFile = tool({
|
|
5
|
+
description: 'Copy a file in Google Drive.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
fileId: z.string().describe('The ID of the file to copy'),
|
|
9
|
+
name: z.string().optional().describe('Name for the copy'),
|
|
10
|
+
parentId: z.string().optional().describe('Parent folder ID for the copy'),
|
|
11
|
+
}),
|
|
12
|
+
execute: async ({ googleDriveToken, fileId, name, parentId }) => {
|
|
13
|
+
try {
|
|
14
|
+
const metadata = {};
|
|
15
|
+
if (name)
|
|
16
|
+
metadata.name = name;
|
|
17
|
+
if (parentId)
|
|
18
|
+
metadata.parents = [parentId];
|
|
19
|
+
const response = await fetch(`https://www.googleapis.com/drive/v3/files/${fileId}/copy`, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${googleDriveToken}`,
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
},
|
|
25
|
+
body: JSON.stringify(metadata),
|
|
26
|
+
});
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
const error = await response.json();
|
|
29
|
+
return { error: 'Failed to copy file', details: error };
|
|
30
|
+
}
|
|
31
|
+
return await response.json();
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
error: 'Error copying file',
|
|
36
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=copy-file.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const createFolder = tool({
|
|
5
|
+
description: 'Create a new folder in Google Drive.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
name: z.string().describe('Name of the folder to create'),
|
|
9
|
+
parentId: z.string().optional().describe('Parent folder ID (defaults to root)'),
|
|
10
|
+
}),
|
|
11
|
+
execute: async ({ googleDriveToken, name, parentId }) => {
|
|
12
|
+
try {
|
|
13
|
+
const metadata = {
|
|
14
|
+
name,
|
|
15
|
+
mimeType: 'application/vnd.google-apps.folder',
|
|
16
|
+
};
|
|
17
|
+
if (parentId) {
|
|
18
|
+
metadata.parents = [parentId];
|
|
19
|
+
}
|
|
20
|
+
const response = await fetch('https://www.googleapis.com/drive/v3/files', {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: `Bearer ${googleDriveToken}`,
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify(metadata),
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const error = await response.json();
|
|
30
|
+
return { error: 'Failed to create folder', details: error };
|
|
31
|
+
}
|
|
32
|
+
return await response.json();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
error: 'Error creating folder',
|
|
37
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=create-folder.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const deleteFile: import("ai").Tool<{
|
|
2
|
+
googleDriveToken: string;
|
|
3
|
+
fileId: string;
|
|
4
|
+
}, {
|
|
5
|
+
error: string;
|
|
6
|
+
details: any;
|
|
7
|
+
success?: undefined;
|
|
8
|
+
fileId?: undefined;
|
|
9
|
+
message?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
success: boolean;
|
|
12
|
+
fileId: string;
|
|
13
|
+
error?: undefined;
|
|
14
|
+
details?: undefined;
|
|
15
|
+
message?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
error: string;
|
|
18
|
+
message: string;
|
|
19
|
+
details?: undefined;
|
|
20
|
+
success?: undefined;
|
|
21
|
+
fileId?: undefined;
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=delete-file.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const deleteFile = tool({
|
|
5
|
+
description: 'Delete a file or folder in Google Drive (moves to trash).',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
fileId: z.string().describe('The ID of the file or folder to delete'),
|
|
9
|
+
}),
|
|
10
|
+
execute: async ({ googleDriveToken, fileId }) => {
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch(`https://www.googleapis.com/drive/v3/files/${fileId}`, {
|
|
13
|
+
method: 'DELETE',
|
|
14
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
18
|
+
return { error: 'Failed to delete file', details: error };
|
|
19
|
+
}
|
|
20
|
+
return { success: true, fileId };
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return {
|
|
24
|
+
error: 'Error deleting file',
|
|
25
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=delete-file.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const downloadFile: import("ai").Tool<{
|
|
2
|
+
googleDriveToken: string;
|
|
3
|
+
fileId: string;
|
|
4
|
+
exportMimeType?: string | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
error: string;
|
|
7
|
+
details: any;
|
|
8
|
+
id?: undefined;
|
|
9
|
+
name?: undefined;
|
|
10
|
+
mimeType?: undefined;
|
|
11
|
+
content?: undefined;
|
|
12
|
+
message?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
id: any;
|
|
15
|
+
name: any;
|
|
16
|
+
mimeType: string;
|
|
17
|
+
content: string;
|
|
18
|
+
error?: undefined;
|
|
19
|
+
details?: undefined;
|
|
20
|
+
message?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
error: string;
|
|
23
|
+
message: string;
|
|
24
|
+
details?: undefined;
|
|
25
|
+
id?: undefined;
|
|
26
|
+
name?: undefined;
|
|
27
|
+
mimeType?: undefined;
|
|
28
|
+
content?: undefined;
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=download-file.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const GOOGLE_EXPORT_MIME = {
|
|
5
|
+
'application/vnd.google-apps.document': 'text/plain',
|
|
6
|
+
'application/vnd.google-apps.spreadsheet': 'text/csv',
|
|
7
|
+
'application/vnd.google-apps.presentation': 'text/plain',
|
|
8
|
+
};
|
|
9
|
+
export const downloadFile = tool({
|
|
10
|
+
description: 'Download file content from Google Drive. Google-native files are exported to a readable format.',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
13
|
+
fileId: z.string().describe('The ID of the file to download'),
|
|
14
|
+
exportMimeType: z.string().optional().describe('Export MIME type for Google-native files (auto-detected if omitted)'),
|
|
15
|
+
}),
|
|
16
|
+
execute: async ({ googleDriveToken, fileId, exportMimeType }) => {
|
|
17
|
+
try {
|
|
18
|
+
const metaUrl = new URL(`https://www.googleapis.com/drive/v3/files/${fileId}`);
|
|
19
|
+
metaUrl.searchParams.set('fields', 'id,name,mimeType');
|
|
20
|
+
const metaResponse = await fetch(metaUrl.toString(), {
|
|
21
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
22
|
+
});
|
|
23
|
+
if (!metaResponse.ok) {
|
|
24
|
+
const error = await metaResponse.json();
|
|
25
|
+
return { error: 'Failed to get file metadata', details: error };
|
|
26
|
+
}
|
|
27
|
+
const meta = await metaResponse.json();
|
|
28
|
+
const mimeType = meta.mimeType;
|
|
29
|
+
const isGoogleNative = mimeType?.startsWith('application/vnd.google-apps.');
|
|
30
|
+
let downloadUrl;
|
|
31
|
+
if (isGoogleNative) {
|
|
32
|
+
const exportType = exportMimeType ?? GOOGLE_EXPORT_MIME[mimeType] ?? 'text/plain';
|
|
33
|
+
downloadUrl = `https://www.googleapis.com/drive/v3/files/${fileId}/export?mimeType=${encodeURIComponent(exportType)}`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
downloadUrl = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
|
|
37
|
+
}
|
|
38
|
+
const response = await fetch(downloadUrl, {
|
|
39
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
40
|
+
});
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
const error = await response.text();
|
|
43
|
+
return { error: 'Failed to download file', details: error };
|
|
44
|
+
}
|
|
45
|
+
const content = await response.text();
|
|
46
|
+
return {
|
|
47
|
+
id: meta.id,
|
|
48
|
+
name: meta.name,
|
|
49
|
+
mimeType: isGoogleNative ? (exportMimeType ?? GOOGLE_EXPORT_MIME[mimeType] ?? 'text/plain') : mimeType,
|
|
50
|
+
content,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return {
|
|
55
|
+
error: 'Error downloading file',
|
|
56
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=download-file.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const getFile = tool({
|
|
5
|
+
description: 'Get metadata for a file or folder in Google Drive by ID.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
fileId: z.string().describe('The ID of the file or folder'),
|
|
9
|
+
}),
|
|
10
|
+
execute: async ({ googleDriveToken, fileId }) => {
|
|
11
|
+
try {
|
|
12
|
+
const url = new URL(`https://www.googleapis.com/drive/v3/files/${fileId}`);
|
|
13
|
+
url.searchParams.set('fields', 'id,name,mimeType,modifiedTime,createdTime,parents,webViewLink,description,size');
|
|
14
|
+
const response = await fetch(url.toString(), {
|
|
15
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
const error = await response.json();
|
|
19
|
+
return { error: 'Failed to get file', details: error };
|
|
20
|
+
}
|
|
21
|
+
return await response.json();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return {
|
|
25
|
+
error: 'Error getting file',
|
|
26
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=get-file.js.map
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { listFiles } from './list-files.js';
|
|
2
|
+
import { getFile } from './get-file.js';
|
|
3
|
+
import { searchFiles } from './search-files.js';
|
|
4
|
+
import { createFolder } from './create-folder.js';
|
|
5
|
+
import { uploadFile } from './upload-file.js';
|
|
6
|
+
import { downloadFile } from './download-file.js';
|
|
7
|
+
import { updateFile } from './update-file.js';
|
|
8
|
+
import { copyFile } from './copy-file.js';
|
|
9
|
+
import { moveFile } from './move-file.js';
|
|
10
|
+
import { deleteFile } from './delete-file.js';
|
|
11
|
+
export { listFiles, getFile, searchFiles, createFolder, uploadFile, downloadFile, updateFile, copyFile, moveFile, deleteFile, };
|
|
12
|
+
export declare const googleDriveTools: ({
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
tool: import("ai").Tool<{
|
|
16
|
+
pageSize: number;
|
|
17
|
+
googleDriveToken: string;
|
|
18
|
+
folderId?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
error: string;
|
|
21
|
+
details: any;
|
|
22
|
+
files?: undefined;
|
|
23
|
+
message?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
files: any;
|
|
26
|
+
error?: undefined;
|
|
27
|
+
details?: undefined;
|
|
28
|
+
message?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
error: string;
|
|
31
|
+
message: string;
|
|
32
|
+
details?: undefined;
|
|
33
|
+
files?: undefined;
|
|
34
|
+
}>;
|
|
35
|
+
requiredAuth: "googleDriveToken";
|
|
36
|
+
scope: "read";
|
|
37
|
+
} | {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
tool: import("ai").Tool<{
|
|
41
|
+
googleDriveToken: string;
|
|
42
|
+
fileId: string;
|
|
43
|
+
}, any>;
|
|
44
|
+
requiredAuth: "googleDriveToken";
|
|
45
|
+
scope: "read";
|
|
46
|
+
} | {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
tool: import("ai").Tool<{
|
|
50
|
+
q: string;
|
|
51
|
+
pageSize: number;
|
|
52
|
+
googleDriveToken: string;
|
|
53
|
+
}, {
|
|
54
|
+
error: string;
|
|
55
|
+
details: any;
|
|
56
|
+
files?: undefined;
|
|
57
|
+
message?: undefined;
|
|
58
|
+
} | {
|
|
59
|
+
files: any;
|
|
60
|
+
error?: undefined;
|
|
61
|
+
details?: undefined;
|
|
62
|
+
message?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
error: string;
|
|
65
|
+
message: string;
|
|
66
|
+
details?: undefined;
|
|
67
|
+
files?: undefined;
|
|
68
|
+
}>;
|
|
69
|
+
requiredAuth: "googleDriveToken";
|
|
70
|
+
scope: "read";
|
|
71
|
+
} | {
|
|
72
|
+
name: string;
|
|
73
|
+
description: string;
|
|
74
|
+
tool: import("ai").Tool<{
|
|
75
|
+
name: string;
|
|
76
|
+
googleDriveToken: string;
|
|
77
|
+
parentId?: string | undefined;
|
|
78
|
+
}, any>;
|
|
79
|
+
requiredAuth: "googleDriveToken";
|
|
80
|
+
scope: "write";
|
|
81
|
+
} | {
|
|
82
|
+
name: string;
|
|
83
|
+
description: string;
|
|
84
|
+
tool: import("ai").Tool<{
|
|
85
|
+
content: string;
|
|
86
|
+
name: string;
|
|
87
|
+
googleDriveToken: string;
|
|
88
|
+
mimeType: string;
|
|
89
|
+
parentId?: string | undefined;
|
|
90
|
+
}, any>;
|
|
91
|
+
requiredAuth: "googleDriveToken";
|
|
92
|
+
scope: "write";
|
|
93
|
+
} | {
|
|
94
|
+
name: string;
|
|
95
|
+
description: string;
|
|
96
|
+
tool: import("ai").Tool<{
|
|
97
|
+
googleDriveToken: string;
|
|
98
|
+
fileId: string;
|
|
99
|
+
exportMimeType?: string | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
error: string;
|
|
102
|
+
details: any;
|
|
103
|
+
id?: undefined;
|
|
104
|
+
name?: undefined;
|
|
105
|
+
mimeType?: undefined;
|
|
106
|
+
content?: undefined;
|
|
107
|
+
message?: undefined;
|
|
108
|
+
} | {
|
|
109
|
+
id: any;
|
|
110
|
+
name: any;
|
|
111
|
+
mimeType: string;
|
|
112
|
+
content: string;
|
|
113
|
+
error?: undefined;
|
|
114
|
+
details?: undefined;
|
|
115
|
+
message?: undefined;
|
|
116
|
+
} | {
|
|
117
|
+
error: string;
|
|
118
|
+
message: string;
|
|
119
|
+
details?: undefined;
|
|
120
|
+
id?: undefined;
|
|
121
|
+
name?: undefined;
|
|
122
|
+
mimeType?: undefined;
|
|
123
|
+
content?: undefined;
|
|
124
|
+
}>;
|
|
125
|
+
requiredAuth: "googleDriveToken";
|
|
126
|
+
scope: "read";
|
|
127
|
+
} | {
|
|
128
|
+
name: string;
|
|
129
|
+
description: string;
|
|
130
|
+
tool: import("ai").Tool<{
|
|
131
|
+
googleDriveToken: string;
|
|
132
|
+
fileId: string;
|
|
133
|
+
description?: string | undefined;
|
|
134
|
+
name?: string | undefined;
|
|
135
|
+
}, any>;
|
|
136
|
+
requiredAuth: "googleDriveToken";
|
|
137
|
+
scope: "write";
|
|
138
|
+
} | {
|
|
139
|
+
name: string;
|
|
140
|
+
description: string;
|
|
141
|
+
tool: import("ai").Tool<{
|
|
142
|
+
googleDriveToken: string;
|
|
143
|
+
fileId: string;
|
|
144
|
+
name?: string | undefined;
|
|
145
|
+
parentId?: string | undefined;
|
|
146
|
+
}, any>;
|
|
147
|
+
requiredAuth: "googleDriveToken";
|
|
148
|
+
scope: "write";
|
|
149
|
+
} | {
|
|
150
|
+
name: string;
|
|
151
|
+
description: string;
|
|
152
|
+
tool: import("ai").Tool<{
|
|
153
|
+
googleDriveToken: string;
|
|
154
|
+
fileId: string;
|
|
155
|
+
newParentId: string;
|
|
156
|
+
removeParentId?: string | undefined;
|
|
157
|
+
}, any>;
|
|
158
|
+
requiredAuth: "googleDriveToken";
|
|
159
|
+
scope: "write";
|
|
160
|
+
} | {
|
|
161
|
+
name: string;
|
|
162
|
+
description: string;
|
|
163
|
+
tool: import("ai").Tool<{
|
|
164
|
+
googleDriveToken: string;
|
|
165
|
+
fileId: string;
|
|
166
|
+
}, {
|
|
167
|
+
error: string;
|
|
168
|
+
details: any;
|
|
169
|
+
success?: undefined;
|
|
170
|
+
fileId?: undefined;
|
|
171
|
+
message?: undefined;
|
|
172
|
+
} | {
|
|
173
|
+
success: boolean;
|
|
174
|
+
fileId: string;
|
|
175
|
+
error?: undefined;
|
|
176
|
+
details?: undefined;
|
|
177
|
+
message?: undefined;
|
|
178
|
+
} | {
|
|
179
|
+
error: string;
|
|
180
|
+
message: string;
|
|
181
|
+
details?: undefined;
|
|
182
|
+
success?: undefined;
|
|
183
|
+
fileId?: undefined;
|
|
184
|
+
}>;
|
|
185
|
+
requiredAuth: "googleDriveToken";
|
|
186
|
+
scope: "delete";
|
|
187
|
+
})[];
|
|
188
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { listFiles } from './list-files.js';
|
|
3
|
+
import { getFile } from './get-file.js';
|
|
4
|
+
import { searchFiles } from './search-files.js';
|
|
5
|
+
import { createFolder } from './create-folder.js';
|
|
6
|
+
import { uploadFile } from './upload-file.js';
|
|
7
|
+
import { downloadFile } from './download-file.js';
|
|
8
|
+
import { updateFile } from './update-file.js';
|
|
9
|
+
import { copyFile } from './copy-file.js';
|
|
10
|
+
import { moveFile } from './move-file.js';
|
|
11
|
+
import { deleteFile } from './delete-file.js';
|
|
12
|
+
export { listFiles, getFile, searchFiles, createFolder, uploadFile, downloadFile, updateFile, copyFile, moveFile, deleteFile, };
|
|
13
|
+
export const googleDriveTools = [
|
|
14
|
+
{
|
|
15
|
+
name: 'googleDriveListFiles',
|
|
16
|
+
description: 'List files and folders in Google Drive.',
|
|
17
|
+
tool: listFiles,
|
|
18
|
+
requiredAuth: 'googleDriveToken',
|
|
19
|
+
scope: 'read',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'googleDriveGetFile',
|
|
23
|
+
description: 'Get metadata for a file or folder in Google Drive by ID.',
|
|
24
|
+
tool: getFile,
|
|
25
|
+
requiredAuth: 'googleDriveToken',
|
|
26
|
+
scope: 'read',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'googleDriveSearchFiles',
|
|
30
|
+
description: 'Search for files and folders in Google Drive using a Drive query.',
|
|
31
|
+
tool: searchFiles,
|
|
32
|
+
requiredAuth: 'googleDriveToken',
|
|
33
|
+
scope: 'read',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'googleDriveCreateFolder',
|
|
37
|
+
description: 'Create a new folder in Google Drive.',
|
|
38
|
+
tool: createFolder,
|
|
39
|
+
requiredAuth: 'googleDriveToken',
|
|
40
|
+
scope: 'write',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'googleDriveUploadFile',
|
|
44
|
+
description: 'Upload a file to Google Drive using multipart upload.',
|
|
45
|
+
tool: uploadFile,
|
|
46
|
+
requiredAuth: 'googleDriveToken',
|
|
47
|
+
scope: 'write',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'googleDriveDownloadFile',
|
|
51
|
+
description: 'Download file content from Google Drive.',
|
|
52
|
+
tool: downloadFile,
|
|
53
|
+
requiredAuth: 'googleDriveToken',
|
|
54
|
+
scope: 'read',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'googleDriveUpdateFile',
|
|
58
|
+
description: 'Update file metadata in Google Drive (rename, description).',
|
|
59
|
+
tool: updateFile,
|
|
60
|
+
requiredAuth: 'googleDriveToken',
|
|
61
|
+
scope: 'write',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'googleDriveCopyFile',
|
|
65
|
+
description: 'Copy a file in Google Drive.',
|
|
66
|
+
tool: copyFile,
|
|
67
|
+
requiredAuth: 'googleDriveToken',
|
|
68
|
+
scope: 'write',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'googleDriveMoveFile',
|
|
72
|
+
description: 'Move a file or folder to a different parent folder in Google Drive.',
|
|
73
|
+
tool: moveFile,
|
|
74
|
+
requiredAuth: 'googleDriveToken',
|
|
75
|
+
scope: 'write',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'googleDriveDeleteFile',
|
|
79
|
+
description: 'Delete a file or folder in Google Drive (moves to trash).',
|
|
80
|
+
tool: deleteFile,
|
|
81
|
+
requiredAuth: 'googleDriveToken',
|
|
82
|
+
scope: 'delete',
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const listFiles: import("ai").Tool<{
|
|
2
|
+
pageSize: number;
|
|
3
|
+
googleDriveToken: string;
|
|
4
|
+
folderId?: string | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
error: string;
|
|
7
|
+
details: any;
|
|
8
|
+
files?: undefined;
|
|
9
|
+
message?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
files: any;
|
|
12
|
+
error?: undefined;
|
|
13
|
+
details?: undefined;
|
|
14
|
+
message?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
error: string;
|
|
17
|
+
message: string;
|
|
18
|
+
details?: undefined;
|
|
19
|
+
files?: undefined;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=list-files.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const listFiles = tool({
|
|
5
|
+
description: 'List files and folders in Google Drive.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDriveToken: z.string().describe('The Google Drive access token'),
|
|
8
|
+
folderId: z.string().optional().describe('Parent folder ID to list children of (defaults to root)'),
|
|
9
|
+
pageSize: z.number().optional().default(20).describe('Maximum number of files to return'),
|
|
10
|
+
}),
|
|
11
|
+
execute: async ({ googleDriveToken, folderId, pageSize = 20 }) => {
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL('https://www.googleapis.com/drive/v3/files');
|
|
14
|
+
let query = 'trashed = false';
|
|
15
|
+
if (folderId) {
|
|
16
|
+
query += ` and '${folderId}' in parents`;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
query += " and 'root' in parents";
|
|
20
|
+
}
|
|
21
|
+
url.searchParams.set('q', query);
|
|
22
|
+
url.searchParams.set('pageSize', String(pageSize));
|
|
23
|
+
url.searchParams.set('fields', 'files(id,name,mimeType,modifiedTime,parents,webViewLink)');
|
|
24
|
+
const response = await fetch(url.toString(), {
|
|
25
|
+
headers: { Authorization: `Bearer ${googleDriveToken}` },
|
|
26
|
+
});
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
const error = await response.json();
|
|
29
|
+
return { error: 'Failed to list files', details: error };
|
|
30
|
+
}
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
return { files: data.files ?? [] };
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
error: 'Error listing files',
|
|
37
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=list-files.js.map
|