diff --git a/apps/rowboat/app/api/generated-images/[...path]/route.ts b/apps/rowboat/app/api/generated-images/[...path]/route.ts index c8cc65b5..ce946169 100644 --- a/apps/rowboat/app/api/generated-images/[...path]/route.ts +++ b/apps/rowboat/app/api/generated-images/[...path]/route.ts @@ -1,5 +1,6 @@ import { NextRequest, NextResponse } from 'next/server'; import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'; +import { Readable } from 'stream'; export async function GET(request: NextRequest, props: { params: Promise<{ path: string[] }> }) { const params = await props.params; @@ -8,12 +9,12 @@ export async function GET(request: NextRequest, props: { params: Promise<{ path: return NextResponse.json({ error: 'Invalid path' }, { status: 400 }); } - const bucket = process.env.UPLOADS_S3_BUCKET || ''; + const bucket = process.env.RAG_UPLOADS_S3_BUCKET || ''; if (!bucket) { return NextResponse.json({ error: 'S3 bucket not configured' }, { status: 500 }); } - const region = process.env.UPLOADS_AWS_REGION || 'us-east-1'; + const region = process.env.RAG_UPLOADS_S3_REGION || 'us-east-1'; const s3 = new S3Client({ region, credentials: process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY ? { @@ -28,7 +29,11 @@ export async function GET(request: NextRequest, props: { params: Promise<{ path: const resp = await s3.send(new GetObjectCommand({ Bucket: bucket, Key: key })); const contentType = resp.ContentType || 'application/octet-stream'; const body = resp.Body as any; - const webStream = body?.transformToWebStream ? body.transformToWebStream() : body; + const webStream = body?.transformToWebStream + ? body.transformToWebStream() + : (Readable as any)?.toWeb + ? (Readable as any).toWeb(body) + : body; return new NextResponse(webStream, { status: 200, headers: { @@ -42,4 +47,3 @@ export async function GET(request: NextRequest, props: { params: Promise<{ path: return NextResponse.json({ error: 'Not found' }, { status: 404 }); } } - diff --git a/apps/rowboat/app/lib/prebuilt-cards/index.ts b/apps/rowboat/app/lib/prebuilt-cards/index.ts new file mode 100644 index 00000000..2faad012 --- /dev/null +++ b/apps/rowboat/app/lib/prebuilt-cards/index.ts @@ -0,0 +1,16 @@ +// Static index of prebuilt workflow templates so they are bundled in Vercel +// If you add/remove a JSON here, update this file accordingly. + +import githubDataToSpreadsheet from './github-data-to-spreadsheet.json'; +import interviewScheduler from './interview-scheduler.json'; +import meetingPrepAssistant from './Meeting Prep Assistant.json'; +import redditOnSlack from './Reddit on Slack.json'; + +// Keep keys consistent with prior file basenames to avoid breaking links. +export const prebuiltTemplates = { + 'github-data-to-spreadsheet': githubDataToSpreadsheet, + 'interview-scheduler': interviewScheduler, + 'Meeting Prep Assistant': meetingPrepAssistant, + 'Reddit on Slack': redditOnSlack, +}; + diff --git a/apps/rowboat/app/lib/project_templates.ts b/apps/rowboat/app/lib/project_templates.ts index e2dd636a..be28137a 100644 --- a/apps/rowboat/app/lib/project_templates.ts +++ b/apps/rowboat/app/lib/project_templates.ts @@ -1,19 +1,13 @@ import { WorkflowTemplate } from "./types/workflow_types"; import { z } from 'zod'; -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +import { prebuiltTemplates } from './prebuilt-cards'; const DEFAULT_MODEL = process.env.PROVIDER_DEFAULT_MODEL || "gpt-4.1"; -// Function to load prebuilt cards from JSON files -function loadTemplatesFromFiles(): { [key: string]: z.infer } { - const templatesDir = path.join(__dirname, 'prebuilt-cards'); +// Build templates object using static imports so Vercel bundles them +function buildTemplates(): { [key: string]: z.infer } { const templates: { [key: string]: z.infer } = {}; - + // Add default template templates['default'] = { name: 'Blank Template', @@ -51,41 +45,19 @@ function loadTemplatesFromFiles(): { [key: string]: z.infer { - if (path.extname(file) === '.json') { - try { - const filePath = path.join(templatesDir, file); - const fileContent = fs.readFileSync(filePath, 'utf-8'); - const templateData = JSON.parse(fileContent); - - // Use filename without extension as template key - const templateKey = path.basename(file, '.json'); - - // Validate template structure (optional - you can add more validation) - if (templateData.agents && Array.isArray(templateData.agents)) { - templates[templateKey] = templateData; - } - } catch (error) { - console.warn(`Failed to load prebuilt card ${file}:`, error); - } - } - }); + + // Merge static prebuilt templates + Object.entries(prebuiltTemplates).forEach(([key, tpl]) => { + // Basic guard to avoid bad entries + if ((tpl as any)?.agents && Array.isArray((tpl as any).agents)) { + templates[key] = tpl as z.infer; } - } catch (error) { - console.warn('Failed to load prebuilt cards from directory:', error); - } - + }); + return templates; } -export const templates: { [key: string]: z.infer } = loadTemplatesFromFiles(); +export const templates: { [key: string]: z.infer } = buildTemplates(); // Note: Prebuilt cards are now loaded from app/lib/prebuilt-cards/ directory // starting_copilot_prompts has been removed as it was unused diff --git a/apps/rowboat/app/lib/uploads_s3_client.ts b/apps/rowboat/app/lib/uploads_s3_client.ts index 1e0de406..b3a35aa0 100644 --- a/apps/rowboat/app/lib/uploads_s3_client.ts +++ b/apps/rowboat/app/lib/uploads_s3_client.ts @@ -1,9 +1,11 @@ import { S3Client } from "@aws-sdk/client-s3"; export const uploadsS3Client = new S3Client({ - region: process.env.UPLOADS_AWS_REGION || 'us-east-1', - credentials: { - accessKeyId: process.env.AWS_ACCESS_KEY_ID || '', - secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || '', - }, -}); \ No newline at end of file + region: process.env.RAG_UPLOADS_S3_REGION || process.env.AWS_REGION || 'us-east-1', + credentials: (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) + ? { + accessKeyId: process.env.AWS_ACCESS_KEY_ID, + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, + } + : undefined as any, +}); diff --git a/apps/rowboat/src/application/lib/agents-runtime/agent-tools.ts b/apps/rowboat/src/application/lib/agents-runtime/agent-tools.ts index dcdfa70b..d7c0672b 100644 --- a/apps/rowboat/src/application/lib/agents-runtime/agent-tools.ts +++ b/apps/rowboat/src/application/lib/agents-runtime/agent-tools.ts @@ -645,9 +645,9 @@ export function createGenerateImageTool( { modelName } ); // If S3 bucket configured, store in S3 under generated_images/// - const s3Bucket = process.env.UPLOADS_S3_BUCKET || ''; + const s3Bucket = process.env.RAG_UPLOADS_S3_BUCKET || ''; if (s3Bucket) { - const s3Region = process.env.UPLOADS_AWS_REGION || 'us-east-1'; + const s3Region = process.env.RAG_UPLOADS_S3_REGION || 'us-east-1'; const s3 = new S3Client({ region: s3Region, credentials: process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY ? {