UNPKG

aios-core

Version:

Synkra AIOS: AI-Orchestrated System for Full Stack Development - Core Framework

100 lines (85 loc) 3.06 kB
/** * Google Workspace Extension Adapter * Story GEMINI-INT.9 - Workspace Integration * * Integrates Gemini CLI's Google Workspace extension for * creating/editing Docs, Sheets, and Slides. */ const { execSync } = require('child_process'); class WorkspaceAdapter { constructor(config = {}) { this.enabled = false; this.timeout = config.timeout || 30000; } /** * Check if Workspace extension is available */ async checkAvailability() { try { const output = execSync('gemini extensions list --output-format json 2>/dev/null', { encoding: 'utf8', timeout: 10000, }); const extensions = JSON.parse(output); this.enabled = extensions.some((e) => e.name === 'workspace' || e.name === 'google-workspace'); return this.enabled; } catch { this.enabled = false; return false; } } /** * Create a Google Doc * @param {string} title - Document title * @param {string} content - Initial content * @returns {Promise<Object>} Created document info */ async createDoc(title, content) { if (!this.enabled) throw new Error('Workspace extension not available'); const prompt = `Use Google Workspace to create a new Google Doc titled "${title}" with the following content:\n\n${content}`; return this._executeWorkspace(prompt); } /** * Create a Google Sheet * @param {string} title - Sheet title * @param {Array<Array>} data - Initial data as 2D array */ async createSheet(title, data) { if (!this.enabled) throw new Error('Workspace extension not available'); const dataStr = data.map((row) => row.join('\t')).join('\n'); const prompt = `Use Google Workspace to create a new Google Sheet titled "${title}" with this data:\n\n${dataStr}`; return this._executeWorkspace(prompt); } /** * Create a Google Slides presentation * @param {string} title - Presentation title * @param {Array<Object>} slides - Slide definitions */ async createPresentation(title, slides) { if (!this.enabled) throw new Error('Workspace extension not available'); const slidesDesc = slides.map((s, i) => `Slide ${i + 1}: ${s.title}\n${s.content}`).join('\n\n'); const prompt = `Use Google Workspace to create a new Google Slides presentation titled "${title}" with these slides:\n\n${slidesDesc}`; return this._executeWorkspace(prompt); } /** * Export story to Google Docs * @param {string} storyPath - Path to story file */ async exportStoryToDoc(storyPath) { const fs = require('fs'); const path = require('path'); const content = fs.readFileSync(storyPath, 'utf8'); const title = path.basename(storyPath, '.md'); return this.createDoc(`AIOS Story: ${title}`, content); } async _executeWorkspace(prompt) { // This would integrate with Gemini CLI's workspace extension // For now, return a placeholder return { success: true, message: 'Workspace operation queued', prompt, }; } } module.exports = { WorkspaceAdapter };