Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
deps: replace googleapis monolith with scoped calendar/gmail/auth packages
[._.]/ Adam Eivya9ad99f5c024
diff --git a/server/package.json b/server/package.jsonindex e0035bdb6a..9c0e4e5e6f 100644--- a/server/package.json+++ b/server/package.json@@ -12,14 +12,16 @@"test:coverage": "vitest run --coverage"},"dependencies": {+ "@googleapis/calendar": "^15.0.0",+ "@googleapis/gmail": "^17.0.0","express": "5.2.1",- "googleapis": "171.4.0",+ "google-auth-library": "^10.7.0","kokoro-js": "1.2.1","node-pty": "1.2.0-beta.10","pdf-lib": "^1.17.1","pg": "8.19.0",- "pm2": "7.0.0",- "sax": "1.4.4",+ "pm2": "7.0.1",+ "sax": "^1.6.0","sharp": "0.34.5","socket.io": "4.8.3","socket.io-client": "4.8.3",diff --git a/server/services/calendarGoogleApiSync.js b/server/services/calendarGoogleApiSync.jsindex dfce20a58b..31938ba045 100644--- a/server/services/calendarGoogleApiSync.js+++ b/server/services/calendarGoogleApiSync.js@@ -1,4 +1,4 @@-import { google } from 'googleapis';+import { calendar } from '@googleapis/calendar';import { getAuthenticatedClient } from './googleAuth.js';import { getAccount, updateSubcalendars, mergeDiscoveredSubcalendars } from './calendarAccounts.js';import { pushSyncEvents, getSyncDateRange } from './calendarGoogleSync.js';@@ -17,7 +17,7 @@ export async function apiSyncAccount(accountId, io) {io?.emit('calendar:sync:started', { accountId, method: 'api' });console.log(`📅 Starting Google API sync for ${account.name} (${enabledCalendars.length} calendars)`);- const calendar = google.calendar({ version: 'v3', auth });+ const cal = calendar({ version: 'v3', auth });const { pastDate, futureDate } = getSyncDateRange();let totalNew = 0;@@ -30,7 +30,7 @@ export async function apiSyncAccount(accountId, io) {const allEvents = [];let pageToken;do {- const response = await calendar.events.list({+ const response = await cal.events.list({calendarId: sc.calendarId,timeMin: pastDate.toISOString(),timeMax: futureDate.toISOString(),@@ -76,21 +76,21 @@ export async function apiDiscoverCalendars(accountId) {const auth = await getAuthenticatedClient();if (!auth) return { error: 'Google OAuth not configured', status: 401 };- const calendar = google.calendar({ version: 'v3', auth });+ const cal = calendar({ version: 'v3', auth });const allCalendars = [];let pageToken;do {- const response = await calendar.calendarList.list({ pageToken });+ const response = await cal.calendarList.list({ pageToken });allCalendars.push(...(response.data.items || []));pageToken = response.data.nextPageToken;} while (pageToken);// Normalize to { id, name, color } shape for merge helper- const discovered = allCalendars.map(cal => ({- id: cal.id,- name: cal.summaryOverride || cal.summary || cal.id,- color: cal.backgroundColor || ''+ const discovered = allCalendars.map(c => ({+ id: c.id,+ name: c.summaryOverride || c.summary || c.id,+ color: c.backgroundColor || ''}));const merged = mergeDiscoveredSubcalendars(account.subcalendars, discovered);diff --git a/server/services/goalCalendarScheduler.js b/server/services/goalCalendarScheduler.jsindex 196755bdce..2475fc8c80 100644--- a/server/services/goalCalendarScheduler.js+++ b/server/services/goalCalendarScheduler.js@@ -1,8 +1,7 @@-import { google } from 'googleapis';-import { writeFile } from 'fs/promises';+import { calendar } from '@googleapis/calendar';import { v4 as uuidv4 } from '../lib/uuid.js';import { join } from 'path';-import { PATHS, readJSONFile, ensureDir } from '../lib/fileUtils.js';+import { PATHS, readJSONFile, ensureDir, atomicWrite } from '../lib/fileUtils.js';import { ServerError } from '../lib/errorHandler.js';import { getAuthenticatedClient, needsScopeUpgrade, getTokens } from './googleAuth.js';@@ -34,7 +33,7 @@ async function loadGoals() {async function saveGoals(data) {await ensureDir(PATHS.digitalTwin);- await writeFile(GOALS_FILE, JSON.stringify(data, null, 2));+ await atomicWrite(GOALS_FILE, data);}export async function scheduleTimeBlocks(goalId) {@@ -55,7 +54,7 @@ export async function scheduleTimeBlocks(goalId) {const milestones = [...(goal.milestones || [])].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));if (!milestones.length) throw new ServerError('No milestones/phases to schedule', { status: 400, code: 'NO_MILESTONES' });- const calendar = google.calendar({ version: 'v3', auth });+ const cal = calendar({ version: 'v3', auth });const { preferredDays, timeSlot, sessionDurationMinutes, subcalendarId } = goal.timeBlockConfig;const calendarId = subcalendarId || 'primary';const preferredDayNums = new Set(preferredDays.map(d => DAY_MAP[d]));@@ -104,7 +103,7 @@ export async function scheduleTimeBlocks(goalId) {for (let i = 0; i < eventDefs.length; i += BATCH_SIZE) {const batch = eventDefs.slice(i, i + BATCH_SIZE);const results = await Promise.all(batch.map(def =>- calendar.events.insert({ calendarId, requestBody: def.requestBody })+ cal.events.insert({ calendarId, requestBody: def.requestBody })));for (let j = 0; j < results.length; j++) {scheduledEvents.push({@@ -135,12 +134,12 @@ export async function removeScheduledEvents(goalId) {const goal = goals.goals.find(g => g.id === goalId);if (!goal) throw new ServerError('Goal not found', { status: 404, code: 'NOT_FOUND' });- const calendar = google.calendar({ version: 'v3', auth });+ const cal = calendar({ version: 'v3', auth });const events = goal.scheduledEvents || [];// Delete events in parallelawait Promise.all(events.map(evt =>- calendar.events.delete({+ cal.events.delete({calendarId: evt.calendarId || 'primary',eventId: evt.googleEventId}).catch(err => {diff --git a/server/services/googleAuth.js b/server/services/googleAuth.jsindex 1b11b963b8..7c2fd16a6f 100644--- a/server/services/googleAuth.js+++ b/server/services/googleAuth.js@@ -1,4 +1,4 @@-import { google } from 'googleapis';+import { OAuth2Client } from 'google-auth-library';import { writeFile } from 'fs/promises';import { join } from 'path';import { ensureDir, PATHS, tryReadFile } from '../lib/fileUtils.js';@@ -55,7 +55,7 @@ export async function clearAuth() {}function createOAuth2Client(credentials) {- return new google.auth.OAuth2(+ return new OAuth2Client(credentials.clientId,credentials.clientSecret,credentials.redirectUri || OAUTH_REDIRECT_URIdiff --git a/server/services/messageGmailSync.js b/server/services/messageGmailSync.jsindex 476e276abe..45da46eb03 100644--- a/server/services/messageGmailSync.js+++ b/server/services/messageGmailSync.js@@ -3,7 +3,7 @@* Uses the shared Google OAuth client from googleAuth.js (same credentials as Calendar).*/-import { google } from 'googleapis';+import { gmail } from '@googleapis/gmail';import { v4 as uuidv4 } from '../lib/uuid.js';import crypto from 'crypto';import { getAuthenticatedClient } from './googleAuth.js';@@ -135,7 +135,7 @@ export async function syncGmail(account, cache, io, options = {}) {return { messages: [], status: 'not-configured' };}- const gmail = google.gmail({ version: 'v1', auth });+ const gmailClient = gmail({ version: 'v1', auth });const maxMessages = mode === 'full' ? 200 : 100;const query = mode === 'unread' ? 'is:unread in:inbox' : 'in:inbox';@@ -148,7 +148,7 @@ export async function syncGmail(account, cache, io, options = {}) {do {io?.emit('messages:sync:progress', { accountId: account.id, current: messageIds.length, total: maxMessages });- const listResult = await gmail.users.messages.list({+ const listResult = await gmailClient.users.messages.list({userId: 'me',q: query,maxResults: Math.min(100, maxMessages - messageIds.length),@@ -171,7 +171,7 @@ export async function syncGmail(account, cache, io, options = {}) {const batch = messageIds.slice(i, i + BATCH_SIZE);const results = await Promise.all(batch.map(({ id: gmailId }) =>- gmail.users.messages.get({ userId: 'me', id: gmailId, format: 'full' })+ gmailClient.users.messages.get({ userId: 'me', id: gmailId, format: 'full' }).catch(err => { console.log(`📧 Gmail: failed to fetch ${gmailId}: ${err.message}`); return null; })));@@ -234,7 +234,7 @@ export async function sendGmail(account, draft) {return { success: false, error: 'Google OAuth not configured', status: 502, code: 'GMAIL_NOT_CONFIGURED' };}- const gmail = google.gmail({ version: 'v1', auth });+ const gmailClient = gmail({ version: 'v1', auth });// Build RFC 2822 messageconst toLine = Array.isArray(draft.to) ? draft.to.join(', ') : draft.to;@@ -257,7 +257,7 @@ export async function sendGmail(account, draft) {const raw = Buffer.from(lines.join('\r\n')).toString('base64url');- const result = await gmail.users.messages.send({+ const result = await gmailClient.users.messages.send({userId: 'me',requestBody: { raw }}).catch(err => {