@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,299 @@
|
|
|
1
|
+
import { listDocuments } from './list-documents.js';
|
|
2
|
+
import { getDocument } from './get-document.js';
|
|
3
|
+
import { getDocumentText } from './get-document-text.js';
|
|
4
|
+
import { createDocument } from './create-document.js';
|
|
5
|
+
import { insertText } from './insert-text.js';
|
|
6
|
+
import { appendText } from './append-text.js';
|
|
7
|
+
import { replaceText } from './replace-text.js';
|
|
8
|
+
import { deleteContent } from './delete-content.js';
|
|
9
|
+
import { copyDocument } from './copy-document.js';
|
|
10
|
+
import { deleteDocument } from './delete-document.js';
|
|
11
|
+
export { listDocuments, getDocument, getDocumentText, createDocument, insertText, appendText, replaceText, deleteContent, copyDocument, deleteDocument, };
|
|
12
|
+
export declare const googleDocsTools: ({
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
tool: import("ai").Tool<{
|
|
16
|
+
pageSize: number;
|
|
17
|
+
googleDocsToken: string;
|
|
18
|
+
q?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
error: string;
|
|
21
|
+
details: any;
|
|
22
|
+
documents?: undefined;
|
|
23
|
+
message?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
documents: any;
|
|
26
|
+
error?: undefined;
|
|
27
|
+
details?: undefined;
|
|
28
|
+
message?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
error: string;
|
|
31
|
+
message: string;
|
|
32
|
+
details?: undefined;
|
|
33
|
+
documents?: undefined;
|
|
34
|
+
}>;
|
|
35
|
+
requiredAuth: "googleDocsToken";
|
|
36
|
+
scope: "read";
|
|
37
|
+
} | {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
tool: import("ai").Tool<{
|
|
41
|
+
googleDocsToken: string;
|
|
42
|
+
documentId: string;
|
|
43
|
+
}, any>;
|
|
44
|
+
requiredAuth: "googleDocsToken";
|
|
45
|
+
scope: "read";
|
|
46
|
+
} | {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
tool: import("ai").Tool<{
|
|
50
|
+
googleDocsToken: string;
|
|
51
|
+
documentId: string;
|
|
52
|
+
}, {
|
|
53
|
+
error: string;
|
|
54
|
+
details: any;
|
|
55
|
+
documentId?: undefined;
|
|
56
|
+
title?: undefined;
|
|
57
|
+
text?: undefined;
|
|
58
|
+
message?: undefined;
|
|
59
|
+
} | {
|
|
60
|
+
documentId: any;
|
|
61
|
+
title: any;
|
|
62
|
+
text: string;
|
|
63
|
+
error?: undefined;
|
|
64
|
+
details?: undefined;
|
|
65
|
+
message?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
error: string;
|
|
68
|
+
message: string;
|
|
69
|
+
details?: undefined;
|
|
70
|
+
documentId?: undefined;
|
|
71
|
+
title?: undefined;
|
|
72
|
+
text?: undefined;
|
|
73
|
+
}>;
|
|
74
|
+
requiredAuth: "googleDocsToken";
|
|
75
|
+
scope: "read";
|
|
76
|
+
} | {
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
tool: import("ai").Tool<{
|
|
80
|
+
title: string;
|
|
81
|
+
googleDocsToken: string;
|
|
82
|
+
}, {
|
|
83
|
+
error: string;
|
|
84
|
+
details: any;
|
|
85
|
+
documentId?: undefined;
|
|
86
|
+
title?: undefined;
|
|
87
|
+
revisionId?: undefined;
|
|
88
|
+
message?: undefined;
|
|
89
|
+
} | {
|
|
90
|
+
documentId: any;
|
|
91
|
+
title: any;
|
|
92
|
+
revisionId: any;
|
|
93
|
+
error?: undefined;
|
|
94
|
+
details?: undefined;
|
|
95
|
+
message?: undefined;
|
|
96
|
+
} | {
|
|
97
|
+
error: string;
|
|
98
|
+
message: string;
|
|
99
|
+
details?: undefined;
|
|
100
|
+
documentId?: undefined;
|
|
101
|
+
title?: undefined;
|
|
102
|
+
revisionId?: undefined;
|
|
103
|
+
}>;
|
|
104
|
+
requiredAuth: "googleDocsToken";
|
|
105
|
+
scope: "write";
|
|
106
|
+
} | {
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
tool: import("ai").Tool<{
|
|
110
|
+
text: string;
|
|
111
|
+
googleDocsToken: string;
|
|
112
|
+
documentId: string;
|
|
113
|
+
index: number;
|
|
114
|
+
}, {
|
|
115
|
+
error: string;
|
|
116
|
+
details: any;
|
|
117
|
+
success?: undefined;
|
|
118
|
+
documentId?: undefined;
|
|
119
|
+
replies?: undefined;
|
|
120
|
+
message?: undefined;
|
|
121
|
+
} | {
|
|
122
|
+
success: boolean;
|
|
123
|
+
documentId: string;
|
|
124
|
+
replies: any;
|
|
125
|
+
error?: undefined;
|
|
126
|
+
details?: undefined;
|
|
127
|
+
message?: undefined;
|
|
128
|
+
} | {
|
|
129
|
+
error: string;
|
|
130
|
+
message: string;
|
|
131
|
+
details?: undefined;
|
|
132
|
+
success?: undefined;
|
|
133
|
+
documentId?: undefined;
|
|
134
|
+
replies?: undefined;
|
|
135
|
+
}>;
|
|
136
|
+
requiredAuth: "googleDocsToken";
|
|
137
|
+
scope: "write";
|
|
138
|
+
} | {
|
|
139
|
+
name: string;
|
|
140
|
+
description: string;
|
|
141
|
+
tool: import("ai").Tool<{
|
|
142
|
+
text: string;
|
|
143
|
+
googleDocsToken: string;
|
|
144
|
+
documentId: string;
|
|
145
|
+
}, {
|
|
146
|
+
error: string;
|
|
147
|
+
details: any;
|
|
148
|
+
success?: undefined;
|
|
149
|
+
documentId?: undefined;
|
|
150
|
+
index?: undefined;
|
|
151
|
+
replies?: undefined;
|
|
152
|
+
message?: undefined;
|
|
153
|
+
} | {
|
|
154
|
+
success: boolean;
|
|
155
|
+
documentId: string;
|
|
156
|
+
index: number;
|
|
157
|
+
replies: any;
|
|
158
|
+
error?: undefined;
|
|
159
|
+
details?: undefined;
|
|
160
|
+
message?: undefined;
|
|
161
|
+
} | {
|
|
162
|
+
error: string;
|
|
163
|
+
message: string;
|
|
164
|
+
details?: undefined;
|
|
165
|
+
success?: undefined;
|
|
166
|
+
documentId?: undefined;
|
|
167
|
+
index?: undefined;
|
|
168
|
+
replies?: undefined;
|
|
169
|
+
}>;
|
|
170
|
+
requiredAuth: "googleDocsToken";
|
|
171
|
+
scope: "write";
|
|
172
|
+
} | {
|
|
173
|
+
name: string;
|
|
174
|
+
description: string;
|
|
175
|
+
tool: import("ai").Tool<{
|
|
176
|
+
googleDocsToken: string;
|
|
177
|
+
documentId: string;
|
|
178
|
+
findText: string;
|
|
179
|
+
replaceText: string;
|
|
180
|
+
matchCase: boolean;
|
|
181
|
+
}, {
|
|
182
|
+
error: string;
|
|
183
|
+
details: any;
|
|
184
|
+
success?: undefined;
|
|
185
|
+
documentId?: undefined;
|
|
186
|
+
occurrencesChanged?: undefined;
|
|
187
|
+
replies?: undefined;
|
|
188
|
+
message?: undefined;
|
|
189
|
+
} | {
|
|
190
|
+
success: boolean;
|
|
191
|
+
documentId: string;
|
|
192
|
+
occurrencesChanged: any;
|
|
193
|
+
replies: any;
|
|
194
|
+
error?: undefined;
|
|
195
|
+
details?: undefined;
|
|
196
|
+
message?: undefined;
|
|
197
|
+
} | {
|
|
198
|
+
error: string;
|
|
199
|
+
message: string;
|
|
200
|
+
details?: undefined;
|
|
201
|
+
success?: undefined;
|
|
202
|
+
documentId?: undefined;
|
|
203
|
+
occurrencesChanged?: undefined;
|
|
204
|
+
replies?: undefined;
|
|
205
|
+
}>;
|
|
206
|
+
requiredAuth: "googleDocsToken";
|
|
207
|
+
scope: "write";
|
|
208
|
+
} | {
|
|
209
|
+
name: string;
|
|
210
|
+
description: string;
|
|
211
|
+
tool: import("ai").Tool<{
|
|
212
|
+
googleDocsToken: string;
|
|
213
|
+
documentId: string;
|
|
214
|
+
startIndex: number;
|
|
215
|
+
endIndex: number;
|
|
216
|
+
}, {
|
|
217
|
+
error: string;
|
|
218
|
+
details: any;
|
|
219
|
+
success?: undefined;
|
|
220
|
+
documentId?: undefined;
|
|
221
|
+
replies?: undefined;
|
|
222
|
+
message?: undefined;
|
|
223
|
+
} | {
|
|
224
|
+
success: boolean;
|
|
225
|
+
documentId: string;
|
|
226
|
+
replies: any;
|
|
227
|
+
error?: undefined;
|
|
228
|
+
details?: undefined;
|
|
229
|
+
message?: undefined;
|
|
230
|
+
} | {
|
|
231
|
+
error: string;
|
|
232
|
+
message: string;
|
|
233
|
+
details?: undefined;
|
|
234
|
+
success?: undefined;
|
|
235
|
+
documentId?: undefined;
|
|
236
|
+
replies?: undefined;
|
|
237
|
+
}>;
|
|
238
|
+
requiredAuth: "googleDocsToken";
|
|
239
|
+
scope: "delete";
|
|
240
|
+
} | {
|
|
241
|
+
name: string;
|
|
242
|
+
description: string;
|
|
243
|
+
tool: import("ai").Tool<{
|
|
244
|
+
googleDocsToken: string;
|
|
245
|
+
documentId: string;
|
|
246
|
+
name?: string | undefined;
|
|
247
|
+
}, {
|
|
248
|
+
error: string;
|
|
249
|
+
details: any;
|
|
250
|
+
documentId?: undefined;
|
|
251
|
+
name?: undefined;
|
|
252
|
+
webViewLink?: undefined;
|
|
253
|
+
message?: undefined;
|
|
254
|
+
} | {
|
|
255
|
+
documentId: any;
|
|
256
|
+
name: any;
|
|
257
|
+
webViewLink: any;
|
|
258
|
+
error?: undefined;
|
|
259
|
+
details?: undefined;
|
|
260
|
+
message?: undefined;
|
|
261
|
+
} | {
|
|
262
|
+
error: string;
|
|
263
|
+
message: string;
|
|
264
|
+
details?: undefined;
|
|
265
|
+
documentId?: undefined;
|
|
266
|
+
name?: undefined;
|
|
267
|
+
webViewLink?: undefined;
|
|
268
|
+
}>;
|
|
269
|
+
requiredAuth: "googleDocsToken";
|
|
270
|
+
scope: "write";
|
|
271
|
+
} | {
|
|
272
|
+
name: string;
|
|
273
|
+
description: string;
|
|
274
|
+
tool: import("ai").Tool<{
|
|
275
|
+
googleDocsToken: string;
|
|
276
|
+
documentId: string;
|
|
277
|
+
}, {
|
|
278
|
+
error: string;
|
|
279
|
+
details: any;
|
|
280
|
+
success?: undefined;
|
|
281
|
+
documentId?: undefined;
|
|
282
|
+
message?: undefined;
|
|
283
|
+
} | {
|
|
284
|
+
success: boolean;
|
|
285
|
+
documentId: string;
|
|
286
|
+
error?: undefined;
|
|
287
|
+
details?: undefined;
|
|
288
|
+
message?: undefined;
|
|
289
|
+
} | {
|
|
290
|
+
error: string;
|
|
291
|
+
message: string;
|
|
292
|
+
details?: undefined;
|
|
293
|
+
success?: undefined;
|
|
294
|
+
documentId?: undefined;
|
|
295
|
+
}>;
|
|
296
|
+
requiredAuth: "googleDocsToken";
|
|
297
|
+
scope: "delete";
|
|
298
|
+
})[];
|
|
299
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { listDocuments } from './list-documents.js';
|
|
3
|
+
import { getDocument } from './get-document.js';
|
|
4
|
+
import { getDocumentText } from './get-document-text.js';
|
|
5
|
+
import { createDocument } from './create-document.js';
|
|
6
|
+
import { insertText } from './insert-text.js';
|
|
7
|
+
import { appendText } from './append-text.js';
|
|
8
|
+
import { replaceText } from './replace-text.js';
|
|
9
|
+
import { deleteContent } from './delete-content.js';
|
|
10
|
+
import { copyDocument } from './copy-document.js';
|
|
11
|
+
import { deleteDocument } from './delete-document.js';
|
|
12
|
+
export { listDocuments, getDocument, getDocumentText, createDocument, insertText, appendText, replaceText, deleteContent, copyDocument, deleteDocument, };
|
|
13
|
+
export const googleDocsTools = [
|
|
14
|
+
{
|
|
15
|
+
name: 'googleDocsListDocuments',
|
|
16
|
+
description: 'List Google Docs documents in the user\'s Drive.',
|
|
17
|
+
tool: listDocuments,
|
|
18
|
+
requiredAuth: 'googleDocsToken',
|
|
19
|
+
scope: 'read',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'googleDocsGetDocument',
|
|
23
|
+
description: 'Get the full Google Docs document structure including title and body content.',
|
|
24
|
+
tool: getDocument,
|
|
25
|
+
requiredAuth: 'googleDocsToken',
|
|
26
|
+
scope: 'read',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'googleDocsGetDocumentText',
|
|
30
|
+
description: 'Get the plain text content of a Google Docs document.',
|
|
31
|
+
tool: getDocumentText,
|
|
32
|
+
requiredAuth: 'googleDocsToken',
|
|
33
|
+
scope: 'read',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'googleDocsCreateDocument',
|
|
37
|
+
description: 'Create a new blank Google Docs document with a title.',
|
|
38
|
+
tool: createDocument,
|
|
39
|
+
requiredAuth: 'googleDocsToken',
|
|
40
|
+
scope: 'write',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'googleDocsInsertText',
|
|
44
|
+
description: 'Insert text at a specific index in a Google Docs document.',
|
|
45
|
+
tool: insertText,
|
|
46
|
+
requiredAuth: 'googleDocsToken',
|
|
47
|
+
scope: 'write',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'googleDocsAppendText',
|
|
51
|
+
description: 'Append text to the end of a Google Docs document.',
|
|
52
|
+
tool: appendText,
|
|
53
|
+
requiredAuth: 'googleDocsToken',
|
|
54
|
+
scope: 'write',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'googleDocsReplaceText',
|
|
58
|
+
description: 'Find and replace all occurrences of text in a Google Docs document.',
|
|
59
|
+
tool: replaceText,
|
|
60
|
+
requiredAuth: 'googleDocsToken',
|
|
61
|
+
scope: 'write',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'googleDocsDeleteContent',
|
|
65
|
+
description: 'Delete a range of content from a Google Docs document.',
|
|
66
|
+
tool: deleteContent,
|
|
67
|
+
requiredAuth: 'googleDocsToken',
|
|
68
|
+
scope: 'delete',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'googleDocsCopyDocument',
|
|
72
|
+
description: 'Copy a Google Docs document.',
|
|
73
|
+
tool: copyDocument,
|
|
74
|
+
requiredAuth: 'googleDocsToken',
|
|
75
|
+
scope: 'write',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'googleDocsDeleteDocument',
|
|
79
|
+
description: 'Delete a Google Docs document (moves to trash).',
|
|
80
|
+
tool: deleteDocument,
|
|
81
|
+
requiredAuth: 'googleDocsToken',
|
|
82
|
+
scope: 'delete',
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const insertText: import("ai").Tool<{
|
|
2
|
+
text: string;
|
|
3
|
+
googleDocsToken: string;
|
|
4
|
+
documentId: string;
|
|
5
|
+
index: number;
|
|
6
|
+
}, {
|
|
7
|
+
error: string;
|
|
8
|
+
details: any;
|
|
9
|
+
success?: undefined;
|
|
10
|
+
documentId?: undefined;
|
|
11
|
+
replies?: undefined;
|
|
12
|
+
message?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
success: boolean;
|
|
15
|
+
documentId: string;
|
|
16
|
+
replies: any;
|
|
17
|
+
error?: undefined;
|
|
18
|
+
details?: undefined;
|
|
19
|
+
message?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
error: string;
|
|
22
|
+
message: string;
|
|
23
|
+
details?: undefined;
|
|
24
|
+
success?: undefined;
|
|
25
|
+
documentId?: undefined;
|
|
26
|
+
replies?: undefined;
|
|
27
|
+
}>;
|
|
28
|
+
//# sourceMappingURL=insert-text.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const insertText = tool({
|
|
5
|
+
description: 'Insert text at a specific index in a Google Docs document.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDocsToken: z.string().describe('The Google Docs access token'),
|
|
8
|
+
documentId: z.string().describe('The ID of the document'),
|
|
9
|
+
text: z.string().describe('Text to insert'),
|
|
10
|
+
index: z.number().optional().default(1).describe('Character index where text should be inserted (default: 1)'),
|
|
11
|
+
}),
|
|
12
|
+
execute: async ({ googleDocsToken, documentId, text, index = 1 }) => {
|
|
13
|
+
try {
|
|
14
|
+
const response = await fetch(`https://docs.googleapis.com/v1/documents/${documentId}:batchUpdate`, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${googleDocsToken}`,
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
requests: [{ insertText: { location: { index }, text } }],
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
const error = await response.json();
|
|
26
|
+
return { error: 'Failed to insert text', details: error };
|
|
27
|
+
}
|
|
28
|
+
const data = await response.json();
|
|
29
|
+
return { success: true, documentId, replies: data.replies };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
error: 'Error inserting text',
|
|
34
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=insert-text.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const listDocuments: import("ai").Tool<{
|
|
2
|
+
pageSize: number;
|
|
3
|
+
googleDocsToken: string;
|
|
4
|
+
q?: string | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
error: string;
|
|
7
|
+
details: any;
|
|
8
|
+
documents?: undefined;
|
|
9
|
+
message?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
documents: any;
|
|
12
|
+
error?: undefined;
|
|
13
|
+
details?: undefined;
|
|
14
|
+
message?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
error: string;
|
|
17
|
+
message: string;
|
|
18
|
+
details?: undefined;
|
|
19
|
+
documents?: undefined;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=list-documents.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const listDocuments = tool({
|
|
5
|
+
description: 'List Google Docs documents in the user\'s Drive.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDocsToken: z.string().describe('The Google Docs access token'),
|
|
8
|
+
q: z.string().optional().describe('Optional name search query'),
|
|
9
|
+
pageSize: z.number().optional().default(20).describe('Maximum number of documents to return'),
|
|
10
|
+
}),
|
|
11
|
+
execute: async ({ googleDocsToken, q, pageSize = 20 }) => {
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL('https://www.googleapis.com/drive/v3/files');
|
|
14
|
+
let query = "mimeType='application/vnd.google-apps.document' and trashed = false";
|
|
15
|
+
if (q) {
|
|
16
|
+
query += ` and name contains '${q.replace(/'/g, "\\'")}'`;
|
|
17
|
+
}
|
|
18
|
+
url.searchParams.set('q', query);
|
|
19
|
+
url.searchParams.set('pageSize', String(pageSize));
|
|
20
|
+
url.searchParams.set('fields', 'files(id,name,modifiedTime,webViewLink)');
|
|
21
|
+
const response = await fetch(url.toString(), {
|
|
22
|
+
headers: { Authorization: `Bearer ${googleDocsToken}` },
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
const error = await response.json();
|
|
26
|
+
return { error: 'Failed to list documents', details: error };
|
|
27
|
+
}
|
|
28
|
+
const data = await response.json();
|
|
29
|
+
return { documents: data.files ?? [] };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
error: 'Error listing documents',
|
|
34
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=list-documents.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const replaceText: import("ai").Tool<{
|
|
2
|
+
googleDocsToken: string;
|
|
3
|
+
documentId: string;
|
|
4
|
+
findText: string;
|
|
5
|
+
replaceText: string;
|
|
6
|
+
matchCase: boolean;
|
|
7
|
+
}, {
|
|
8
|
+
error: string;
|
|
9
|
+
details: any;
|
|
10
|
+
success?: undefined;
|
|
11
|
+
documentId?: undefined;
|
|
12
|
+
occurrencesChanged?: undefined;
|
|
13
|
+
replies?: undefined;
|
|
14
|
+
message?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
success: boolean;
|
|
17
|
+
documentId: string;
|
|
18
|
+
occurrencesChanged: any;
|
|
19
|
+
replies: any;
|
|
20
|
+
error?: undefined;
|
|
21
|
+
details?: undefined;
|
|
22
|
+
message?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
error: string;
|
|
25
|
+
message: string;
|
|
26
|
+
details?: undefined;
|
|
27
|
+
success?: undefined;
|
|
28
|
+
documentId?: undefined;
|
|
29
|
+
occurrencesChanged?: undefined;
|
|
30
|
+
replies?: undefined;
|
|
31
|
+
}>;
|
|
32
|
+
//# sourceMappingURL=replace-text.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const replaceText = tool({
|
|
5
|
+
description: 'Find and replace all occurrences of text in a Google Docs document.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
googleDocsToken: z.string().describe('The Google Docs access token'),
|
|
8
|
+
documentId: z.string().describe('The ID of the document'),
|
|
9
|
+
findText: z.string().describe('Text to find'),
|
|
10
|
+
replaceText: z.string().describe('Replacement text'),
|
|
11
|
+
matchCase: z.boolean().optional().default(false).describe('Whether the search is case-sensitive'),
|
|
12
|
+
}),
|
|
13
|
+
execute: async ({ googleDocsToken, documentId, findText, replaceText: replacement, matchCase = false }) => {
|
|
14
|
+
try {
|
|
15
|
+
const response = await fetch(`https://docs.googleapis.com/v1/documents/${documentId}:batchUpdate`, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${googleDocsToken}`,
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
requests: [
|
|
23
|
+
{
|
|
24
|
+
replaceAllText: {
|
|
25
|
+
containsText: { text: findText, matchCase },
|
|
26
|
+
replaceText: replacement,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
const error = await response.json();
|
|
34
|
+
return { error: 'Failed to replace text', details: error };
|
|
35
|
+
}
|
|
36
|
+
const data = await response.json();
|
|
37
|
+
const occurrencesChanged = data.replies?.[0]?.replaceAllText?.occurrencesChanged ?? 0;
|
|
38
|
+
return { success: true, documentId, occurrencesChanged, replies: data.replies };
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return {
|
|
42
|
+
error: 'Error replacing text',
|
|
43
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=replace-text.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function extractPlainText(document: {
|
|
2
|
+
body?: {
|
|
3
|
+
content?: Array<Record<string, unknown>>;
|
|
4
|
+
};
|
|
5
|
+
title?: string;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function getDocumentEndIndex(document: {
|
|
8
|
+
body?: {
|
|
9
|
+
content?: Array<Record<string, unknown>>;
|
|
10
|
+
};
|
|
11
|
+
}): number;
|
|
12
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
export function extractPlainText(document) {
|
|
3
|
+
const parts = [];
|
|
4
|
+
const content = document.body?.content ?? [];
|
|
5
|
+
for (const element of content) {
|
|
6
|
+
if (element.paragraph) {
|
|
7
|
+
const paragraph = element.paragraph;
|
|
8
|
+
for (const el of paragraph.elements ?? []) {
|
|
9
|
+
if (el.textRun) {
|
|
10
|
+
const textRun = el.textRun;
|
|
11
|
+
if (textRun.content)
|
|
12
|
+
parts.push(textRun.content);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else if (element.table) {
|
|
17
|
+
const table = element.table;
|
|
18
|
+
for (const row of table.tableRows ?? []) {
|
|
19
|
+
const tableRow = row;
|
|
20
|
+
for (const cell of tableRow.tableCells ?? []) {
|
|
21
|
+
const tableCell = cell;
|
|
22
|
+
for (const cellEl of tableCell.content ?? []) {
|
|
23
|
+
if (cellEl.paragraph) {
|
|
24
|
+
const paragraph = cellEl.paragraph;
|
|
25
|
+
for (const el of paragraph.elements ?? []) {
|
|
26
|
+
if (el.textRun) {
|
|
27
|
+
const textRun = el.textRun;
|
|
28
|
+
if (textRun.content)
|
|
29
|
+
parts.push(textRun.content);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return parts.join('');
|
|
39
|
+
}
|
|
40
|
+
export function getDocumentEndIndex(document) {
|
|
41
|
+
const content = document.body?.content ?? [];
|
|
42
|
+
if (content.length === 0)
|
|
43
|
+
return 1;
|
|
44
|
+
const last = content[content.length - 1];
|
|
45
|
+
const endIndex = last.endIndex;
|
|
46
|
+
return typeof endIndex === 'number' ? endIndex - 1 : 1;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" viewBox="0 0 192 192" fill="none"><mask id="a" width="168" height="154" x="12" y="18" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#b43333" d="M63.09 37c14.626-25.333 51.193-25.334 65.819 0l45.033 78c14.626 25.334-3.657 57.001-32.91 57.001H50.967c-29.253 0-47.536-31.667-32.91-57.001z"/></mask><g mask="url(#a)"><path fill="url(#b)" d="M206.905 172.02h-91.888l-19.015-32.934 45.944-79.578z"/><path fill="url(#c)" d="M-14.919 172.006 50.04 59.494v.002L31.032 92.422h38.02L115 172.004l-129.918.001z"/><path fill="url(#d)" d="M96.007-20.085 141.954 59.5l-19.011 32.928H31.048z"/></g><defs><linearGradient id="b" x1="193.6" x2="103.09" y1="165.6" y2="111.21" gradientUnits="userSpaceOnUse"><stop offset=".09" stop-color="#ffe921"/><stop offset="1" stop-color="#fec700"/></linearGradient><linearGradient id="c" x1="114.4" x2="15.53" y1="181.61" y2="121.8" gradientUnits="userSpaceOnUse"><stop offset=".15" stop-color="#a9a8ff"/><stop offset=".33" stop-color="#6d97ff"/><stop offset=".48" stop-color="#3186ff"/></linearGradient><linearGradient id="d" x1="128.88" x2="28.7" y1="37.88" y2="84.64" gradientUnits="userSpaceOnUse"><stop offset=".55" stop-color="#0ebc5f"/><stop offset=".85" stop-color="#78c9ff"/></linearGradient></defs></svg>`;
|
|
2
|
+
export const GDRIVE_ICON = {
|
|
3
|
+
kind: 'svg',
|
|
4
|
+
dataUri: `data:image/svg+xml;base64,${Buffer.from(SVG).toString('base64')}`,
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=icon.js.map
|