@plosson/agentio 0.3.2 → 0.4.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/package.json +1 -1
- package/src/auth/oauth.ts +24 -2
- package/src/auth/token-manager.ts +10 -8
- package/src/commands/discourse.ts +3 -3
- package/src/commands/gchat.ts +4 -4
- package/src/commands/gdocs.ts +186 -0
- package/src/commands/gdrive.ts +285 -0
- package/src/commands/github.ts +2 -2
- package/src/commands/gmail.ts +10 -10
- package/src/commands/jira.ts +16 -14
- package/src/commands/slack.ts +1 -1
- package/src/commands/sql.ts +3 -2
- package/src/commands/status.ts +14 -0
- package/src/commands/telegram.ts +1 -1
- package/src/config/config-manager.ts +35 -1
- package/src/index.ts +4 -0
- package/src/services/gdocs/client.ts +165 -0
- package/src/services/gdrive/client.ts +452 -0
- package/src/types/config.ts +3 -1
- package/src/types/gdocs.ts +28 -0
- package/src/types/gdrive.ts +81 -0
- package/src/utils/client-factory.ts +12 -9
- package/src/utils/output.ts +109 -0
package/src/utils/output.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { GmailMessage, GmailAttachmentInfo } from '../types/gmail';
|
|
2
2
|
import type { GChatMessage, GChatSpace } from '../types/gchat';
|
|
3
|
+
import type { GDocsDocument, GDocsCreateResult } from '../types/gdocs';
|
|
4
|
+
import type { GDriveFile, GDriveDownloadResult, GDriveUploadResult } from '../types/gdrive';
|
|
3
5
|
import type { JiraProject, JiraIssue, JiraTransition, JiraCommentResult, JiraTransitionResult } from '../types/jira';
|
|
4
6
|
import type { SlackSendResult } from '../types/slack';
|
|
5
7
|
import type { RssFeed, RssArticle } from '../types/rss';
|
|
@@ -373,3 +375,110 @@ export function printDiscourseTopic(topic: DiscourseTopicDetail): void {
|
|
|
373
375
|
console.log(content);
|
|
374
376
|
}
|
|
375
377
|
}
|
|
378
|
+
|
|
379
|
+
// Google Docs specific formatters
|
|
380
|
+
export function printGDocsList(docs: GDocsDocument[]): void {
|
|
381
|
+
if (docs.length === 0) {
|
|
382
|
+
console.log('No documents found');
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
console.log(`Documents (${docs.length})\n`);
|
|
387
|
+
|
|
388
|
+
for (let i = 0; i < docs.length; i++) {
|
|
389
|
+
const doc = docs[i];
|
|
390
|
+
console.log(`[${i + 1}] ${doc.title}`);
|
|
391
|
+
console.log(` ID: ${doc.id}`);
|
|
392
|
+
if (doc.owner) console.log(` Owner: ${doc.owner}`);
|
|
393
|
+
if (doc.modifiedTime) console.log(` Modified: ${doc.modifiedTime}`);
|
|
394
|
+
console.log(` Link: ${doc.webViewLink}`);
|
|
395
|
+
console.log('');
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export function printGDocCreated(result: GDocsCreateResult): void {
|
|
400
|
+
console.log('Document created');
|
|
401
|
+
console.log(`ID: ${result.id}`);
|
|
402
|
+
console.log(`Title: ${result.title}`);
|
|
403
|
+
console.log(`Link: ${result.webViewLink}`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Google Drive specific formatters
|
|
407
|
+
function getShortMimeType(mimeType: string): string {
|
|
408
|
+
const shortTypes: Record<string, string> = {
|
|
409
|
+
'application/vnd.google-apps.folder': 'folder',
|
|
410
|
+
'application/vnd.google-apps.document': 'gdoc',
|
|
411
|
+
'application/vnd.google-apps.spreadsheet': 'gsheet',
|
|
412
|
+
'application/vnd.google-apps.presentation': 'gslide',
|
|
413
|
+
'application/pdf': 'pdf',
|
|
414
|
+
'image/png': 'png',
|
|
415
|
+
'image/jpeg': 'jpg',
|
|
416
|
+
'text/plain': 'txt',
|
|
417
|
+
'application/zip': 'zip',
|
|
418
|
+
};
|
|
419
|
+
if (shortTypes[mimeType]) return shortTypes[mimeType];
|
|
420
|
+
if (mimeType.startsWith('image/')) return 'image';
|
|
421
|
+
if (mimeType.startsWith('video/')) return 'video';
|
|
422
|
+
if (mimeType.startsWith('audio/')) return 'audio';
|
|
423
|
+
if (mimeType.startsWith('text/')) return 'text';
|
|
424
|
+
return 'file';
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export function printGDriveFileList(files: GDriveFile[], title: string = 'Files'): void {
|
|
428
|
+
if (files.length === 0) {
|
|
429
|
+
console.log('No files found');
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
console.log(`${title} (${files.length})\n`);
|
|
434
|
+
|
|
435
|
+
for (let i = 0; i < files.length; i++) {
|
|
436
|
+
const file = files[i];
|
|
437
|
+
const isFolder = file.mimeType === 'application/vnd.google-apps.folder';
|
|
438
|
+
const typeIndicator = isFolder ? '[folder]' : `[${getShortMimeType(file.mimeType)}]`;
|
|
439
|
+
const flags: string[] = [];
|
|
440
|
+
if (file.starred) flags.push('*');
|
|
441
|
+
if (file.shared) flags.push('shared');
|
|
442
|
+
const flagStr = flags.length > 0 ? ` (${flags.join(', ')})` : '';
|
|
443
|
+
|
|
444
|
+
console.log(`[${i + 1}] ${file.name} ${typeIndicator}${flagStr}`);
|
|
445
|
+
console.log(` ID: ${file.id}`);
|
|
446
|
+
if (file.size) console.log(` Size: ${formatBytes(file.size)}`);
|
|
447
|
+
if (file.owners?.length) console.log(` Owner: ${file.owners[0]}`);
|
|
448
|
+
if (file.modifiedTime) console.log(` Modified: ${file.modifiedTime}`);
|
|
449
|
+
if (file.webViewLink) console.log(` Link: ${file.webViewLink}`);
|
|
450
|
+
console.log('');
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export function printGDriveFile(file: GDriveFile): void {
|
|
455
|
+
console.log(`ID: ${file.id}`);
|
|
456
|
+
console.log(`Name: ${file.name}`);
|
|
457
|
+
console.log(`Type: ${file.mimeType}`);
|
|
458
|
+
if (file.size) console.log(`Size: ${formatBytes(file.size)}`);
|
|
459
|
+
if (file.description) console.log(`Description: ${file.description}`);
|
|
460
|
+
if (file.owners?.length) console.log(`Owners: ${file.owners.join(', ')}`);
|
|
461
|
+
if (file.parents?.length) console.log(`Parents: ${file.parents.join(', ')}`);
|
|
462
|
+
console.log(`Starred: ${file.starred ? 'yes' : 'no'}`);
|
|
463
|
+
console.log(`Shared: ${file.shared ? 'yes' : 'no'}`);
|
|
464
|
+
console.log(`Trashed: ${file.trashed ? 'yes' : 'no'}`);
|
|
465
|
+
if (file.createdTime) console.log(`Created: ${file.createdTime}`);
|
|
466
|
+
if (file.modifiedTime) console.log(`Modified: ${file.modifiedTime}`);
|
|
467
|
+
if (file.webViewLink) console.log(`View: ${file.webViewLink}`);
|
|
468
|
+
if (file.webContentLink) console.log(`Download: ${file.webContentLink}`);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export function printGDriveDownloaded(result: GDriveDownloadResult): void {
|
|
472
|
+
console.log(`Downloaded: ${result.filename}`);
|
|
473
|
+
console.log(` Path: ${result.path}`);
|
|
474
|
+
console.log(` Size: ${formatBytes(result.size)}`);
|
|
475
|
+
console.log(` Type: ${result.mimeType}`);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export function printGDriveUploaded(result: GDriveUploadResult): void {
|
|
479
|
+
console.log(`Uploaded: ${result.name}`);
|
|
480
|
+
console.log(` ID: ${result.id}`);
|
|
481
|
+
console.log(` Size: ${formatBytes(result.size)}`);
|
|
482
|
+
console.log(` Type: ${result.mimeType}`);
|
|
483
|
+
if (result.webViewLink) console.log(` Link: ${result.webViewLink}`);
|
|
484
|
+
}
|