mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-30 20:39:46 +02:00
fix sync script errs
This commit is contained in:
parent
317029ef5f
commit
4546f4e22a
4 changed files with 1077 additions and 15 deletions
1066
apps/cli/package-lock.json
generated
1066
apps/cli/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -30,6 +30,7 @@
|
||||||
"@ai-sdk/openai": "^2.0.53",
|
"@ai-sdk/openai": "^2.0.53",
|
||||||
"@ai-sdk/openai-compatible": "^1.0.27",
|
"@ai-sdk/openai-compatible": "^1.0.27",
|
||||||
"@ai-sdk/provider": "^2.0.0",
|
"@ai-sdk/provider": "^2.0.0",
|
||||||
|
"@google-cloud/local-auth": "^3.0.1",
|
||||||
"@hono/node-server": "^1.19.6",
|
"@hono/node-server": "^1.19.6",
|
||||||
"@hono/standard-validator": "^0.1.5",
|
"@hono/standard-validator": "^0.1.5",
|
||||||
"@modelcontextprotocol/sdk": "^1.20.2",
|
"@modelcontextprotocol/sdk": "^1.20.2",
|
||||||
|
|
@ -37,6 +38,8 @@
|
||||||
"ai": "^5.0.102",
|
"ai": "^5.0.102",
|
||||||
"awilix": "^12.0.5",
|
"awilix": "^12.0.5",
|
||||||
"eventsource-parser": "^1.1.2",
|
"eventsource-parser": "^1.1.2",
|
||||||
|
"google-auth-library": "^10.5.0",
|
||||||
|
"googleapis": "^169.0.0",
|
||||||
"hono": "^4.10.7",
|
"hono": "^4.10.7",
|
||||||
"hono-openapi": "^1.1.1",
|
"hono-openapi": "^1.1.1",
|
||||||
"ink": "^5.1.0",
|
"ink": "^5.1.0",
|
||||||
|
|
@ -45,6 +48,7 @@
|
||||||
"ink-text-input": "^6.0.0",
|
"ink-text-input": "^6.0.0",
|
||||||
"json-schema-to-zod": "^2.6.1",
|
"json-schema-to-zod": "^2.6.1",
|
||||||
"nanoid": "^5.1.6",
|
"nanoid": "^5.1.6",
|
||||||
|
"node-html-markdown": "^2.0.0",
|
||||||
"ollama-ai-provider-v2": "^1.5.4",
|
"ollama-ai-provider-v2": "^1.5.4",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"yargs": "^18.0.0",
|
"yargs": "^18.0.0",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import path from 'path';
|
||||||
import { google } from 'googleapis';
|
import { google } from 'googleapis';
|
||||||
import { authenticate } from '@google-cloud/local-auth';
|
import { authenticate } from '@google-cloud/local-auth';
|
||||||
import { OAuth2Client } from 'google-auth-library';
|
import { OAuth2Client } from 'google-auth-library';
|
||||||
import TurndownService from 'turndown';
|
import { NodeHtmlMarkdown } from 'node-html-markdown'
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
|
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
|
||||||
|
|
@ -14,11 +14,7 @@ const SCOPES = [
|
||||||
'https://www.googleapis.com/auth/drive.readonly'
|
'https://www.googleapis.com/auth/drive.readonly'
|
||||||
];
|
];
|
||||||
|
|
||||||
// Initialize Turndown
|
const nhm = new NodeHtmlMarkdown();
|
||||||
const turndownService = new TurndownService({
|
|
||||||
headingStyle: 'atx',
|
|
||||||
codeBlockStyle: 'fenced'
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Auth Functions ---
|
// --- Auth Functions ---
|
||||||
|
|
||||||
|
|
@ -188,7 +184,7 @@ async function processAttachments(drive: any, event: any, syncDir: string) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const html = res.data;
|
const html = res.data;
|
||||||
const md = turndownService.turndown(html);
|
const md = nhm.translate(html);
|
||||||
|
|
||||||
const frontmatter = [
|
const frontmatter = [
|
||||||
`# ${att.title}`,
|
`# ${att.title}`,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { google } from 'googleapis';
|
import { google } from 'googleapis';
|
||||||
import { authenticate } from '@google-cloud/local-auth';
|
import { authenticate } from '@google-cloud/local-auth';
|
||||||
import TurndownService from 'turndown';
|
import { NodeHtmlMarkdown } from 'node-html-markdown'
|
||||||
import { OAuth2Client } from 'google-auth-library';
|
import { OAuth2Client } from 'google-auth-library';
|
||||||
|
|
||||||
// Configuration
|
// 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 SYNC_INTERVAL_MS = 60 * 1000;
|
||||||
const SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];
|
const SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];
|
||||||
|
|
||||||
// Initialize Turndown service for HTML to Markdown
|
const nhm = new NodeHtmlMarkdown();
|
||||||
const turndownService = new TurndownService({
|
|
||||||
headingStyle: 'atx',
|
|
||||||
codeBlockStyle: 'fenced'
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Auth Functions ---
|
// --- Auth Functions ---
|
||||||
|
|
||||||
|
|
@ -112,7 +108,7 @@ function getBody(payload: any): string {
|
||||||
body += cleanLines.join('\n');
|
body += cleanLines.join('\n');
|
||||||
} else if (part.mimeType === 'text/html' && part.body && part.body.data) {
|
} else if (part.mimeType === 'text/html' && part.body && part.body.data) {
|
||||||
const html = decodeBase64(part.body.data);
|
const html = decodeBase64(part.body.data);
|
||||||
let md = turndownService.turndown(html);
|
let md = nhm.translate(html);
|
||||||
// Simple quote stripping for MD
|
// Simple quote stripping for MD
|
||||||
const cleanLines = md.split('\n').filter((line: string) => !line.trim().startsWith('>'));
|
const cleanLines = md.split('\n').filter((line: string) => !line.trim().startsWith('>'));
|
||||||
body += cleanLines.join('\n');
|
body += cleanLines.join('\n');
|
||||||
|
|
@ -123,7 +119,7 @@ function getBody(payload: any): string {
|
||||||
} else if (payload.body && payload.body.data) {
|
} else if (payload.body && payload.body.data) {
|
||||||
const data = decodeBase64(payload.body.data);
|
const data = decodeBase64(payload.body.data);
|
||||||
if (payload.mimeType === 'text/html') {
|
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');
|
body += md.split('\n').filter((line: string) => !line.trim().startsWith('>')).join('\n');
|
||||||
} else {
|
} else {
|
||||||
body += data.split('\n').filter((line: string) => !line.trim().startsWith('>')).join('\n');
|
body += data.split('\n').filter((line: string) => !line.trim().startsWith('>')).join('\n');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue