mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-02 20:03:21 +02:00
Fix vercel (#241)
* use static imports for prebuilt cards * fixed s3 env variables
This commit is contained in:
parent
5efdee18eb
commit
ad7a0d313b
5 changed files with 47 additions and 53 deletions
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
16
apps/rowboat/app/lib/prebuilt-cards/index.ts
Normal file
16
apps/rowboat/app/lib/prebuilt-cards/index.ts
Normal file
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
@ -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<typeof WorkflowTemplate> } {
|
||||
const templatesDir = path.join(__dirname, 'prebuilt-cards');
|
||||
// Build templates object using static imports so Vercel bundles them
|
||||
function buildTemplates(): { [key: string]: z.infer<typeof WorkflowTemplate> } {
|
||||
const templates: { [key: string]: z.infer<typeof WorkflowTemplate> } = {};
|
||||
|
||||
|
||||
// Add default template
|
||||
templates['default'] = {
|
||||
name: 'Blank Template',
|
||||
|
|
@ -51,41 +45,19 @@ function loadTemplatesFromFiles(): { [key: string]: z.infer<typeof WorkflowTempl
|
|||
},
|
||||
],
|
||||
};
|
||||
|
||||
try {
|
||||
// Check if prebuilt cards directory exists
|
||||
if (fs.existsSync(templatesDir)) {
|
||||
const files = fs.readdirSync(templatesDir);
|
||||
|
||||
// Load each JSON file
|
||||
files.forEach(file => {
|
||||
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<typeof WorkflowTemplate>;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to load prebuilt cards from directory:', error);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return templates;
|
||||
}
|
||||
|
||||
export const templates: { [key: string]: z.infer<typeof WorkflowTemplate> } = loadTemplatesFromFiles();
|
||||
export const templates: { [key: string]: z.infer<typeof WorkflowTemplate> } = buildTemplates();
|
||||
|
||||
// Note: Prebuilt cards are now loaded from app/lib/prebuilt-cards/ directory
|
||||
// starting_copilot_prompts has been removed as it was unused
|
||||
|
|
|
|||
|
|
@ -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 || '',
|
||||
},
|
||||
});
|
||||
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,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue