fix sync script errs

This commit is contained in:
Ramnique Singh 2025-12-17 07:29:56 +05:30
parent d0d0a3612e
commit f1219db4ac
4 changed files with 1077 additions and 15 deletions

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,7 @@
"@ai-sdk/openai": "^2.0.53",
"@ai-sdk/openai-compatible": "^1.0.27",
"@ai-sdk/provider": "^2.0.0",
"@google-cloud/local-auth": "^3.0.1",
"@hono/node-server": "^1.19.6",
"@hono/standard-validator": "^0.1.5",
"@modelcontextprotocol/sdk": "^1.20.2",
@ -37,6 +38,8 @@
"ai": "^5.0.102",
"awilix": "^12.0.5",
"eventsource-parser": "^1.1.2",
"google-auth-library": "^10.5.0",
"googleapis": "^169.0.0",
"hono": "^4.10.7",
"hono-openapi": "^1.1.1",
"ink": "^5.1.0",
@ -45,6 +48,7 @@
"ink-text-input": "^6.0.0",
"json-schema-to-zod": "^2.6.1",
"nanoid": "^5.1.6",
"node-html-markdown": "^2.0.0",
"ollama-ai-provider-v2": "^1.5.4",
"react": "^18.3.1",
"yargs": "^18.0.0",

View file

@ -3,7 +3,7 @@ import path from 'path';
import { google } from 'googleapis';
import { authenticate } from '@google-cloud/local-auth';
import { OAuth2Client } from 'google-auth-library';
import TurndownService from 'turndown';
import { NodeHtmlMarkdown } from 'node-html-markdown'
// Configuration
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
@ -14,11 +14,7 @@ const SCOPES = [
'https://www.googleapis.com/auth/drive.readonly'
];
// Initialize Turndown
const turndownService = new TurndownService({
headingStyle: 'atx',
codeBlockStyle: 'fenced'
});
const nhm = new NodeHtmlMarkdown();
// --- Auth Functions ---
@ -188,7 +184,7 @@ async function processAttachments(drive: any, event: any, syncDir: string) {
});
const html = res.data;
const md = turndownService.turndown(html);
const md = nhm.translate(html);
const frontmatter = [
`# ${att.title}`,

View file

@ -2,7 +2,7 @@ import fs from 'fs';
import path from 'path';
import { google } from 'googleapis';
import { authenticate } from '@google-cloud/local-auth';
import TurndownService from 'turndown';
import { NodeHtmlMarkdown } from 'node-html-markdown'
import { OAuth2Client } from 'google-auth-library';
// Configuration
@ -12,11 +12,7 @@ const TOKEN_PATH = path.join(process.cwd(), 'token_api.json'); // Reuse Python's
const SYNC_INTERVAL_MS = 60 * 1000;
const SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];
// Initialize Turndown service for HTML to Markdown
const turndownService = new TurndownService({
headingStyle: 'atx',
codeBlockStyle: 'fenced'
});
const nhm = new NodeHtmlMarkdown();
// --- Auth Functions ---
@ -112,7 +108,7 @@ function getBody(payload: any): string {
body += cleanLines.join('\n');
} else if (part.mimeType === 'text/html' && part.body && part.body.data) {
const html = decodeBase64(part.body.data);
let md = turndownService.turndown(html);
let md = nhm.translate(html);
// Simple quote stripping for MD
const cleanLines = md.split('\n').filter((line: string) => !line.trim().startsWith('>'));
body += cleanLines.join('\n');
@ -123,7 +119,7 @@ function getBody(payload: any): string {
} else if (payload.body && payload.body.data) {
const data = decodeBase64(payload.body.data);
if (payload.mimeType === 'text/html') {
let md = turndownService.turndown(data);
let md = nhm.translate(data);
body += md.split('\n').filter((line: string) => !line.trim().startsWith('>')).join('\n');
} else {
body += data.split('\n').filter((line: string) => !line.trim().startsWith('>')).join('\n');